reap 4.5.2 → 5.0.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.
@@ -0,0 +1,12 @@
1
+ #require 'rake'
2
+ require 'reap/reap'
3
+
4
+ app = Reap.application
5
+
6
+ app.tasks.each do |name, task|
7
+ desc task.task_desc
8
+ task( name ) do |*args|
9
+ task.execute( *args )
10
+ end
11
+ end
12
+
@@ -1,8 +1,10 @@
1
1
 
2
2
  module Reap
3
- Version = "4.5.0"
3
+ Version = "5.0.1"
4
4
  end
5
5
 
6
+ require 'reap/app'
7
+
6
8
  # Reap project information object.
7
9
  require 'reap/projectinfo'
8
10
 
@@ -27,3 +29,4 @@ require 'reap/task/release'
27
29
  require 'reap/task/doap'
28
30
  require 'reap/task/manifest'
29
31
  require 'reap/task/fileperm' # needs work
32
+ require 'reap/task/custom'
@@ -28,11 +28,10 @@ require 'reap/projectinfo'
28
28
  #
29
29
  # task_attr :mytask
30
30
  #
31
- # def init
31
+ # def run
32
+ #
32
33
  # mytask.message ||= 'None Found!'
33
- # end
34
34
  #
35
- # def run
36
35
  # puts mytask.message #=> Hello!
37
36
  # puts master.default #=> Yo!
38
37
  # puts mytask.default #=> Yo! (inherited from master)
@@ -49,23 +48,8 @@ require 'reap/projectinfo'
49
48
 
50
49
  module Reap
51
50
 
52
- # Hash of all possible tasks
53
- # { task name => task class }
54
-
55
51
  def self.registry
56
- Task.task_list
57
- end
58
-
59
- # Hash of tasks available to this project
60
-
61
- def self.tasks
62
- unless @tasks
63
- @tasks = {}
64
- registry.each do |name, klass|
65
- @tasks[name] = klass if klass.available?
66
- end
67
- end
68
- @tasks
52
+ Task.registry
69
53
  end
70
54
 
71
55
  # Task base class.
@@ -79,25 +63,23 @@ module Reap
79
63
 
80
64
  class << self
81
65
 
82
- # When this class is inherited the new task is registered
83
- # by adding it to the task_list hash.
66
+ # When this class is inherited the new task is registered.
84
67
  def inherited( base )
85
- task_list[base.task_name] = base
68
+ registry << base
69
+ YAML.add_private_type( base.basename.downcase ) do |type, val|
70
+ base.new( val )
71
+ end
86
72
  end
87
73
 
88
- # Task list hash.
89
- def task_list
90
- @task_list ||= {}
74
+ # List of task classes.
75
+ def registry
76
+ @registry ||= []
91
77
  end
92
78
 
93
- # === Task DSL methods
79
+ # Task DSL
94
80
 
95
- #def task_section_required( val ) ; @section_required = val ; end
96
- #def section_required? ; @section_required ; end
97
-
98
- # Provided the tasks name. This defualt's the task's
99
- # class' name downcased, so it is rarely needed.
100
- def task_name
81
+ # Provides tasks type.
82
+ def task_class
101
83
  basename.downcase
102
84
  end
103
85
 
@@ -107,6 +89,7 @@ module Reap
107
89
  return @task_desc = block if block_given?
108
90
  return @task_desc.call
109
91
  end
92
+ alias_method :desc, :task_desc
110
93
 
111
94
  # Takes a string or a block the evaluates to a string
112
95
  # providing detailed help information about the task.
@@ -115,9 +98,11 @@ module Reap
115
98
  return @task_help = block if block_given?
116
99
  return @task_help.call
117
100
  end
101
+ alias_method :help, :task_help
118
102
 
119
103
  # Set alias for 'task' attribute, which provides
120
104
  # inherited (from master) access to section data.
105
+ # (Deprecate? You can use "alias_method name, :task")
121
106
  def task_attr( name )
122
107
  define_method(name) { @task }
123
108
  end
@@ -137,7 +122,7 @@ module Reap
137
122
  def task_available( bool=false, &block )
138
123
  if bool
139
124
  (class << self; self; end).class_eval {
140
- define_method( :available? ){ true }
125
+ define_method( :available? ){ |app| true }
141
126
  }
142
127
  else
143
128
  (class << self; self; end).class_eval {
@@ -147,21 +132,12 @@ module Reap
147
132
  end
148
133
 
149
134
  # Is the task available for use? By default
150
- # a task is only made available if the ProjectInfo
151
- # is present and the task's section is present.
152
- def available?
153
- return false unless Reap.projectfile?
154
- #if section_required?
155
- return has_section?
156
- #end
157
- #true
158
- end
135
+ # a task is only made available if the
136
+ # ProjectInfo file has a task for it.
159
137
 
160
- # Project file exists and has task's section?
161
- def has_section?
162
- return false unless Reap.projectfile?
163
- ProjectInfo.instance.info.key?( task_name )
164
- end
138
+ def available?(app)
139
+ false
140
+ end
165
141
 
166
142
  # Class-level access to Project file's master data
167
143
  # provided via a CascadingOpenObject.
@@ -173,77 +149,71 @@ module Reap
173
149
 
174
150
  # instance methods
175
151
 
176
- def task_name ; self.class.task_name ; end
177
- def task_desc ; self.class.task_desc ; end
178
- def task_help ; self.class.task_help ; end
152
+ attr_accessor :task_name
153
+ def name ; task_name ; end
179
154
 
180
- #def section_required? ; self.class.section_required? ; end
155
+ def task_desc ; @section[:desc] || self.class.task_desc ; end
156
+ def task_help ; self.class.task_help ; end
181
157
 
182
- #def master ; ::ProjectInfo.info ; end
183
- def master ; self.class.master ; end
184
- def section ; @section ; end
185
- def task ; @task ; end
158
+ def master ; self.class.master ; end
159
+ def setting ; @task ; end
186
160
 
187
- def initialize( *args )
188
- #@master = CascadingOpenObject.new( $PROJECT_INFO )
189
- @args = args
190
- end
161
+ attr :section
191
162
 
192
- # Run task for each section entires given.
193
-
194
- def execute( section=nil )
195
- section = section || master[task_name]
196
- case section
197
- when Array
198
- section.each do |s|
199
- initiate( s )
200
- end
163
+ def initialize( section )
164
+ case section when Hash, nil
165
+ @section = CascadingOpenObject.new( section || {} )
201
166
  else
202
- initiate( section )
167
+ @section = section
203
168
  end
204
169
  end
205
170
 
206
- # Per section entry execution of task.
171
+ # Run task.
207
172
 
208
- def initiate( section )
209
- @section = CascadingOpenObject.new( section )
173
+ def execute( *args )
174
+ #@section = CascadingOpenObject.new( section )
210
175
 
211
- task_properties = {} # needed?
212
- #self.class.task_only_properties.each { |t| section[t] ||= nil }
213
- task_properties = CascadingOpenObject.new( section )
214
- task_properties.__parent__ = master
215
- @task = task_properties
176
+ task = section.dup
177
+ if task.respond_to?(:__parent__)
178
+ task.__parent__ = master
179
+ end
180
+ @task = task
216
181
 
217
182
  # deprecate init ?
218
183
  if respond_to?( :init )
219
184
  if method(:init).arity == 0
220
185
  init
221
186
  else
222
- init( *@args )
187
+ init( *args )
223
188
  end
224
189
  end
225
190
 
226
191
  if method(:run).arity == 0
227
192
  run
228
193
  else
229
- run( *@args )
194
+ run( *args )
230
195
  end
231
196
  end
232
197
 
233
198
  # interface
234
199
 
235
200
  #def init
236
- # raise "not implemented for '#{task_name}' task"
201
+ # raise "not implemented for '#{name}' task"
237
202
  #end
238
203
 
239
204
  def run
240
205
  raise "no action defined for task #{task_name}"
241
206
  end
242
207
 
208
+ # delegate to section hash
209
+ def method_missing( *args, &block )
210
+ @section.send( *args, &block )
211
+ end
212
+
243
213
  # Task support methods
244
214
 
245
215
  def use_subsection( name )
246
- subsection = @section.__send__(name)
216
+ subsection = @section.__send__(task_name)
247
217
  if subsection
248
218
  subsection.__parent__ = @section
249
219
  @task = subsection
@@ -70,7 +70,7 @@ class Reap::Announce < Reap::Task
70
70
 
71
71
  }
72
72
 
73
- alias_method :anc, :task
73
+ task_attr :anc
74
74
 
75
75
  def run
76
76
 
@@ -0,0 +1,12 @@
1
+
2
+ class Custom < Reap::Task
3
+
4
+ task_desc "Custom task"
5
+
6
+ task_attr :cust
7
+
8
+ def run
9
+ instance_eval cust.task
10
+ end
11
+
12
+ end
@@ -24,9 +24,9 @@ module Reap
24
24
 
25
25
  }
26
26
 
27
- task_available { Reap.projectfile? }
27
+ task_available { |app| app.projectfile? }
28
28
 
29
- alias_method :prj, :task
29
+ task_attr :prj
30
30
 
31
31
  def run
32
32
 
@@ -37,7 +37,7 @@ class Reap::ExTest < Reap::Task
37
37
 
38
38
  }
39
39
 
40
- alias_method :tst, :task
40
+ task_attr :tst
41
41
 
42
42
  def run
43
43
 
@@ -20,8 +20,6 @@ class Reap::Perm < Reap::Task
20
20
 
21
21
  task_help %{
22
22
 
23
- reap perm
24
-
25
23
  Normalizes file permissions.
26
24
 
27
25
  user user name to use
@@ -29,7 +27,7 @@ class Reap::Perm < Reap::Task
29
27
 
30
28
  }
31
29
 
32
- alias_method :perm, :task
30
+ task_attr :perm
33
31
 
34
32
  def run
35
33
 
@@ -23,7 +23,7 @@ class Reap::Info < Reap::Task
23
23
 
24
24
  }
25
25
 
26
- task_available { Reap.projectfile? }
26
+ task_available { |app| app.projectfile? }
27
27
 
28
28
  def run
29
29
  puts ProjectInfo.instance.info_stream
@@ -22,12 +22,11 @@ class Reap::Install < Reap::Task
22
22
 
23
23
  }
24
24
 
25
- # For now. In future I think an install section will be required.
26
- task_available { Reap.projectfile? }
25
+ task_attr :ins
27
26
 
28
27
  def run
29
28
 
30
- task.options ||= []
29
+ ins.options ||= []
31
30
 
32
31
  #exe = %w{ setup.rb install.rb }.find{ |f| File.exists?(f) }
33
32
  #raise "setup.rb or install.rb not found" if exe == nil
@@ -45,7 +44,7 @@ class Reap::Install < Reap::Task
45
44
 
46
45
  exe = %{ruby setup.rb}
47
46
  exe << ' -q ' unless $VERBOSE
48
- exe << task.options.join(' ')
47
+ exe << ins.options.join(' ')
49
48
  exe << ' all'
50
49
  sh exe
51
50
 
@@ -16,8 +16,6 @@ class Reap::Manifest < Reap::Task
16
16
 
17
17
  task_desc "Create a MANIFEST file for this package."
18
18
 
19
- task_available { Reap.projectfile? }
20
-
21
19
  task_help %{
22
20
 
23
21
  reap manifest
@@ -29,7 +27,7 @@ class Reap::Manifest < Reap::Task
29
27
 
30
28
  }
31
29
 
32
- alias_method :man, :task
30
+ task_attr :man
33
31
 
34
32
  def run
35
33
 
@@ -1,13 +1,6 @@
1
1
 
2
2
  require 'reap/task'
3
3
 
4
- begin
5
- require 'rubygems'
6
- rescue LoadError
7
- # no rubygems
8
- end
9
-
10
-
11
4
  # ___ _ _____ _
12
5
  # | _ \__ _ __| |____ _ __ _ ___ |_ _|_ _ __| |__
13
6
  # | _/ _` / _| / / _` / _` / -_) | |/ _` (_-< / /
@@ -81,10 +74,19 @@ class Reap::Package < Reap::Task
81
74
 
82
75
  # Alternate for task properties accessor.
83
76
 
84
- alias_method :pkg, :task
77
+ task_attr :pkg
85
78
 
86
79
  def run
87
80
 
81
+ # load rubygems if available
82
+ # (only do this if need be in future?)
83
+
84
+ begin
85
+ require 'rubygems'
86
+ rescue LoadError
87
+ # no rubygems
88
+ end
89
+
88
90
  # setup package defaults
89
91
 
90
92
  # Do not look in master information for this
@@ -60,7 +60,7 @@ class Reap::Publish < Reap::Task
60
60
  #attr_accessor :host, :type, :dir, :project, :username
61
61
  #attr_accessor :exclude # not using yet
62
62
 
63
- alias_method :pub, :task
63
+ task_attr :pub
64
64
 
65
65
  # Run the publishing task.
66
66
 
@@ -24,14 +24,12 @@ require 'reap/task'
24
24
 
25
25
  class Reap::RDoc < Reap::Task
26
26
 
27
- MUST_EXCLUDE = [ 'InstalledFiles', 'CVS/**/*' ]
27
+ MUST_EXCLUDE = [ 'InstalledFiles', 'CVS/**/*', '_darcs/**/*' ]
28
28
 
29
29
  task_desc "Generate RDoc API documentation."
30
30
 
31
31
  task_help %{
32
32
 
33
- reap rdoc
34
-
35
33
  Generate RDoc doumentation.
36
34
 
37
35
  dir Directory to store documentation [doc].
@@ -44,7 +42,7 @@ class Reap::RDoc < Reap::Task
44
42
 
45
43
  }
46
44
 
47
- alias_method :doc, :task
45
+ task_attr :doc
48
46
 
49
47
  def run
50
48
 
@@ -54,7 +52,7 @@ class Reap::RDoc < Reap::Task
54
52
  doc.main ||= 'README'
55
53
  doc.title ||= master.title
56
54
  doc.template ||= 'html' # 'jamis'
57
- doc.include ||= [ 'A-Z*', 'lib/**/*', 'ext/**/*' ]
55
+ doc.include ||= [ 'A-Z*', 'lib/**/*', 'ext/**/*', doc.main ]
58
56
  doc.exclude ||= [ 'demo/**/*', 'example/**/*', 'sample/**/*' ]
59
57
  doc.options ||= ['--merge', '--all']
60
58