tap 0.11.1 → 0.12.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (103) hide show
  1. data/History +35 -1
  2. data/MIT-LICENSE +1 -1
  3. data/README +16 -15
  4. data/bin/tap +1 -1
  5. data/cmd/console.rb +4 -3
  6. data/cmd/manifest.rb +2 -2
  7. data/cmd/run.rb +12 -15
  8. data/doc/Class Reference +120 -117
  9. data/doc/Command Reference +27 -27
  10. data/doc/Syntax Reference +55 -111
  11. data/doc/Tutorial +69 -26
  12. data/lib/tap.rb +3 -8
  13. data/lib/tap/app.rb +122 -146
  14. data/lib/tap/constants.rb +2 -2
  15. data/lib/tap/env.rb +178 -252
  16. data/lib/tap/exe.rb +67 -30
  17. data/lib/tap/file_task.rb +224 -411
  18. data/lib/tap/generator/arguments.rb +13 -0
  19. data/lib/tap/generator/base.rb +112 -30
  20. data/lib/tap/generator/destroy.rb +36 -13
  21. data/lib/tap/generator/generate.rb +69 -48
  22. data/lib/tap/generator/generators/command/templates/command.erb +3 -3
  23. data/lib/tap/generator/generators/config/config_generator.rb +82 -10
  24. data/lib/tap/generator/generators/generator/generator_generator.rb +16 -6
  25. data/lib/tap/generator/generators/generator/templates/task.erb +2 -2
  26. data/lib/tap/generator/generators/generator/templates/test.erb +26 -0
  27. data/lib/tap/generator/generators/root/root_generator.rb +24 -13
  28. data/lib/tap/generator/generators/root/templates/Rakefile +4 -4
  29. data/lib/tap/generator/generators/root/templates/{tapfile → Rapfile} +6 -6
  30. data/lib/tap/generator/generators/root/templates/gemspec +0 -1
  31. data/lib/tap/generator/generators/task/task_generator.rb +3 -3
  32. data/lib/tap/generator/generators/task/templates/test.erb +1 -1
  33. data/lib/tap/generator/manifest.rb +7 -1
  34. data/lib/tap/generator/preview.rb +76 -0
  35. data/lib/tap/root.rb +222 -156
  36. data/lib/tap/spec.rb +41 -0
  37. data/lib/tap/support/aggregator.rb +25 -28
  38. data/lib/tap/support/audit.rb +278 -357
  39. data/lib/tap/support/constant.rb +2 -1
  40. data/lib/tap/support/constant_manifest.rb +28 -25
  41. data/lib/tap/support/dependency.rb +1 -1
  42. data/lib/tap/support/executable.rb +52 -183
  43. data/lib/tap/support/executable_queue.rb +50 -20
  44. data/lib/tap/support/gems.rb +1 -1
  45. data/lib/tap/support/intern.rb +0 -6
  46. data/lib/tap/support/join.rb +49 -83
  47. data/lib/tap/support/joins.rb +0 -3
  48. data/lib/tap/support/joins/switch.rb +13 -11
  49. data/lib/tap/support/joins/sync_merge.rb +25 -50
  50. data/lib/tap/support/manifest.rb +1 -0
  51. data/lib/tap/support/node.rb +140 -20
  52. data/lib/tap/support/parser.rb +56 -42
  53. data/lib/tap/support/schema.rb +183 -157
  54. data/lib/tap/support/templater.rb +9 -1
  55. data/lib/tap/support/versions.rb +39 -0
  56. data/lib/tap/task.rb +150 -177
  57. data/lib/tap/tasks/dump.rb +4 -4
  58. data/lib/tap/tasks/load.rb +29 -29
  59. data/lib/tap/test.rb +66 -53
  60. data/lib/tap/test/env_vars.rb +3 -3
  61. data/lib/tap/test/extensions.rb +11 -17
  62. data/lib/tap/test/file_test.rb +74 -132
  63. data/lib/tap/test/file_test_class.rb +4 -1
  64. data/lib/tap/test/regexp_escape.rb +2 -2
  65. data/lib/tap/test/script_test.rb +2 -2
  66. data/lib/tap/test/subset_test.rb +6 -6
  67. data/lib/tap/test/tap_test.rb +28 -154
  68. metadata +30 -51
  69. data/bin/rap +0 -118
  70. data/cgi/run.rb +0 -97
  71. data/lib/tap/declarations.rb +0 -229
  72. data/lib/tap/generator/generators/config/templates/doc.erb +0 -12
  73. data/lib/tap/generator/generators/config/templates/nodoc.erb +0 -8
  74. data/lib/tap/generator/generators/file_task/file_task_generator.rb +0 -27
  75. data/lib/tap/generator/generators/file_task/templates/file.txt +0 -11
  76. data/lib/tap/generator/generators/file_task/templates/result.yml +0 -6
  77. data/lib/tap/generator/generators/file_task/templates/task.erb +0 -33
  78. data/lib/tap/generator/generators/file_task/templates/test.erb +0 -29
  79. data/lib/tap/generator/generators/root/templates/test/tap_test_suite.rb +0 -5
  80. data/lib/tap/patches/optparse/summarize.rb +0 -62
  81. data/lib/tap/support/assignments.rb +0 -173
  82. data/lib/tap/support/class_configuration.rb +0 -182
  83. data/lib/tap/support/combinator.rb +0 -125
  84. data/lib/tap/support/configurable.rb +0 -113
  85. data/lib/tap/support/configurable_class.rb +0 -271
  86. data/lib/tap/support/configuration.rb +0 -170
  87. data/lib/tap/support/gems/rake.rb +0 -111
  88. data/lib/tap/support/instance_configuration.rb +0 -173
  89. data/lib/tap/support/joins/fork.rb +0 -19
  90. data/lib/tap/support/joins/merge.rb +0 -22
  91. data/lib/tap/support/joins/sequence.rb +0 -21
  92. data/lib/tap/support/lazy_attributes.rb +0 -45
  93. data/lib/tap/support/lazydoc.rb +0 -386
  94. data/lib/tap/support/lazydoc/comment.rb +0 -503
  95. data/lib/tap/support/lazydoc/config.rb +0 -17
  96. data/lib/tap/support/lazydoc/definition.rb +0 -36
  97. data/lib/tap/support/lazydoc/document.rb +0 -152
  98. data/lib/tap/support/lazydoc/method.rb +0 -24
  99. data/lib/tap/support/tdoc.rb +0 -409
  100. data/lib/tap/support/tdoc/tdoc_html_generator.rb +0 -38
  101. data/lib/tap/support/tdoc/tdoc_html_template.rb +0 -42
  102. data/lib/tap/support/validation.rb +0 -479
  103. data/lib/tap/tasks/rake.rb +0 -57
@@ -1,170 +0,0 @@
1
- module Tap
2
- module Support
3
-
4
- # Represents a configuration declared by a Configurable class.
5
- class Configuration
6
- class << self
7
-
8
- # Matches a short option
9
- SHORT_OPTION = /^-[A-z]$/
10
-
11
- # Turns the input string into a short-format option. Raises
12
- # an error if the option does not match SHORT_REGEXP.
13
- #
14
- # Configuration.shortify("-o") # => '-o'
15
- # Configuration.shortify(:o) # => '-o'
16
- #
17
- def shortify(str)
18
- str = str.to_s
19
- str = "-#{str}" unless str[0] == ?-
20
- raise "invalid short option: #{str}" unless str =~ SHORT_OPTION
21
- str
22
- end
23
-
24
- # Matches a long option
25
- LONG_OPTION = /^--(\[no-\])?([A-z][\w-]*)$/
26
-
27
- # Turns the input string into a long-format option. Raises
28
- # an error if the option does not match LONG_REGEXP.
29
- #
30
- # Configuration.longify("--opt") # => '--opt'
31
- # Configuration.longify(:opt) # => '--opt'
32
- # Configuration.longify(:opt, true) # => '--[no-]opt'
33
- # Configuration.longify(:opt_ion) # => '--opt-ion'
34
- # Configuration.longify(:opt_ion, false, false) # => '--opt_ion'
35
- #
36
- def longify(str, switch_notation=false, hyphenize=true)
37
- str = str.to_s
38
- str = "--#{str}" unless str.index("--")
39
- str.gsub!(/_/, '-') if hyphenize
40
-
41
- raise "invalid long option: #{str}" unless str =~ LONG_OPTION
42
-
43
- if switch_notation && $1.nil?
44
- str = "--[no-]#{$2}"
45
- end
46
-
47
- str
48
- end
49
- end
50
-
51
- # The name of the configuration
52
- attr_reader :name
53
-
54
- # The reader method, by default name
55
- attr_reader :reader
56
-
57
- # The writer method, by default name=
58
- attr_reader :writer
59
-
60
- # True if the default value may be duplicated
61
- attr_reader :duplicable
62
-
63
- # An array of optional metadata for self
64
- attr_reader :attributes
65
-
66
- # Initializes a new Configuration with the specified name and default
67
- # value. Options may specify an alternate reader/writer; any
68
- # additional options are set as attributes.
69
- def initialize(name, default=nil, options={})
70
- @name = name
71
- self.default = default
72
-
73
- self.reader = options.has_key?(:reader) ? options.delete(:reader) : name
74
- self.writer = options.has_key?(:writer) ? options.delete(:writer) : "#{name}="
75
- @attributes = options
76
- end
77
-
78
- # Sets the default value for self and determines if the
79
- # default is duplicable. Non-duplicable values include
80
- # nil, true, false, Symbol, Numeric, and any object that
81
- # does not respond to dup.
82
- def default=(value)
83
- @duplicable = case value
84
- when nil, true, false, Symbol, Numeric, Method then false
85
- else value.respond_to?(:dup)
86
- end
87
-
88
- @default = value.freeze
89
- end
90
-
91
- # Returns the default value, or a duplicate of the default
92
- # value if specified and the default value is duplicable.
93
- def default(duplicate=true)
94
- duplicate && duplicable ? @default.dup : @default
95
- end
96
-
97
- # Sets the reader for self. The reader is symbolized,
98
- # but may also be set to nil.
99
- def reader=(value)
100
- @reader = value == nil ? value : value.to_sym
101
- end
102
-
103
- # Sets the writer for self. The writer is symbolized,
104
- # but may also be set to nil.
105
- def writer=(value)
106
- @writer = value == nil ? value : value.to_sym
107
- end
108
-
109
- # The argument name for self: either attributes[:arg_name]
110
- # or name.to_s.upcase
111
- def arg_name
112
- attributes[:arg_name] || name.to_s.upcase
113
- end
114
-
115
- # The argument type for self: either attributes[:arg_type]
116
- # or :mandatory
117
- def arg_type
118
- attributes[:arg_type] || :mandatory
119
- end
120
-
121
- # The long version of name.
122
- def long(switch_notation=false, hyphenize=true)
123
- Configuration.longify(attributes[:long] || name.to_s, switch_notation, hyphenize)
124
- end
125
-
126
- # The short version of name.
127
- def short
128
- attributes[:short] ? Configuration.shortify(attributes[:short]) : nil
129
- end
130
-
131
- # The description for self: attributes[:desc]
132
- def desc
133
- attributes[:desc]
134
- end
135
-
136
- # True if another is a kind of Configuration with the same name,
137
- # default value, reader and writer; other attributes are NOT
138
- # taken into account.
139
- def ==(another)
140
- another.kind_of?(Configuration) &&
141
- self.name == another.name &&
142
- self.reader == another.reader &&
143
- self.writer == another.writer &&
144
- self.default(false) == another.default(false)
145
- end
146
-
147
- # Returns self as an argv that can be used to register
148
- # an option with OptionParser.
149
- def to_optparse_argv
150
- argtype = case arg_type
151
- when :optional
152
- "#{long} [#{arg_name}]"
153
- when :switch
154
- long(true)
155
- when :flag
156
- long
157
- when :list
158
- "#{long} a,b,c"
159
- when :mandatory, nil
160
- "#{long} #{arg_name}"
161
- else
162
- raise "unknown arg_type: #{arg_type}"
163
- end
164
-
165
- [short, argtype, desc].compact
166
- end
167
-
168
- end
169
- end
170
- end
@@ -1,111 +0,0 @@
1
- require 'rake'
2
- require 'tap'
3
-
4
- module Tap
5
- module Support
6
- module Gems
7
- class RakeManifest < Support::Manifest
8
- def initialize(env)
9
- @env = env
10
- rake = ::Rake.application
11
- super(rake.have_rakefile(env.root.root) ? [rake.instance_variable_get(:@rakefile)] : [])
12
- end
13
- end
14
-
15
- module Rake
16
-
17
- def self.extended(base)
18
- Tap::Env.instance_for(Dir.pwd).activate unless Tap::Env.instance
19
- base.env = Tap::Env.instance
20
- end
21
-
22
- attr_accessor :env
23
-
24
- def enq_top_level(app)
25
- # takes the place of rake.top_level
26
- if options.show_tasks
27
- display_tasks_and_comments
28
- exit
29
- elsif options.show_prereqs
30
- display_prerequisites
31
- exit
32
- else
33
- top_level_tasks.each do |task_string|
34
- name, args = parse_task_string(task_string)
35
- task = self[name]
36
- app.mq(task, :invoke, *args)
37
- end
38
- end
39
- end
40
-
41
- def collect_tasks(*args)
42
- # a little song and dance for compliance with
43
- # rake pre- and post-0.8.2
44
- argv = args.empty? ? ARGV : args[0]
45
- argv.collect! do |arg|
46
- next(arg) unless arg =~ /^:([a-z_\d]+):(.*)$/
47
- env_pattern = $1
48
- rake_task = $2
49
-
50
- next(arg) unless entry = env.find(:envs, env_pattern, false)
51
-
52
- mini_path, env = entry
53
- root_path = env.root.root
54
-
55
- if have_rakefile(root_path)
56
- # load sequence echos that in raw_load_rakefile
57
- puts "(in #{root_path})" unless options.silent
58
- current_global_rakefile = $rakefile
59
- $rakefile = @rakefile
60
-
61
- namespaces = Tap::Root.split(mini_path, false).delete_if do |segment|
62
- segment.empty?
63
- end
64
-
65
- #if @rakefile != ''
66
- eval nest_namespace(%Q{load "#{File.join(root_path, @rakefile)}"}, namespaces.dup)
67
- #end
68
-
69
- $rakefile = current_global_rakefile
70
- @rakefile = nil
71
-
72
- namespaces << rake_task
73
- namespaces.join(":")
74
- else
75
- fail "No Rakefile found for '#{env_pattern}' (looking for: #{@rakefiles.join(', ')})"
76
- end
77
- end
78
-
79
- super
80
- end
81
-
82
- def have_rakefile(dir=nil)
83
- return super() if dir == nil
84
- Tap::Root.chdir(dir) { super() }
85
- end
86
-
87
- protected
88
-
89
- NAMESPACE_STR = %Q{
90
- namespace(:'%s') do
91
- %s
92
- end
93
- }.strip
94
-
95
- def nest_namespace(nest_str, namespaces)
96
- return nest_str if namespaces.empty?
97
-
98
- NAMESPACE_STR % [
99
- namespaces.shift,
100
- namespaces.empty? ? nest_str : nest_namespace(nest_str, namespaces)
101
- ]
102
- end
103
- end
104
- end
105
- end
106
- end
107
-
108
- Rake.application.extend Tap::Support::Gems::Rake
109
- Tap::Env.manifest(:rakefiles) do |env|
110
- Tap::Support::Gems::RakeManifest.new(env)
111
- end
@@ -1,173 +0,0 @@
1
- module Tap
2
- module Support
3
-
4
- # InstanceConfiguration serves as a forwarding hash, where get and set operations
5
- # for configurations are sent to instance methods rather than to an underlying data
6
- # store.
7
- #
8
- # class Sample
9
- # attr_accessor :key
10
- # end
11
- # sample = Sample.new
12
- #
13
- # class_config = ClassConfiguration.new(Sample)
14
- # class_config.add(:key)
15
- #
16
- # config = InstanceConfiguration.new(class_config)
17
- # config.bind(sample)
18
- #
19
- # sample.key = 'value'
20
- # config[:key] # => 'value'
21
- #
22
- # config[:key] = 'another'
23
- # sample.key # => 'another'
24
- #
25
- # Non-config keys are simply stored:
26
- #
27
- # config[:not_a_key] = 'value'
28
- # config[:not_a_key] # => 'value'
29
- #
30
- # config.store # => {:not_a_key => 'value'}
31
- # config.to_hash # => {:key => 'another', :not_a_key => 'value'}
32
- #
33
- class InstanceConfiguration
34
-
35
- # The bound receiver
36
- attr_reader :receiver
37
-
38
- # The underlying data store for non-config keys
39
- attr_reader :store
40
-
41
- # The ClassConfiguration specifying config keys
42
- attr_reader :class_config
43
-
44
- def initialize(class_config, receiver=nil, store={})
45
- @receiver = receiver
46
- @store = store
47
- @class_config = class_config
48
- end
49
-
50
- # Updates self to ensure that each class_config key
51
- # has a value in self; the config.default value is
52
- # set if a value does not already exist.
53
- #
54
- # Returns self.
55
- def update(class_config=self.class_config)
56
- class_config.each_pair do |key, config|
57
- self[key] ||= config.default
58
- end
59
- self
60
- end
61
-
62
- # Binds self to the specified receiver. Mapped keys are
63
- # removed from store and sent to their writer method on
64
- # receiver.
65
- def bind(receiver)
66
- raise "already bound to: #{@receiver}" if bound?
67
- raise ArgumentError, "receiver cannot be nil" if receiver == nil
68
-
69
- class_config.each_pair do |key, config|
70
- receiver.send(config.writer, store.delete(key)) if config.writer
71
- end
72
- @receiver = receiver
73
-
74
- self
75
- end
76
-
77
- # Returns true if self is bound to a receiver
78
- def bound?
79
- receiver != nil
80
- end
81
-
82
- # Unbinds self from the specified receiver. Mapped values
83
- # are stored in store. Returns the unbound receiver.
84
- def unbind
85
- class_config.each_pair do |key, config|
86
- store[key] = receiver.send(config.reader) if config.reader
87
- end
88
- r = receiver
89
- @receiver = nil
90
-
91
- r
92
- end
93
-
94
- # Duplicates self, returning an unbound InstanceConfiguration.
95
- def dup
96
- duplicate = super()
97
- duplicate.instance_variable_set(:@receiver, nil)
98
- duplicate.instance_variable_set(:@store, @store.dup)
99
- duplicate
100
- end
101
-
102
- # Associates the value the key. If bound? and the key
103
- # is a class_config key, then the value will be forwarded
104
- # to the config.writer method on the receiver.
105
- def []=(key, value)
106
- case
107
- when bound? && config = class_config.map[key.to_sym]
108
- config.writer ? receiver.send(config.writer, value) : store[key] = value
109
- else store[key] = value
110
- end
111
- end
112
-
113
- # Retrieves the value corresponding to the key. If bound?
114
- # and the key is a class_config key, then the value is
115
- # obtained from the config.reader method on the receiver.
116
- def [](key)
117
- case
118
- when bound? && config = class_config.map[key.to_sym]
119
- config.reader ? receiver.send(config.reader) : store[key]
120
- else store[key]
121
- end
122
- end
123
-
124
- # True if the key is assigned in self.
125
- def has_key?(key)
126
- (bound? && class_config.key?(key)) || store.has_key?(key)
127
- end
128
-
129
- # Calls block once for each key-value pair stored in self.
130
- def each_pair # :yields: key, value
131
- class_config.each_pair do |key, config|
132
- yield(key, receiver.send(config.reader)) if config.reader
133
- end if bound?
134
-
135
- store.each_pair do |key, value|
136
- yield(key, value)
137
- end
138
- end
139
-
140
- # Equal if the to_hash values of self and another are equal.
141
- def ==(another)
142
- another.respond_to?(:to_hash) && to_hash == another.to_hash
143
- end
144
-
145
- # Returns self as a hash.
146
- def to_hash
147
- hash = store.dup
148
- class_config.keys.each do |key|
149
- hash[key] = self[key]
150
- end if bound?
151
- hash
152
- end
153
-
154
- def to_yaml(opts)
155
- hash = {}
156
- store.each_pair do |key, value|
157
- hash[key.to_s] = value
158
- end
159
-
160
- class_config.each_pair do |key, config|
161
- hash[key.to_s] = bound? ? self[key] : config.default
162
- end
163
-
164
- hash.to_yaml(opts)
165
- end
166
-
167
- # Overrides default inspect to show the to_hash values.
168
- def inspect
169
- "#<#{self.class}:#{object_id} to_hash=#{to_hash.inspect}>"
170
- end
171
- end
172
- end
173
- end