roll 0.8.0 → 1.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (63) hide show
  1. data/{LICENSE → COPYING} +1 -1
  2. data/HISTORY +62 -0
  3. data/README.rdoc +169 -0
  4. data/TODO +4 -0
  5. data/bin/roll +3 -44
  6. data/lib/oll.rb +1 -2
  7. data/lib/roll.rb +87 -0
  8. data/lib/roll/command.rb +207 -0
  9. data/lib/roll/config.rb +80 -0
  10. data/lib/roll/environment.rb +317 -0
  11. data/lib/roll/errors.rb +13 -0
  12. data/lib/roll/kernel.rb +41 -0
  13. data/lib/roll/ledger.rb +299 -0
  14. data/lib/roll/library.rb +241 -558
  15. data/lib/roll/locals.rb +96 -0
  16. data/lib/roll/metadata.rb +112 -0
  17. data/lib/roll/original.rb +10 -0
  18. data/lib/roll/version.rb +91 -101
  19. data/meta/active +1 -0
  20. data/meta/authors +1 -0
  21. data/meta/contact +1 -0
  22. data/meta/created +1 -0
  23. data/meta/description +5 -0
  24. data/meta/homepage +1 -0
  25. data/meta/maintainer +1 -0
  26. data/meta/name +1 -0
  27. data/meta/repository +1 -0
  28. data/meta/ruby +2 -0
  29. data/meta/suite +1 -0
  30. data/meta/summary +1 -0
  31. data/meta/version +1 -0
  32. data/script/rdoc +4 -0
  33. data/script/setup +1344 -0
  34. data/script/test +23 -0
  35. data/test/benchmarks/vsgems.rb +11 -0
  36. data/test/benchmarks/vsgems_bm.rb +17 -0
  37. data/test/demonstrations/01_library.rdoc +33 -0
  38. data/test/demonstrations/04_version.rdoc +56 -0
  39. data/test/fixtures/env.list +1 -0
  40. data/{demo/sample → test/fixtures}/inspect.rb +0 -0
  41. data/test/fixtures/tryme/1.0/lib/tryme.rb +1 -0
  42. data/test/fixtures/tryme/1.0/meta/homepage +1 -0
  43. data/test/fixtures/tryme/1.0/meta/name +1 -0
  44. data/test/fixtures/tryme/1.0/meta/version +1 -0
  45. data/test/fixtures/tryme/1.1/lib/tryme.rb +1 -0
  46. data/test/fixtures/tryme/1.1/meta/homepage +1 -0
  47. data/test/fixtures/tryme/1.1/meta/name +1 -0
  48. data/test/fixtures/tryme/1.1/meta/version +1 -0
  49. data/test/{test_version.rb → unit/version_test.rb} +21 -21
  50. data/test/unitcases/version_case.rb +69 -0
  51. metadata +102 -65
  52. data/README +0 -17
  53. data/demo/bench/bench_load.rb +0 -7
  54. data/demo/sample/tryme/1.0/lib/tryme.rb +0 -1
  55. data/demo/sample/tryme/1.1/lib/tryme.rb +0 -1
  56. data/lib/roll/attributes.rb +0 -72
  57. data/lib/roll/package.rb +0 -300
  58. data/lib/roll/remote.rb +0 -37
  59. data/meta/ROLL-0.8.0.roll +0 -21
  60. data/task/rdoc +0 -9
  61. data/task/setup +0 -1616
  62. data/task/test +0 -5
  63. data/test/test_library.rb +0 -10
@@ -0,0 +1,96 @@
1
+ module Roll
2
+
3
+ #
4
+ class Locals
5
+
6
+ include Enumerable
7
+
8
+ #
9
+ DIR = XDG.config_home, 'roll', 'locals'
10
+
11
+ #
12
+ #def self.save(name)
13
+ # File.open(file, 'w'){ |f| f << "#{name}" }
14
+ #end
15
+
16
+ # List of available environments.
17
+ def self.list
18
+ Dir[File.join(DIR, '*')].map do |file|
19
+ File.basename(file)
20
+ end
21
+ end
22
+
23
+ #
24
+ def initialize(name=nil)
25
+ @name = name || self.class.current
26
+ reload
27
+ end
28
+
29
+ #
30
+ def name
31
+ @name
32
+ end
33
+
34
+ #
35
+ def file
36
+ @file ||= File.join(DIR, name)
37
+ end
38
+
39
+ #
40
+ def reload
41
+ t = []
42
+ if File.exist?(file)
43
+ lines = File.readlines(file)
44
+ lines.each do |line|
45
+ line = line.strip
46
+ path, depth = *line.split(/\s+/)
47
+ next if line =~ /^\s*$/ # blank
48
+ next if line =~ /^\#/ # comment
49
+ dir, depth = *line.split(/\s+/)
50
+ t << [path, (depth || 3).to_i]
51
+ end
52
+ else
53
+ t = []
54
+ end
55
+ @table = t
56
+ end
57
+
58
+ #
59
+ def each(&block)
60
+ @table.each(&block)
61
+ end
62
+
63
+ #
64
+ def size
65
+ @table.size
66
+ end
67
+
68
+ #
69
+ def append(path, depth=3)
70
+ path = File.expand_path(path)
71
+ depth = (depth || 3).to_i
72
+ @table = @table.reject{ |(p, d)| path == p }
73
+ @table.push([path, depth])
74
+ end
75
+
76
+ #
77
+ def delete(path)
78
+ @table.reject!{ |p,d| path == p }
79
+ end
80
+
81
+ #
82
+ def save
83
+ out = @table.map do |(path, depth)|
84
+ "#{path} #{depth}"
85
+ end
86
+ dir = File.dirname(file)
87
+ FileUtils.mkdir_p(dir) unless File.exist?(dir)
88
+ File.open(file, 'w') do |f|
89
+ f << out.join("\n")
90
+ end
91
+ end
92
+
93
+ end
94
+
95
+ end
96
+
@@ -0,0 +1,112 @@
1
+ module Roll
2
+
3
+ #--
4
+ # TODO: Use POM? If available?
5
+ #--
6
+ class Metadata
7
+
8
+ #TODO: hide most methods
9
+
10
+ attr :location
11
+
12
+ #
13
+ def initialize(location)
14
+ @location = location
15
+ @cache = {}
16
+ end
17
+
18
+ # Get library name.
19
+ def name
20
+ @cache[:name] ||= read('name')
21
+ end
22
+
23
+ # Get library version.
24
+ #--
25
+ # TODO: handle VERSION file
26
+ # TODO: handle YAML
27
+ #++
28
+ def version
29
+ @cache[:version] ||= Version.new(read(:version))
30
+ end
31
+
32
+ # Get library active state.
33
+ def active
34
+ return @cache[:active] if @cache.key?(:active)
35
+ @cache[:active] = (
36
+ case read(:active).to_s.downcase
37
+ when 'false', 'no'
38
+ false
39
+ else
40
+ true
41
+ end
42
+ )
43
+ end
44
+
45
+ # Get library release date.
46
+ #--
47
+ # TODO: default date to what?
48
+ #++
49
+ def released
50
+ @cache[:released] ||= read(:released) || "1900-01-01"
51
+ end
52
+
53
+ # Get library loadpath.
54
+ def loadpath
55
+ @cache[:loadpath] ||= (
56
+ val = read(:loadpath).to_s.strip.split(/\s*\n/) # TODO: handle YAML
57
+ val = ['lib'] if val.empty?
58
+ val
59
+ )
60
+ end
61
+
62
+ #
63
+ def requires
64
+ @cache[:requires] ||= (
65
+ if entry = read(:requires)
66
+ entry.strip.split("\n").map do |line|
67
+ line.strip.split(/\s+/)
68
+ end
69
+ else
70
+ []
71
+ end
72
+ )
73
+ end
74
+
75
+ #
76
+ def method_missing(name, *args)
77
+ if @cache.key?(name)
78
+ @cache[name]
79
+ else
80
+ @cache[name] = read(name)
81
+ end
82
+ end
83
+
84
+ private
85
+
86
+ #
87
+ def read(name)
88
+ file = Dir[File.join(location, "{meta,.meta}", name.to_s)].first
89
+ if file
90
+ text = File.read(file)
91
+ if text =~ /^---/
92
+ require_yaml
93
+ YAML.load(text)
94
+ else
95
+ text.strip
96
+ end
97
+ else
98
+ nil
99
+ end
100
+ end
101
+
102
+ #
103
+ def require_yaml
104
+ @require_yaml ||=(
105
+ require 'yaml'
106
+ true
107
+ )
108
+ end
109
+ end
110
+
111
+ end
112
+
@@ -0,0 +1,10 @@
1
+ # Rubinius
2
+ RUBY_IGNORE_CALLERS = [] unless defined? RUBY_IGNORE_CALLERS
3
+ RUBY_IGNORE_CALLERS << %r{roll/kernel\.rb$}
4
+ RUBY_IGNORE_CALLERS << %r{roll/original\.rb$}
5
+
6
+ module ::Kernel
7
+ alias_method :original_require, :require
8
+ alias_method :original_load, :load
9
+ end
10
+
@@ -1,127 +1,117 @@
1
- # TITLE:
2
- #
3
- # VersionNumber
4
- #
5
- # DESCRIPTION:
6
- #
7
- # VersionNumber is a simplified form of a Tuple class
8
- # desgined specifically for dealing with version numbers.
9
- #
10
- # AUTHOR:
11
- #
12
- # - Thomas Sawyer (7rans)
13
- #
14
- # LICENSE:
15
- #
16
- # Copyright (c) 2005 Thomas Sawyer
17
- #
18
- # Ruby License
19
- #
20
- # This module is free software. You may use, modify, and/or redistribute this
21
- # software under the same terms as Ruby.
22
- #
23
- # This program is distributed in the hope that it will be useful, but WITHOUT
24
- # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
25
- # FOR A PARTICULAR PURPOSE.
26
- #
27
- # TODO:
28
- #
29
- # - Maybe add Kernel method #version ?
30
- #
31
- # - If Tuple were standard part of Ruby this probably would
32
- # not be needed or at least might be simple sublcass instead.
33
-
34
-
35
- # = VersionNumber
36
- #
37
- # VersionNumber is a simplified form of a Tuple class
38
- # desgined specifically for dealing with version numbers.
39
- #
40
- class VersionNumber #< Tuple
41
-
42
- #include Enumerable
43
- include Comparable
44
-
45
- def initialize( *args )
46
- args = args.join('.').split(/\W+/)
47
- @self = args.collect { |i| i.to_i }
48
- end
1
+ module Roll
49
2
 
50
- def to_s ; @self.join('.') ; end
3
+ # = Version
4
+ #
5
+ # VersionNumber is a simplified form of a Tuple class
6
+ # desgined specifically for dealing with version numbers.
7
+ #
8
+ class Version #< Tuple
51
9
 
52
- # This is here only becuase File.join calls it instead of to_s.
10
+ #include Enumerable
11
+ include Comparable
53
12
 
54
- def to_str ; @self.join('.') ; end
13
+ # metaclass
14
+ class << self
15
+ # Convenience alias for ::new.
55
16
 
56
- def inspect
57
- @self.to_s
58
- end
17
+ def [](*args)
18
+ new(*args)
19
+ end
59
20
 
60
- def [](i)
61
- @self.fetch(i,0)
62
- end
21
+ # Parses a string constraint returning the operation as a lambda.
63
22
 
64
- # "Spaceship" comparsion operator.
23
+ def constraint_lambda(constraint)
24
+ op, val = *parse_constraint(constraint)
25
+ lambda{ |t| t.send(op, val) }
26
+ end
65
27
 
66
- def <=>( other )
67
- #other = other.to_t
68
- [@self.size, other.size].max.times do |i|
69
- c = @self[i] <=> other[i]
70
- return c if c != 0
28
+ # Converts a constraint into an operator and value.
29
+
30
+ def parse_constraint(constraint)
31
+ constraint = constraint.strip
32
+ re = %r{^(=~|~>|<=|>=|==|=|<|>)?\s*(\d+(:?[-.]\d+)*)$}
33
+ if md = re.match(constraint)
34
+ if op = md[1]
35
+ op = '=~' if op == '~>'
36
+ op = '==' if op == '='
37
+ val = new(*md[2].split(/\W+/))
38
+ else
39
+ op = '=='
40
+ val = new(*constraint.split(/\W+/))
41
+ end
42
+ else
43
+ raise ArgumentError, "invalid constraint"
44
+ end
45
+ return op, val
71
46
  end
72
- 0
73
47
  end
74
48
 
75
- # For pessimistic constraint (like '~>' in gems)
49
+ private
76
50
 
77
- def =~( other )
78
- #other = other.to_t
79
- upver = other.dup
80
- upver[0] += 1
81
- @self >= other and @self < upver
82
- end
51
+ def initialize(*args)
52
+ args = args.join('.').split(/\W+/)
53
+ @tuple = args.collect { |i| i.to_i }
54
+ #@tuple.extend(Comparable)
55
+ end
83
56
 
84
- # Major is the first number in the version series.
57
+ public
85
58
 
86
- def major ; @self[0] ; end
59
+ def to_s ; @tuple.join('.') ; end
87
60
 
88
- # Minor is the second number in the version series.
61
+ # This is here only becuase File.join calls it instead of to_s.
62
+ def to_str ; @tuple.join('.') ; end
89
63
 
90
- def minor ; @self[1] || 0 ; end
64
+ #def inspect; to_s; end
91
65
 
92
- # Teeny is third number in the version series.
66
+ def [](i)
67
+ @tuple.fetch(i,0)
68
+ end
93
69
 
94
- def teeny ; @self[2] || 0 ; end
70
+ # "Spaceship" comparsion operator.
95
71
 
96
- # Delegate to the array.
72
+ def <=>(other)
73
+ #other = other.to_t
74
+ [@tuple.size, other.size].max.times do |i|
75
+ c = @tuple[i] <=> other[i]
76
+ return c if c != 0
77
+ end
78
+ 0
79
+ end
97
80
 
98
- def method_missing( sym, *args, &blk )
99
- @self.send(sym, *args, &blk ) rescue super
100
- end
81
+ # For pessimistic constraint (like '~>' in gems).
101
82
 
102
- # Parses a string constraint returning the operation as a lambda.
83
+ def =~(other)
84
+ #other = other.to_t
85
+ upver = other.tuple.dup
86
+ i = upver.index(0)
87
+ i = upver.size unless i
88
+ upver[i-1] += 1
89
+ self >= other && self < upver
90
+ end
103
91
 
104
- def self.constraint_lambda( constraint )
105
- op, val = *parse_constraint( constraint )
106
- lambda { |t| t.send(op, val) }
107
- end
92
+ # Major is the first number in the version series.
108
93
 
109
- def self.parse_constraint( constraint )
110
- constraint = constraint.strip
111
- re = %r{^(=~|~>|<=|>=|==|=|<|>)?\s*(\d+(:?[-.]\d+)*)$}
112
- if md = re.match( constraint )
113
- if op = md[1]
114
- op = '=~' if op == '~>'
115
- op = '==' if op == '='
116
- val = new( *md[2].split(/\W+/) )
117
- else
118
- op = '=='
119
- val = new( *constraint.split(/\W+/) )
120
- end
121
- else
122
- raise ArgumentError, "invalid constraint"
94
+ def major ; @tuple[0] ; end
95
+
96
+ # Minor is the second number in the version series.
97
+
98
+ def minor ; @tuple[1] || 0 ; end
99
+
100
+ # Teeny is third number in the version series.
101
+
102
+ def teeny ; @tuple[2] || 0 ; end
103
+
104
+ # Delegate to the array.
105
+
106
+ def method_missing(sym, *args, &blk)
107
+ @tuple.send(sym, *args, &blk) rescue super
123
108
  end
124
- return op, val
109
+
110
+ protected
111
+
112
+ def tuple ; @tuple ; end
113
+
125
114
  end
126
115
 
127
116
  end
117
+
@@ -0,0 +1 @@
1
+ false
@@ -0,0 +1 @@
1
+ Thomas Sawyer
@@ -0,0 +1 @@
1
+ http://groups.google.com/group/proutils
@@ -0,0 +1 @@
1
+ 2006-12-10