Class: Gembrew::Adder

Inherits:
Object
  • Object
show all
Defined in:
lib/gembrew/adder.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(gem_name, project_path: Pathname.pwd) ⇒ Adder

Returns a new instance of Adder.



10
11
12
13
# File 'lib/gembrew/adder.rb', line 10

def initialize(gem_name, project_path: Pathname.pwd)
  @gem_name = gem_name
  @project_path = Pathname(project_path).expand_path
end

Instance Attribute Details

#gem_nameObject (readonly)

Returns the value of attribute gem_name.



8
9
10
# File 'lib/gembrew/adder.rb', line 8

def gem_name
  @gem_name
end

#project_pathObject (readonly)

Returns the value of attribute project_path.



8
9
10
# File 'lib/gembrew/adder.rb', line 8

def project_path
  @project_path
end

Instance Method Details

#callObject

Raises:



15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/gembrew/adder.rb', line 15

def call
  Config.validate_name! gem_name
  unless formula_path.directory?
    raise Error, "Directory is not a Homebrew tap: #{project_path} (Formula/ does not exist)"
  end

  config_directory.mkpath
  raise Error, "Gem configuration already exists: #{config_path}" if config_path.exist?

  config_path.write render
  config_path
end