Narnach-gems 0.1.3 → 0.1.4
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 +4 -0
- data/bin/gems +6 -0
- data/gems.gemspec +1 -1
- data/lib/gems_config.rb +27 -1
- data/lib/gems_parser.rb +2 -2
- metadata +1 -1
data/README.rdoc
CHANGED
@@ -5,6 +5,10 @@ Rails code would not get into dependency issues.
|
|
5
5
|
|
6
6
|
== Recent changes
|
7
7
|
|
8
|
+
=== Version 0.1.4
|
9
|
+
It is now possible to add a list of gems to an existing project.
|
10
|
+
Changed internal storage format of ~/.gems.yml, which is auto-converted on use.
|
11
|
+
|
8
12
|
=== Version 0.1.3
|
9
13
|
Bugfix: gem-specific installation options actually work as intended: passing compiler options to gems with C extensions.
|
10
14
|
|
data/bin/gems
CHANGED
@@ -31,6 +31,10 @@ when 'configure'
|
|
31
31
|
gems_config = GemsConfig.new(project)
|
32
32
|
gemname = ARGV.shift
|
33
33
|
gems_config.set_gem_options(gemname, ARGV)
|
34
|
+
when 'add'
|
35
|
+
gems_config = GemsConfig.new(project)
|
36
|
+
gems_file = ARGV.shift.to_s.strip
|
37
|
+
gems_config.add_gems(gems_file)
|
34
38
|
else 'help'
|
35
39
|
puts <<-EOS
|
36
40
|
Syntax:
|
@@ -49,6 +53,8 @@ Actions and arguments:
|
|
49
53
|
export <name> <file>
|
50
54
|
Export all gems in project <name> to <file>.
|
51
55
|
The file will be overwritten and can be parsed by the import action.
|
56
|
+
add <name> <file>
|
57
|
+
Add the gems <file> to project <name>.
|
52
58
|
projects
|
53
59
|
List all stored project names.
|
54
60
|
configure <name> <gem> [option1 option2 option3]
|
data/gems.gemspec
CHANGED
@@ -3,7 +3,7 @@ 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.1.
|
6
|
+
s.version = '0.1.4'
|
7
7
|
s.date = '2008-08-19'
|
8
8
|
s.platform = Gem::Platform::RUBY
|
9
9
|
s.authors = ["Wes Oldenbeuving"]
|
data/lib/gems_config.rb
CHANGED
@@ -7,6 +7,16 @@ class GemsConfig
|
|
7
7
|
def initialize(name)
|
8
8
|
@name = name
|
9
9
|
end
|
10
|
+
|
11
|
+
def add_gems(file)
|
12
|
+
new_gems = GemsParser.new(file).gems
|
13
|
+
new_gems.each do |gemname, versions|
|
14
|
+
versions.each do |version|
|
15
|
+
add_gem(gemname, version)
|
16
|
+
end
|
17
|
+
end
|
18
|
+
save_config
|
19
|
+
end
|
10
20
|
|
11
21
|
def export_gems(file)
|
12
22
|
File.open(file,'wb') do |f|
|
@@ -31,8 +41,17 @@ class GemsConfig
|
|
31
41
|
save_config
|
32
42
|
end
|
33
43
|
|
44
|
+
# Load gems. Old data is automatically converted to new data.
|
34
45
|
def gems
|
35
|
-
project['gems'] ||= {}
|
46
|
+
gem_data = (project['gems'] ||= {})
|
47
|
+
return gem_data if gem_data.kind_of? Hash
|
48
|
+
new_gems = {}
|
49
|
+
gem_data.each do |gem_ary|
|
50
|
+
new_gems[gem_ary[0]] = gem_ary[1]
|
51
|
+
end
|
52
|
+
project['gems'] = new_gems
|
53
|
+
save_config
|
54
|
+
return gems
|
36
55
|
end
|
37
56
|
|
38
57
|
def project_names
|
@@ -40,6 +59,13 @@ class GemsConfig
|
|
40
59
|
end
|
41
60
|
|
42
61
|
protected
|
62
|
+
|
63
|
+
def add_gem(gemname, version)
|
64
|
+
gems[gemname] ||= []
|
65
|
+
gems[gemname] << version
|
66
|
+
gems[gemname].uniq!
|
67
|
+
gems[gemname].sort!
|
68
|
+
end
|
43
69
|
|
44
70
|
def config
|
45
71
|
@config ||= load_config
|
data/lib/gems_parser.rb
CHANGED
@@ -18,7 +18,7 @@ class GemsParser
|
|
18
18
|
private
|
19
19
|
|
20
20
|
def parse_gems
|
21
|
-
parsed_gems =
|
21
|
+
parsed_gems = {}
|
22
22
|
str.each do |line|
|
23
23
|
gemname, *versions = line.split(" ")
|
24
24
|
next if gemname.to_s.size == 0
|
@@ -28,7 +28,7 @@ class GemsParser
|
|
28
28
|
versions.compact!
|
29
29
|
versions.uniq!
|
30
30
|
next if versions.size == 0
|
31
|
-
parsed_gems
|
31
|
+
parsed_gems[gemname] = versions
|
32
32
|
end
|
33
33
|
return parsed_gems
|
34
34
|
end
|