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



129
130
131
# File 'lib/bundler_auto_update.rb', line 129

def content
  @content ||= read
end

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



106
107
108
# File 'lib/bundler_auto_update.rb', line 106

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



111
112
113
114
115
116
117
118
119
120
121
122
# File 'lib/bundler_auto_update.rb', line 111

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



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

def reload!
  @content = read
end

#update_gem(gem) ⇒ Object

TODO:

spec



125
126
127
# File 'lib/bundler_auto_update.rb', line 125

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