roll 1.1.0 → 1.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (62) hide show
  1. data/HISTORY +28 -4
  2. data/PACKAGE +6 -0
  3. data/PROFILE +22 -0
  4. data/README.rdoc +66 -59
  5. data/bin/roll +7 -1
  6. data/lib/oll.rb +1 -1
  7. data/lib/roll.rb +30 -9
  8. data/lib/roll/command.rb +40 -177
  9. data/lib/roll/commands/env.rb +24 -0
  10. data/lib/roll/commands/help.rb +30 -0
  11. data/lib/roll/commands/in.rb +26 -0
  12. data/lib/roll/commands/index.rb +20 -0
  13. data/lib/roll/commands/list.rb +33 -0
  14. data/lib/roll/commands/out.rb +22 -0
  15. data/lib/roll/commands/path.rb +50 -0
  16. data/lib/roll/commands/sync.rb +29 -0
  17. data/lib/roll/commands/use.rb +25 -0
  18. data/lib/roll/commands/verify.rb +22 -0
  19. data/lib/roll/config.rb +8 -3
  20. data/lib/roll/environment.rb +84 -42
  21. data/lib/roll/kernel.rb +9 -2
  22. data/lib/roll/library.rb +360 -21
  23. data/lib/roll/metadata.rb +282 -51
  24. data/lib/roll/original.rb +3 -3
  25. data/lib/roll/version.rb +6 -7
  26. data/script/setup +14 -18
  27. data/script/setup.old +1344 -0
  28. data/test/{unitcases/version_case.rb → version_case.rb} +1 -1
  29. metadata +30 -47
  30. data/TODO +0 -4
  31. data/lib/roll/errors.rb +0 -13
  32. data/lib/roll/ledger.rb +0 -299
  33. data/lib/roll/locals.rb +0 -96
  34. data/meta/active +0 -1
  35. data/meta/authors +0 -1
  36. data/meta/contact +0 -1
  37. data/meta/created +0 -1
  38. data/meta/description +0 -5
  39. data/meta/homepage +0 -1
  40. data/meta/maintainer +0 -1
  41. data/meta/name +0 -1
  42. data/meta/repository +0 -1
  43. data/meta/ruby +0 -2
  44. data/meta/suite +0 -1
  45. data/meta/summary +0 -1
  46. data/meta/version +0 -1
  47. data/script/test +0 -23
  48. data/test/benchmarks/vsgems.rb +0 -11
  49. data/test/benchmarks/vsgems_bm.rb +0 -17
  50. data/test/demonstrations/01_library.rdoc +0 -33
  51. data/test/demonstrations/04_version.rdoc +0 -56
  52. data/test/fixtures/env.list +0 -1
  53. data/test/fixtures/inspect.rb +0 -12
  54. data/test/fixtures/tryme/1.0/lib/tryme.rb +0 -1
  55. data/test/fixtures/tryme/1.0/meta/homepage +0 -1
  56. data/test/fixtures/tryme/1.0/meta/name +0 -1
  57. data/test/fixtures/tryme/1.0/meta/version +0 -1
  58. data/test/fixtures/tryme/1.1/lib/tryme.rb +0 -1
  59. data/test/fixtures/tryme/1.1/meta/homepage +0 -1
  60. data/test/fixtures/tryme/1.1/meta/name +0 -1
  61. data/test/fixtures/tryme/1.1/meta/version +0 -1
  62. data/test/unit/version_test.rb +0 -71
data/HISTORY CHANGED
@@ -1,11 +1,35 @@
1
1
  = RELEASE HISTORY
2
2
 
3
+ == 1.2.0 / 2010-06-15
4
+
5
+ This release gets roll command working and improves
6
+ the reliability of the system as a whole, including making
7
+ metadata lookup more consistant (hint: you want a PACKAGE file).
8
+ It is even partially compatible with Gem stores now (exceptions
9
+ being loadpaths other than lib/ and the use of autoload).
10
+
11
+ Changes:
12
+
13
+ * Reworked metadata system (in line with evolving POM).
14
+ * Improved search heuristics (usually much faster now).
15
+
16
+
17
+ == 1.1.0 / 2010-03-01
18
+
19
+ This release fix a few bugs and makes a few adjustments,
20
+ but mostly cleans up code behind the scenes.
21
+
22
+ Changes:
23
+
24
+ * Fix incorrect multi-match and absolute path lookup
25
+ * Support for Rubinius RUBY_IGNORE_CALLERS
26
+
27
+
3
28
  == 1.0.0 / 2010-02-11
4
29
 
5
- Roll is finally ready for the masses. This release overhauls
6
- the underlying system, which is now blazing fast, supports
7
- customizable library environments, and banashes all traces
8
- of package management to the domain of other tools.
30
+ This release overhauls the underlying system, which is now very
31
+ fast. It supports customizable library environments, and banashes
32
+ all traces of package management to the domain of other tools.
9
33
 
10
34
  Changes:
11
35
 
data/PACKAGE ADDED
@@ -0,0 +1,6 @@
1
+ name : roll
2
+ major: 1
3
+ minor: 2
4
+ patch: 0
5
+ date : 2010-06-15
6
+ omit : true
data/PROFILE ADDED
@@ -0,0 +1,22 @@
1
+ ---
2
+ title: Roll
3
+ suite: proutils
4
+ summary: Ruby Object-Oriented Library Ledger
5
+ contact: Trans <transfire@gmail.com>
6
+ authors: Thomas Sawyer
7
+ created: 2006-12-10
8
+
9
+ description:
10
+ Roll is a library manager for Ruby. Code repositories
11
+ can be made visible to Ruby just by setting an
12
+ environment variable. Rolls effectively trivializes
13
+ Ruby package management.
14
+
15
+ resources:
16
+ home: http://proutils.github.com/roll
17
+ repo: git://github.com/proutils/roll.git
18
+ mail: http://groups.google.com/group/proutils
19
+
20
+ copyright:
21
+ Copyright (c) 2006 Thomas Sawyer
22
+
@@ -15,14 +15,29 @@
15
15
  """"........
16
16
 
17
17
  * home: http://proutils.github.com/roll
18
+ * worl: http://github.com/protuils/roll
18
19
 
19
20
 
20
21
  == DESCRIPTION
21
22
 
22
- Roll is a library manager for Ruby. With Rolls developers can run there
23
+ Roll is a library manager for Ruby. With Rolls developers can run their
23
24
  programs in real time --no install phase is required for one program
24
25
  to depend on another. This makes it very easy to work on a set of
25
- interdependent projects.
26
+ interdependent projects --without vendering. It also makes easy to
27
+ create isolated library environments. Yet Rolls does so efficiently
28
+ --there need only be a single copy of any given version of a library
29
+ on disc. And libraries can be stored anywhere. There is no special place
30
+ they must all reside. You simple tell Rolls where they are.
31
+
32
+ == STATUS
33
+
34
+ Rolls works fairly well. I have used it for development for years, so
35
+ on the whole it stays in working order. However it is still under
36
+ heavy development, so configuration is still subject to a fair bit
37
+ of change. The loading heuristics are quite advanced, which accounts
38
+ for the speed, but as a trade-off the first library that is not found
39
+ "early" can initilially slow the system as all of an environments
40
+ metadata if loaded.
26
41
 
27
42
 
28
43
  == HOW TO USE
@@ -36,7 +51,7 @@ variable.
36
51
 
37
52
  I suspect you will be using RubyGems too, in which case do:
38
53
 
39
- $ export RUBYOPT="-rubygems -roll"
54
+ $ export RUBYOPT="-roll -rubygems"
40
55
 
41
56
  To support executables you will also need to add a line to your startup
42
57
  .bashrc (or equivalent) file.
@@ -51,72 +66,57 @@ b/c it has some shortcomings.)
51
66
 
52
67
  === Preparing your Projects
53
68
 
54
- For your projects to be detected by Rolls they must conform to a
55
- minimal POM[http://proutils.github.com/pom] setup. In particular
56
- the project must contain a +meta/+ directory with a +name+ and +version+
57
- entry. That is the bare minimum for a project to to be loadable via
58
- Rolls. Optionally you may provide a +loadpath+ entry if the load path
59
- is not the +lib/+ default, as well as a +released+ date entry.
60
-
61
- (NOTE: +meta/+ can be named +.meta/+ if you would prefer to hide the
62
- directory, though we recommend keeping it visible.)
63
-
64
- Here are examples of Ruby Facets +meta/+ entries.
65
-
66
- $ cat facets/meta/name
67
- facets
68
-
69
- $ cat facets/meta/version
70
- 2.8.0
71
-
72
- $ cat facets/meta/loadpath
73
- lib/core
74
- lib/more
75
-
76
- $ cat facets/meta/ruby
77
- 1.8+
78
-
79
- The +ruby+ entry informs Rolls of the particular implementations and versions
80
- of Ruby the project should operate under successfully.
81
- (NOTE: Rolls doesn't actually do anything with the ruby entry yet.)
82
-
83
- Lastly, an +active+ entry can be set to +false+ to tell Rolls to skip the
84
- project when searching for library files. See POM[http://proutils.github.com/pom]
85
- for more information.
86
-
69
+ For a project to be detected by Rolls it must conform to a
70
+ minimal POM[http://proutils.github.com/pom] setup. Specifically
71
+ the project must have a <code>PACKAGE</code> file and it must
72
+ have at least one <code>lib/*.rb</code> file. In the future this
73
+ should become a little more flexible, but that is the bare minimum
74
+ for a project to to be loadable via Rolls as of v1.2. The only
75
+ exception is for Gem stores. If you point Rolls torwards a gems/
76
+ location it will attempt to parse the name and version from a
77
+ library's directory name (e.g. facets-2.8.4/). It does not read
78
+ the gemspec (that would be slow). So alternate loadpaths are not
79
+ supported for Gem stores at this time.
80
+
81
+ Also, note that #autoload will not work with Rolls. Ruby has a bug
82
+ that prevents #autoload from using any custom defined #require method.
83
+ (Why this has never been fixed is both annoying and frustrating
84
+ to say the least.)
85
+
86
+ See POM[http://proutils.github.com/pom] for more information about
87
+ the POM standard.
87
88
 
88
89
  === Library Management
89
90
 
90
91
  Next you need to setup an roll *environment*. The default environment
91
- is call +production+. You can add a library search location to it
92
+ is called +production+. You can add a library search location to it
92
93
  using +roll in+. Eg.
93
94
 
94
95
  $ roll in /opt/ruby/
95
96
 
96
- As a developer you will often want to use a +development+ environment.
97
- To change or add and environment, modify the RUBYENV environment variable.
97
+ As a developer you will may want to setup a +development+ environment.
98
+ To change or add an environment use the +use+ command.
98
99
 
99
- $ export RUBYENV="development"
100
+ $ roll use development
100
101
 
101
102
  Then you can add the paths you want. For instance my development
102
- environment is basically constructed like this:
103
+ environment is essentially constructed like this:
103
104
 
104
105
  $ roll in ~/programs/proutils
105
106
  $ roll in ~/programs/rubyworks
106
- $ roll in ~/programs/thedeadly
107
- $ roll in ~/programs/transcode
107
+ $ roll in ~/programs/trans
108
108
 
109
109
  By default these paths will be searched for POM conforming projects
110
110
  up to a depth of three sub-directories. That's suitable for
111
111
  most needs. You can specify the the depth explicitly with the
112
- <tt>--depth</tt> or <tt>-d</tt> option. For example, lets say you
113
- just want to add a single ruby project to the current environment.
114
- You can do so by navigating to the root directory of a project and
115
- executing:
112
+ <tt>--depth</tt> or <tt>-d</tt> option. You can roll in the
113
+ current working directory by leaving off the path argument.
114
+ If the current directory has a +VERSION+ file, a depth of +1+
115
+ will automatically be used.
116
116
 
117
- $ roll in --depth 1
117
+ $ roll in
118
118
 
119
- That's it. Your project is *READY-TO-ROLL*!
119
+ So that's it. You are *READY-TO-ROLL*!
120
120
 
121
121
 
122
122
  == LEARNING MORE
@@ -128,19 +128,26 @@ it fullest extent, please visit http://proutils.github.org/roll/.
128
128
 
129
129
  == HOW TO INSTALL
130
130
 
131
- === Manual Installation
131
+ === Manual Installation (Recommended)
132
132
 
133
- You will need Ruby Setup, the standalone setup.rb script, in order
134
- to install Roll. See: http://setup.rubyforge.org.
135
-
136
- Once you have setup.rb, download the Roll tarball and install
137
- it manually as follows:
133
+ First you need a copy of the roll tarball (or zip) archive.
134
+ You will find them here[http://github.com/proutils/roll/download].
138
135
 
139
136
  $ tar -xvzf roll-1.0.0
137
+
138
+ If you already have Ruby Setup installed on your system you can
139
+ use it to install Rolls (See: http://setup.rubyforge.org).
140
+
141
+ $ cd roll-1.0.0
142
+ $ sudo setup.rb
143
+
144
+ Otherwise, Rolls includes a copy of Ruby Setup that you can
145
+ use.
146
+
140
147
  $ cd roll-1.0.0
141
- $ sudo setup.rb all
148
+ $ sudo script/setup.
142
149
 
143
- On Windows, this last line needs to be 'ruby setup.rb all'.
150
+ On Windows, this last line needs to be 'ruby script/setup'.
144
151
 
145
152
  === RubyGems Installation
146
153
 
@@ -151,7 +158,7 @@ install it; and this is a convenient way to try it out.
151
158
  gem install roll
152
159
 
153
160
  If you like Rolls, then later you can uninstall the gem and
154
- install manually.
161
+ do a proper manual install.
155
162
 
156
163
 
157
164
  == BY THE WAY
@@ -161,7 +168,7 @@ Roll was RubyForge project #1004. She's been around a while! ;)
161
168
 
162
169
  == LICENSE & COPYRIGHT
163
170
 
164
- Roll, Copyright (c) 2006,2007 Thomas Sawyer
171
+ Roll/Rolls Copyright (c) 2006,2007 Thomas Sawyer
165
172
 
166
173
  Rolls is distributed under the same terms as Ruby.
167
174
 
data/bin/roll CHANGED
@@ -1,3 +1,9 @@
1
1
  #!/usr/bin/env ruby
2
2
  require 'roll/command'
3
- Roll::Command.main(*ARGV)
3
+ begin
4
+ Roll::Command.main(*ARGV)
5
+ rescue => err
6
+ raise err if $DEBUG
7
+ $stderr.puts(err.message)
8
+ end
9
+
data/lib/oll.rb CHANGED
@@ -1 +1 @@
1
- require 'roll'
1
+ require 'roll' #File.dirname(__FILE__) + '/roll.rb'
@@ -1,10 +1,11 @@
1
- require 'roll/kernel'
1
+ require 'roll/config'
2
+ require 'roll/library'
3
+ require 'roll/kernel' # require last
2
4
 
3
5
  module Roll
4
- VERSION = "1.0.0" #:till: VERSION = "<%= version %>"
6
+ VERSION = "1.2.0" # TODO: make verison reference dynamic
5
7
 
6
8
  # Get environment.
7
-
8
9
  def self.env(name=nil)
9
10
  if name
10
11
  env = Environment.new(name)
@@ -14,6 +15,17 @@ module Roll
14
15
  env
15
16
  end
16
17
 
18
+ # Change current environment.
19
+ def self.use(name)
20
+ Environment.save(name)
21
+ end
22
+
23
+ # Return Array of environment names.
24
+ def self.list
25
+ Environment.list
26
+ end
27
+
28
+ #
17
29
  def self.index(name=nil)
18
30
  #if name
19
31
  # env = Environment.new(name)
@@ -25,7 +37,6 @@ module Roll
25
37
 
26
38
  # Synchronize an environment by +name+. If a +name+
27
39
  # is not given the current environment is synchronized.
28
-
29
40
  def self.sync(name=nil)
30
41
  env = env(name)
31
42
  env.sync
@@ -33,7 +44,6 @@ module Roll
33
44
  end
34
45
 
35
46
  # Add path to current environment.
36
-
37
47
  def self.in(path, depth=3)
38
48
  env = Environment.new
39
49
 
@@ -48,7 +58,6 @@ module Roll
48
58
  end
49
59
 
50
60
  # Remove path from current environment.
51
-
52
61
  def self.out(path)
53
62
  env = Environment.new
54
63
 
@@ -63,7 +72,6 @@ module Roll
63
72
  end
64
73
 
65
74
  # Go thru each roll lib and collect bin paths.
66
-
67
75
  def self.path
68
76
  binpaths = []
69
77
  Library.list.each do |name|
@@ -79,8 +87,21 @@ module Roll
79
87
  #--
80
88
  # TODO: Instead of Dir.pwd, lookup project root.
81
89
  #++
82
- def self.verify(root=Dir.pwd)
83
- Library.new(root).verify
90
+ def self.verify(name=nil)
91
+ if name
92
+ Library.open(name).verify
93
+ else
94
+ Library.new(Dir.pwd).verify
95
+ end
96
+ end
97
+
98
+ # VersionError is raised when a requested version cannot be found.
99
+ class VersionError < ::RangeError # :nodoc:
100
+ end
101
+
102
+ # VersionConflict is raised when selecting another version
103
+ # of a library when a previous version has already been selected.
104
+ class VersionConflict < ::LoadError # :nodoc:
84
105
  end
85
106
 
86
107
  end
@@ -1,205 +1,68 @@
1
+ #require File.dirname(File.dirname(__FILE__)) + '/roll.rb'
1
2
  require 'roll'
2
- #require 'roll/platform'
3
- require 'optparse'
4
-
5
- #--
6
- # TODO: clean command to remove dead directories from environment
7
- #++
8
3
 
9
4
  module Roll
10
5
 
11
6
  # = Command-line Interface
12
- #
7
+ #--
8
+ # TODO: clean command to remove dead directories from environment
9
+ #++
13
10
  class Command
14
11
 
12
+ # Command-line arguments.
13
+ attr :args
14
+
15
+ # Command-line options.
16
+ attr :opts
17
+
18
+ # Instance of OptionParser.
19
+ attr :op
20
+
15
21
  # Initialize and execute command.
16
22
  def self.main(*argv)
17
- new(*argv).execute
23
+ #cmd = argv.shift
24
+ idx = argv.index{ |e| e !~ /^\-/ }
25
+ cmd = idx ? argv.delete_at(idx) : 'help'
26
+ begin
27
+ require "roll/commands/#{cmd}"
28
+ rescue LoadError
29
+ cmd = 'help'
30
+ require "roll/commands/#{cmd}"
31
+ end
32
+ klass = ::Roll.const_get("Command#{cmd.capitalize}")
33
+ klass.new(*argv).execute
18
34
  end
19
35
 
20
36
  # New Command.
21
37
  def initialize(*argv)
22
- @argv = argv
38
+ # only need optparse when command is run
39
+ require 'optparse'
40
+ @op = OptionParser.new
41
+ @args = argv
42
+ @opts = {}
23
43
  end
24
44
 
25
45
  #
26
46
  def execute
27
- cmd = @argv.find{ |e| e !~ /^\-/ }
28
-
29
- options = {}
30
-
31
- parser = OptionParser.new
32
-
33
- parser.banner = "Usage: roll [COMMAND]"
47
+ setup
34
48
 
35
- __send__("#{cmd}_optparse", parser, options) if cmd
36
-
37
- if !cmd
38
- parser.separator "Commands:"
39
- parser.separator " in [DIR] " + (" " * 23) + "Roll directory into current environment."
40
- parser.separator " out [DIR] " + (" " * 23) + "Remove directory from current environment."
41
- parser.separator " env " + (" " * 23) + "Show current environment."
42
- parser.separator " index " + (" " * 23) + "Show current environment index."
43
- parser.separator " sync " + (" " * 23) + "Synchronize environment indexes."
44
- parser.separator " path " + (" " * 23) + "Output bin PATH list."
45
- parser.separator " verify " + (" " * 23) + "Verify project dependencies in current environment."
46
- parser.separator "Options:"
47
- end
48
-
49
- parser.on_tail("--help", "-h", "Display this help message.") do
50
- puts parser
51
- exit
49
+ op.on_tail("--warn", "-w", "Show warnings.") do
50
+ $VERBOSE = true
52
51
  end
53
52
 
54
- parser.parse!
55
-
56
- ARGV.shift # remove command
57
-
58
- if cmd
59
- __send__(cmd, ARGV, options)
60
- else
61
- # no command ?
53
+ op.on_tail("--debug", "Run in debugging mode.") do
54
+ $DEBUG = true
55
+ $VERBOSE = true
62
56
  end
63
- end
64
-
65
- #
66
- def env_optparse(op, options)
67
- op.banner = "Usage: roll env [NAME]"
68
- op.separator "Show current environment."
69
- op
70
- end
71
-
72
- #
73
- def index_optparse(op, options)
74
- op.banner = "Usage: roll index [NAME]"
75
- op.separator "Show current environment index."
76
- op
77
- end
78
-
79
- #
80
- def sync_optparse(op, options)
81
- op.banner = "Usage: roll sync [NAME]"
82
- op.separator "Synchronize ledger(s) to their respective environment(s)."
83
- op
84
- end
85
-
86
- #
87
- def in_optparse(op, options)
88
- op.banner = "Usage: roll in [PATH]"
89
- op.separator "Insert path into current environment."
90
- op.separator "Options:"
91
- op.on("--depth", "-d [INTEGER]") do |int|
92
- options[:depth] = int
93
- end
94
- end
95
-
96
- #
97
- def out_optparse(op, options)
98
- op.banner = "Usage: roll out [PATH]"
99
- op.separator "Remove path from current environment."
100
- op
101
- end
102
57
 
103
- #
104
- def path_optparse(op, options)
105
- op.banner = "Usage: roll path"
106
- op.separator "Generate executable PATH list."
107
- op
108
- end
109
-
110
- #
111
- def verify_optparse(op, options)
112
- op.banner = "Usage: roll verify"
113
- op.separator "Verify dependencies in current environment."
114
- op
115
- end
116
-
117
- # Show/Change current environment.
118
- #
119
- def env(args, opts)
120
- puts Roll.env(*args)
121
- end
122
-
123
- # Show/Change current environment.
124
- #
125
- def index(args, opts)
126
- puts Roll.index(*args)
127
- end
128
-
129
- # Synchronize ledgers.
130
- #
131
- def sync(args, opts)
132
- name = args.first
133
- list = name ? [name] : Environment.list
134
- list.each do |name|
135
- result = Roll.sync(name)
136
- if result
137
- puts " saved #{name}"
138
- else
139
- puts " current #{name}"
140
- end
58
+ op.on_tail("--help", "-h", "Display this help message.") do
59
+ puts op
60
+ exit
141
61
  end
142
- end
143
62
 
144
- #
145
- def in(args, opts)
146
- path = File.expand_path(args.first || Dir.pwd)
147
- depth = opts[:depth]
148
- path, file = *Roll.in(path, depth)
149
- puts "#{path}"
150
- puts " '-> #{file}"
151
- end
152
-
153
- #
154
- def out(args, opts)
155
- path = File.expand_path(args.first || Dir.pwd)
156
- path, file = *Roll.out(path)
157
- puts "#{file}"
158
- puts " '-> #{path} -> [x]"
159
- end
63
+ op.parse!(args)
160
64
 
161
- #
162
- def verify(args, opts)
163
- list = Roll.verify
164
- list.each do |(name, constraint)|
165
- puts "#{name} #{constraint}"
166
- end
167
- end
168
-
169
- # This script builds a list of all roll-ready bin locations
170
- # and writes that list as an environment setting shell script.
171
- # On Linux a call to this to you .bashrc file. Eg.
172
- #
173
- # if [ -f ~/.rollrc ]; then
174
- # . roll
175
- # fi
176
- #
177
- # Currently this only supports bash.
178
- #
179
- # TODO: It would be better to "install" executables
180
- # to an appropriate bin dir, using links (soft if possible).
181
- # There could go in ~/.bin or .config/roll/<ledger>.bin/
182
- #
183
- def path(args, opts)
184
- case RUBY_PLATFORM
185
- when /mswin/, /wince/
186
- div = ';'
187
- else
188
- div = ':'
189
- end
190
- env_path = ENV['PATH'].split(/[#{div}]/)
191
- # Go thru each roll lib and make sure bin path is in path.
192
- binpaths = []
193
- Library.list.each do |name|
194
- lib = Library[name]
195
- if lib.bindir?
196
- binpaths << lib.bindir
197
- end
198
- end
199
- #pathenv = (["$PATH"] + binpaths).join(div)
200
- pathenv = binpaths.join(div)
201
- #puts %{export PATH="#{pathenv}"}
202
- puts pathenv
65
+ call
203
66
  end
204
67
 
205
68
  end