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.


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

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

Instance Attribute Details

#dependenciesObject (readonly)

Returns the value of attribute dependencies


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

def dependencies
  @dependencies
end

Instance Method Details

#for_dupObject


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

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

#gem(name, *requirements) ⇒ Object


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

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

#gemspec(options = {}) ⇒ Object


83
84
85
# File 'lib/appraisal/bundler_dsl.rb', line 83

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

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


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

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

#git_source(source, &block) ⇒ Object


87
88
89
# File 'lib/appraisal/bundler_dsl.rb', line 87

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

#group(*names, &block) ⇒ Object


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

def group(*names, &block)
  @groups[names] ||=
    Group.new(names).tap { |g| g.git_sources = @git_sources.dup }
  @groups[names].run(&block)
end

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


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

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

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


41
42
43
44
45
# File 'lib/appraisal/bundler_dsl.rb', line 41

def platforms(*names, &block)
  @platforms[names] ||=
    Platform.new(names).tap { |g| g.git_sources = @git_sources.dup }
  @platforms[names].run(&block)
end

#remove_gem(name) ⇒ Object


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

def remove_gem(name)
  @dependencies.remove(name)
end

#ruby(ruby_version) ⇒ Object


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

def ruby(ruby_version)
  @ruby_version = ruby_version
end

#run(&block) ⇒ Object


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

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

#source(source, &block) ⇒ Object


49
50
51
52
53
54
55
56
57
# File 'lib/appraisal/bundler_dsl.rb', line 49

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

#to_sObject


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

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