markbates-gemtronics 0.5.1.20090902162844 → 0.6.0.20090918181322
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 +59 -0
- data/lib/gemtronics/definition.rb +26 -2
- data/lib/gemtronics/manager.rb +23 -1
- metadata +4 -3
data/bin/gemtronics
CHANGED
@@ -22,10 +22,69 @@ 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)
|
28
52
|
Gemtronics.install_gems(ARGV[1] || 'everything!')
|
53
|
+
when 'restore'
|
54
|
+
path = ARGV[1] || 'system_gemtronics_dump.rb'
|
55
|
+
Gemtronics.load(path)
|
56
|
+
Gemtronics.install_gems('everything!')
|
57
|
+
when 'dump'
|
58
|
+
gem_list = `gem list`
|
59
|
+
|
60
|
+
gems = {}
|
61
|
+
|
62
|
+
gem_list.each do |line|
|
63
|
+
defs = line.scan(/([^\s\(\)\,]+)/).flatten
|
64
|
+
gems[defs.first] = defs[1..defs.size]
|
65
|
+
end
|
66
|
+
|
67
|
+
groups = []
|
68
|
+
|
69
|
+
gems.each do |name, versions|
|
70
|
+
versions.each_with_index do |version, i|
|
71
|
+
groups[i] ||= {}
|
72
|
+
groups[i][name] = {:name => name, :version => version}
|
73
|
+
end
|
74
|
+
end
|
75
|
+
|
76
|
+
out = ''
|
77
|
+
|
78
|
+
groups.each_with_index do |gems, i|
|
79
|
+
out << "group(:group_#{i}) do |g|\n"
|
80
|
+
gems.each do |name, gemdef|
|
81
|
+
out << " g.add('#{name}', :version => '#{gemdef[:version]}')\n"
|
82
|
+
end
|
83
|
+
out << "end\n"
|
84
|
+
end
|
85
|
+
|
86
|
+
puts out
|
87
|
+
File.open('system_gemtronics_dump.rb', 'w') {|f| f.write out}
|
29
88
|
when 'generate'
|
30
89
|
path = ARGV[1] || 'config'
|
31
90
|
FileUtils.mkdir_p(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.
|
@@ -59,7 +61,12 @@ module Gemtronics
|
|
59
61
|
# gd.version = '2.3.0'
|
60
62
|
# gd.install_command #=> 'gem install configatron --source=http://gems.rubyforge.org --version=2.3.0'
|
61
63
|
def install_command
|
62
|
-
cmd = "gem install #{self.name}
|
64
|
+
cmd = "gem install #{self.name}"
|
65
|
+
|
66
|
+
if self.source
|
67
|
+
cmd << " --source=#{self.source}"
|
68
|
+
end
|
69
|
+
|
63
70
|
unless self.ri?
|
64
71
|
cmd << ' --no-ri'
|
65
72
|
end
|
@@ -108,6 +115,23 @@ module Gemtronics
|
|
108
115
|
end
|
109
116
|
end
|
110
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
|
+
|
111
135
|
private
|
112
136
|
def self.build_method(name, defval = nil, key = name) # :nodoc:
|
113
137
|
define_method(name) do
|
@@ -121,7 +145,7 @@ module Gemtronics
|
|
121
145
|
|
122
146
|
build_method(:name)
|
123
147
|
build_method(:version, '>=0.0.0')
|
124
|
-
build_method(:source,
|
148
|
+
build_method(:source, nil)
|
125
149
|
build_method(:load?, true, :load)
|
126
150
|
build_method(:ri?, false, :ri)
|
127
151
|
build_method(:rdoc?, false, :rdoc)
|
data/lib/gemtronics/manager.rb
CHANGED
@@ -5,7 +5,7 @@ module Gemtronics
|
|
5
5
|
# A Hash of the default options that are applied to all the gems.
|
6
6
|
# These options can be overidden at both the group and the individual
|
7
7
|
# gem level.
|
8
|
-
GLOBAL_DEFAULT_OPTIONS = {:load => true, :version => '>=0.0.0', :
|
8
|
+
GLOBAL_DEFAULT_OPTIONS = {:load => true, :version => '>=0.0.0', :ri => false, :rdoc => false}
|
9
9
|
|
10
10
|
# A Hash of all the groups that have been defined.
|
11
11
|
attr_accessor :groups
|
@@ -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: markbates-gemtronics
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.6.0.20090918181322
|
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-
|
12
|
+
date: 2009-09-18 00:00:00 -07:00
|
13
13
|
default_executable: gemtronics
|
14
14
|
dependencies: []
|
15
15
|
|
@@ -33,6 +33,7 @@ files:
|
|
33
33
|
- bin/gemtronics
|
34
34
|
has_rdoc: false
|
35
35
|
homepage: http://www.metabates.com
|
36
|
+
licenses:
|
36
37
|
post_install_message:
|
37
38
|
rdoc_options: []
|
38
39
|
|
@@ -53,7 +54,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
53
54
|
requirements: []
|
54
55
|
|
55
56
|
rubyforge_project: magrathea
|
56
|
-
rubygems_version: 1.
|
57
|
+
rubygems_version: 1.3.5
|
57
58
|
signing_key:
|
58
59
|
specification_version: 3
|
59
60
|
summary: gemtronics
|