Class: Appraisal::BundlerDSL

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

Direct Known Subclasses

Gemfile, Git, Group, Path, Platform, Source

Constant Summary collapse

PARTS =
%w(source ruby_version gits paths dependencies groups
platforms source_blocks gemspec)

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeBundlerDSL

Returns a new instance of BundlerDSL


11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/appraisal/bundler_dsl.rb', line 11

def initialize
  @sources = []
  @ruby_version = nil
  @dependencies = DependencyList.new
  @gemspecs = []
  @groups = OrderedHash.new
  @platforms = OrderedHash.new
  @gits = OrderedHash.new
  @paths = OrderedHash.new
  @source_blocks = OrderedHash.new
  @git_sources = {}
end

Instance Attribute Details

#dependenciesObject (readonly)

Returns the value of attribute dependencies


6
7
8
# File 'lib/appraisal/bundler_dsl.rb', line 6

def dependencies
  @dependencies
end

Instance Method Details

#for_dupObject


71
72
73
# File 'lib/appraisal/bundler_dsl.rb', line 71

def for_dup
  Utils.join_parts PARTS.map { |part| send("#{part}_entry_for_dup") }
end

#gem(name, *requirements) ⇒ Object


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

def gem(name, *requirements)
  @dependencies.add(name, substitute_git_source(requirements))
end

#gemspec(options = {}) ⇒ Object


75
76
77
# File 'lib/appraisal/bundler_dsl.rb', line 75

def gemspec(options = {})
  @gemspecs << Gemspec.new(options)
end

#git(source, options = {}, &block) ⇒ Object


57
58
59
60
# File 'lib/appraisal/bundler_dsl.rb', line 57

def git(source, options = {}, &block)
  @gits[source] ||= Git.new(source, options)
  @gits[source].run(&block)
end

#git_source(source, &block) ⇒ Object


79
80
81
# File 'lib/appraisal/bundler_dsl.rb', line 79

def git_source(source, &block)
  @git_sources[source] = block
end

#group(*names, &block) ⇒ Object


32
33
34
35
# File 'lib/appraisal/bundler_dsl.rb', line 32

def group(*names, &block)
  @groups[names] ||= Group.new(names)
  @groups[names].run(&block)
end

#path(source, options = {}, &block) ⇒ Object


62
63
64
65
# File 'lib/appraisal/bundler_dsl.rb', line 62

def path(source, options = {}, &block)
  @paths[source] ||= Path.new(source, options)
  @paths[source].run(&block)
end

#platforms(*names, &block) ⇒ Object Also known as: platform


37
38
39
40
# File 'lib/appraisal/bundler_dsl.rb', line 37

def platforms(*names, &block)
  @platforms[names] ||= Platform.new(names)
  @platforms[names].run(&block)
end

#ruby(ruby_version) ⇒ Object


53
54
55
# File 'lib/appraisal/bundler_dsl.rb', line 53

def ruby(ruby_version)
  @ruby_version = ruby_version
end

#run(&block) ⇒ Object


24
25
26
# File 'lib/appraisal/bundler_dsl.rb', line 24

def run(&block)
  instance_exec(&block)
end

#source(source, &block) ⇒ Object


44
45
46
47
48
49
50
51
# File 'lib/appraisal/bundler_dsl.rb', line 44

def source(source, &block)
  if block_given?
    @source_blocks[source] ||= Source.new(source)
    @source_blocks[source].run(&block)
  else
    @sources << source
  end
end

#to_sObject


67
68
69
# File 'lib/appraisal/bundler_dsl.rb', line 67

def to_s
  Utils.join_parts PARTS.map { |part| send("#{part}_entry") }
end