runcoderun-gem_sync 0.5.15 → 1.1.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/.gitignore ADDED
@@ -0,0 +1 @@
1
+ pkg
data/LICENSE ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2008 Relevance, Inc.
2
+
3
+ Permission is hereby granted, free of charge, to any person
4
+ obtaining a copy of this software and associated documentation
5
+ files (the "Software"), to deal in the Software without
6
+ restriction, including without limitation the rights to use,
7
+ copy, modify, merge, publish, distribute, sublicense, and/or sell
8
+ copies of the Software, and to permit persons to whom the
9
+ Software is furnished to do so, subject to the following
10
+ conditions:
11
+
12
+ The above copyright notice and this permission notice shall be
13
+ included in all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
16
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
17
+ OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
18
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
19
+ HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
20
+ WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
21
+ FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
22
+ OTHER DEALINGS IN THE SOFTWARE.
data/README.txt CHANGED
@@ -14,7 +14,7 @@ sudo gem install runcoderun-gem_sync --source http://gems.github.com
14
14
 
15
15
  (The MIT License)
16
16
 
17
- Copyright (c) 2008 Relevance, Inc.
17
+ Copyright (c) 2009 Relevance, Inc.
18
18
 
19
19
  Permission is hereby granted, free of charge, to any person obtaining
20
20
  a copy of this software and associated documentation files (the
data/Rakefile CHANGED
@@ -1,18 +1,21 @@
1
1
  require 'rubygems'
2
- require 'echoe'
3
- require './lib/rcr/gem_sync.rb'
4
- gem "spicycode-micronaut"
5
- require 'micronaut'
2
+ require 'rake'
6
3
  require 'micronaut/rake_task'
7
4
 
8
- Echoe.new('gem_sync', Rcr::GemSync::VERSION) do |p|
9
- p.rubyforge_name = 'gem_sync'
10
- p.email = 'rob@runcoderun.com'
11
- p.author = ["Rob Sanheim @ Relevance"]
12
- p.summary = "Tool to install dependencies for RunCodeRun, though it could be used to bootstrap your own machines as well."
13
- p.url = "http://runcoderun.com"
14
- p.test_pattern = 'spec/**/*_spec.rb'
15
- p.gemspec_format = :ruby
5
+ begin
6
+ require 'jeweler'
7
+ Jeweler::Tasks.new do |gem|
8
+ gem.name = "gem_sync"
9
+ gem.summary = %Q{gem_sync}
10
+ gem.description = %Q{Tool to install rubygems for RunCodeRun, though it could be used to bootstrap your own machines as well.}
11
+ gem.email = "rob@runcoderun.com"
12
+ gem.homepage = "http://github.com/runcoderun/gem_sync"
13
+ gem.authors = ["Rob Sanheim"]
14
+ gem.add_development_dependency "spicycode-micronaut"
15
+ # gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
16
+ end
17
+ rescue LoadError
18
+ puts "Jeweler (or a dependency) not available. Install it with: sudo gem install jeweler"
16
19
  end
17
20
 
18
21
  Micronaut::RakeTask.new(:examples)
@@ -31,3 +34,5 @@ desc 'Load the library in an IRB session'
31
34
  task :console do
32
35
  sh %(irb -r lib/rcr/gem_sync.rb)
33
36
  end
37
+
38
+ task :default => [:check_dependencies, :examples]
data/VERSION ADDED
@@ -0,0 +1 @@
1
+ 1.1.0
data/bin/gem_sync CHANGED
@@ -1,5 +1,7 @@
1
1
  #!/usr/bin/env ruby
2
- require File.join(File.dirname(__FILE__), *%w[.. lib rcr gem_sync])
2
+ lib_path = File.join(File.dirname(__FILE__), *%w[.. lib])
3
+ $LOAD_PATH.unshift lib_path unless $LOAD_PATH.include?(lib_path)
3
4
 
4
- gem_list = (ARGV[0] || nil)
5
- Rcr::GemSync.install_gems gem_list
5
+ require 'rcr/gem_sync'
6
+
7
+ Rcr::GemSync.new(ARGV).sync
@@ -0,0 +1,30 @@
1
+ lib_path = File.expand_path(File.dirname(__FILE__) + "/../lib")
2
+ $LOAD_PATH.unshift lib_path unless $LOAD_PATH.include?(lib_path)
3
+
4
+ require 'rubygems'
5
+ gem "spicycode-micronaut"
6
+ gem "mocha"
7
+ require 'micronaut'
8
+ require 'mocha'
9
+ require 'log_buddy'
10
+ require 'rcr/gem_sync'
11
+
12
+ LogBuddy.init
13
+
14
+ def not_in_editor?
15
+ ['TM_MODE', 'EMACS', 'VIM'].all? { |k| !ENV.has_key?(k) }
16
+ end
17
+
18
+ def in_runcoderun?
19
+ ENV["RUN_CODE_RUN"]
20
+ end
21
+
22
+ Micronaut.configure do |c|
23
+ c.formatter = :documentation if in_runcoderun?
24
+ c.alias_example_to :fit, :focused => true
25
+ c.alias_example_to :xit, :disabled => true
26
+ c.mock_with :mocha
27
+ c.color_enabled = not_in_editor?
28
+ c.filter_run :focused => true
29
+ end
30
+
@@ -0,0 +1,121 @@
1
+ require 'examples/example_helper'
2
+
3
+ describe Rcr::GemParser do
4
+
5
+ describe "converting a gem list" do
6
+ it "parses gems without a version" do
7
+ list = %[wirble]
8
+ gems = Rcr::GemParser.convert_gem_list(list)
9
+ gems[0].name.should == "wirble"
10
+ gems[0].version.should == nil
11
+ end
12
+
13
+ it "parses okay with commented lines" do
14
+ list = %[# here is a comment
15
+ # and another
16
+
17
+ xml-simple (1.0.11)]
18
+ gems = Rcr::GemParser.convert_gem_list(list)
19
+ gems.size.should == 1
20
+ end
21
+
22
+ it "parses gem list" do
23
+ list = %[wirble (0.1.2)
24
+ xml-simple (1.0.11)
25
+ ZenTest (3.10.0, 3.9.2, 3.9.1, 3.8.0, 3.6.0)]
26
+ gems = Rcr::GemParser.convert_gem_list(list)
27
+ gems[0].name.should == "wirble"
28
+ gems[0].version.should == "0.1.2"
29
+ gems[1].name.should == "xml-simple"
30
+ gems[1].version.should == "1.0.11"
31
+ gems[2..-1].each { |gem| gem.name.should == "ZenTest"}
32
+ gems[2].version.should == "3.10.0"
33
+ gems[3].version.should == "3.9.2"
34
+ end
35
+
36
+ it "can use version strings" do
37
+ list = %[do_sqlite3 (<= 0.9.8)]
38
+ gems = Rcr::GemParser.convert_gem_list(list)
39
+ gems.first.version.should == '<= 0.9.8'
40
+ end
41
+ end
42
+
43
+ describe "parsing platforms" do
44
+ it "is parses a single platform" do
45
+ list = %[rambow_likes_gerbils (<= 7.3.2) +ruby186]
46
+ gem = Rcr::GemParser.convert_gem_list(list).first
47
+ gem.platforms.should == %w{ruby186}
48
+ end
49
+
50
+ it "parses multiple platforms" do
51
+ list = %[some-gem-foo (<= 7.3.2) +ruby186 +jruby130]
52
+ gem = Rcr::GemParser.convert_gem_list(list).first
53
+ gem.platforms.should == %w{ruby186 jruby130}
54
+ end
55
+
56
+ it "parses platforms with dashes and underscores" do
57
+ list = %[rambow_likes_gerbils (1.0, 2.0) +ruby-186 +jruby_130]
58
+ gem = Rcr::GemParser.convert_gem_list(list).first
59
+ gem.platforms.should == %w{ruby-186 jruby_130}
60
+ end
61
+ end
62
+
63
+ describe "parsing versions" do
64
+ it "parses without a version" do
65
+ versions = Rcr::GemParser.parse_versions("foo")
66
+ versions[0].should == nil
67
+ end
68
+
69
+ it "parses single version" do
70
+ versions = Rcr::GemParser.parse_versions("foo (1.0.10)")
71
+ versions[0].should == "1.0.10"
72
+ end
73
+
74
+ it "parses single digit version" do
75
+ versions = Rcr::GemParser.parse_versions("echoe (3)")
76
+ versions[0].should == "3"
77
+ end
78
+
79
+ it "parses four digit versions" do
80
+ versions = Rcr::GemParser.parse_versions("fiveruns-memcache-client (1.5.0.3)")
81
+ versions[0].should == "1.5.0.3"
82
+ end
83
+
84
+ it "parses with multiple versions" do
85
+ versions = Rcr::GemParser.parse_versions("foo (1.0.10, 1.0.11)")
86
+ versions[0].should == "1.0.10"
87
+ versions[1].should == "1.0.11"
88
+ end
89
+
90
+ it "parses gems with numbers in the name" do
91
+ Rcr::GemParser.parse_versions("open4 (0.9.6)")[0].should == "0.9.6"
92
+ end
93
+ end
94
+
95
+ describe "parsing gem names" do
96
+ it "returns nil for comments" do
97
+ Rcr::GemParser.parse_name("# I hate factory-girl").should be_nil
98
+ end
99
+
100
+ it "returns nil for empty lines" do
101
+ Rcr::GemParser.parse_name(" ").should be_nil
102
+ end
103
+
104
+ it "parses gem name without versions" do
105
+ Rcr::GemParser.parse_name("factory-girl").should == "factory-girl"
106
+ end
107
+
108
+ it "parses simple gem name" do
109
+ Rcr::GemParser.parse_name("daemons (1.0.10)").should == "daemons"
110
+ end
111
+
112
+ it "parses name with dashes" do
113
+ Rcr::GemParser.parse_name("diff-lcs (1.0.10)").should == "diff-lcs"
114
+ end
115
+
116
+ it "parses name with underscores" do
117
+ Rcr::GemParser.parse_name("spec_converter_foo (1.0.10)").should == "spec_converter_foo"
118
+ end
119
+ end
120
+
121
+ end
@@ -0,0 +1,100 @@
1
+ require 'examples/example_helper'
2
+
3
+ describe Rcr::GemSync do
4
+
5
+ describe "creating a gem_sync" do
6
+ it "saves github gem list source" do
7
+ Rcr::GemSync.new(["--github"]).gem_list.should == Rcr::GemSync::RCR_GITHUB_GEM_LIST
8
+ end
9
+ end
10
+
11
+ describe "sync" do
12
+ it "should read gem list, install each gem, ..." do
13
+ gem_sync = Rcr::GemSync.new(["--github"])
14
+ gem_sync.expects(:read_gem_list)
15
+ gem_sync.expects(:parse_gems)
16
+ gem_sync.expects(:install_gems)
17
+ gem_sync.sync
18
+ end
19
+ end
20
+
21
+ describe "install_gems" do
22
+ it "should iterate over each gem, and install unless already installed" do
23
+ gem_sync = Rcr::GemSync.new(["--github"])
24
+ gem_sync.expects(:read_gem_list).returns(<<-EOL)
25
+ gem1 (1.0.0)
26
+ gem2 (1.0.0)
27
+ EOL
28
+ gem_sync.stubs(:installed?).returns(true, false)
29
+ gem_sync.expects(:install!).once
30
+ gem_sync.sync
31
+ end
32
+
33
+ it "shoud do nothing if the platform does not match" do
34
+ gem_sync = Rcr::GemSync.new(["-p ruby191"])
35
+ gem_sync.expects(:read_gem_list).returns(<<-EOL)
36
+ gem1 (1.0.0) +jruby130
37
+ EOL
38
+ gem_sync.expects(:install!).never
39
+ gem_sync.sync
40
+ end
41
+ end
42
+
43
+ describe "install!" do
44
+ it "should try installing as rubyforge first" do
45
+ gem = OpenStruct.new(:name => "foo", :version => "1.0.0")
46
+ gem_sync = Rcr::GemSync.new
47
+ gem_sync.expects(:run).with("gem install foo --no-ri --no-rdoc --version 1.0.0").returns(true)
48
+ gem_sync.install!(gem)
49
+ end
50
+
51
+ it "should fall back to github if not found on rubyforge" do
52
+ gem = OpenStruct.new(:name => "johndoe-foo", :version => "1.0.0")
53
+ gem_sync = Rcr::GemSync.new
54
+ gem_sync.expects(:run).with("gem install johndoe-foo --no-ri --no-rdoc --version 1.0.0").returns(false)
55
+ gem_sync.expects(:run).with("gem install johndoe-foo --no-ri --no-rdoc --version 1.0.0 --source http://gems.github.com")
56
+ gem_sync.install!(gem)
57
+ end
58
+ end
59
+
60
+ describe "platform_matches?" do
61
+ it "should return true if there is no platform" do
62
+ Rcr::GemSync.new.platform_matches?(OpenStruct.new).should == true
63
+ end
64
+
65
+ it "should return false gem sync and gem platform do not match" do
66
+ gem_sync = Rcr::GemSync.new(["-p ruby191"])
67
+ gem_sync.platform_matches?(OpenStruct.new(:platforms => ["jruby130"])).should == false
68
+ end
69
+
70
+ it "should return true if gem platform and current platform match" do
71
+ gem_sync = Rcr::GemSync.new(["-p ruby191"])
72
+ gem_sync.platform_matches?(OpenStruct.new(:platforms => ["ruby191"])).should == true
73
+ end
74
+
75
+ it "should return if gem platforms includes the current platform" do
76
+ gem_sync = Rcr::GemSync.new(["-p ruby191"])
77
+ gem_sync.platform_matches?(OpenStruct.new(:platforms => ["jruby130", "ruby191"])).should == true
78
+ end
79
+ end
80
+
81
+ describe "read gem list" do
82
+ it "should read the gem list" do
83
+ gem_sync = Rcr::GemSync.new(["--github"])
84
+ gem_sync.expects(:open).with(Rcr::GemSync::RCR_GITHUB_GEM_LIST).returns(StringIO.new)
85
+ gem_sync.read_gem_list
86
+ end
87
+ end
88
+
89
+ describe "failed installation" do
90
+ xit "should skip the gem and move on if failed due to permission denied" do
91
+ out = "Permission denied - /opt/local/lib/ruby/gems/1.8/cache/activesupport-1.4.4.gem"
92
+ end
93
+
94
+ xit "logs connection refused and skips gem, usually due to firewall blocking or gem mirrir is down"
95
+
96
+ xit "should try to install from github if gem was not found in default source(s)" do
97
+ end
98
+ end
99
+
100
+ end
@@ -0,0 +1,22 @@
1
+ require 'examples/example_helper'
2
+
3
+ describe Rcr::OptionParsing do
4
+
5
+ describe "gem list" do
6
+ it "uses github list for -g" do
7
+ opts = Rcr::OptionParsing.parse(["-g"])
8
+ opts[:github].should be_true
9
+ end
10
+
11
+ it "defaults to non github" do
12
+ opts = Rcr::OptionParsing.parse([])
13
+ opts[:github].should be_nil
14
+ end
15
+
16
+ it "returns github source url if github list selected" do
17
+ opts = Rcr::OptionParsing.parse(["-g"])
18
+ opts[:gem_list].should == Rcr::GemSync::RCR_GITHUB_GEM_LIST
19
+ end
20
+ end
21
+
22
+ end
data/gem_sync.gemspec CHANGED
@@ -1,37 +1,65 @@
1
+ # Generated by jeweler
2
+ # DO NOT EDIT THIS FILE
3
+ # Instead, edit Jeweler::Tasks in Rakefile, and run `rake gemspec`
1
4
  # -*- encoding: utf-8 -*-
2
5
 
3
6
  Gem::Specification.new do |s|
4
7
  s.name = %q{gem_sync}
5
- s.version = "0.5.15"
8
+ s.version = "1.1.0"
6
9
 
7
- s.required_rubygems_version = Gem::Requirement.new(">= 1.2") if s.respond_to? :required_rubygems_version=
8
- s.authors = ["Rob Sanheim @ Relevance"]
9
- s.date = %q{2008-12-09}
10
+ s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
+ s.authors = ["Rob Sanheim"]
12
+ s.date = %q{2009-09-04}
10
13
  s.default_executable = %q{gem_sync}
11
- s.description = %q{Tool to install dependencies for RunCodeRun, though it could be used to bootstrap your own machines as well.}
14
+ s.description = %q{Tool to install rubygems for RunCodeRun, though it could be used to bootstrap your own machines as well.}
12
15
  s.email = %q{rob@runcoderun.com}
13
16
  s.executables = ["gem_sync"]
14
- s.extra_rdoc_files = ["bin/gem_sync", "lib/rcr/gem_sync.rb", "lib/runcoderun_gems.txt", "README.txt"]
15
- s.files = ["bin/gem_sync", "gem_sync.gemspec", "History.txt", "lib/rcr/gem_sync.rb", "lib/runcoderun_gems.txt", "Manifest", "Manifest.txt", "Rakefile", "README.txt", "spec/gem_sync_spec.rb"]
16
- s.has_rdoc = true
17
- s.homepage = %q{http://runcoderun.com}
18
- s.rdoc_options = ["--line-numbers", "--inline-source", "--title", "Gem_sync", "--main", "README.txt"]
17
+ s.extra_rdoc_files = [
18
+ "LICENSE",
19
+ "README.txt"
20
+ ]
21
+ s.files = [
22
+ ".gitignore",
23
+ "History.txt",
24
+ "LICENSE",
25
+ "Manifest",
26
+ "Manifest.txt",
27
+ "README.txt",
28
+ "Rakefile",
29
+ "VERSION",
30
+ "bin/gem_sync",
31
+ "examples/example_helper.rb",
32
+ "examples/rcr/gem_parser_example.rb",
33
+ "examples/rcr/gem_sync_example.rb",
34
+ "examples/rcr/option_parsing_example.rb",
35
+ "gem_sync.gemspec",
36
+ "lib/rcr/gem_parser.rb",
37
+ "lib/rcr/gem_sync.rb",
38
+ "lib/rcr/option_parsing.rb",
39
+ "lib/runcoderun_gems.txt"
40
+ ]
41
+ s.homepage = %q{http://github.com/runcoderun/gem_sync}
42
+ s.rdoc_options = ["--charset=UTF-8"]
19
43
  s.require_paths = ["lib"]
20
- s.rubyforge_project = %q{gem_sync}
21
- s.rubygems_version = %q{1.3.1}
22
- s.summary = %q{Tool to install dependencies for RunCodeRun, though it could be used to bootstrap your own machines as well.}
23
- s.test_files = ["spec/gem_sync_spec.rb"]
44
+ s.rubygems_version = %q{1.3.5}
45
+ s.summary = %q{gem_sync}
46
+ s.test_files = [
47
+ "examples/example_helper.rb",
48
+ "examples/rcr/gem_parser_example.rb",
49
+ "examples/rcr/gem_sync_example.rb",
50
+ "examples/rcr/option_parsing_example.rb"
51
+ ]
24
52
 
25
53
  if s.respond_to? :specification_version then
26
54
  current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
27
- s.specification_version = 2
55
+ s.specification_version = 3
28
56
 
29
57
  if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
30
- s.add_development_dependency(%q<echoe>, [">= 0"])
58
+ s.add_development_dependency(%q<spicycode-micronaut>, [">= 0"])
31
59
  else
32
- s.add_dependency(%q<echoe>, [">= 0"])
60
+ s.add_dependency(%q<spicycode-micronaut>, [">= 0"])
33
61
  end
34
62
  else
35
- s.add_dependency(%q<echoe>, [">= 0"])
63
+ s.add_dependency(%q<spicycode-micronaut>, [">= 0"])
36
64
  end
37
65
  end
@@ -0,0 +1,42 @@
1
+ require 'ostruct'
2
+
3
+ module Rcr
4
+ class GemParser
5
+
6
+ def self.convert_gem_list(string)
7
+ gems = []
8
+ string.each do |line|
9
+ name = parse_name(line)
10
+ next unless name
11
+ versions = parse_versions(line)
12
+ platforms = parse_platforms(line)
13
+ if versions.empty?
14
+ gems << OpenStruct.new(:name => name, :platforms => platforms)
15
+ else
16
+ versions.each do |version|
17
+ gems << OpenStruct.new(:name => name, :version => version.strip, :platforms => platforms)
18
+ end
19
+ end
20
+ end
21
+ gems
22
+ end
23
+
24
+ def self.parse_name(string)
25
+ result = string.gsub(/#.*/, "").match(/[\w\-_]*/)[0]
26
+ result != "" ? result : nil
27
+ end
28
+
29
+ def self.parse_versions(string)
30
+ output = string.scan(/\((.*?)\)/).flatten
31
+ output = output.map {|s| s.split(",") }.flatten
32
+ output = output.map {|s| s.strip}
33
+ output
34
+ end
35
+
36
+ def self.parse_platforms(string)
37
+ string.scan(/\+[\w-]+\b/).map! { |platform| platform.gsub!('+', '') }
38
+ end
39
+
40
+
41
+ end
42
+ end
data/lib/rcr/gem_sync.rb CHANGED
@@ -1,114 +1,96 @@
1
- require 'ostruct'
2
1
  require 'open-uri'
2
+ require 'rcr/option_parsing'
3
+ require 'rcr/gem_parser'
3
4
 
4
5
  module Rcr
5
6
  class GemSync
6
- VERSION = '0.5.13'
7
7
  GITHUB = "http://gems.github.com"
8
8
  RCR_DEFAULT_GEM_LIST = File.expand_path(File.join(File.dirname(__FILE__), *%w[.. runcoderun_gems.txt]))
9
9
  RCR_GITHUB_GEM_LIST = "http://github.com/runcoderun/gem_sync/raw/master/lib/runcoderun_gems.txt"
10
10
  RCR_GITHUB_GEM_BLACKLIST = "http://github.com/runcoderun/gem_sync/raw/master/lib/gem_blacklist.txt"
11
11
 
12
- def self.install_gems(gem_list = nil)
13
- gem_list = RCR_DEFAULT_GEM_LIST unless gem_list
14
- # puts "gem_list: #{gem_list.inspect}"
15
- update_self
16
- read_gem_list(gem_list)
17
- install_gems_from_list
18
- update_gems
19
- uninstall_bad_gems(gem_list)
12
+ attr_accessor :gem_list
13
+ def initialize(args = ["--github"])
14
+ options = Rcr::OptionParsing.parse(args)
15
+ @platform = options[:platform]
16
+ @verbose = options[:verbose]
17
+ @dry_run = options[:dry_run]
18
+ @gem_list = options[:gem_list]
19
+ system("gem env") if verbose?
20
20
  end
21
21
 
22
- def self.uninstall_bad_gems(gem_list)
23
- return unless gem_list == "__from_github__"
24
- # puts "Uninstalling any gems on the blacklist..."
25
- blacklist = open(RCR_GITHUB_GEM_BLACKLIST).read
26
- convert_gem_list(blacklist).each do |rubygem|
27
- cmd = "gem uninstall #{rubygem.name} -I -a -x"
28
- cmd << " --version '#{rubygem.version}'" if rubygem.version
29
- puts cmd
30
- `#{cmd}`
31
- end
22
+ def verbose?
23
+ @verbose
32
24
  end
33
25
 
34
- def self.fail_if_gem_list_doesnt_exist(gem_list)
35
- raise("gem_list should not be nil") unless gem_list
36
- unless gem_list[0..3] == "http"
37
- raise("file for gem_list #{gem_list} not found!") unless File.exists?(gem_list)
38
- end
26
+ def dry_run?
27
+ @dry_run
28
+ end
29
+
30
+ def read_gem_list
31
+ open(gem_list).read
39
32
  end
40
33
 
41
- def self.update_self
42
- puts "Updating runcoderun-gem_sync from github..."
43
- puts `gem update runcoderun-gem_sync --source #{GITHUB}`
34
+ def platform_matches?(gem)
35
+ if gem.platforms && @platform
36
+ gem.platforms.include?(@platform)
37
+ else
38
+ true
39
+ end
44
40
  end
45
41
 
46
- def self.read_gem_list(gem_list)
47
- list = gem_list == "__from_github__" ? RCR_GITHUB_GEM_LIST : gem_list
48
- fail_if_gem_list_doesnt_exist(list)
49
- # puts "Running gem_sync with list: #{list}."
50
- @@gem_list = open(list).read
42
+ def sync
43
+ @gem_list = read_gem_list
44
+ @gems = parse_gems
45
+ install_gems
51
46
  end
52
47
 
53
- def self.update_gems
54
- puts "Updating all gems to latest..."
55
- puts `gem update`
48
+ def parse_gems
49
+ @gems = Rcr::GemParser.convert_gem_list(@gem_list)
56
50
  end
57
51
 
58
- def self.install_gems_from_list
59
- convert_gem_list(@@gem_list).each do |rubygem|
60
- if gem_installed?(rubygem.name, rubygem.version)
61
- puts "skipping #{rubygem.name} #{rubygem.version} - already installed..."
62
- next
63
- end
64
- cmd = "gem install #{rubygem.name} --no-ri --no-rdoc"
65
- cmd << " --version #{rubygem.version}" if rubygem.version
66
- puts cmd
67
- puts `#{cmd}`
68
- unless $?.success?
69
- cmd << " --source #{GITHUB}"
70
- puts "***** WARNING Trying to install gem #{rubygem.name} from github - watch for security issues."
71
- puts cmd
72
- puts `#{cmd}`
73
- end
52
+ def install_gems
53
+ @gems.each do |rubygem|
54
+ next unless platform_matches?(rubygem)
55
+ next if installed?(rubygem)
56
+ install!(rubygem)
74
57
  end
75
58
  end
76
-
77
- def self.convert_gem_list(string)
78
- gems = []
79
- string.each do |line|
80
- name = parse_name(line)
81
- next unless name
82
- versions = parse_versions(line)
83
- if versions.empty?
84
- gems << OpenStruct.new(:name => name)
85
- else
86
- versions.each do |version|
87
- gems << OpenStruct.new(:name => name, :version => version.strip)
88
- end
89
- end
90
- end
91
- gems
59
+
60
+ def installed?(rubygem)
61
+ installed_gems.detect {|gem| gem.name == rubygem.name && gem.version == rubygem.version}
62
+ end
63
+
64
+ def installed_gems
65
+ @installed_gems ||= Rcr::GemParser.convert_gem_list(`gem list`)
92
66
  end
93
67
 
94
- def self.parse_name(string)
95
- string.match(/[\w\-_]*/)[0]
68
+ def install!(rubygem)
69
+ install_from_rubyforge(rubygem) || install_from_github(rubygem)
96
70
  end
97
71
 
98
- def self.parse_versions(string)
99
- output = string.scan(/\((.*?)\)/).flatten
100
- output = output.map {|s| s.split(",") }.flatten
101
- output = output.map {|s| s.strip}
102
- output
72
+ def install_from_rubyforge(rubygem)
73
+ cmd = "gem install #{rubygem.name} --no-ri --no-rdoc"
74
+ cmd << " --version #{rubygem.version}" if rubygem.version
75
+ run(cmd)
103
76
  end
104
-
105
- def self.gem_installed?(name, version)
106
- installed_gems.detect {|gem| gem.name == name && gem.version == version}
77
+
78
+ def install_from_github(rubygem)
79
+ cmd = "gem install #{rubygem.name} --no-ri --no-rdoc"
80
+ cmd << " --version #{rubygem.version}" if rubygem.version
81
+ cmd << " --source #{GITHUB}"
82
+ run(cmd)
107
83
  end
108
-
109
- def self.installed_gems
110
- @installed_gems ||= convert_gem_list `gem list`
84
+
85
+ def run(cmd)
86
+ if dry_run?
87
+ puts cmd
88
+ true
89
+ else
90
+ puts cmd if verbose?
91
+ system(cmd)
92
+ end
111
93
  end
112
-
94
+
113
95
  end
114
96
  end
@@ -0,0 +1,35 @@
1
+ require 'optparse'
2
+
3
+ module Rcr
4
+ class OptionParsing
5
+
6
+ def self.parse(args)
7
+ options = {}
8
+
9
+ OptionParser.new do |opts|
10
+ opts.banner = "Usage: gem_sync [options]"
11
+
12
+ opts.on('-p', '--platform [PLATFORM]', 'Specify an optional platform') do |o|
13
+ options[:platform] = o.strip
14
+ end
15
+
16
+ opts.on('-g', '--github', 'Pull the list of gems to install from github') do |o|
17
+ options[:github] = o
18
+ options[:gem_list] = Rcr::GemSync::RCR_GITHUB_GEM_LIST
19
+ end
20
+
21
+ opts.on('-v', '--verbose', 'Run in verbose mode') do |o|
22
+ options[:verbose] = o
23
+ end
24
+
25
+ opts.on('-n', '--dry-run', 'Do a dry run without executing actions') do |o|
26
+ options[:dry_run] = o
27
+ end
28
+
29
+ end.parse!(args)
30
+
31
+ options
32
+ end
33
+
34
+ end
35
+ end
@@ -1,3 +1,7 @@
1
+ # Don't add these gems -- they break things bad:
2
+ # watir
3
+ # do_sqlite3 (<= 0.9.8)
4
+
1
5
  actionmailer (2.3.2, 2.2.2, 2.1.2, 2.1.0, 2.0.2, 2.0.1, 1.3.6)
2
6
  actionpack (2.3.2, 2.2.2, 2.1.2, 2.1.0, 2.0.2, 2.0.1, 1.13.6)
3
7
  actionwebservice (1.2.6)
@@ -10,6 +14,7 @@ addressable (2.0.2, 1.0.4)
10
14
  allison (2.0.3)
11
15
  andand
12
16
  andre-geokit
17
+ antage-postgres +ruby_191
13
18
  archive-tar-minitar (0.5.2)
14
19
  ar-extensions
15
20
  arrayfields (4.7.3, 4.6.0)
@@ -29,23 +34,23 @@ cgi_multipart_eof_fix (2.5.0)
29
34
  chrisk-fakeweb
30
35
  chronic
31
36
  coderay
32
- color (1.4.0)
37
+ colors
33
38
  configatron (2.2.2, 2.1.5)
34
39
  configuration (0.0.5)
35
40
  context
36
- crack (0.1.3)
41
+ crack
37
42
  csv-mapper (0.0.3)
38
43
  cucumber (0.3.96, 0.3.94, 0.3.92, 0.3.9, 0.3.11, 0.3.0)
39
- curb
40
- daemons (1.0.10)
41
- dancroak-clearance (0.1.3)
42
- dancroak-clearance-admin (0.0.1)
43
- dancroak-ruby-summize (0.4)
44
- dancroak-twitter-search (0.5)
45
- dancroak-validates_email_format_of (1.2.1)
44
+ curb +ruby_186 +ruby_191
45
+ daemons
46
+ dancroak-clearance
47
+ dancroak-clearance-admin
48
+ dancroak-ruby-summize
49
+ dancroak-twitter-search
50
+ dancroak-validates_email_format_of
46
51
  data_objects (0.9.12, 0.9.6)
47
- dbd-mysql
48
- dbd-sqlite3
52
+ dbd-mysql +ruby_186 +ruby_191
53
+ dbd-sqlite3 +ruby_186 +ruby_191
49
54
  dbi
50
55
  dfl-factories-and-workers
51
56
  diff-lcs (1.1.2)
@@ -53,13 +58,13 @@ dm-core (0.9.11)
53
58
  dm-tags (0.9.11)
54
59
  dm-validations (0.9.11)
55
60
  dnsruby (1.26, 1.24, 1.2)
56
- do_mysql
61
+ do_mysql +ruby_186 +ruby_191
57
62
  echoe (3.1.1, 3.0.2, 3)
58
63
  editalign
59
64
  erubis
60
65
  eventmachine
61
- expectations (1.2.0)
62
- extensions (0.6.0)
66
+ expectations
67
+ extensions
63
68
  extlib (0.9.12, 0.9.5)
64
69
  ezamar
65
70
  facets (2.5.2, 2.5.0, 2.4.5, 2.4.4, 2.4.1, 2.3.0, 2.2.1, 2.2.0, 2.1.3, 2.0.5)
@@ -69,7 +74,7 @@ faker
69
74
  fakeweb
70
75
  fastercsv (1.4.0, 1.2.3)
71
76
  fastthread (1.0.7, 1.0.1)
72
- fattr (1.0.3)
77
+ fattr
73
78
  feed-normalizer
74
79
  feedvalidator
75
80
  ferret
@@ -80,12 +85,12 @@ flog (2.1.0, 2.0.0, 1.1.0)
80
85
  freelancing-god-ginger
81
86
  freelancing-god-thinking-sphinx
82
87
  geminstaller
83
- gem_plugin (0.2.3)
88
+ gem_plugin
84
89
  geokit
85
90
  giraffesoft-resource_controller
86
- git (1.0.5)
87
- god (0.7.13, 0.7.12, 0.7.8)
88
- google-geocode (1.2.1)
91
+ git
92
+ god
93
+ google-geocode
89
94
  grancher
90
95
  grempe-amazon-ec2
91
96
  haml (2.2.1, 2.0.9, 2.0.7, 2.0.2, 2.0.1)
@@ -94,43 +99,45 @@ hashtostruct
94
99
  heckle (1.4.2, 1.4.1)
95
100
  highline (1.5.0, 1.4.0)
96
101
  hoe (1.12.2, 1.8.3, 1.8.2, 1.7.0)
97
- hpricot (0.8.1, 0.6.164, 0.6)
102
+ hpricot (0.8.1, 0.6.164, 0.6) +ruby_186 +ruby_191
98
103
  htmlentities (4.0.0)
99
104
  httparty
100
105
  httpauth
101
106
  httpclient
107
+ ianwhite-garlic
102
108
  icalendar (1.1.0, 1.0.2)
103
- image_science (1.1.3)
109
+ image_science (1.1.3) +ruby_186 +ruby_191
104
110
  innate
105
- javan-whenever (0.3.5)
106
- jeremymcanally-context (0.5)
107
- jeremymcanally-matchy (0.0.1)
108
- jeremymcanally-pending (0.1)
109
- jeremymcanally-stump (0.0.2)
110
- jnunemaker-twitter (0.6.12)
111
+ javan-whenever
112
+ jeremymcanally-context
113
+ jeremymcanally-matchy
114
+ jeremymcanally-pending
115
+ jeremymcanally-stump
116
+ jnunemaker-twitter
117
+ jruby-openssl +jruby
118
+ jruby-rcov +jruby
111
119
  jscruggs-metric_fu (1.1.4, 1.0.2)
112
- json (1.1.4, 1.1.3)
120
+ json (1.1.4, 1.1.3) +ruby_186 +ruby_191
113
121
  jsonbuilder
114
122
  juggernaut
115
- kematzy-sinatra-cache (0.2.2)
116
- lame_encoder (0.1.1)
123
+ kematzy-sinatra-cache
124
+ lame_encoder
117
125
  launchy (0.3.3, 0.3.2)
118
126
  less
119
- libxml-ruby (1.1.3, 0.9.8, 0.8.3)
127
+ libxml-ruby (1.1.3, 0.9.8, 0.8.3) +ruby_186 +ruby_191
120
128
  Linguistics
121
129
  liquid
122
130
  locale
123
131
  log4r
124
- log_buddy (0.4.10, 0.4.9, 0.0.5)
132
+ log_buddy
125
133
  main (2.8.3, 2.8.2)
126
- markaby (0.5)
134
+ markaby
127
135
  maruku
128
- mash (0.0.3)
136
+ mash
129
137
  mbleigh-acts-as-taggable-on
130
138
  mdoel-cukesteps
131
139
  mechanize
132
140
  memcache-client
133
- memcached (0.12, 0.11)
134
141
  merb-core (0.9.9)
135
142
  merb-exceptions (0.9.9)
136
143
  merb-freezer (0.9.5)
@@ -152,7 +159,7 @@ mixlib-cli (1.0.4)
152
159
  mixlib-config (1.0.9)
153
160
  mixlib-log (1.0.3)
154
161
  mocha (0.9.5, 0.9.4, 0.9.0)
155
- mojombo-chronic (0.3.0)
162
+ mojombo-chronic
156
163
  mojombo-grit (1.1.1, 0.9.4)
157
164
  mojombo-jekyll
158
165
  money
@@ -160,16 +167,16 @@ mongrel
160
167
  mosquito (0.1.4, 0.1.3)
161
168
  mwmitchell-rsolr
162
169
  mwmitchell-material_girl
163
- mysql (2.7)
170
+ mysql (2.7) +ruby_186 +ruby_191
164
171
  nagoro
165
172
  net-ssh (2.0.11, 2.0.4)
166
173
  newgem (1.3.0, 1.2.3, 1.1.0)
167
174
  nokogiri (1.3.2)
168
- oauth (0.3.4)
175
+ oauth
169
176
  obsidian
170
177
  ohai
171
- oniguruma (1.1.0)
172
- open4 (0.9.6)
178
+ oniguruma (1.1.0) +ruby_186
179
+ open4
173
180
  opscode-ohai
174
181
  opscode-mixlib-cli (1.0.4)
175
182
  opscode-mixlib-config (1.0.9)
@@ -178,12 +185,13 @@ patron
178
185
  orderedhash (0.0.6, 0.0.4)
179
186
  packet (0.1.15, 0.1.14)
180
187
  ParseTree (3.0.3, 2.2.0)
188
+ pauldix-sax-machine
181
189
  pdf-writer (1.1.8)
182
190
  peterwald-git (1.1.4)
183
191
  picnic (0.8.0, 0.7.1, 0.6.4)
184
192
  plist
185
193
  polyglot (0.2.6, 0.2.5, 0.2.3)
186
- postgres
194
+ postgres +ruby_186
187
195
  populator
188
196
  prawn
189
197
  PriorityQueue
@@ -191,48 +199,48 @@ quietbacktrace
191
199
  rack (1.0.0, 0.9.1, 0.4.0)
192
200
  rack-test (0.2.0, 0.1.0)
193
201
  rails (2.3.2, 2.3.1, 2.2.2, 2.1.2, 2.1.1, 2.1.0, 2.0.5, 2.0.4, 2.0.2, 1.2.6, 1.2.5, 1.2.4, 1.2.3, 1.2.2, 1.2.1, 1.2.0)
194
- rake (0.8.7, 0.8.4, 0.8.3, 0.8.2, 0.8.1)
202
+ rake (0.8.7, 0.8.4, 0.8.3)
195
203
  railroad
196
- rc-rest (2.2.1)
204
+ rc-rest
197
205
  rdiscount
198
206
  RedCloth (4.1.9, 4.1.1, 4.0.3, 4.0.1, 3.0.4, 3.0.3)
199
- redgreen (1.2.2)
207
+ redgreen
200
208
  reek (1.1.3)
201
- relevance-cap_gun (0.0.7)
209
+ relevance-cap_gun
202
210
  relevance-castronaut (0.3.6)
203
- relevance-github_hook (0.7.0)
204
- relevance-grit (0.8.3)
205
- relevance-log_buddy (0.4.10)
206
- relevance-multi_rails (0.0.7)
207
- relevance-rcov
208
- relevance-rubycas-server (0.6.99)
211
+ relevance-github_hook
212
+ relevance-grit
213
+ relevance-log_buddy
214
+ relevance-multi_rails
215
+ relevance-rcov +ruby_186 +ruby_191
216
+ relevance-rubycas-server
209
217
  relevance-tarantula
210
218
  relevance-test-spec
211
- remarkable (3.1.7)
212
- remarkable_activerecord (3.1.7)
219
+ remarkable
220
+ remarkable_activerecord
213
221
  remarkable_rails
214
222
  remarkably
215
223
  rest-client (0.9.2, 0.7)
216
- right_aws (1.8.1)
224
+ right_aws
217
225
  rio
218
- rmagick (2.10.0, 2.9.1, 2.6.0, 2.5.2)
226
+ rmagick (2.10.0, 2.9.1, 2.6.0) +ruby_186 +ruby_191
219
227
  roman-merb_cucumber
220
228
  roo
221
229
  roodi (1.4.0)
222
230
  rr
223
- rspec (1.2.7, 1.2.4, 1.1.8, 1.1.4, 0.5.0)
231
+ rspec (1.2.7, 1.2.4, 1.1.8, 1.1.4)
224
232
  rspec-rails (1.2.7.1, 1.2.4, 1.2.2, 1.2.0, 1.1.12, 1.1.11)
225
233
  rspec_hpricot_matchers
226
234
  rubigen
227
235
  ruby-aaws
228
236
  ruby-debug (0.10.2)
229
237
  ruby-hmac (0.3.2)
230
- ruby-json (1.1.2)
231
- ruby-net-ldap (0.0.4)
238
+ ruby-json
239
+ ruby-net-ldap
232
240
  ruby-openid
233
241
  ruby2ruby (1.2.2, 1.1.9)
234
242
  rubyforge (1.0.3, 1.0.2, 1.0.1, 1.0.0)
235
- rubygems-update (1.3.2, 1.3.1)
243
+ rubygems-update
236
244
  RubyInline (3.8.1, 3.7.0)
237
245
  rubyzip
238
246
  ruby_parser (2.0.3, 2.0.2)
@@ -251,8 +259,8 @@ sinatra
251
259
  spicycode-micronaut
252
260
  spicycode-micronaut-rails
253
261
  spork
254
- sql-parser (0.0.2)
255
- sqlite3-ruby (1.2.4, 1.2.3, 1.2.1)
262
+ sql-parser
263
+ sqlite3-ruby (1.2.4, 1.2.3, 1.2.1) +ruby_186 +ruby_191
256
264
  starling
257
265
  starling-starling
258
266
  stomp
@@ -262,32 +270,32 @@ systemu (1.2.0)
262
270
  system_timer (1.0)
263
271
  taf2-curb
264
272
  tagz
265
- technicalpickles-echoe (3)
273
+ technicalpickles-echoe
266
274
  technicalpickles-jeweler
267
- term-ansicolor (1.0.3)
268
- termios (0.9.4)
275
+ term-ansicolor
276
+ termios
269
277
  test-spec (0.10.0, 0.9.0)
270
278
  thin
271
279
  thinking_sphinx
272
- thoughtbot-clearance (0.1.6)
280
+ thoughtbot-clearance
273
281
  thoughtbot-factory_girl (1.2.1, 1.1.3)
274
282
  thoughtbot-paperclip (2.3.0, 2.3.1)
275
- thoughtbot-quietbacktrace (1.1.4)
276
- thoughtbot-shoulda (2.0.2)
283
+ thoughtbot-quietbacktrace
284
+ thoughtbot-shoulda
277
285
  timcharper-spork
278
- tidy (1.1.2)
286
+ tidy
279
287
  tinder (1.2.0, 1.1.7)
280
288
  tmm1-amqp
281
- topfunky-gruff (0.3.5)
282
- transaction-simple (1.4.0)
289
+ topfunky-gruff
290
+ transaction-simple
283
291
  treetop (1.2.6, 1.2.5, 1.2.4)
284
292
  twitter
285
293
  tzinfo
286
294
  unit_record
287
295
  uuidtools (1.0.7, 1.0.3)
288
- validatable (1.6.7)
296
+ validatable
289
297
  webrat
290
- will_paginate (2.2.2)
298
+ will_paginate
291
299
  xmlelements
292
300
  xml-simple
293
301
  yajl-ruby
metadata CHANGED
@@ -1,19 +1,19 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: runcoderun-gem_sync
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.15
4
+ version: 1.1.0
5
5
  platform: ruby
6
6
  authors:
7
- - Rob Sanheim @ Relevance
7
+ - Rob Sanheim
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2008-12-09 00:00:00 -08:00
12
+ date: 2009-09-04 00:00:00 -07:00
13
13
  default_executable: gem_sync
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
- name: echoe
16
+ name: spicycode-micronaut
17
17
  type: :development
18
18
  version_requirement:
19
19
  version_requirements: !ruby/object:Gem::Requirement
@@ -22,38 +22,40 @@ dependencies:
22
22
  - !ruby/object:Gem::Version
23
23
  version: "0"
24
24
  version:
25
- description: Tool to install dependencies for RunCodeRun, though it could be used to bootstrap your own machines as well.
25
+ description: Tool to install rubygems for RunCodeRun, though it could be used to bootstrap your own machines as well.
26
26
  email: rob@runcoderun.com
27
27
  executables:
28
28
  - gem_sync
29
29
  extensions: []
30
30
 
31
31
  extra_rdoc_files:
32
- - bin/gem_sync
33
- - lib/rcr/gem_sync.rb
34
- - lib/runcoderun_gems.txt
32
+ - LICENSE
35
33
  - README.txt
36
34
  files:
37
- - bin/gem_sync
38
- - gem_sync.gemspec
35
+ - .gitignore
39
36
  - History.txt
40
- - lib/rcr/gem_sync.rb
41
- - lib/runcoderun_gems.txt
37
+ - LICENSE
42
38
  - Manifest
43
39
  - Manifest.txt
44
- - Rakefile
45
40
  - README.txt
46
- - spec/gem_sync_spec.rb
47
- has_rdoc: true
48
- homepage: http://runcoderun.com
41
+ - Rakefile
42
+ - VERSION
43
+ - bin/gem_sync
44
+ - examples/example_helper.rb
45
+ - examples/rcr/gem_parser_example.rb
46
+ - examples/rcr/gem_sync_example.rb
47
+ - examples/rcr/option_parsing_example.rb
48
+ - gem_sync.gemspec
49
+ - lib/rcr/gem_parser.rb
50
+ - lib/rcr/gem_sync.rb
51
+ - lib/rcr/option_parsing.rb
52
+ - lib/runcoderun_gems.txt
53
+ has_rdoc: false
54
+ homepage: http://github.com/runcoderun/gem_sync
55
+ licenses:
49
56
  post_install_message:
50
57
  rdoc_options:
51
- - --line-numbers
52
- - --inline-source
53
- - --title
54
- - Gem_sync
55
- - --main
56
- - README.txt
58
+ - --charset=UTF-8
57
59
  require_paths:
58
60
  - lib
59
61
  required_ruby_version: !ruby/object:Gem::Requirement
@@ -66,14 +68,17 @@ required_rubygems_version: !ruby/object:Gem::Requirement
66
68
  requirements:
67
69
  - - ">="
68
70
  - !ruby/object:Gem::Version
69
- version: "1.2"
71
+ version: "0"
70
72
  version:
71
73
  requirements: []
72
74
 
73
- rubyforge_project: gem_sync
74
- rubygems_version: 1.2.0
75
+ rubyforge_project:
76
+ rubygems_version: 1.3.5
75
77
  signing_key:
76
- specification_version: 2
77
- summary: Tool to install dependencies for RunCodeRun, though it could be used to bootstrap your own machines as well.
78
+ specification_version: 3
79
+ summary: gem_sync
78
80
  test_files:
79
- - spec/gem_sync_spec.rb
81
+ - examples/example_helper.rb
82
+ - examples/rcr/gem_parser_example.rb
83
+ - examples/rcr/gem_sync_example.rb
84
+ - examples/rcr/option_parsing_example.rb
@@ -1,139 +0,0 @@
1
- require 'rubygems'
2
- gem 'spicycode-micronaut'
3
- require 'micronaut'
4
- require 'mocha'
5
- require File.join(File.dirname(__FILE__), *%w[.. lib rcr gem_sync])
6
- require File.join(File.dirname(__FILE__), *%w[example_helper])
7
-
8
- describe 'GemSync' do
9
-
10
- describe "calling gem_sync" do
11
- end
12
-
13
- describe "reading file" do
14
- before do
15
- Rcr::GemSync.stubs :update_self
16
- Rcr::GemSync.stubs :install_gems_from_list
17
- Rcr::GemSync.stubs :update_gems
18
- end
19
-
20
- it "uses default gem list for nil gem list" do
21
- Rcr::GemSync.expects(:open).with(Rcr::GemSync::RCR_DEFAULT_GEM_LIST).returns(StringIO.new)
22
- Rcr::GemSync.install_gems
23
- Rcr::GemSync.expects(:open).with(Rcr::GemSync::RCR_DEFAULT_GEM_LIST).returns(StringIO.new)
24
- Rcr::GemSync.install_gems nil
25
- end
26
-
27
- it "allows overriding gem list file" do
28
- Rcr::GemSync.stubs(:fail_if_gem_list_doesnt_exist).returns(true)
29
- Rcr::GemSync.expects(:open).with("/my/gems.txt").returns(StringIO.new)
30
- Rcr::GemSync.install_gems "/my/gems.txt"
31
- end
32
-
33
- it "reads file for gem list" do
34
- Rcr::GemSync.stubs(:fail_if_gem_list_doesnt_exist).returns(true)
35
- Rcr::GemSync.expects(:open).with("/my/gems.txt").returns(StringIO.new)
36
- Rcr::GemSync.read_gem_list "/my/gems.txt"
37
- end
38
-
39
- it "reads from gem list and blacklist on github if passed github param" do
40
- Rcr::GemSync.expects(:open).with(Rcr::GemSync::RCR_GITHUB_GEM_LIST).returns(StringIO.new)
41
- Rcr::GemSync.expects(:open).with(Rcr::GemSync::RCR_GITHUB_GEM_BLACKLIST).returns(StringIO.new)
42
-
43
- Rcr::GemSync.install_gems "__from_github__"
44
- end
45
-
46
- end
47
-
48
- describe "parsing a gem list" do
49
- it "parses gems without a version" do
50
- list = %[wirble]
51
- gems = Rcr::GemSync.convert_gem_list(list)
52
- gems[0].name.should == "wirble"
53
- gems[0].version.should == nil
54
- end
55
-
56
- it "parses gem list" do
57
- list = %[wirble (0.1.2)
58
- xml-simple (1.0.11)
59
- ZenTest (3.10.0, 3.9.2, 3.9.1, 3.8.0, 3.6.0)]
60
- gems = Rcr::GemSync.convert_gem_list(list)
61
- gems[0].name.should == "wirble"
62
- gems[0].version.should == "0.1.2"
63
- gems[1].name.should == "xml-simple"
64
- gems[1].version.should == "1.0.11"
65
- gems[2..-1].each { |gem| gem.name.should == "ZenTest"}
66
- gems[2].version.should == "3.10.0"
67
- gems[3].version.should == "3.9.2"
68
- end
69
-
70
- it "can use version strings" do
71
- list = %[do_sqlite3 (<= 0.9.8)]
72
- gems = Rcr::GemSync.convert_gem_list(list)
73
- gems.first.version.should == '<= 0.9.8'
74
- end
75
- end
76
-
77
- describe "parsing versions" do
78
- it "parses without a version" do
79
- versions = Rcr::GemSync.parse_versions("foo")
80
- versions[0].should == nil
81
- end
82
-
83
- it "parses single version" do
84
- versions = Rcr::GemSync.parse_versions("foo (1.0.10)")
85
- versions[0].should == "1.0.10"
86
- end
87
-
88
- it "parses single digit version" do
89
- versions = Rcr::GemSync.parse_versions("echoe (3)")
90
- versions[0].should == "3"
91
- end
92
-
93
- it "parses four digit versions" do
94
- versions = Rcr::GemSync.parse_versions("fiveruns-memcache-client (1.5.0.3)")
95
- versions[0].should == "1.5.0.3"
96
- end
97
-
98
- it "parses with multiple versions" do
99
- versions = Rcr::GemSync.parse_versions("foo (1.0.10, 1.0.11)")
100
- versions[0].should == "1.0.10"
101
- versions[1].should == "1.0.11"
102
- end
103
-
104
- it "parses gems with numbers in the name" do
105
- Rcr::GemSync.parse_versions("open4 (0.9.6)")[0].should == "0.9.6"
106
- end
107
- end
108
-
109
- describe "parsing gem names" do
110
-
111
- it "parses gem name without versions" do
112
- Rcr::GemSync.parse_name("factory-girl").should == "factory-girl"
113
- end
114
-
115
- it "parses simple gem name" do
116
- Rcr::GemSync.parse_name("daemons (1.0.10)").should == "daemons"
117
- end
118
-
119
- it "parses name with dashes" do
120
- Rcr::GemSync.parse_name("diff-lcs (1.0.10)").should == "diff-lcs"
121
- end
122
-
123
- it "parses name with underscores" do
124
- Rcr::GemSync.parse_name("spec_converter_foo (1.0.10)").should == "spec_converter_foo"
125
- end
126
- end
127
-
128
- describe "failed installation" do
129
- xit "should skip the gem and move on if failed due to permission denied" do
130
- out = "Permission denied - /opt/local/lib/ruby/gems/1.8/cache/activesupport-1.4.4.gem"
131
- end
132
-
133
- xit "logs connection refused and skips gem, usually due to firewall blocking or gem mirrir is down"
134
-
135
- xit "should try to install from github if gem was not found in default source(s)" do
136
- end
137
- end
138
-
139
- end