gemtronics 0.5.3 → 0.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/bin/gemtronics CHANGED
@@ -22,6 +22,30 @@ require 'fileutils'
22
22
  require 'yaml'
23
23
 
24
24
  case command
25
+ when 'outdated', 'outdated?'
26
+ require 'benchmark'
27
+ path = ARGV[1] || File.join('config', 'gemtronics.rb')
28
+ Gemtronics.load(path)
29
+ puts "Please wait while we check the versions of your gems (This may take a few minutes)\n"
30
+ list = {}
31
+ elapsed = Benchmark.realtime {
32
+ list = Gemtronics.find_out_of_date_gems(true)
33
+ }
34
+ if list.empty?
35
+ puts ''
36
+ puts 'All of your gems are up to date!'
37
+ puts ''
38
+ else
39
+ puts ''
40
+ puts "There are #{list.size} out of date gem(s)."
41
+ puts ''
42
+ list.each do |gemdef|
43
+ puts "#{gemdef.name}\n\t#{gemdef.version} --> #{gemdef.update_version}"
44
+ end
45
+ puts ''
46
+ end
47
+ puts "-------------"
48
+ puts "Completed in #{elapsed} seconds."
25
49
  when 'install'
26
50
  path = ARGV[2] || File.join('config', 'gemtronics.rb')
27
51
  Gemtronics.load(path)
@@ -9,6 +9,8 @@ module Gemtronics
9
9
  # Get/set the source of the gem. Defaults to <tt>http://gems.rubyforge.org</tt>
10
10
  attr_accessor :source
11
11
 
12
+ attr_accessor :update_version # :nodoc:
13
+
12
14
  # Returns true/false if the gem should be required. Defaults to <tt>true</tt>.
13
15
  def load?
14
16
  # method built dynamically. This is just a stub for RDoc.
@@ -113,6 +115,23 @@ module Gemtronics
113
115
  end
114
116
  end
115
117
 
118
+ def has_update?
119
+ cmd = "gem list --remote ^#{self.name}$"
120
+ res = `#{cmd}`
121
+ return false unless res.is_a?(String)
122
+ res.match(/^#{self.name}\s\(([\d\.]+)/)
123
+ ext_v = $1
124
+ return false if ext_v.nil?
125
+ self.version.match(/[^\d]{0,2}(.+)$/)
126
+ v = $1
127
+ self.update_version = ext_v
128
+ return ext_v > v ? self : false
129
+ end
130
+
131
+ def <=>(other)
132
+ "#{self.name.downcase}-#{self.version}" <=> "#{other.name.downcase}-#{other.version}"
133
+ end
134
+
116
135
  private
117
136
  def self.build_method(name, defval = nil, key = name) # :nodoc:
118
137
  define_method(name) do
@@ -207,6 +207,28 @@ module Gemtronics
207
207
  return res
208
208
  end
209
209
 
210
+ def find_out_of_date_gems(indicate = false)
211
+ tested = []
212
+ outdated = []
213
+ self.groups.each do |name, group|
214
+ group.gems.each do |g|
215
+ unless tested.include?("#{g.name}-#{g.version}")
216
+ if indicate
217
+ $stdout.write('.')
218
+ $stdout.flush
219
+ end
220
+ v = g.has_update?
221
+ # puts "!!!#{g.name} #{v}"
222
+ if v
223
+ outdated << v
224
+ end
225
+ tested << "#{g.name}-#{g.version}"
226
+ end
227
+ end
228
+ end
229
+ return outdated.sort
230
+ end
231
+
210
232
  def for_rails(config = nil, options = {})
211
233
  options = {:gemtronics_path => File.join(RAILS_ROOT, 'config', 'gemtronics.rb'),
212
234
  :group => RAILS_ENV}.merge(options)
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gemtronics
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.3
4
+ version: 0.6.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - markbates
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-09-04 00:00:00 -04:00
12
+ date: 2009-09-18 00:00:00 -04:00
13
13
  default_executable:
14
14
  dependencies: []
15
15