Class: Jeweler::Commands::WriteGemspec

Inherits:
Object
  • Object
show all
Defined in:
lib/jeweler/commands/write_gemspec.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeWriteGemspec

Returns a new instance of WriteGemspec.



7
8
9
# File 'lib/jeweler/commands/write_gemspec.rb', line 7

def initialize
  self.output = $stdout
end

Instance Attribute Details

#base_dirObject

Returns the value of attribute base_dir.



4
5
6
# File 'lib/jeweler/commands/write_gemspec.rb', line 4

def base_dir
  @base_dir
end

#gemspecObject

Returns the value of attribute gemspec.



4
5
6
# File 'lib/jeweler/commands/write_gemspec.rb', line 4

def gemspec
  @gemspec
end

#gemspec_helperObject



22
23
24
# File 'lib/jeweler/commands/write_gemspec.rb', line 22

def gemspec_helper
  @gemspec_helper ||= GemSpecHelper.new(gemspec, base_dir)
end

#outputObject

Returns the value of attribute output.



4
5
6
# File 'lib/jeweler/commands/write_gemspec.rb', line 4

def output
  @output
end

#versionObject

Returns the value of attribute version.



4
5
6
# File 'lib/jeweler/commands/write_gemspec.rb', line 4

def version
  @version
end

#version_helperObject

Returns the value of attribute version_helper.



4
5
6
# File 'lib/jeweler/commands/write_gemspec.rb', line 4

def version_helper
  @version_helper
end

Class Method Details

.build_for(jeweler) ⇒ Object



26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/jeweler/commands/write_gemspec.rb', line 26

def self.build_for(jeweler)
  command = new

  command.base_dir = jeweler.base_dir
  command.gemspec = jeweler.gemspec
  command.version = jeweler.version
  command.output = jeweler.output
  command.gemspec_helper = jeweler.gemspec_helper
  command.version_helper = jeweler.version_helper

  command
end

Instance Method Details

#runObject



11
12
13
14
15
16
17
18
19
20
# File 'lib/jeweler/commands/write_gemspec.rb', line 11

def run
  gemspec_helper.spec.version ||= begin
    version_helper.refresh
    version_helper.to_s
  end

  gemspec_helper.write

  output.puts "Generated: #{gemspec_helper.path}"
end