Narnach-gems 0.1.7 → 0.2.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/README.rdoc +9 -30
- data/bin/gems +17 -17
- data/gems.gemspec +9 -4
- data/lib/gems.rb +24 -25
- data/lib/gems_config.rb +15 -6
- data/lib/gems_list.rb +17 -0
- data/lib/gems_parser.rb +1 -1
- metadata +3 -3
data/README.rdoc
CHANGED
@@ -5,6 +5,9 @@ Rails code would not get into dependency issues.
|
|
5
5
|
|
6
6
|
== Recent changes
|
7
7
|
|
8
|
+
=== Version 0.2.0
|
9
|
+
Most gems commands can now work on multiple projects at the same time. The 'gems help' command has been updated to reflect this.
|
10
|
+
|
8
11
|
=== Version 0.1.7
|
9
12
|
Gem install only installs missing gems; it does not re-install gems.
|
10
13
|
|
@@ -50,36 +53,8 @@ From the project root, use rake to install:
|
|
50
53
|
This will build the gem and install it for you.
|
51
54
|
|
52
55
|
== Usage
|
53
|
-
|
54
|
-
|
55
|
-
gems 'action' 'arguments'
|
56
|
-
|
57
|
-
Actions and arguments:
|
58
|
-
install 'name'
|
59
|
-
Install all missing gems in project 'name'.
|
60
|
-
uninstall 'name'
|
61
|
-
Uninstall all gems in project 'name'.
|
62
|
-
diff 'name'
|
63
|
-
See difference between the current gem configuration and that of project 'name'.
|
64
|
-
switch 'name'
|
65
|
-
Switch to the exact gem configuration in project 'name'.
|
66
|
-
This will preserve all shared gems in the current state and in the target
|
67
|
-
project, only installing and uninstalling what is needed.
|
68
|
-
list 'name'
|
69
|
-
List all gems in project 'name'.
|
70
|
-
import 'name' 'file'
|
71
|
-
Import all gems in 'file' into project 'name'.
|
72
|
-
This will overwrite the gems currently in this project.
|
73
|
-
The special file 'current' will use the output of `gems list` instead of a file.
|
74
|
-
export 'name' 'file'
|
75
|
-
Export all gems in project 'name' to 'file'.
|
76
|
-
The file will be overwritten and can be parsed by the import action.
|
77
|
-
add 'name' 'file'
|
78
|
-
Add the gems 'file' to project 'name'.
|
79
|
-
projects
|
80
|
-
List all stored project names.
|
81
|
-
configure 'name' 'gem' [option1 option2 option3]
|
82
|
-
Configure a specific gem inside a project to use specific options when installing.
|
56
|
+
See the gems help for the syntax
|
57
|
+
gems help
|
83
58
|
|
84
59
|
== Examples
|
85
60
|
To store your current gems as project 'dev', do the following:
|
@@ -88,9 +63,13 @@ To store your current gems as project 'dev', do the following:
|
|
88
63
|
To switch from project 'dev' to 'server', do the following:
|
89
64
|
gems uninstall dev
|
90
65
|
gems install server
|
66
|
+
It is also possible to directly switch to a project:
|
67
|
+
gems switch server
|
91
68
|
To export project 'dev' to the file 'gems.dev', do the following:
|
92
69
|
gems export dev gems.dev
|
93
70
|
|
71
|
+
== Ideas / plans / todo
|
72
|
+
|
94
73
|
== About
|
95
74
|
Author:: Wes 'Narnach' Oldenbeuving (http://github.com/Narnach)
|
96
75
|
Website:: http://github.com/Narnach/gems
|
data/bin/gems
CHANGED
@@ -6,13 +6,13 @@ project = ARGV.shift.to_s.strip
|
|
6
6
|
|
7
7
|
case action
|
8
8
|
when 'install'
|
9
|
-
gems = Gems.new
|
9
|
+
gems = Gems.new([project] + ARGV)
|
10
10
|
gems.install
|
11
11
|
when 'uninstall'
|
12
|
-
gems = Gems.new
|
12
|
+
gems = Gems.new([project] + ARGV)
|
13
13
|
gems.uninstall
|
14
14
|
when 'list'
|
15
|
-
gems = Gems.new
|
15
|
+
gems = Gems.new([project] + ARGV)
|
16
16
|
gems.list
|
17
17
|
when 'import'
|
18
18
|
gems_config = GemsConfig.new(project)
|
@@ -36,10 +36,10 @@ when 'add'
|
|
36
36
|
gems_file = ARGV.shift.to_s.strip
|
37
37
|
gems_config.add_gems(gems_file)
|
38
38
|
when 'diff'
|
39
|
-
gems = Gems.new
|
39
|
+
gems = Gems.new([project] + ARGV)
|
40
40
|
gems.diff_current
|
41
41
|
when 'switch'
|
42
|
-
gems = Gems.new
|
42
|
+
gems = Gems.new([project] + ARGV)
|
43
43
|
gems.switch_from_current
|
44
44
|
else 'help'
|
45
45
|
puts <<-EOS
|
@@ -47,18 +47,18 @@ Syntax:
|
|
47
47
|
gems <action> <arguments>
|
48
48
|
|
49
49
|
Actions and arguments:
|
50
|
-
install <
|
51
|
-
Install all missing gems in project
|
52
|
-
uninstall <
|
53
|
-
Uninstall all gems in project
|
54
|
-
diff <
|
55
|
-
See difference between the current gem configuration and that of
|
56
|
-
switch <
|
57
|
-
Switch to
|
58
|
-
This will preserve all shared gems in the current state and in the target
|
59
|
-
|
60
|
-
list <
|
61
|
-
List all gems in
|
50
|
+
install <name1> [name2 .. nameN]
|
51
|
+
Install all missing gems in project name1..nameN.
|
52
|
+
uninstall <name1> [name2 .. nameN]
|
53
|
+
Uninstall all gems in project name1..nameN.
|
54
|
+
diff <name1> [name2 .. nameN]
|
55
|
+
See difference between the current gem configuration and that of the union of projects name1..nameN.
|
56
|
+
switch <name1> [name2 .. nameN]
|
57
|
+
Switch to gem configuration in the union of projects name1..nameN.
|
58
|
+
This will preserve all shared gems in the current state and in the target state,
|
59
|
+
only installing and uninstalling what is needed.
|
60
|
+
list <name1> [name2 .. nameN]
|
61
|
+
List all gems in union of projects name1..nameN.
|
62
62
|
import <name> <file>
|
63
63
|
Import all gems in <file> into project <name>.
|
64
64
|
This will overwrite the gems currently in this project.
|
data/gems.gemspec
CHANGED
@@ -3,8 +3,8 @@ Gem::Specification.new do |s|
|
|
3
3
|
s.name = 'gems'
|
4
4
|
s.summary = "Gems is a simple tool to manage sets of RubyGems."
|
5
5
|
s.description = "Gems is a simple tool to manage sets of RubyGems. It can be used to install and uninstall large numbers of gems."
|
6
|
-
s.version = '0.
|
7
|
-
s.date = '2008-08-
|
6
|
+
s.version = '0.2.0'
|
7
|
+
s.date = '2008-08-26'
|
8
8
|
s.platform = Gem::Platform::RUBY
|
9
9
|
s.authors = ["Wes Oldenbeuving"]
|
10
10
|
s.email = "narnach@gmail.com"
|
@@ -14,8 +14,13 @@ Gem::Specification.new do |s|
|
|
14
14
|
s.bindir = "bin"
|
15
15
|
s.executables = %w[gems]
|
16
16
|
s.require_path = "lib"
|
17
|
-
|
18
|
-
|
17
|
+
root_files = %w[MIT-LICENSE README.rdoc Rakefile gems.gemspec]
|
18
|
+
bin_files = %w[gems]
|
19
|
+
lib_files = %w[gems gems_config gems_parser gems_list]
|
20
|
+
test_files = %w[]
|
21
|
+
spec_files = %w[]
|
22
|
+
s.test_files = test_files.map {|f| 'test/%s_test.rb' % f} + spec_files.map {|f| 'spec/%s_spec.rb' % f}
|
23
|
+
s.files = root_files + s.test_files + bin_files.map {|f| 'bin/%s' % f} + lib_files.map {|f| 'lib/%s.rb' % f}
|
19
24
|
|
20
25
|
# rdoc
|
21
26
|
s.has_rdoc = true
|
data/lib/gems.rb
CHANGED
@@ -2,28 +2,21 @@ require 'gems_config'
|
|
2
2
|
require 'gems_parser'
|
3
3
|
require 'gems_list'
|
4
4
|
|
5
|
-
class Hash
|
6
|
-
def longest_key_length
|
7
|
-
map{|key, value| key.to_s.size}.max || 0
|
8
|
-
end
|
9
|
-
end
|
10
|
-
|
11
5
|
class Gems
|
12
|
-
attr_reader :project, :gems, :gems_config
|
6
|
+
attr_reader :project, :projects, :gems, :gems_config
|
13
7
|
|
14
|
-
def initialize(
|
15
|
-
@
|
8
|
+
def initialize(*projects)
|
9
|
+
@projects = projects.flatten
|
10
|
+
@project = projects.first
|
16
11
|
@gems_config = GemsConfig.new(@project)
|
17
12
|
@gems = @gems_config.gems
|
18
13
|
end
|
19
14
|
|
20
15
|
def diff_current
|
21
|
-
|
22
|
-
|
23
|
-
not_in_current = project_gems - current_gems
|
24
|
-
in_current = current_gems - project_gems
|
16
|
+
not_in_current = projects_gems - current_gems_list
|
17
|
+
in_current = current_gems_list - projects_gems
|
25
18
|
|
26
|
-
puts 'Gems unique to "%s":' %
|
19
|
+
puts 'Gems unique to "%s":' % projects.join(", ")
|
27
20
|
print_gem_list(not_in_current)
|
28
21
|
puts
|
29
22
|
puts 'Gems unique to the current gems list:'
|
@@ -31,29 +24,29 @@ class Gems
|
|
31
24
|
end
|
32
25
|
|
33
26
|
def list
|
34
|
-
|
35
|
-
|
27
|
+
list_name = projects.size == 1 ? 'Gems in' : 'Union of all gems in'
|
28
|
+
projects_list = projects.join(", ")
|
29
|
+
puts '%s %s:' % [list_name, projects_list]
|
30
|
+
print_gem_list(projects_gems)
|
36
31
|
end
|
37
32
|
|
38
33
|
def install
|
39
|
-
puts "Installing all gems and versions in '%s'" %
|
40
|
-
install_gems_list(
|
34
|
+
puts "Installing all gems and versions in '%s'" % projects.join(", ")
|
35
|
+
install_gems_list(projects_gems - current_gems_list)
|
41
36
|
end
|
42
37
|
|
43
38
|
def switch_from_current
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
to_install = project_gems - current_gems
|
48
|
-
to_uninstall = current_gems - project_gems
|
39
|
+
puts 'Switching to %s:' % projects.join(", ")
|
40
|
+
to_install = projects_gems - current_gems_list
|
41
|
+
to_uninstall = current_gems_list - projects_gems
|
49
42
|
|
50
43
|
install_gems_list(to_install)
|
51
44
|
uninstall_gems_list(to_uninstall)
|
52
45
|
end
|
53
46
|
|
54
47
|
def uninstall
|
55
|
-
puts "Uninstalling all gems and versions in '%s'" %
|
56
|
-
uninstall_gems_list(
|
48
|
+
puts "Uninstalling all gems and versions in '%s'" % projects.join(", ")
|
49
|
+
uninstall_gems_list(projects_gems)
|
57
50
|
end
|
58
51
|
|
59
52
|
private
|
@@ -93,6 +86,12 @@ class Gems
|
|
93
86
|
end
|
94
87
|
end
|
95
88
|
|
89
|
+
def projects_gems
|
90
|
+
@projects_gems ||= projects.inject(GemsList.new) do |gems_list, project|
|
91
|
+
gems_list + GemsConfig.new(project).gems
|
92
|
+
end
|
93
|
+
end
|
94
|
+
|
96
95
|
def uninstall_gems_list(gems)
|
97
96
|
results = {}
|
98
97
|
gems.each_gem_with_version do |gemname, version|
|
data/lib/gems_config.rb
CHANGED
@@ -7,7 +7,7 @@ class GemsConfig
|
|
7
7
|
def initialize(name)
|
8
8
|
@name = name
|
9
9
|
end
|
10
|
-
|
10
|
+
|
11
11
|
def add_gems(file)
|
12
12
|
new_gems = GemsParser.new(file).gems
|
13
13
|
new_gems.each do |gemname, versions|
|
@@ -41,11 +41,20 @@ class GemsConfig
|
|
41
41
|
save_config
|
42
42
|
end
|
43
43
|
|
44
|
-
# Load gems.
|
44
|
+
# Load gems.
|
45
|
+
#
|
46
|
+
# Returns a GemsList.
|
47
|
+
#
|
48
|
+
# Old data structures are automatically converted to new data structures.
|
45
49
|
def gems
|
46
|
-
gem_data = (project['gems'] ||=
|
47
|
-
return gem_data if gem_data.kind_of?
|
48
|
-
|
50
|
+
gem_data = (project['gems'] ||= GemsList.new)
|
51
|
+
return gem_data if gem_data.kind_of? GemsList
|
52
|
+
if gem_data.kind_of? Hash
|
53
|
+
project['gems'] = GemsList.new(gem_data)
|
54
|
+
save_config
|
55
|
+
return gems
|
56
|
+
end
|
57
|
+
new_gems = GemsList.new
|
49
58
|
gem_data.each do |gem_ary|
|
50
59
|
new_gems[gem_ary[0]] = gem_ary[1]
|
51
60
|
end
|
@@ -59,7 +68,7 @@ class GemsConfig
|
|
59
68
|
end
|
60
69
|
|
61
70
|
protected
|
62
|
-
|
71
|
+
|
63
72
|
def add_gem(gemname, version)
|
64
73
|
gems[gemname] ||= []
|
65
74
|
gems[gemname] << version
|
data/lib/gems_list.rb
CHANGED
@@ -19,6 +19,19 @@ class GemsList < Hash
|
|
19
19
|
diff
|
20
20
|
end
|
21
21
|
|
22
|
+
# Returns a new Gemlist which is the union of both GemLists.
|
23
|
+
def +(other)
|
24
|
+
union = self.dup
|
25
|
+
other.each do |gem, versions|
|
26
|
+
if union.has_key? gem
|
27
|
+
union[gem] = (union[gem] + versions).uniq.sort
|
28
|
+
else
|
29
|
+
union[gem] = versions
|
30
|
+
end
|
31
|
+
end
|
32
|
+
union
|
33
|
+
end
|
34
|
+
|
22
35
|
def each_gem_with_version(&block)
|
23
36
|
raise ArgumentError, 'No block provided' unless block
|
24
37
|
self.each do |gemname, versions|
|
@@ -27,4 +40,8 @@ class GemsList < Hash
|
|
27
40
|
end
|
28
41
|
end
|
29
42
|
end
|
43
|
+
|
44
|
+
def longest_key_length
|
45
|
+
map{|key, value| key.to_s.size}.max || 0
|
46
|
+
end
|
30
47
|
end
|
data/lib/gems_parser.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: Narnach-gems
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Wes Oldenbeuving
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2008-08-
|
12
|
+
date: 2008-08-26 00:00:00 -07:00
|
13
13
|
default_executable:
|
14
14
|
dependencies: []
|
15
15
|
|
@@ -26,11 +26,11 @@ files:
|
|
26
26
|
- MIT-LICENSE
|
27
27
|
- README.rdoc
|
28
28
|
- Rakefile
|
29
|
+
- gems.gemspec
|
29
30
|
- bin/gems
|
30
31
|
- lib/gems.rb
|
31
32
|
- lib/gems_config.rb
|
32
33
|
- lib/gems_parser.rb
|
33
|
-
- gems.gemspec
|
34
34
|
- lib/gems_list.rb
|
35
35
|
has_rdoc: true
|
36
36
|
homepage: http://www.github.com/Narnach/gems
|