Class: Bundler::AutoUpdate::Gemfile

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

Overview

class Updater

Instance Method Summary collapse

Instance Method Details

#contentObject



138
139
140
# File 'lib/bundler_auto_update.rb', line 138

def content
  @content ||= read
end

#gem_line_regex(gem_name = '(\w+)') ⇒ Object



115
116
117
# File 'lib/bundler_auto_update.rb', line 115

def gem_line_regex(gem_name = '(\w+)')
  /^\s*gem\s*['"]#{gem_name}['"]\s*(,\s*['"](.+)['"])?\s*(,\s*(.*))?\n?$/
end

#gemsObject

Note:

This funky code parser could be replaced by a funky dsl re-implementation



120
121
122
123
124
125
126
127
128
129
130
131
# File 'lib/bundler_auto_update.rb', line 120

def gems
  gems = []

  content.dup.each_line do |l|
    if match = l.match(gem_line_regex)
      _, name, _, version, _, options = match.to_a
      gems << Dependency.new(name, version, options)
    end
  end

  gems
end

#reload!Object



142
143
144
# File 'lib/bundler_auto_update.rb', line 142

def reload!
  @content = read
end

#update_gem(gem) ⇒ Object

TODO:

spec



134
135
136
# File 'lib/bundler_auto_update.rb', line 134

def update_gem(gem)
  update_content(gem) and write and run_bundle_update(gem)
end