Class: Gemkeeper::GemBuilder

Inherits:
Object
  • Object
show all
Defined in:
lib/gemkeeper/gem_builder.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(repo_path, output_dir = nil) ⇒ GemBuilder

Returns a new instance of GemBuilder.



10
11
12
13
# File 'lib/gemkeeper/gem_builder.rb', line 10

def initialize(repo_path, output_dir = nil)
  @repo_path = repo_path
  @output_dir = output_dir
end

Instance Attribute Details

#output_dirObject (readonly)

Returns the value of attribute output_dir.



8
9
10
# File 'lib/gemkeeper/gem_builder.rb', line 8

def output_dir
  @output_dir
end

#repo_pathObject (readonly)

Returns the value of attribute repo_path.



8
9
10
# File 'lib/gemkeeper/gem_builder.rb', line 8

def repo_path
  @repo_path
end

Instance Method Details

#buildObject



15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/gemkeeper/gem_builder.rb', line 15

def build
  gemspec_path = find_gemspec
  raise GemspecNotFoundError, "No gemspec found in #{@repo_path}" unless gemspec_path

  Dir.chdir(@repo_path) do
    gem_file = run_gem_build(gemspec_path)
    gem_path = File.join(@repo_path, gem_file)

    if @output_dir
      FileUtils.mkdir_p(@output_dir)
      dest_path = File.join(@output_dir, gem_file)
      FileUtils.mv(gem_path, dest_path)
      dest_path
    else
      gem_path
    end
  end
end

#gem_nameObject



34
35
36
37
38
39
# File 'lib/gemkeeper/gem_builder.rb', line 34

def gem_name
  gemspec_path = find_gemspec
  return nil unless gemspec_path

  File.basename(gemspec_path, ".gemspec")
end