gem_tools 0.2.5 → 0.2.6

Sign up to get free protection for your applications and to get access to all the features.
data/README.textile CHANGED
@@ -7,10 +7,6 @@ similar to GemInstaller.
7
7
 
8
8
  My blog post on why "I prefer GemTools over config:gem":http://underpantsgnome.com/2009/4/8/i-prefer-gemtools-over-config-gem
9
9
 
10
- h2. FEATURES/PROBLEMS:
11
-
12
- Doesn't yet work in Windows
13
-
14
10
  h2. SYNOPSIS:
15
11
 
16
12
  I use this to manage gem versions in my apps, it has a script to install gems
@@ -44,7 +40,7 @@ See the "sample config":http://github.com/UnderpantsGnome/gem_tools/blob/master/
44
40
 
45
41
  h2. INSTALL:
46
42
 
47
- sudo gem install gem_tools
43
+ [sudo] gem install gem_tools
48
44
 
49
45
  h2. TODO
50
46
 
data/README.txt CHANGED
@@ -7,10 +7,6 @@ similar to GemInstaller.
7
7
 
8
8
  My blog post on why "I prefer GemTools over config:gem":http://underpantsgnome.com/2009/4/8/i-prefer-gemtools-over-config-gem
9
9
 
10
- h2. FEATURES/PROBLEMS:
11
-
12
- Doesn't yet work in Windows
13
-
14
10
  h2. SYNOPSIS:
15
11
 
16
12
  I use this to manage gem versions in my apps, it has a script to install gems
@@ -44,7 +40,7 @@ See the "sample config":http://github.com/UnderpantsGnome/gem_tools/blob/master/
44
40
 
45
41
  h2. INSTALL:
46
42
 
47
- sudo gem install gem_tools
43
+ [sudo] gem install gem_tools
48
44
 
49
45
  h2. TODO
50
46
 
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.2.5
1
+ 0.2.6
data/config/gems.yml CHANGED
@@ -1,164 +1,21 @@
1
+ # this is optional
2
+ # source: http://local_mirror.example.com
3
+ # gem_command: 'jruby -S gem'
1
4
  gems:
2
- - name: 'authlogic'
3
- version: '1.3.9'
4
-
5
- - name: 'datanoise-actionwebservice'
6
- version: '2.2.2'
7
- require_name: 'actionwebservice'
8
- source: 'http://gems.github.com/'
9
-
10
- - name: 'fastercsv'
11
- version: '1.5.0'
12
-
13
- - name: 'GData'
14
- version: '0.0.4'
15
- require_name: 'gdata/spreadsheet'
16
-
17
- - name: 'hpricot'
18
- version: '0.8.2'
19
-
20
- - name: 'httparty'
21
- version: '0.5.0'
22
-
23
- - name: 'newrelic_rpm'
24
- version: '2.9.5'
25
-
26
- - name: 'parseexcel'
27
- version: '0.5.2'
28
-
29
- - name: 'prawn'
30
- version: '0.5.0.1'
31
-
32
- - name: 'prawn-core'
33
- version: '0.5.0.1'
34
-
35
- - name: 'prawn-layout'
36
- version: '0.2.0.1'
37
-
38
- - name: 'rails'
39
- version: '2.2.2'
40
-
41
- - name: 'roo'
42
- version: '1.2.3'
43
-
44
- - name: 'rubaidh-google_analytics'
45
- version: '1.1.4'
46
- require_name: 'rubaidh/google_analytics'
47
- source: 'http://gems.github.com/'
48
-
49
- - name: 'aasm'
50
- version: '2.0.5'
51
-
52
- - name: 'rubyzip'
53
- version: '0.9.1'
54
- require_name: 'zip/zipfilesystem'
55
-
56
- - name: 'serviceproxy'
57
- version: '0.2.1'
58
-
59
- - name: 'settingslogic'
60
- version: '2.0.3'
61
-
62
- - name: 'spreadsheet-excel'
63
- version: '0.3.5.1'
64
- require_name: 'spreadsheet/excel'
65
-
66
- - name: 'thoughtbot-paperclip'
67
- version: '2.2.7'
68
- require_name: 'paperclip'
69
-
70
- - name: 'will_paginate'
71
- version: '2.2.2'
72
-
73
- - name: 'inaction_mailer'
74
- version: '0.6'
75
- load: false
76
-
77
- - name: 'capistrano-ext'
78
- version: '1.2.1'
79
- load: false
80
-
81
- - name: 'chronic'
82
- version: '0.2.3'
83
- load: false
84
-
85
- - name: 'whenever'
86
- version: '0.3.7'
87
- load: false
88
-
89
- - name: 'soap4r'
90
- version: '1.5.8'
91
- load: false
92
-
93
- - name: 'crack'
94
- version: '0.1.4'
95
- load: false
96
-
97
- - name: 'ruby-debug'
98
- version: '0.10.3'
99
- load: false
100
-
101
- - name: 'cucumber'
102
- version: '0.6.2'
103
- load: false
104
-
105
- - name: 'cucumber-rails'
106
- version: '0.2.4'
107
- load: false
108
-
109
- - name: 'database_cleaner'
110
- version: '0.4.3'
111
- load: false
112
-
113
- - name: 'webrat'
114
- version: '0.7.0'
115
- load: false
116
-
117
- - name: 'rspec'
118
- version: '1.3.0'
119
- load: false
120
-
121
- - name: 'rspec-rails'
122
- version: '1.3.2'
123
- load: false
124
-
125
- - name: 'launchy'
126
- version: '0.3.5'
127
- load: false
128
-
129
- - name: 'mocha'
130
- version: '0.9.5'
131
- load: false
132
-
133
- - name: 'machinist'
134
- version: '1.0.6'
135
- load: false
136
-
137
- - name: 'shoulda'
138
- version: '2.9.1'
139
- load: false
140
-
141
- - name: 'xml-simple'
142
- version: '1.0.12'
143
- load: false
144
-
145
- - name: 'memcache'
146
- version: '1.2.0'
147
- load: false
148
-
149
- - name: 'tzinfo'
150
- version: '0.3.16'
151
- load: false
152
-
153
- - name: 'tmail'
154
- version: '1.2.7.1'
155
- load: false
156
-
157
- - name: 'text-format'
158
- version: '1.0.0'
159
- load: false
160
-
161
- - name: 'cwninja-inaction_mailer'
162
- version: '0.6'
163
- require_name: 'inaction_mailer'
164
- load: false
5
+ - name: rake
6
+ load: true
7
+ version: >=0.7.3
8
+ - name: foo_gem
9
+ version: 0.0.1
10
+ load: true
11
+ # - name: postgres
12
+ # # the version to use
13
+ # version: '0.7.1'
14
+ # # this gem has a specfic source URL
15
+ # source: 'http://mongrel.rubyforge.org/releases'
16
+ # # this tells us to load not just install
17
+ # load: true
18
+ # # any extra config that needs to be passed to gem install
19
+ # config: '--with-pgsql-include-dir=/usr/local/pgsql/include --with-pgsql-lib-dir=/usr/local/pgsql/lib'
20
+ # # if the require name is different than the gem name
21
+ # require_name: foo-bar
data/gem_tools.gemspec CHANGED
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{gem_tools}
8
- s.version = "0.2.5"
8
+ s.version = "0.2.6"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Michael Moen"]
12
- s.date = %q{2010-02-11}
12
+ s.date = %q{2010-02-19}
13
13
  s.default_executable = %q{gemtools}
14
14
  s.description = %q{A lightweight tool to manage gems using a config file, similar to GemInstaller}
15
15
  s.email = %q{michael@underpantsgnome.com}
data/lib/gem_tools.rb CHANGED
@@ -2,7 +2,6 @@ $:.unshift(File.dirname(__FILE__)) unless
2
2
  $:.include?(File.dirname(__FILE__)) || $:.include?(File.expand_path(File.dirname(__FILE__)))
3
3
 
4
4
  require 'rubygems'
5
- require 'ruby-debug'
6
5
 
7
6
  module GemTools
8
7
  extend self
@@ -11,6 +10,10 @@ module GemTools
11
10
  send(cmd.to_sym) rescue help
12
11
  end
13
12
 
13
+ def help
14
+ puts OPTS
15
+ end
16
+
14
17
  def setup
15
18
  require 'fileutils'
16
19
  dest_file = File.join(ARGV[1], '/config/gems.yml')
@@ -23,28 +26,21 @@ module GemTools
23
26
  end
24
27
  end
25
28
 
26
- def load_gems
27
- config = load_config
28
- unless config['gems'].nil?
29
- gems = config['gems'].reject {|gem_info| ! gem_info['load'] }
30
- gems.each do |gem_info|
31
- if defined?(gem)
32
- gem gem_info['name'], gem_info['version']
33
- else
34
- require_gem gem_info['name'], gem_info['version']
35
- end
36
- require gem_info['require_name'] || gem_info['name']
37
- end
29
+ def install
30
+ commands.each do |command|
31
+ ret = system command
32
+ # something bad happened, pass on the message
33
+ p $? unless ret
38
34
  end
39
35
  end
40
36
 
41
- def help
42
- puts OPTS
37
+ def dryrun
38
+ puts "\n#{commands.join("\n")}\n\n"
43
39
  end
44
40
 
45
41
  def to_gemfile
46
42
  config = load_config
47
-
43
+
48
44
  if File.exist?('Gemfile')
49
45
  puts "GemFile already exists, not overwriting."
50
46
  exit 1
@@ -77,114 +73,95 @@ module GemTools
77
73
  end
78
74
  end
79
75
 
80
- def load_config
81
- require 'yaml'
82
- require 'erb'
83
- config_file = find_config
84
- unless config_file
85
- puts 'Could not find a gems.yml, checked . and ./config'
86
- exit 1
87
- end
88
- YAML.load(ERB.new(File.open(config_file).read).result)
89
- end
76
+ private
90
77
 
91
- def install
92
- require 'rubygems'
93
- if RUBY_PLATFORM =~ /MSWIN/
94
- puts "gemtools install doesn't currently work in windows. The commands you need to install the gems will be printed out for you.\n"
95
- dryrun
96
- return
97
- else
98
- commands.each do |command|
99
- ret = system command
100
- # something bad happened, pass on the message
101
- p $? unless ret
78
+ def load_gems
79
+ config = load_config
80
+ unless config['gems'].nil?
81
+ gems = config['gems'].reject {|gem_info| ! gem_info['load'] }
82
+ gems.each do |gem_info|
83
+ if defined?(gem)
84
+ gem gem_info['name'], gem_info['version']
85
+ else
86
+ require_gem gem_info['name'], gem_info['version']
87
+ end
88
+ require gem_info['require_name'] || gem_info['name']
89
+ end
102
90
  end
103
91
  end
104
- end
105
92
 
106
- def dryrun
107
- puts "\n#{commands.join("\n")}\n\n"
108
- end
109
-
110
- def commands
111
- config = load_config
112
- gems = config['gems']
113
- commands = []
114
-
115
- unless gems.nil?
116
- docs = ''
117
- unless OPTIONS.has_key?(:docs)
118
- docs << '--no-rdoc ' unless (`rdoc --version 2> /dev/null`).nil?
119
- docs << '--no-ri ' unless (`ri --version 2> /dev/null`).nil?
93
+ def load_config
94
+ require 'yaml'
95
+ require 'erb'
96
+ config_file = find_config
97
+ unless config_file
98
+ puts 'Could not find a gems.yml, checked . and ./config'
99
+ exit 1
120
100
  end
101
+ YAML.load(ERB.new(File.open(config_file).read).result)
102
+ end
121
103
 
122
- gem_command = config['gem_command'] || 'gem'
123
- gem_dash_y = "1.0" > Gem::RubyGemsVersion ? '-y' : ''
104
+ def commands
105
+ config = load_config
106
+ gems = config['gems']
107
+ commands = []
124
108
 
125
- gems.each do |gem|
126
- spec, loaded, version = check_gem(gem_command, gem['name'], gem['version'])
127
- # if forced
128
- # or the spec version doesn't match the required version
129
- # or require_gem returns false
130
- # (return false also happens if the gem has already been loaded)
131
- if OPTIONS.has_key?(:force) || !spec || (! loaded || version != gem['version'])
132
- gem_config = gem['config'] ? " -- #{gem['config']}" : ''
133
- source = gem['source'] || config['source'] || nil
134
- source = "--source #{source}" if source
135
- cmd = "#{gem_command} install #{gem['path'] || gem['name']} -v #{gem['version']} #{gem_dash_y} #{source} #{docs} #{gem_config}"
136
- commands << cmd
137
- else
138
- puts "#{gem['name']} #{gem['version']} already installed"
109
+ unless gems.nil?
110
+ docs = ''
111
+ unless OPTIONS.has_key?(:docs) || RUBY_PLATFORM =~ /(win|mingw)/i
112
+ docs << '--no-rdoc ' unless (`rdoc --version 2> /dev/null`).nil?
113
+ docs << '--no-ri ' unless (`ri --version 2> /dev/null`).nil?
114
+ end
115
+
116
+ gem_command = config['gem_command'] || 'gem'
117
+ gem_dash_y = "1.0" > Gem::RubyGemsVersion ? '-y' : ''
118
+
119
+ gems.each do |gem|
120
+ meets_reqs =
121
+
122
+ # if forced
123
+ # or the installed gems don't meet requirements
124
+ if OPTIONS.has_key?(:force) || meets_requirements?(gem['name'], gem['version'])
125
+ gem_config = gem['config'] ? " -- #{gem['config']}" : ''
126
+ source = gem['source'] || config['source'] || nil
127
+ source = "--source #{source}" if source
128
+ cmd = "#{gem_command} install #{gem['path'] || gem['name']} -v #{gem['version']} #{gem_dash_y} #{source} #{docs} #{gem_config}"
129
+ commands << cmd
130
+ else
131
+ puts "#{gem['name']} #{gem['version']} already installed"
132
+ end
139
133
  end
140
134
  end
135
+ commands
141
136
  end
142
- commands
143
- end
144
137
 
145
- def check_gem(command, name, version='')
146
- ENV['PATH'] ||= '/usr/bin'
147
- ENV['PATH'] += ':/usr/local/bin:/usr/bin'
148
- spec = YAML.load(`PATH=#{ENV['PATH']} #{command} spec #{name} 2> /dev/null`)
149
- loaded = false
150
- begin
151
- loaded = defined?(gem) ? gem(name, version) : require_gem(name, version)
152
- version = spec.version.version
153
- rescue Exception => e
154
- # puts e
138
+ def find_config
139
+ %w( . config ).each do |dir|
140
+ config_file = File.join(dir, 'gems.yml')
141
+ return config_file if File.exist?(config_file)
142
+ end
143
+ nil
155
144
  end
156
- [spec, loaded, version]
157
- end
158
145
 
159
- def find_config
160
- %w( . config ).each do |dir|
161
- config_file = File.join(dir, 'gems.yml')
162
- return config_file if File.exist?(config_file)
146
+ def meets_requirements?(name, version)
147
+ @specs ||= Gem::SourceIndex.from_installed_gems
148
+ @specs.find_name(name, Gem::Requirement.new(version)).empty?
163
149
  end
164
- nil
165
- end
166
150
 
167
- def has_gem?(gem)
168
- @gems ||= Gem::SourceIndex.from_installed_gems
169
- @gems.search(gem['name'], gem['version']).empty?
170
- end
151
+ def check_updates
152
+ config = load_config
153
+ gems = config['gems']
171
154
 
172
- def check_updates
173
- config = load_config
174
- gems = config['gems']
175
-
176
- gems.each do |gem|
177
- source = gem['source'] || config['source'] || nil
178
- source = "--source #{source}" if source
179
- # puts "Checking #{gem['name']}"
180
- out = `gem list -r #{gem['name']} #{source}`
181
- ver = out.match(/\(([0-9\.]+)/)[1] #rescue 0
182
- puts "#{gem['name']} #{ver} is available, #{gem['version']} installed" if ver > gem['version']
155
+ gems.each do |gem|
156
+ source = gem['source'] || config['source'] || nil
157
+ source = "--source #{source}" if source
158
+ # puts "Checking #{gem['name']}"
159
+ out = `gem list -r #{gem['name']} #{source}`
160
+ ver = out.match(/\(([0-9\.]+)/)[1] #rescue 0
161
+ puts "#{gem['name']} #{ver} is available, #{gem['version']} installed" if ver > gem['version']
162
+ end
183
163
  end
184
- end
185
-
186
- private
187
-
164
+
188
165
  def bundler_gem_line(gem)
189
166
  line = "gem '#{gem['name']}', '#{gem['version']}'"
190
167
  line += ", :require => '#{gem['require_name']}'" if gem['require_name']
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gem_tools
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.5
4
+ version: 0.2.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Michael Moen
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2010-02-11 00:00:00 -06:00
12
+ date: 2010-02-19 00:00:00 -06:00
13
13
  default_executable: gemtools
14
14
  dependencies: []
15
15