Class: Appraisal::Appraisal

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

Overview

Represents one appraisal and its dependencies

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name, source_gemfile) ⇒ Appraisal

Returns a new instance of Appraisal.



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

def initialize(name, source_gemfile)
  @name = name
  @gemfile = source_gemfile.dup
end

Instance Attribute Details

#gemfileObject (readonly)

Returns the value of attribute gemfile.



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

def gemfile
  @gemfile
end

#nameObject (readonly)

Returns the value of attribute name.



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

def name
  @name
end

Instance Method Details

#gem(name, *requirements) ⇒ Object



15
16
17
# File 'lib/appraisal/appraisal.rb', line 15

def gem(name, *requirements)
  gemfile.gem(name, *requirements)
end

#gemfile_pathObject



31
32
33
34
35
36
37
# File 'lib/appraisal/appraisal.rb', line 31

def gemfile_path
  unless ::File.exist?(gemfile_root)
    FileUtils.mkdir(gemfile_root)
  end

  ::File.join(gemfile_root, "#{name}.gemfile")
end

#installObject



27
28
29
# File 'lib/appraisal/appraisal.rb', line 27

def install
  Command.new("bundle install --gemfile=#{gemfile_path}").run
end

#write_gemfileObject



19
20
21
22
23
24
25
# File 'lib/appraisal/appraisal.rb', line 19

def write_gemfile
  ::File.open(gemfile_path, "w") do |file|
    file.puts("# This file was generated by Appraisal")
    file.puts
    file.write(gemfile.to_s)
  end
end