detroit 0.2.0 → 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
data/EXAMPLE.md CHANGED
@@ -1,18 +1,18 @@
1
1
  # Detroit
2
2
 
3
- Detroit's main configuration file is called a *Pitfile*. Pitfiles define the
3
+ Detroit's main configuration file is called an *assembly*. Assemblies define the
4
4
  <i>service instances</i> that a project will utilize.
5
5
 
6
- Pitfiles can be written in a few different formats thanks to the flexibility
6
+ Assemblies can be written in a few different formats thanks to the flexibility
7
7
  of Ruby. All formats are equivalent. Which format you use is strictly a regard
8
8
  of your personal preference.
9
9
 
10
10
  ## Ruby-based Detroit
11
11
 
12
- ### Traditional Format
12
+ ### Service Method Notation
13
13
 
14
- Traditionally a Ruby-based Detroit is dominated by calls to the `service` method
15
- with an optional service instance name and a setter block.
14
+ Traditionally a Ruby-based assembly file is dominated by calls to the `service`
15
+ method with an optional service instance name and a setter block.
16
16
 
17
17
  ```ruby
18
18
  service :myself do |s|
@@ -31,8 +31,9 @@ If no `service` setting is given, it is assumed to be same as the service instan
31
31
  In the above example `rdoc` is taken to be both the service desired and the name of
32
32
  this particular instance.
33
33
 
34
- A few years ago, Sinatra came along and popularized the use of the `#set` method. A simple addition
35
- to the the Detroit parser now allows for the slightly cleaner notation:
34
+ A few years ago, Sinatra came along and popularized the use of the `#set` method.
35
+ A simple addition to Detroit's assembly file parser now allows for the slightly
36
+ cleaner notation:
36
37
 
37
38
  ```ruby
38
39
  service :myself do
@@ -71,12 +72,12 @@ definition to be written as simply as:
71
72
  service :rdoc
72
73
  ```
73
74
 
74
- ### Modern Notation
75
+ ### Service Name Notation
75
76
 
76
- Thanks to some straight-forward meta-programming, a Ruby-based Detroit can
77
- be written in a more concisely notation by using the name of the service class as a
77
+ Thanks to some straight-forward meta-programming, a Ruby-based assembly file can
78
+ be written in a more concise notation by using the name of the service class as a
78
79
  method. This can be followed by a settings block, as with the above examples,
79
- or passed a <i>settings hash</i>. In which case a Detroit can look like this:
80
+ or passed a <i>settings hash</i>. In which case an assembly file can look like this:
80
81
 
81
82
  ```ruby
82
83
  Announce :mailto => "ruby-talk@ruby-lang.org",
@@ -113,16 +114,16 @@ need to define service instances. With Ruby 1.9 it can be even more conisce
113
114
  using the new Hash syntax.
114
115
 
115
116
  ```ruby
116
- Announce :myself,
117
- mailto: "transfire@gmail.com",
118
- priority: -1
119
- active: true
117
+ Announce :myself,
118
+ mailto: "transfire@gmail.com",
119
+ priority: -1
120
+ active: true
120
121
  ```
121
122
 
122
- But you might want to hold off on that a couple of years until Ruby 1.8 is pretty much
123
- shot and buried ;)
123
+ But you might want to hold off on that a couple of years until Ruby 1.8 is pretty
124
+ much shot and buried ;)
124
125
 
125
- ## YAML-based Detroit
126
+ ## YAML-based Assembly Files
126
127
 
127
128
  We have saved the most concise notation for last. The YAML format is
128
129
  essentially the same as the traditional Ruby format except that
@@ -132,7 +133,7 @@ setting which defaults to the name. Also, notice the start document indicator
132
133
  recognized as YAML, rather than Ruby.
133
134
 
134
135
  ```yaml
135
- --- !detroit
136
+ ---
136
137
 
137
138
  announce:
138
139
  mailto: "transfire@gmail.com"
@@ -172,17 +173,16 @@ recognized as YAML, rather than Ruby.
172
173
  sitemap:
173
174
  site: <% name %>
174
175
  active: false
175
- ```
176
176
 
177
177
  As we can see in the last entry, the YAML format also supports ERB and provides
178
178
  access to project metadata via the ERB's binding.
179
179
 
180
- With the Ruby format it is easy enough to load external Detroit plugins using
180
+ With the Ruby format it is easy enough to load external library using
181
181
  standard `require` and `load` methods. Since the YAML format supports ERB
182
182
  it can be used to achieve the same effect.
183
183
 
184
- ```ruby
185
- --- !detroit
186
- <% require 'some/detroit/plugin' %>
184
+ ```yaml
185
+ ---
186
+ <% require 'some/external/library' %>
187
187
  ```
188
188
 
@@ -1,5 +1,21 @@
1
1
  = RELEASE HISTORY
2
2
 
3
+ == 0.3.0 / 2012-04-02
4
+
5
+ This significant release changes the interface for tools to tap
6
+ into the assembly line. Where as before specially named methods
7
+ in the form of `station_{stop}` were used, now two special methods
8
+ are expected `#assemble?` and `#assemble`. The first checks to see
9
+ if a particular stop is supported and the later is used to execute
10
+ it if it does.
11
+
12
+ Changes:
13
+
14
+ * Simplify the assembly interface for tools.
15
+ * Tool classes ending in Base are abstract base class.
16
+ * Add #on as alias from #track.
17
+
18
+
3
19
  == 0.2.0 / 2011-10-19
4
20
 
5
21
  The big news here is that Detroit configuration files are now
@@ -1,8 +1,8 @@
1
1
  = Detroit
2
2
 
3
- Author:: Thomas Sawyer
4
- License:: GPL v.3
5
- Copyright:: (c) 2011 Rubyworks, Thomas Sawyer
3
+ {Homepage}[http://rubyworks.github.com/detroit] /
4
+ {Development}[http://github.com/rubyworks/detroit] /
5
+ {Mailing List}[http://googlegroups.com/group/rubyworks-mailinglist]
6
6
 
7
7
 
8
8
  == DESCRIPTION
@@ -12,13 +12,6 @@ Detroit utilizes a life-cycle methodology to help developers prepare and
12
12
  release Ruby software in a clear, repeatable, linear fashion.
13
13
 
14
14
 
15
- == RESOURCES
16
-
17
- * {Homepage}[http://rubyworks.github.com/detroit]
18
- * {Development}[http://github.com/rubyworks/detroit]
19
- * {Mailing List}[http://googlegroups.com/group/rubyworks-mailinglist]
20
-
21
-
22
15
  == HOW IT WORKS
23
16
 
24
17
  Detroit defines development processions which consist of a set of named
@@ -13,7 +13,7 @@ module Detroit
13
13
  end
14
14
 
15
15
  # TODO: Only here b/c of bug in Ruby 1.8.x
16
- #VERSION = "0.2.0"
16
+ #VERSION = "0.3.0"
17
17
  end
18
18
 
19
19
  # Erb is used to to script YAML-based schedule files.
@@ -1,4 +1,7 @@
1
1
  ---
2
+ source:
3
+ - PROFILE
4
+ - meta
2
5
  authors:
3
6
  - name: Trans
4
7
  email: transfire@gmail.com
@@ -6,8 +9,6 @@ copyrights:
6
9
  - holder: Thomas Sawyer
7
10
  year: '2007'
8
11
  license: GPL3
9
- replacements: []
10
- conflicts: []
11
12
  requirements:
12
13
  - name: facets
13
14
  - name: pom
@@ -16,6 +17,8 @@ requirements:
16
17
  - test
17
18
  development: true
18
19
  dependencies: []
20
+ alternatives: []
21
+ conflicts: []
19
22
  repositories:
20
23
  - uri: http://github.com/proutils/detroit.git
21
24
  scm: git
@@ -24,20 +27,18 @@ resources:
24
27
  home: http://rubyworks.github.com/detroit
25
28
  code: http://github.com/rubyworks/detroit
26
29
  mail: http://groups.google.com/rubyworks-mailinglist
30
+ extra: {}
27
31
  load_path:
28
32
  - lib
29
- extra: {}
30
- source:
31
- - PROFILE
32
- alternatives: []
33
33
  revision: 0
34
- version: 0.2.0
35
- date: '2011-10-18'
36
- name: detroit
37
- title: Detroit
38
- summary: Software Production Mangement
39
34
  created: '2007-10-10'
35
+ summary: Software Production Mangement
36
+ title: Detroit
37
+ version: 0.3.0
38
+ name: detroit
39
+ suite: detroit
40
40
  description: Detroit is an advanced lifecycle build system. With Detroit, build tasks
41
41
  are user defined service instances tied to stops along a track. Whenever the detroit
42
42
  console command is run, a track is followed from beginning to designated destination.
43
- organization: Detroit
43
+ organization: rubyworks
44
+ date: '2012-04-01'
@@ -233,6 +233,8 @@ module Detroit
233
233
 
234
234
  @destination = stop
235
235
 
236
+ # TODO: Using #preconfigure as part of the protocol should probably change.
237
+
236
238
  # prime the services (so as to fail early)
237
239
  active_services.each do |srv|
238
240
  srv.preconfigure if srv.respond_to?("preconfigure")
@@ -256,12 +258,13 @@ module Detroit
256
258
  puts "\nFinished in #{stop_time - start_time} seconds." unless quiet?
257
259
  end
258
260
 
259
- # Execute service hook for given track and destination.
260
- #--
261
261
  # TODO: Deprecate service hooks?
262
+
263
+ #
264
+ # Execute service hook for given track and destination.
265
+ #
266
+ # @todo Currently only stop counts, maybe add track subdirs.
262
267
  #
263
- # TODO: Currently only stop counts, maybe add track subdirs.
264
- #++
265
268
  def service_hooks(track, stop)
266
269
  #hook = dir + ("#{track}/#{stop}.rb".gsub('_', '-'))
267
270
  dir = hook_directory
@@ -321,11 +324,13 @@ module Detroit
321
324
  end
322
325
  end
323
326
 
324
- # Run a service given the service, track name and stop name.
327
+ #
328
+ # Run a service given the service, track and stop name.
329
+ #
325
330
  def run_a_service(srv, track, stop)
326
331
  # run if the service supports the track and stop.
327
332
  #if srv.respond_to?("#{track}_#{stop}")
328
- if srv.stop?(stop)
333
+ if srv.stop?(stop, @destination)
329
334
  if options[:trace] #options[:verbose]
330
335
  #status_line("#{srv.key.to_s} (#{srv.class}##{track}_#{stop})", stop.to_s.gsub('_', '-').capitalize)
331
336
  status_line("#{srv.key.to_s} (#{srv.class}##{stop})", stop.to_s.gsub('_', '-').capitalize)
@@ -21,10 +21,12 @@ module Detroit
21
21
  # Plural alias for #track.
22
22
  alias_accessor :tracks, :track
23
23
 
24
+ alias_accessor :on, :track
25
+
24
26
  private
25
27
 
26
28
  SPECIAL_OPTIONS = %w{
27
- service track tracks active priority project
29
+ service track tracks on active priority project
28
30
  trial trace verbose force quiet
29
31
  }
30
32
 
@@ -59,22 +61,42 @@ module Detroit
59
61
 
60
62
  #
61
63
  def method_missing(s, *a, &b)
62
- if @context.respond_to?(s)
63
- @context.__send__(s,*a,&b)
64
+ if s.to_s.end_with?('=')
65
+ # stop = s.to_s.chomp('=')
66
+ # if !SPECIAL_OPTIONS.include?(stop)
67
+ # (class << self; self; end).module_eval %{
68
+ # def station_#{stop}
69
+ # #{a.first}
70
+ # end
71
+ # }
72
+ # end
64
73
  else
65
- super(s, *a, &b)
74
+ if @context.respond_to?(s)
75
+ @context.__send__(s,*a,&b)
76
+ else
77
+ super(s, *a, &b)
78
+ end
66
79
  end
67
80
  end
68
81
 
69
- public
70
-
71
- #
72
- #def respond_to?(name)
73
- # r = super(name)
74
- # return r if r
75
- # @context.respond_to?(s)
82
+ # @todo should only respond to stop names and special options.
83
+ #def respond_to?(s)
84
+ # return true if SPECIAL_OPTIONS.include?(s.to_s)
85
+ # return true
76
86
  #end
77
87
 
88
+ # RUBY 1.9
89
+ def respond_to_missing?(name, privy)
90
+ #return true if name.to_s.start_with?('station_')
91
+ return true if name.to_s.end_with?('=')
92
+ return true if @context.respond_to?(name)
93
+ false
94
+ end
95
+
96
+ def inspect
97
+ "#<Custom @on=#{track.join(',')}>"
98
+ end
99
+
78
100
  end
79
101
 
80
102
  end
@@ -1,14 +1,9 @@
1
1
  module Detroit
2
2
 
3
- #
4
- #def self.services
5
- # @registry ||= {}
6
- #end
7
-
8
- # Service class wraps a Tool instance when it is made
9
- # part of an assembly.
10
- #
11
3
  # TODO: Need to work on how to limit a service's tracks per-assembly.
4
+
5
+ # Service class wraps a Tool instance when it is made part of an assembly.
6
+ #
12
7
  class Service
13
8
  attr :key
14
9
  attr :tracks
@@ -17,23 +12,31 @@ module Detroit
17
12
  attr :service
18
13
  #attr :options
19
14
 
15
+ #
20
16
  # Set the priority. Priority determines the order which
21
17
  # services on the same stop are run.
18
+ #
22
19
  def priority=(integer)
23
20
  @priority = integer.to_i
24
21
  end
25
22
 
23
+ #
26
24
  # Set the tracks a service will be available on.
25
+ #
27
26
  def tracks=(list)
28
27
  @tracks = list.to_list
29
28
  end
30
29
 
30
+ #
31
+ #
31
32
  #
32
33
  def active=(boolean)
33
34
  @active = !!boolean
34
35
  end
35
36
 
37
+ #
36
38
  # Create new ServiceWrapper.
39
+ #
37
40
  def initialize(key, service_class, options)
38
41
  @key = key
39
42
 
@@ -49,147 +52,27 @@ module Detroit
49
52
  @service = service_class.new(options)
50
53
  end
51
54
 
52
- # Does the service support the given stop.
53
- def stop?(name)
54
- @service.respond_to?("station_#{name}")
55
- end
56
-
57
- # Run the service stop procedure.
58
- def invoke(name, stop=nil)
59
- sm = @service.method("station_#{name}") # public_send
60
- sm.arity == 0 ? sm.call : sm.call(stop)
61
- end
62
-
63
55
  #
64
- def inspect
65
- "<#{self.class}:#{object_id} @key='#{key}'>"
56
+ # Does the service support the given assembly station?
57
+ #
58
+ def stop?(station, stop=nil)
59
+ @service.assemble?(station.to_sym, :destination=>stop.to_sym)
66
60
  end
67
61
 
68
62
  #
69
- #def self.assemble(name, method=nil)
70
- # define_method("assembly_#{name}") do
71
- # __send__(method || name) # public_send
72
- # end
73
- #end
74
- end
75
-
76
- end
77
-
78
-
79
-
80
- =begin
81
- # Mixin module is added to Service and Tool.
82
- module Serviceable
83
-
63
+ # Run the service assembly station procedure.
84
64
  #
85
- def self.included(base)
86
- base.extend ClassRegistry
87
- base.extend DomainLanguage
88
- end
89
-
90
- # Register new instance of the Service class.
91
- module ClassRegistry
92
-
93
- # Class-level attribute of registered Service subclasses.
94
- #
95
- # Returns a Hash.
96
- def registry
97
- Detroit.services
98
- end
99
-
100
- # TODO: Probably should make a named registry instead.
101
- def inherited(base)
102
- return if base.name.to_s.empty?
103
- if base.name !~ /Service$/
104
- registry[base.basename.downcase] = base
105
- end
106
- end
107
-
108
- # Returns a Class which is a new subclass of the current class.
109
- def factory(&block)
110
- Class.new(self, &block)
111
- end
112
-
113
- #
114
- def options(service_class=self)
115
- service_class.instance_methods.
116
- select{ |m| m.to_s =~ /\w+=$/ && !%w{taguri=}.include?(m.to_s) }.
117
- map{ |m| m.to_s.chomp('=') }
118
- end
119
-
120
- end
121
-
122
- # Service Domain language. This module extends the Service class,
123
- # to provide a convenience interface for defining stops.
124
- module DomainLanguage
125
- ## TODO: Err.. Is this being used?
126
- #def init(&block)
127
- # define_method(:init, &block)
128
- #end
129
-
130
- # Override the `tracks` method to limit the lines a service
131
- # will work with by default. Generally this is not used,
132
- # and a return value of +nil+ means all lines apply.
133
- def tracks
134
- end
135
-
136
- # TODO: Perhaps deprecate this in favor of just defining an `availabe?`
137
- # class method.
138
- def available(&block)
139
- @available = block if block
140
- @available ||= nil
141
- end
142
-
143
- #
144
- def available?(project)
145
- return true unless available
146
- @available.call(project)
147
- end
65
+ def invoke(station, stop=nil)
66
+ @service.assemble(station.to_sym, :destination=>stop.to_sym)
148
67
  end
149
68
 
150
- #attr_reader :service_name
151
-
152
69
  #
153
- def service_title
154
- self.class.name
155
- end
156
-
157
- # TODO: Is this being used?
158
- #def service_actions
159
- # self.class.service_actions
160
- #end
161
-
162
70
  #
163
- #def inspect
164
- # "<#{self.class}:#{object_id}>"
165
- #end
166
- end
167
-
168
- # The Service class is the base class for defining basic or delgated services.
169
- class Service
170
- include Serviceable
171
-
172
71
  #
173
- attr :options
174
-
175
- def initialize(options={})
176
- @options = options
72
+ def inspect
73
+ "<#{self.class}:#{object_id} @key='#{key}'>"
177
74
  end
178
- end
179
-
180
75
 
181
- end #module Detroit
76
+ end
182
77
 
183
- # Provides a clean namespace for creating services.
184
- module Detroit::Plugins
185
- Service = Detroit::Service
186
- Tool = Detroit::Tool
187
78
  end
188
-
189
- =end
190
-
191
- # TOPLEVEL DSL?
192
- #def service(name, &block)
193
- # #Detroit.services[name] = Service.factory(&block)
194
- # Detroit::Service.registry[name.to_s] = Detroit::Service.factory(&block)
195
- #end