gemsync 0.1.3 → 0.1.4

Sign up to get free protection for your applications and to get access to all the features.
data/Rakefile CHANGED
@@ -5,7 +5,7 @@ begin
5
5
  require 'jeweler'
6
6
  Jeweler::Tasks.new do |gem|
7
7
  gem.name = "gemsync"
8
- gem.version = "0.1.3"
8
+ gem.version = "0.1.4"
9
9
  gem.summary = %Q{Small gem to sync multiple gem installations.}
10
10
  gem.description = %Q{Small gem to sync multiple gem installations. This can be done by pointing to a ruby installation or from a text file created by `gem list > file.txt`.}
11
11
  gem.email = "quest@mac.com"
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.1.3
1
+ 0.1.4
data/bin/gemsync CHANGED
@@ -6,8 +6,9 @@ require 'rubygems'
6
6
  require 'trollop'
7
7
 
8
8
  # Setup arguments from the command line.
9
+ # This uses the trollop library on github.
9
10
  opts = Trollop::options do
10
- version "gemsync 0.1.3 (c) 2010 Josh Ellithorpe"
11
+ version "gemsync 0.1.4 (c) 2010 Josh Ellithorpe"
11
12
  banner <<-EOS
12
13
  Small gem to sync multiple gem installations.
13
14
 
@@ -24,6 +25,7 @@ end
24
25
  # Check if the file or directory exists, if not exit
25
26
  Trollop::die :source, "\n\t-- Directory or file '#{opts[:source]}' does not exist" unless File.exists?(opts[:source])
26
27
 
28
+ # Check if source is a file or directory.
27
29
  if File.ftype(opts[:source]) == 'file'
28
30
  @source_type = 'file'
29
31
  else
@@ -31,16 +33,14 @@ else
31
33
  Trollop::die :source, "\n\t-- Binary '#{opts[:source]}/bin/gem' does not exist" unless File.exists?("#{opts[:source]}/bin/gem")
32
34
  end
33
35
 
36
+ # Die if destination is set incorrectly
34
37
  Trollop::die :destination, "\n\t-- Directory '#{opts[:destination]}' does not exist" unless File.directory?(opts[:destination])
35
38
  Trollop::die :destination, "\n\t-- Binary '#{opts[:destination]}/bin/gem' does not exist" unless File.exists?("#{opts[:destination]}/bin/gem")
36
39
 
37
- @main_dir = opts[:source]
38
- @sync_dir = opts[:destination]
39
-
40
40
  # Cleanup main and sync dir, they shouldn't end in a '/' so lets chomp it.
41
41
  # Couldn't use chomp! since opts are frozen.
42
- @main_dir = @main_dir.chomp('/')
43
- @sync_dir = @sync_dir.chomp('/')
42
+ @main_dir = opts[:source].chomp('/')
43
+ @sync_dir = opts[:destination].chomp('/')
44
44
 
45
45
  # Setup additional flags
46
46
  @docstring = opts[:build_docs] ? '' : '--no-ri --no-rdoc'
@@ -49,13 +49,19 @@ Trollop::die :destination, "\n\t-- Binary '#{opts[:destination]}/bin/gem' does n
49
49
  # Gems you don't want to sync
50
50
  def get_exceptions
51
51
  # Setup hash of common gems that certain ruby installs can't support
52
- # For now this is just rubynode for REE, feel free to add more
53
- common_exceptions = {:ree => ["rubynode"]}
52
+ # For now this is just rubynode for REE and JRuby, feel free to add more
53
+ # hpricot is not in the jruby list because 0.6.x is supported.
54
+ common_exceptions = {
55
+ :ree => ["rubynode"],
56
+ :jruby => ["acts_as_ferret", "bleak_house", "bluecloth", "dnssd", "fastthread", "fcgi", "ferret", "fraction", "jk-ferret", "json", "libxml-ruby", "linecache","mysql", "mysql2", "mysqlplus", "passenger", "pauldix-feedzirra", "pcaprub", "rb-appscript", "rmagick", "ruby-debug-base", "ruby-prof", "rubynode", "sqlite3-ruby", "system_timer", "taf2-curb", "termios", "timetrap", "unicorn", "wikitext", "yajl-ruby"]
57
+ }
54
58
  mandated_version = {:ruby187 => ["bleak_house"]}
55
- returned_exceptions = []
59
+ returned_exceptions = ['']
56
60
  sync_version = `#{@sync_dir}/bin/gem --version`
57
61
  if @sync_dir.match('enterprise')
58
62
  returned_exceptions += common_exceptions[:ree]
63
+ elsif @sync_dir.match('jruby')
64
+ returned_exceptions += common_exceptions[:jruby]
59
65
  end
60
66
  if sync_version != '1.8.7'
61
67
  returned_exceptions += mandated_version[:ruby187]
@@ -63,6 +69,7 @@ def get_exceptions
63
69
  return returned_exceptions
64
70
  end
65
71
 
72
+ # Get file as string
66
73
  def get_file_as_string(filename)
67
74
  data = ''
68
75
  f = File.open(filename, "r")
@@ -72,20 +79,32 @@ def get_file_as_string(filename)
72
79
  return data
73
80
  end
74
81
 
82
+ # Get gem list from source
75
83
  if @source_type == 'directory'
76
84
  gem_list = %x[#{@main_dir}/bin/gem list].split("\n")
77
85
  else
78
86
  gem_list = get_file_as_string(opts[:source]).split("\n")
79
87
  end
80
-
88
+
89
+ # Get gem list from destination
81
90
  sync_gem_list = %x[#{@sync_dir}/bin/gem list].split("\n")
82
91
 
83
92
  # Cleanup gems we know we don't need to update
84
93
  gems = gem_list - sync_gem_list
85
94
 
95
+ # Loop through gems and update them.
86
96
  for gem in gems
87
- gem_name = gem.match(/(.*) \((.*)\)/)[1]
88
- gem_versions = gem.match(/(.*) \((.*)\)/)[2]
97
+ # Trap regexps in try block incase matches don't work out.
98
+ begin
99
+ gem_name = gem.match(/(.*) \((.*)\)/)[1]
100
+ gem_versions = gem.match(/(.*) \((.*)\)/)[2]
101
+ rescue
102
+ gem_name = nil
103
+ gem_versions = nil
104
+ end
105
+ next if gem_name.nil? || gem_versions.nil?
106
+
107
+ # If valid gem start checking/updating it.
89
108
  puts "## Checking #{gem_name}"
90
109
  if get_exceptions().include?(gem_name)
91
110
  puts "This gem is known to be incompatible with the sync'd ruby installation"
@@ -109,7 +128,7 @@ for gem in gems
109
128
  # Also look for mysql5 type binaries that some package managers use
110
129
  mysql_config = `which mysql_config` || `which mysql_config5`
111
130
  mysql_dir = `which mysql` || `which mysql5`
112
- mysql_dir.split('/')[0..-2].join('/')
131
+ mysql_dir = mysql_dir.split('/')[0..-2].join('/')
113
132
  system("#{@sudostring}#{@sync_dir}/bin/gem install #{gem_name} -v #{version} -- --with-mysql-dir=#{mysql_dir} --with-mysql-config=#{mysql_config} #{@docstring}")
114
133
  else
115
134
  system("#{@sudostring}#{@sync_dir}/bin/gem install #{gem_name} -v #{version} #{@docstring}")
data/gemsync.gemspec CHANGED
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{gemsync}
8
- s.version = "0.1.3"
8
+ s.version = "0.1.4"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["quest"]
12
- s.date = %q{2010-09-19}
12
+ s.date = %q{2010-09-20}
13
13
  s.default_executable = %q{gemsync}
14
14
  s.description = %q{Small gem to sync multiple gem installations. This can be done by pointing to a ruby installation or from a text file created by `gem list > file.txt`.}
15
15
  s.email = %q{quest@mac.com}
@@ -26,7 +26,7 @@ Gem::Specification.new do |s|
26
26
  "VERSION",
27
27
  "bin/gemsync",
28
28
  "gemsync.gemspec",
29
- "pkg/gemsync-0.1.3.gem",
29
+ "pkg/gemsync-0.1.4.gem",
30
30
  "rdoc/created.rid",
31
31
  "rdoc/files/README_rdoc.html",
32
32
  "rdoc/fr_class_index.html",
Binary file
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gemsync
3
3
  version: !ruby/object:Gem::Version
4
- hash: 29
4
+ hash: 19
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 1
9
- - 3
10
- version: 0.1.3
9
+ - 4
10
+ version: 0.1.4
11
11
  platform: ruby
12
12
  authors:
13
13
  - quest
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2010-09-19 00:00:00 -07:00
18
+ date: 2010-09-20 00:00:00 -07:00
19
19
  default_executable: gemsync
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency
@@ -51,7 +51,7 @@ files:
51
51
  - VERSION
52
52
  - bin/gemsync
53
53
  - gemsync.gemspec
54
- - pkg/gemsync-0.1.3.gem
54
+ - pkg/gemsync-0.1.4.gem
55
55
  - rdoc/created.rid
56
56
  - rdoc/files/README_rdoc.html
57
57
  - rdoc/fr_class_index.html
Binary file