bones 2.1.1 → 2.2.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.
@@ -37,8 +37,6 @@ class GemPackageTask < Rake::PackageTask
37
37
  local_setup = File.join(Dir.pwd, %w[tasks setup.rb])
38
38
  if !test(?e, local_setup)
39
39
  Dir.glob(::Bones.path(%w[lib bones tasks *])).each {|fn| bones_files << fn}
40
- gem_spec.files = (gem_spec.files +
41
- bones_files.map {|fn| File.join('tasks', File.basename(fn))}).sort
42
40
  end
43
41
  end
44
42
 
@@ -63,6 +61,10 @@ class GemPackageTask < Rake::PackageTask
63
61
 
64
62
  file package_dir_path => bones_files do
65
63
  mkdir_p package_dir rescue nil
64
+
65
+ gem_spec.files = (gem_spec.files +
66
+ bones_files.map {|fn| File.join('tasks', File.basename(fn))}).sort
67
+
66
68
  bones_files.each do |fn|
67
69
  base_fn = File.join('tasks', File.basename(fn))
68
70
  f = File.join(package_dir_path, base_fn)
@@ -157,6 +159,13 @@ namespace :gem do
157
159
  puts PROJ.gem._spec.to_ruby
158
160
  end
159
161
 
162
+ desc 'Write the gemspec '
163
+ task :spec => 'gem:prereqs' do
164
+ File.open("#{PROJ.name}.gemspec", 'w') do |f|
165
+ f.write PROJ.gem._spec.to_ruby
166
+ end
167
+ end
168
+
160
169
  desc 'Install the gem'
161
170
  task :install => [:clobber, 'gem:package'] do
162
171
  sh "#{SUDO} #{GEM} install --local pkg/#{PROJ.gem._spec.full_name}"
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bones
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.1.1
4
+ version: 2.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tim Pease
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2008-12-15 00:00:00 -07:00
12
+ date: 2009-01-01 00:00:00 -07:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
@@ -44,7 +44,6 @@ extra_rdoc_files:
44
44
  - lib/bones/tasks/spec.rake
45
45
  - lib/bones/tasks/svn.rake
46
46
  - lib/bones/tasks/test.rake
47
- - spec/data/data/README.txt
48
47
  - spec/data/foo/README.txt
49
48
  files:
50
49
  - History.txt
@@ -52,19 +51,27 @@ files:
52
51
  - README.rdoc
53
52
  - Rakefile
54
53
  - bin/bones
55
- - data/History.txt.erb
54
+ - bones.gemspec
55
+ - data/History.txt.bns
56
56
  - data/Manifest.txt
57
- - data/README.txt.erb
58
- - data/Rakefile.erb
59
- - data/bin/NAME.erb
60
- - data/lib/NAME.rb.erb
61
- - data/spec/NAME_spec.rb.erb
62
- - data/spec/spec_helper.rb.erb
57
+ - data/README.txt.bns
58
+ - data/Rakefile.bns
59
+ - data/bin/NAME.bns
60
+ - data/lib/NAME.rb.bns
61
+ - data/spec/NAME_spec.rb.bns
62
+ - data/spec/spec_helper.rb.bns
63
63
  - data/test/test_NAME.rb
64
64
  - lib/bones.rb
65
65
  - lib/bones/annotation_extractor.rb
66
+ - lib/bones/app.rb
67
+ - lib/bones/app/command.rb
68
+ - lib/bones/app/create_command.rb
69
+ - lib/bones/app/file_manager.rb
70
+ - lib/bones/app/freeze_command.rb
71
+ - lib/bones/app/info_command.rb
72
+ - lib/bones/app/unfreeze_command.rb
73
+ - lib/bones/app/update_command.rb
66
74
  - lib/bones/debug.rb
67
- - lib/bones/main.rb
68
75
  - lib/bones/smtp_tls.rb
69
76
  - lib/bones/tasks/ann.rake
70
77
  - lib/bones/tasks/bones.rake
@@ -79,10 +86,13 @@ files:
79
86
  - lib/bones/tasks/spec.rake
80
87
  - lib/bones/tasks/svn.rake
81
88
  - lib/bones/tasks/test.rake
82
- - spec/bones/main_spec.rb
89
+ - spec/bones/app/file_manager_spec.rb
90
+ - spec/bones/app_spec.rb
83
91
  - spec/bones_spec.rb
84
- - spec/data/data/README.txt
85
- - spec/data/data/Rakefile
92
+ - spec/data/data/NAME/NAME.rb.bns
93
+ - spec/data/data/README.txt.bns
94
+ - spec/data/data/Rakefile.bns
95
+ - spec/data/data/lib/NAME.rb.bns
86
96
  - spec/data/foo/README.txt
87
97
  - spec/data/foo/Rakefile
88
98
  - spec/spec_helper.rb
@@ -1,380 +0,0 @@
1
-
2
- require 'fileutils'
3
- require 'optparse'
4
- require 'erb'
5
-
6
- module Bones
7
- class Main
8
-
9
- attr_reader :options
10
-
11
- # Create a new instance of Main, and run the +bones+ application given
12
- # the command line _args_.
13
- #
14
- def self.run( args )
15
- bones = self.new
16
- bones.parse(args)
17
- bones.run
18
- end
19
-
20
- # Create a new main instance using _io_ for standard output and _err_ for
21
- # error messages.
22
- #
23
- def initialize( io = STDOUT, err = STDERR )
24
- @io = io
25
- @err = err
26
- @options = {
27
- :skeleton_dir => File.join(mrbones_dir, 'data'),
28
- :with_tasks => false,
29
- :verbose => false,
30
- :name => nil,
31
- :output_dir => nil,
32
- :action => nil
33
- }
34
- @options[:skeleton_dir] = ::Bones.path('data') unless test(?d, skeleton_dir)
35
- end
36
-
37
- # The output directory where files will be written.
38
- #
39
- def output_dir
40
- options[:output_dir]
41
- end
42
-
43
- # The directory where the project skeleton is located.
44
- #
45
- def skeleton_dir
46
- options[:skeleton_dir]
47
- end
48
-
49
- # The project name from the command line.
50
- #
51
- def name
52
- options[:name]
53
- end
54
-
55
- # Returns the project name but converted to be usable as a Ruby class
56
- # name.
57
- #
58
- def classname
59
- name.tr('-','_').split('_').map {|x| x.capitalize}.join
60
- end
61
-
62
- # Returns +true+ if we are updating an already existing project. Returns
63
- # +false+ if we are creating a new project.
64
- #
65
- def update?
66
- test(?e, output_dir) and with_tasks?
67
- end
68
-
69
- # Returns +true+ if we are going to copy the Mr Bones tasks into the
70
- # destination directory. Normally this will return +false+.
71
- #
72
- def with_tasks?
73
- options[:with_tasks]
74
- end
75
-
76
- # Returns +true+ if the user has requested verbose messages.
77
- #
78
- def verbose?
79
- options[:verbose]
80
- end
81
-
82
- # Parse the command line arguments and store the values for later use by
83
- # the +create+ and +update+ methods.
84
- #
85
- def parse( args )
86
- opts = OptionParser.new
87
- opts.banner << ' project_name'
88
-
89
- opts.separator ''
90
- opts.on('-v', '--verbose', 'enable verbose output') {
91
- options[:verbose] = true
92
- }
93
- opts.on('-d', '--directory DIRECTORY', String,
94
- 'project directory to create', '(defaults to project_name)') {|dir|
95
- options[:output_dir] = dir
96
- }
97
- opts.on('-s', '--skeleton NAME', String,
98
- 'project skeleton to use') do |skeleton_name|
99
- path = File.join(mrbones_dir, skeleton_name)
100
- if test(?d, path)
101
- options[:skeleton_dir] = path
102
- elsif test(?d, skeleton_name)
103
- options[:skeleton_dir] = skeleton_name
104
- else
105
- @io.puts " unknown skeleton '#{skeleton_name}'"
106
- exit
107
- end
108
- end
109
- opts.on('--with-tasks', 'copy rake tasks to the project folder') {
110
- options[:with_tasks] = true
111
- }
112
-
113
- opts.separator ''
114
- opts.on('--freeze', 'freeze the project skeleton') {
115
- options[:action] = :freeze
116
- }
117
- opts.on('--unfreeze', 'use the standard project skeleton') {
118
- options[:action] = :unfreeze
119
- }
120
- opts.on('-i', '--info', 'report on the project skeleton being used') {
121
- options[:action] = :info
122
- }
123
-
124
- opts.separator ''
125
- opts.separator 'common options:'
126
- opts.on_tail( '-h', '--help', 'show this message' ) {
127
- @io.puts opts
128
- exit
129
- }
130
- opts.on_tail( '--version', 'show version' ) {
131
- @io.puts "Mr Bones #{::Bones::VERSION}"
132
- exit
133
- }
134
-
135
- # parse the command line arguments
136
- opts.parse! args
137
- options[:name] = args.empty? ? nil : args.join('_')
138
-
139
- if options[:action].nil? and name.nil?
140
- @io.puts opts
141
- ::Kernel.abort
142
- end
143
-
144
- options[:output_dir] = name if output_dir.nil?
145
- nil
146
- end
147
-
148
- # Run the main application.
149
- #
150
- def run
151
- case options[:action]
152
- when :freeze
153
- freeze
154
- when :unfreeze
155
- unfreeze
156
- when :info
157
- @io.puts "the project skeleton will be copied from"
158
- @io.write " "
159
- @io.puts skeleton_dir
160
- else
161
- if update? then update
162
- else create end
163
- end
164
- end
165
-
166
- # Create a new project from the bones/data project template.
167
- #
168
- def create
169
- # see if the directory already exists
170
- abort "'#{output_dir}' already exists" if test ?e, output_dir
171
-
172
- begin
173
- files_to_copy.each {|fn| cp fn}
174
- copy_tasks(File.join(output_dir, 'tasks')) if with_tasks?
175
-
176
- pwd = File.expand_path(FileUtils.pwd)
177
- msg = "created '#{name}'"
178
- msg << " in directory '#{output_dir}'" if name != output_dir
179
- @io.puts msg
180
-
181
- if test(?f, File.join(output_dir, 'Rakefile'))
182
- begin
183
- FileUtils.cd output_dir
184
- system "rake manifest:create 2>&1 > #{::Bones::DEV_NULL}"
185
- @io.puts "now you need to fix these files"
186
- system "rake notes"
187
- ensure
188
- FileUtils.cd pwd
189
- end
190
- end
191
- rescue Exception => err
192
- FileUtils.rm_rf output_dir
193
- msg = "could not create '#{name}'"
194
- msg << " in directory '#{output_dir}'" if name != output_dir
195
- abort msg
196
- end
197
- end
198
-
199
- # Archive any existing tasks in the project's tasks folder, and then
200
- # copy in new tasks from the bones/data directory.
201
- #
202
- def update
203
- abort "'#{output_dir}' does not exist" unless test ?e, output_dir
204
-
205
- task_dir = File.join(output_dir, 'tasks')
206
- FileUtils.mkdir_p(task_dir) unless test(?d, task_dir)
207
-
208
- archive_dir = File.join(task_dir, 'archive')
209
- FileUtils.rm_rf archive_dir
210
- FileUtils.mkdir archive_dir
211
-
212
- Dir.glob(File.join(task_dir, '*')).each do |fn|
213
- next if fn == archive_dir
214
- FileUtils.cp fn, archive_dir
215
- end
216
-
217
- copy_tasks(task_dir)
218
-
219
- msg = "updated tasks for '#{name}'"
220
- msg << " in directory '#{output_dir}'" if name != output_dir
221
- @io.puts msg
222
- end
223
-
224
- # Freeze the project skeleton to the current Mr Bones gem. If the project
225
- # skeleton has already been frozen, then it will be archived before being
226
- # overwritten by the current Mr Bones skeleton.
227
- #
228
- # If the project skeleton is already frozen, only the tasks from the Mr
229
- # Bones skeleton will be copied to the user's data directory.
230
- #
231
- def freeze
232
- options[:skeleton_dir] = ::Bones.path('data')
233
- options[:name] = 'data' if name.nil?
234
- options[:output_dir] = File.join(mrbones_dir, name)
235
-
236
- archive(output_dir, "#{output_dir}.archive")
237
- FileUtils.mkdir_p(output_dir)
238
-
239
- files_to_copy.each do |file|
240
- src = File.join(skeleton_dir, file)
241
- dst = File.join(output_dir, file)
242
-
243
- @io.puts "freezing #{dst}" if verbose?
244
- FileUtils.mkdir_p(File.dirname(dst))
245
- FileUtils.cp(src, dst)
246
- end
247
-
248
- copy_tasks(File.join(output_dir, 'tasks'), 'freezing') if with_tasks?
249
-
250
- File.open(frozen_version_file, 'w') {|fd| fd.puts ::Bones::VERSION}
251
-
252
- @io.puts "project skeleton has been frozen " <<
253
- "to Mr Bones #{::Bones::VERSION}"
254
- end
255
-
256
- # Unfreeze the project skeleton. The default Mr Bones skeleton will be
257
- # used insetad. This method will archive the current frozen skeleton if
258
- # one exists.
259
- #
260
- def unfreeze
261
- options[:name] = 'data' if name.nil?
262
- options[:output_dir] = File.join(mrbones_dir, name)
263
-
264
- if archive(output_dir, "#{output_dir}.archive")
265
- @io.puts "project skeleton has been unfrozen"
266
- @io.puts "(default Mr Bones #{::Bones::VERSION} skeleton will be used)"
267
- else
268
- @io.puts "project skeleton is not frozen (no action taken)"
269
- end
270
- FileUtils.rm_f frozen_version_file
271
- end
272
-
273
- # Returns a list of the files to copy from the bones/data directory to
274
- # the new project directory
275
- #
276
- def files_to_copy
277
- rgxp = %r/\A#{skeleton_dir}\/?/o
278
- exclude = %r/tmp$|bak$|~$|CVS|\.svn/o
279
-
280
- ary = Dir.glob(File.join(skeleton_dir, '**', '*')).map do |filename|
281
- next if exclude =~ filename
282
- next if test(?d, filename)
283
- filename.sub rgxp, ''
284
- end
285
-
286
- ary.compact!
287
- ary.sort!
288
- ary
289
- end
290
-
291
- # Copy a file from the Bones prototype project location to the user
292
- # specified project location. A message will be displayed to the screen
293
- # indicating that the file is being created.
294
- #
295
- def cp( file )
296
- dir = File.dirname(file).sub('NAME', name)
297
- dir = (dir == '.' ? output_dir : File.join(output_dir, dir))
298
- dst = File.join(dir, File.basename(file, '.erb').sub('NAME', name))
299
- src = File.join(skeleton_dir, file)
300
-
301
- @io.puts(test(?e, dst) ? "updating #{dst}" : "creating #{dst}") if verbose?
302
- FileUtils.mkdir_p(dir)
303
-
304
- if '.erb' == File.extname(file)
305
- txt = ERB.new(File.read(src), nil, '-').result(binding)
306
- File.open(dst, 'w') {|fd| fd.write(txt)}
307
- else
308
- FileUtils.cp src, dst
309
- end
310
-
311
- FileUtils.chmod(File.stat(src).mode, dst)
312
- end
313
-
314
- # Archive the contents of the _from_ directory into the _to_ directory.
315
- # The _to_ directory will be deleted if it currently exists. After the
316
- # copy the _from_ directory will be deleted.
317
- #
318
- # Returns +true+ if the directory was archived. Returns +false+ if the
319
- # directory was not archived.
320
- #
321
- def archive( from, to )
322
- if test(?d, from)
323
- @io.puts "archiving #{from}" if verbose?
324
- FileUtils.rm_rf(to)
325
- FileUtils.mkdir(to)
326
- FileUtils.cp_r(File.join(from, '.'), to)
327
- FileUtils.rm_rf(from)
328
- true
329
- else
330
- false
331
- end
332
- end
333
-
334
- # Copy the Mr Bones tasks into the _to_ directory. If we are in verbose
335
- # mode, then a message will be displayed to the user. This message can be
336
- # passed in as the _msg_ argument. The current file being copied is
337
- # appened to the end of the message.
338
- #
339
- def copy_tasks( to, msg = nil )
340
- Dir.glob(::Bones.path(%w[lib bones tasks *])).sort.each do |src|
341
- dst = File.join(to, File.basename(src))
342
-
343
- if msg
344
- @io.puts "#{msg} #{dst}" if verbose?
345
- else
346
- @io.puts(test(?e, dst) ? "updating #{dst}" : "creating #{dst}") if verbose?
347
- end
348
-
349
- FileUtils.mkdir_p(File.dirname(dst))
350
- FileUtils.cp(src, dst)
351
- end
352
- end
353
-
354
- # Prints an abort _msg_ to the screen and then exits the Ruby interpreter.
355
- #
356
- def abort( msg )
357
- @err.puts msg
358
- exit 1
359
- end
360
-
361
- # Returns the .bones resource directory in the user's home directory.
362
- #
363
- def mrbones_dir
364
- return @mrbones_dir if defined? @mrbones_dir
365
-
366
- path = (::Bones::WIN32 ? ENV['HOMEPATH'].tr("\\", "/") : ENV['HOME'])
367
- path = File.join(path, '.mrbones')
368
- @mrbones_dir = File.expand_path(path)
369
- end
370
-
371
- # File containing the Mr Bones version from which the skeleton was frozen.
372
- #
373
- def frozen_version_file
374
- File.join(mrbones_dir, 'version.txt')
375
- end
376
-
377
- end # class Main
378
- end # module Bones
379
-
380
- # EOF