Class: Appraisal::BundlerDSL
- Inherits:
-
Object
- Object
- Appraisal::BundlerDSL
show all
- Defined in:
- lib/appraisal/bundler_dsl.rb
Constant Summary
collapse
- PARTS =
%w[
source
ruby_version
gits
paths
dependencies
groups
platforms
source_blocks
install_if
gemspec
eval_gemfile
]
Instance Attribute Summary collapse
Instance Method Summary
collapse
-
#eval_gemfile(path, contents = nil) ⇒ Object
-
#for_dup ⇒ Object
-
#gem(name, *requirements) ⇒ Object
-
#gemspec(options = {}) ⇒ Object
-
#git(source, options = {}, &block) ⇒ Object
-
#git_source(source, &block) ⇒ Object
-
#group(*names, &block) ⇒ Object
-
#initialize ⇒ BundlerDSL
constructor
A new instance of BundlerDSL.
-
#install_if(condition, &block) ⇒ Object
-
#path(source, options = {}, &block) ⇒ Object
-
#platforms(*names, &block) ⇒ Object
(also: #platform)
-
#remove_gem(name) ⇒ Object
-
#ruby(ruby_version) ⇒ Object
-
#run(&block) ⇒ Object
-
#source(source, &block) ⇒ Object
-
#to_s ⇒ Object
Constructor Details
Returns a new instance of BundlerDSL.
Instance Attribute Details
#dependencies ⇒ Object
Returns the value of attribute dependencies.
8
9
10
|
# File 'lib/appraisal/bundler_dsl.rb', line 8
def dependencies
@dependencies
end
|
Instance Method Details
#eval_gemfile(path, contents = nil) ⇒ Object
43
44
45
|
# File 'lib/appraisal/bundler_dsl.rb', line 43
def eval_gemfile(path, contents = nil)
@eval_gemfile << [path, contents]
end
|
#for_dup ⇒ Object
105
106
107
|
# File 'lib/appraisal/bundler_dsl.rb', line 105
def for_dup
Utils.join_parts(PARTS.map { |part| send(:"#{part}_entry_for_dup") })
end
|
#gem(name, *requirements) ⇒ Object
47
48
49
|
# File 'lib/appraisal/bundler_dsl.rb', line 47
def gem(name, *requirements)
@dependencies.add(name, substitute_git_source(requirements))
end
|
#gemspec(options = {}) ⇒ Object
109
110
111
|
# File 'lib/appraisal/bundler_dsl.rb', line 109
def gemspec(options = {})
@gemspecs << Gemspec.new(options)
end
|
#git(source, options = {}, &block) ⇒ Object
89
90
91
92
93
|
# File 'lib/appraisal/bundler_dsl.rb', line 89
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
113
114
115
|
# File 'lib/appraisal/bundler_dsl.rb', line 113
def git_source(source, &block)
@git_sources[source] = block
end
|
#group(*names, &block) ⇒ Object
55
56
57
58
59
|
# File 'lib/appraisal/bundler_dsl.rb', line 55
def group(*names, &block)
@groups[names] ||=
Group.new(names).tap { |g| g.git_sources = @git_sources.dup }
@groups[names].run(&block)
end
|
#install_if(condition, &block) ⇒ Object
61
62
63
64
65
|
# File 'lib/appraisal/bundler_dsl.rb', line 61
def install_if(condition, &block)
@install_if[condition] ||=
Conditional.new(condition).tap { |g| g.git_sources = @git_sources.dup }
@install_if[condition].run(&block)
end
|
#path(source, options = {}, &block) ⇒ Object
95
96
97
98
99
|
# File 'lib/appraisal/bundler_dsl.rb', line 95
def path(source, options = {}, &block)
@paths[source] ||=
Path.new(source, options).tap { |g| g.git_sources = @git_sources.dup }
@paths[source].run(&block)
end
|
67
68
69
70
71
|
# File 'lib/appraisal/bundler_dsl.rb', line 67
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
51
52
53
|
# File 'lib/appraisal/bundler_dsl.rb', line 51
def remove_gem(name)
@dependencies.remove(name)
end
|
#ruby(ruby_version) ⇒ Object
85
86
87
|
# File 'lib/appraisal/bundler_dsl.rb', line 85
def ruby(ruby_version)
@ruby_version = ruby_version
end
|
#run(&block) ⇒ Object
39
40
41
|
# File 'lib/appraisal/bundler_dsl.rb', line 39
def run(&block)
instance_exec(&block)
end
|
#source(source, &block) ⇒ Object
75
76
77
78
79
80
81
82
83
|
# File 'lib/appraisal/bundler_dsl.rb', line 75
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_s ⇒ Object
101
102
103
|
# File 'lib/appraisal/bundler_dsl.rb', line 101
def to_s
Utils.join_parts(PARTS.map { |part| send(:"#{part}_entry") })
end
|