Class: Gemfiler::BundlerShim

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeBundlerShim

Returns a new instance of BundlerShim.



6
7
8
9
10
11
# File 'lib/gemfiler/bundler_shim.rb', line 6

def initialize
  @gems         = []
  @sources      = []
  @ruby_version = nil
  @has_gemspec  = false
end

Instance Attribute Details

#cabinetObject (readonly)

Returns the value of attribute cabinet.



4
5
6
# File 'lib/gemfiler/bundler_shim.rb', line 4

def cabinet
  @cabinet
end

#gemsObject

Returns the value of attribute gems.



3
4
5
# File 'lib/gemfiler/bundler_shim.rb', line 3

def gems
  @gems
end

#has_gemspecObject

Returns the value of attribute has_gemspec.



3
4
5
# File 'lib/gemfiler/bundler_shim.rb', line 3

def has_gemspec
  @has_gemspec
end

#ruby_versionObject

Returns the value of attribute ruby_version.



3
4
5
# File 'lib/gemfiler/bundler_shim.rb', line 3

def ruby_version
  @ruby_version
end

#sourcesObject

Returns the value of attribute sources.



3
4
5
# File 'lib/gemfiler/bundler_shim.rb', line 3

def sources
  @sources
end

Instance Method Details

#gather(source) ⇒ Object



13
14
15
16
# File 'lib/gemfiler/bundler_shim.rb', line 13

def gather(source)
  source = source.gsub /source[\s]+\:([\w_]+)/, "source(:\\1)"
  instance_eval(source)
end

#gem(name, *args) ⇒ Object



22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
# File 'lib/gemfiler/bundler_shim.rb', line 22

def gem(name, *args)
  return unless name.length > 0
  gem = {name: name}

  case args.first
  when String
    gem[:version] = args.first
  when Hash
    gem.merge! args.first
  end

  gem[:groups]    = @groups.map(&:to_s) if @groups
  gem[:platforms] = @platforms.map(&:to_s) if @platforms

  if @git
    gem[:git] = @git
    gem.merge! @git_options
  end

  if gem[:group]
    gem[:groups] ||= []
    gem[:groups] << gem.delete(:group)
  end

  @gems << gem

  gem
end

#gemspecObject



51
52
53
# File 'lib/gemfiler/bundler_shim.rb', line 51

def gemspec
  @has_gemspec = true
end

#gemspec?Boolean

Returns:

  • (Boolean)


18
19
20
# File 'lib/gemfiler/bundler_shim.rb', line 18

def gemspec?
  @has_gemspec
end

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



75
76
77
78
79
80
81
82
83
# File 'lib/gemfiler/bundler_shim.rb', line 75

def git(url, options={}, &block)
  @git         = url
  @git_options = options

  self.instance_eval(&block)
  
  @git         = nil
  @git_options = nil
end

#group(*names, &block) ⇒ Object



63
64
65
66
67
# File 'lib/gemfiler/bundler_shim.rb', line 63

def group(*names, &block)
  @groups = names.uniq
  self.instance_eval(&block)
  @groups = nil
end

#platforms(*names, &block) ⇒ Object



69
70
71
72
73
# File 'lib/gemfiler/bundler_shim.rb', line 69

def platforms(*names, &block)
  @platforms = names.uniq
  self.instance_eval(&block)
  @platforms = nil
end

#ruby(version, engine = {}) ⇒ Object



55
56
57
# File 'lib/gemfiler/bundler_shim.rb', line 55

def ruby(version, engine={})
  @ruby_version = {version: version}.merge(engine)
end

#source(source) ⇒ Object



59
60
61
# File 'lib/gemfiler/bundler_shim.rb', line 59

def source(source)
  @sources << source
end