Parent

Class Index [+]

Quicksearch

Jeweler::GemSpecHelper

Attributes

spec[RW]
base_dir[RW]

Public Class Methods

new(spec, base_dir = nil) click to toggle source
    # File lib/jeweler/gemspec_helper.rb, line 7
 7:     def initialize(spec, base_dir = nil)
 8:       self.spec = spec
 9:       self.base_dir = base_dir || ''
10: 
11:       yield spec if block_given?
12:     end

Public Instance Methods

gem_path() click to toggle source
    # File lib/jeweler/gemspec_helper.rb, line 78
78:     def gem_path
79:       File.join(@base_dir, 'pkg', parse.file_name)
80:     end
has_version?() click to toggle source

Checks whether it uses the version helper or the users defined version.

    # File lib/jeweler/gemspec_helper.rb, line 87
87:     def has_version?
88:       !@spec.version.nil?
89:     end
normalize_files(array_attribute) click to toggle source
    # File lib/jeweler/gemspec_helper.rb, line 60
60:     def normalize_files(array_attribute)
61:       array = @spec.send(array_attribute)
62:       # only keep files, no directories, and sort
63:       array = array.select do |path|
64:         File.file? File.join(@base_dir, path)
65:       end.sort
66: 
67:       @spec.send("#{array_attribute}=", array)
68:     end
parse() click to toggle source
    # File lib/jeweler/gemspec_helper.rb, line 53
53:     def parse
54:       data = self.to_ruby
55:       parsed_gemspec = nil
56:       Thread.new { parsed_gemspec = eval("$SAFE = 3\n#{data}", binding, path) }.join
57:       parsed_gemspec
58:     end
path() click to toggle source
    # File lib/jeweler/gemspec_helper.rb, line 47
47:     def path
48:       denormalized_path = File.join(@base_dir, "#{@spec.name}.gemspec")
49:       absolute_path = File.expand_path(denormalized_path)
50:       absolute_path.gsub(Dir.getwd + File::SEPARATOR, '') 
51:     end
prettyify_array(gemspec_ruby, array_name) click to toggle source

Adds extra space when outputting an array. This helps create better version control diffs, because otherwise it is all on the same line.

    # File lib/jeweler/gemspec_helper.rb, line 71
71:     def prettyify_array(gemspec_ruby, array_name)
72:       gemspec_ruby.gsub(/s\.#{array_name.to_s} = \[.+?\]/) do |match|
73:         leadin, files = match[0..2].split("[")
74:         leadin + "[\n    #{files.split(",").join(",\n    ")}\n  ]"
75:       end
76:     end
to_ruby() click to toggle source
    # File lib/jeweler/gemspec_helper.rb, line 30
30:     def to_ruby
31:       normalize_files(:files)
32:       normalize_files(:files)
33:       normalize_files(:extra_rdoc_files)
34: 
35:       gemspec_ruby = @spec.to_ruby
36:       gemspec_ruby = prettyify_array(gemspec_ruby, :files)
37:       gemspec_ruby = prettyify_array(gemspec_ruby, :test_files)
38:       gemspec_ruby = prettyify_array(gemspec_ruby, :extra_rdoc_files)
39:       gemspec_ruby = # Generated by jeweler# DO NOT EDIT THIS FILE DIRECTLY# Instead, edit Jeweler::Tasks in #{Rake.application.rakefile}, and run the gemspec command#{gemspec_ruby}
40:     end
update_version(version) click to toggle source
    # File lib/jeweler/gemspec_helper.rb, line 82
82:     def update_version(version)
83:       @spec.version = version.to_s
84:     end
valid?() click to toggle source
    # File lib/jeweler/gemspec_helper.rb, line 14
14:     def valid?
15:       begin
16:         parse
17:         true
18:       rescue
19:         false
20:       end
21:     end
write() click to toggle source
    # File lib/jeweler/gemspec_helper.rb, line 23
23:     def write
24: 
25:       File.open(path, 'w') do |f|
26:         f.write self.to_ruby
27:       end 
28:     end

Disabled; run with --debug to generate this.

[Validate]

Generated with the Darkfish Rdoc Generator 1.1.6.