gem_tools 0.2.2 → 0.2.3

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/.gitignore ADDED
@@ -0,0 +1,22 @@
1
+ ## MAC OS
2
+ .DS_Store
3
+
4
+ ## TEXTMATE
5
+ *.tmproj
6
+ tmtags
7
+
8
+ ## EMACS
9
+ *~
10
+ \#*
11
+ .\#*
12
+
13
+ ## VIM
14
+ *.swp
15
+
16
+ ## PROJECT::GENERAL
17
+ coverage
18
+ rdoc
19
+ pkg
20
+ *.gem
21
+
22
+ ## PROJECT::SPECIFIC
data/History.txt CHANGED
@@ -1,3 +1,11 @@
1
+ == 0.2.4 2010-01-27
2
+ * move to jeweler for packaging
3
+ fix error when checking for updated gems
4
+
5
+ == 0.2.3 2009-05-18
6
+ * add STDERR redirection for the rdoc and ri checks, throwing funky errors when
7
+ there is no TTY
8
+
1
9
  == 0.2.0 2009-04-27
2
10
  * Fixed the broken refs to opts as a Hash, no really this time. Thanks cohesive
3
11
 
data/README.textile ADDED
@@ -0,0 +1,72 @@
1
+ h1. GemTools
2
+
3
+ h2. DESCRIPTION:
4
+
5
+ The gem verison of my lightweight tool to manage gems using a config file,
6
+ similar to GemInstaller.
7
+
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
+
10
+ h2. FEATURES/PROBLEMS:
11
+
12
+ Doesn't yet work in Windows
13
+
14
+ h2. SYNOPSIS:
15
+
16
+ I use this to manage gem versions in my apps, it has a script to install gems
17
+ and a load utility to load them on startup.
18
+
19
+ h3. create a gems.yml in a new project
20
+
21
+ gemtools setup path/to/app
22
+
23
+ h3. Install or update required gems
24
+
25
+ gemtools install
26
+
27
+ h3. Check to see if any of the gems in your app have newer versions
28
+
29
+ gemtools check_updates
30
+
31
+ Make sure they are loaded with the right versions during startup, by adding the
32
+ following to your script or environment.rb (Rails)
33
+
34
+ require 'gem_tools'
35
+ GemTools.load_gems
36
+
37
+
38
+ See the "sample config":http://github.com/UnderpantsGnome/gem_tools/blob/master/gems.yml.sample for the format
39
+
40
+ h2. INSTALL:
41
+
42
+ sudo gem install gem_tools
43
+
44
+ h2. TODO
45
+
46
+ * Write the tests/specs
47
+ * Make it work in Windows
48
+
49
+ h2. LICENSE:
50
+
51
+ (The MIT License)
52
+
53
+ Copyright (c) 2008 Michael Moen
54
+
55
+ Permission is hereby granted, free of charge, to any person obtaining
56
+ a copy of this software and associated documentation files (the
57
+ 'Software'), to deal in the Software without restriction, including
58
+ without limitation the rights to use, copy, modify, merge, publish,
59
+ distribute, sublicense, and/or sell copies of the Software, and to
60
+ permit persons to whom the Software is furnished to do so, subject to
61
+ the following conditions:
62
+
63
+ The above copyright notice and this permission notice shall be
64
+ included in all copies or substantial portions of the Software.
65
+
66
+ THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
67
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
68
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
69
+ IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
70
+ CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
71
+ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
72
+ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.txt CHANGED
@@ -1,82 +1,52 @@
1
- = GemTools
1
+ h1. GemTools
2
2
 
3
- http://github.com/UnderpantsGnome/gem_tools-gem/wikis
4
-
5
- == DESCRIPTION:
3
+ h2. DESCRIPTION:
6
4
 
7
5
  The gem verison of my lightweight tool to manage gems using a config file,
8
6
  similar to GemInstaller.
9
7
 
10
- == FEATURES/PROBLEMS:
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
+
10
+ h2. FEATURES/PROBLEMS:
11
11
 
12
12
  Doesn't yet work in Windows
13
13
 
14
- == SYNOPSIS:
14
+ h2. SYNOPSIS:
15
15
 
16
16
  I use this to manage gem versions in my apps, it has a script to install gems
17
17
  and a load utility to load them on startup.
18
18
 
19
- create a gems.yml in a new project
20
- <pre><code>
21
- gemtools setup path/to/app
22
- </pre></code>
19
+ h3. create a gems.yml in a new project
20
+
21
+ gemtools setup path/to/app
22
+
23
+ h3. Install or update required gems
23
24
 
24
- Install or update required gems
25
- <pre><code>
26
- gemtools install
27
- </pre></code>
25
+ gemtools install
26
+
27
+ h3. Check to see if any of the gems in your app have newer versions
28
+
29
+ gemtools check_updates
28
30
 
29
31
  Make sure they are loaded with the right versions during startup, by adding the
30
32
  following to your script or environment.rb (Rails)
31
- <pre><code>
32
- require 'gem_tools'
33
- GemTools.load_gems
34
- </pre></code>
35
-
36
- The config file looks like
37
- <pre><code>
38
- # These are optional
39
- source: http://local_mirror.example.com
40
- gem_command: 'jruby -S gem'
41
- gems:
42
- - name: mongrel
43
- version: "1.0"
44
- # this gem has a specfic source URL
45
- source: 'http://mongrel.rubyforge.org/releases'
46
-
47
- - name: hpricot_scrub
48
- version: '0.3.3'
49
- # this tells us to load not just install
50
- load: true
51
-
52
- - name: postgres
53
- version: '0.7.1'
54
- load: true
55
- # any extra config that needs to be passed to gem install
56
- config: '--with-pgsql-include-dir=/usr/local/pgsql/include
57
- --with-pgsql-lib-dir=/usr/local/pgsql/lib'
58
-
59
- - name: rfeedparser_ictv
60
- version: '0.9.932'
61
- load: true
62
- # this one has a different load name than the gem name (not a normal need)
63
- require_name: 'rfeedparser'
64
- </pre></code>
65
-
66
- == REQUIREMENTS:
67
-
68
- None
69
-
70
- == INSTALL:
71
-
72
- sudo gem install gem_tools
73
-
74
- == TODO
75
-
76
- * Write the tests/specs
77
- * Make it work in Windows
78
-
79
- == LICENSE:
33
+
34
+ require 'gem_tools'
35
+ GemTools.load_gems
36
+
37
+
38
+ See the "sample config":http://github.com/UnderpantsGnome/gem_tools/blob/master/gems.yml.sample for the format
39
+
40
+ h2. INSTALL:
41
+
42
+ sudo gem install gem_tools
43
+
44
+ h2. TODO
45
+
46
+ * Write the tests/specs
47
+ * Make it work in Windows
48
+
49
+ h2. LICENSE:
80
50
 
81
51
  (The MIT License)
82
52
 
data/Rakefile ADDED
@@ -0,0 +1,52 @@
1
+ require 'rubygems'
2
+ require 'rake'
3
+
4
+ begin
5
+ require 'jeweler'
6
+ Jeweler::Tasks.new do |gem|
7
+ gem.name = "gem_tools"
8
+ gem.summary = "A gem manager"
9
+ gem.description = "A lightweight tool to manage gems using a config file, similar to GemInstaller"
10
+ gem.email = "michael@underpantsgnome.com"
11
+ gem.homepage = "http://github.com/UnderpantsGnome/gem_tools-gem"
12
+ gem.authors = ["Michael Moen"]
13
+ # gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
14
+ end
15
+ Jeweler::GemcutterTasks.new
16
+ rescue LoadError
17
+ puts "Jeweler (or a dependency) not available. Install it with: gem install jeweler"
18
+ end
19
+
20
+ require 'rake/testtask'
21
+ Rake::TestTask.new(:test) do |test|
22
+ test.libs << 'lib' << 'test'
23
+ test.pattern = 'test/**/test_*.rb'
24
+ test.verbose = true
25
+ end
26
+
27
+ begin
28
+ require 'rcov/rcovtask'
29
+ Rcov::RcovTask.new do |test|
30
+ test.libs << 'test'
31
+ test.pattern = 'test/**/test_*.rb'
32
+ test.verbose = true
33
+ end
34
+ rescue LoadError
35
+ task :rcov do
36
+ abort "RCov is not available. In order to run rcov, you must: sudo gem install spicycode-rcov"
37
+ end
38
+ end
39
+
40
+ task :test => :check_dependencies
41
+
42
+ task :default => :test
43
+
44
+ require 'rake/rdoctask'
45
+ Rake::RDocTask.new do |rdoc|
46
+ version = File.exist?('VERSION') ? File.read('VERSION') : ""
47
+
48
+ rdoc.rdoc_dir = 'rdoc'
49
+ rdoc.title = "gem_tools #{version}"
50
+ rdoc.rdoc_files.include('README*')
51
+ rdoc.rdoc_files.include('lib/**/*.rb')
52
+ end
data/bin/gemtools CHANGED
@@ -51,6 +51,11 @@ BANNER
51
51
  "Default: off") { |opt| options[:force] = opt }
52
52
  opts.on("-h", "--help",
53
53
  "Show this help message") { puts opts; exit }
54
+ opts.on("-v", "--version",
55
+ "Display the version") {
56
+ puts "#{File.basename($0)} #{GemTools::VERSION::STRING}"
57
+ exit
58
+ }
54
59
  opts.parse!(ARGV)
55
60
 
56
61
  if MANDATORY_OPTIONS && MANDATORY_OPTIONS.find { |option| options[option.to_sym].nil? }
data/config/gems.yml ADDED
@@ -0,0 +1,21 @@
1
+ # this is optional
2
+ # source: http://local_mirror.example.com
3
+ # gem_command: 'jruby -S gem'
4
+ gems:
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 ADDED
@@ -0,0 +1,57 @@
1
+ # Generated by jeweler
2
+ # DO NOT EDIT THIS FILE DIRECTLY
3
+ # Instead, edit Jeweler::Tasks in Rakefile, and run the gemspec command
4
+ # -*- encoding: utf-8 -*-
5
+
6
+ Gem::Specification.new do |s|
7
+ s.name = %q{gem_tools}
8
+ s.version = "0.2.3"
9
+
10
+ s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
+ s.authors = ["Michael Moen"]
12
+ s.date = %q{2010-01-27}
13
+ s.default_executable = %q{gemtools}
14
+ s.description = %q{A lightweight tool to manage gems using a config file, similar to GemInstaller}
15
+ s.email = %q{michael@underpantsgnome.com}
16
+ s.executables = ["gemtools"]
17
+ s.extra_rdoc_files = [
18
+ "README.textile",
19
+ "README.txt"
20
+ ]
21
+ s.files = [
22
+ ".gitignore",
23
+ "History.txt",
24
+ "License.txt",
25
+ "README.textile",
26
+ "README.txt",
27
+ "Rakefile",
28
+ "bin/gemtools",
29
+ "config/gems.template.yml",
30
+ "config/gems.yml",
31
+ "gem_tools.gemspec",
32
+ "lib/gem_tools.rb",
33
+ "spec/gem_tools_spec.rb",
34
+ "spec/spec.opts",
35
+ "spec/spec_helper.rb"
36
+ ]
37
+ s.homepage = %q{http://github.com/UnderpantsGnome/gem_tools-gem}
38
+ s.rdoc_options = ["--charset=UTF-8"]
39
+ s.require_paths = ["lib"]
40
+ s.rubygems_version = %q{1.3.5}
41
+ s.summary = %q{A gem manager}
42
+ s.test_files = [
43
+ "spec/gem_tools_spec.rb",
44
+ "spec/spec_helper.rb"
45
+ ]
46
+
47
+ if s.respond_to? :specification_version then
48
+ current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
49
+ s.specification_version = 3
50
+
51
+ if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
52
+ else
53
+ end
54
+ else
55
+ end
56
+ end
57
+
data/lib/gem_tools.rb CHANGED
@@ -77,8 +77,8 @@ module GemTools
77
77
  unless gems.nil?
78
78
  docs = ''
79
79
  unless OPTIONS.has_key?(:docs)
80
- docs << '--no-rdoc ' unless (`rdoc --version`).nil?
81
- docs << '--no-ri ' unless (`ri --version`).nil?
80
+ docs << '--no-rdoc ' unless (`rdoc --version 2> /dev/null`).nil?
81
+ docs << '--no-ri ' unless (`ri --version 2> /dev/null`).nil?
82
82
  end
83
83
 
84
84
  gem_command = config['gem_command'] || 'gem'
@@ -105,12 +105,15 @@ module GemTools
105
105
  end
106
106
 
107
107
  def check_gem(command, name, version='')
108
- spec = YAML.load(`#{command} spec #{name} 2> /dev/null`)
108
+ ENV['PATH'] ||= '/usr/bin'
109
+ ENV['PATH'] += ':/usr/local/bin:/usr/bin'
110
+ spec = YAML.load(`PATH=#{ENV['PATH']} #{command} spec #{name} 2> /dev/null`)
109
111
  loaded = false
110
112
  begin
111
113
  loaded = defined?(gem) ? gem(name, version) : require_gem(name, version)
112
114
  version = spec.version.version
113
- rescue Exception
115
+ rescue Exception => e
116
+ # puts e
114
117
  end
115
118
  [spec, loaded, version]
116
119
  end
@@ -123,14 +126,22 @@ module GemTools
123
126
  nil
124
127
  end
125
128
 
129
+ def has_gem?(gem)
130
+ @gems ||= Gem::SourceIndex.from_installed_gems
131
+ @gems.search(gem['name'], gem['version']).empty?
132
+ end
133
+
126
134
  def check_updates
127
135
  config = load_config
128
136
  gems = config['gems']
129
137
 
130
138
  gems.each do |gem|
131
- out = `gem list -r #{gem['name']}`
132
- ver = out.match(/\(([0-9\.]+)\)/)[1] rescue 0
133
- puts "#{gem['name']} #{ver} is available." if ver > gem['version']
139
+ source = gem['source'] || config['source'] || nil
140
+ source = "--source #{source}" if source
141
+ # puts "Checking #{gem['name']}"
142
+ out = `gem list -r #{gem['name']} #{source}`
143
+ ver = out.match(/\(([0-9\.]+)/)[1] #rescue 0
144
+ puts "#{gem['name']} #{ver} is available, #{gem['version']} installed" if ver > gem['version']
134
145
  end
135
146
  end
136
147
  end
@@ -0,0 +1,11 @@
1
+ require File.dirname(__FILE__) + '/spec_helper.rb'
2
+
3
+ # Time to add your specs!
4
+ # http://rspec.info/
5
+ describe "Place your specs here" do
6
+
7
+ it "find this spec in spec directory" do
8
+ violated "Be sure to write your specs"
9
+ end
10
+
11
+ end
data/spec/spec.opts ADDED
@@ -0,0 +1 @@
1
+ --colour
@@ -0,0 +1,10 @@
1
+ begin
2
+ require 'spec'
3
+ rescue LoadError
4
+ require 'rubygems'
5
+ gem 'rspec'
6
+ require 'spec'
7
+ end
8
+
9
+ $:.unshift(File.dirname(__FILE__) + '/../lib')
10
+ require 'gem_tools'
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.2
4
+ version: 0.2.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Michael Moen
@@ -9,49 +9,41 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-04-27 00:00:00 -05:00
13
- default_executable:
14
- dependencies:
15
- - !ruby/object:Gem::Dependency
16
- name: hoe
17
- type: :development
18
- version_requirement:
19
- version_requirements: !ruby/object:Gem::Requirement
20
- requirements:
21
- - - ">="
22
- - !ruby/object:Gem::Version
23
- version: 1.8.0
24
- version:
12
+ date: 2010-01-27 00:00:00 -06:00
13
+ default_executable: gemtools
14
+ dependencies: []
15
+
25
16
  description: A lightweight tool to manage gems using a config file, similar to GemInstaller
26
- email:
27
- - michael@underpantsgnome.com
17
+ email: michael@underpantsgnome.com
28
18
  executables:
29
19
  - gemtools
30
20
  extensions: []
31
21
 
32
22
  extra_rdoc_files:
33
- - History.txt
34
- - License.txt
35
- - PostInstall.txt
23
+ - README.textile
36
24
  - README.txt
37
25
  files:
26
+ - .gitignore
38
27
  - History.txt
39
28
  - License.txt
40
- - PostInstall.txt
29
+ - README.textile
41
30
  - README.txt
42
- - lib/gem_tools.rb
43
- - lib/gem_tools/version.rb
31
+ - Rakefile
44
32
  - bin/gemtools
45
33
  - config/gems.template.yml
34
+ - config/gems.yml
35
+ - gem_tools.gemspec
36
+ - lib/gem_tools.rb
37
+ - spec/gem_tools_spec.rb
38
+ - spec/spec.opts
39
+ - spec/spec_helper.rb
46
40
  has_rdoc: true
47
- homepage: http://underpantsgnome.rubyforge.org
48
- post_install_message: |
49
-
50
- For more information on GemTools see http://github.com/UnderpantsGnome/gem_tools/wikis
41
+ homepage: http://github.com/UnderpantsGnome/gem_tools-gem
42
+ licenses: []
51
43
 
44
+ post_install_message:
52
45
  rdoc_options:
53
- - --main
54
- - README.txt
46
+ - --charset=UTF-8
55
47
  require_paths:
56
48
  - lib
57
49
  required_ruby_version: !ruby/object:Gem::Requirement
@@ -68,10 +60,11 @@ required_rubygems_version: !ruby/object:Gem::Requirement
68
60
  version:
69
61
  requirements: []
70
62
 
71
- rubyforge_project: underpantsgnome
72
- rubygems_version: 1.3.1
63
+ rubyforge_project:
64
+ rubygems_version: 1.3.5
73
65
  signing_key:
74
- specification_version: 2
75
- summary: A lightweight tool to manage gems using a config file, similar to GemInstaller
76
- test_files: []
77
-
66
+ specification_version: 3
67
+ summary: A gem manager
68
+ test_files:
69
+ - spec/gem_tools_spec.rb
70
+ - spec/spec_helper.rb
data/PostInstall.txt DELETED
@@ -1,2 +0,0 @@
1
-
2
- For more information on GemTools see http://github.com/UnderpantsGnome/gem_tools/wikis
@@ -1,9 +0,0 @@
1
- module GemTools
2
- module VERSION #:nodoc:
3
- MAJOR = 0
4
- MINOR = 2
5
- TINY = 2
6
-
7
- STRING = [MAJOR, MINOR, TINY].join('.')
8
- end
9
- end