Module: GemHelpers

Defined in:
lib/potassium/helpers/gem-helpers.rb

Instance Method Summary collapse

Instance Method Details

#build_gemfileObject



35
36
37
# File 'lib/potassium/helpers/gem-helpers.rb', line 35

def build_gemfile
  fix_withespace_issues if call_gem_for_gathered_gems
end

#clean_gemfileObject



30
31
32
33
# File 'lib/potassium/helpers/gem-helpers.rb', line 30

def clean_gemfile
  remove_everything_but_source
  add_original_rails_gems
end

#discard_gem(name) ⇒ Object



14
15
16
17
18
19
20
21
# File 'lib/potassium/helpers/gem-helpers.rb', line 14

def discard_gem(name)
  ensure_variable(:gems, {})
  get(:gems).each do |_environments, gems|
    gems.delete_if do |gem_entry|
      gem_entry[:name] == name
    end
  end
end

#gather_gem(name, *attributes) ⇒ Object



6
7
8
9
10
11
12
# File 'lib/potassium/helpers/gem-helpers.rb', line 6

def gather_gem(name, *attributes)
  ensure_variable(:gems, {})
  current_gem_groups = get(:current_gem_groups) || [:base]

  get(:gems)[current_gem_groups] ||= []
  get(:gems)[current_gem_groups] << { name: name, attributes: attributes }
end

#gather_gems(*environments, &block) ⇒ Object



23
24
25
26
27
28
# File 'lib/potassium/helpers/gem-helpers.rb', line 23

def gather_gems(*environments, &block)
  ensure_variable(:gems, {})
  set(:current_gem_groups, environments)
  instance_exec(&block)
  set(:current_gem_groups, [:base])
end

#gem_exists?(regexp) ⇒ Boolean

Returns:

  • (Boolean)


2
3
4
# File 'lib/potassium/helpers/gem-helpers.rb', line 2

def gem_exists?(regexp)
  File.open("Gemfile").each_line.any? { |line| line =~ regexp }
end