bones 2.1.1 → 2.2.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,3 +1,15 @@
1
+ == 2.2.0 / 2009-01-01
2
+
3
+ * 4 minor enhancements
4
+ - projects can be instantiated from git or svn repositories
5
+ - added a task to generate a project gemspec for use on github [Sandro Turriate]
6
+ - Mr Bones erb translation is now applied to files with a
7
+ '.bns' extension instead of an '.erb' extension
8
+ - refactored the main bones application
9
+ * 1 bugfix
10
+ - Mr Bones tasks are only added to the gemspec when a package
11
+ is being built
12
+
1
13
  == 2.1.1 / 2008-12-15
2
14
 
3
15
  * 1 minor enhancement
@@ -3,19 +3,27 @@ Manifest.txt
3
3
  README.rdoc
4
4
  Rakefile
5
5
  bin/bones
6
- data/History.txt.erb
6
+ bones.gemspec
7
+ data/History.txt.bns
7
8
  data/Manifest.txt
8
- data/README.txt.erb
9
- data/Rakefile.erb
10
- data/bin/NAME.erb
11
- data/lib/NAME.rb.erb
12
- data/spec/NAME_spec.rb.erb
13
- data/spec/spec_helper.rb.erb
9
+ data/README.txt.bns
10
+ data/Rakefile.bns
11
+ data/bin/NAME.bns
12
+ data/lib/NAME.rb.bns
13
+ data/spec/NAME_spec.rb.bns
14
+ data/spec/spec_helper.rb.bns
14
15
  data/test/test_NAME.rb
15
16
  lib/bones.rb
16
17
  lib/bones/annotation_extractor.rb
18
+ lib/bones/app.rb
19
+ lib/bones/app/command.rb
20
+ lib/bones/app/create_command.rb
21
+ lib/bones/app/file_manager.rb
22
+ lib/bones/app/freeze_command.rb
23
+ lib/bones/app/info_command.rb
24
+ lib/bones/app/unfreeze_command.rb
25
+ lib/bones/app/update_command.rb
17
26
  lib/bones/debug.rb
18
- lib/bones/main.rb
19
27
  lib/bones/smtp_tls.rb
20
28
  lib/bones/tasks/ann.rake
21
29
  lib/bones/tasks/bones.rake
@@ -30,10 +38,13 @@ lib/bones/tasks/setup.rb
30
38
  lib/bones/tasks/spec.rake
31
39
  lib/bones/tasks/svn.rake
32
40
  lib/bones/tasks/test.rake
33
- spec/bones/main_spec.rb
41
+ spec/bones/app/file_manager_spec.rb
42
+ spec/bones/app_spec.rb
34
43
  spec/bones_spec.rb
35
- spec/data/data/README.txt
36
- spec/data/data/Rakefile
44
+ spec/data/data/NAME/NAME.rb.bns
45
+ spec/data/data/README.txt.bns
46
+ spec/data/data/Rakefile.bns
47
+ spec/data/data/lib/NAME.rb.bns
37
48
  spec/data/foo/README.txt
38
49
  spec/data/foo/Rakefile
39
50
  spec/spec_helper.rb
@@ -60,6 +60,7 @@ Mr Bones provides the following rake tasks:
60
60
  gem:reinstall # Reinstall the gem
61
61
  gem:release # Package and upload to RubyForge
62
62
  gem:repackage # Force a rebuild of the package files
63
+ gem:spec # Write the gemspec
63
64
  gem:uninstall # Uninstall the gem
64
65
  git:create_tag # Create a new tag in the Git repository
65
66
  git:show_tags # Show tags from the Git repository
@@ -86,7 +87,7 @@ directory. Add your own tasks there when you need more functionality.
86
87
 
87
88
  To create a new "Get Fuzzy" project:
88
89
 
89
- bones get_fuzzy
90
+ bones create get_fuzzy
90
91
 
91
92
  If you ever get confused about what Mr Bones can do:
92
93
 
@@ -182,7 +183,7 @@ copied to the ".mrbones" directory in your home directory. From there, the
182
183
  skeleton can be modified however you like (add new files and tasks, add new
183
184
  directories, etc).
184
185
 
185
- bones --freeze
186
+ bones freeze
186
187
 
187
188
  Typical uses of this feature would be to fill in user specific data like the
188
189
  author, e-mail address, etc. You can also add more default code to the skeleton
@@ -191,11 +192,11 @@ project or your own ".rake" task files.
191
192
  You can have multiple skeletons with different names. Your projects can be
192
193
  instantiated from any of these skeletons. Just supply a name when freezing:
193
194
 
194
- bones --freeze foo
195
+ bones freeze foo
195
196
 
196
197
  You can instantiate a project from the "foo" skeleton:
197
198
 
198
- bones --skeleton foo get_fuzzy
199
+ bones create --skeleton foo get_fuzzy
199
200
 
200
201
  The default skeleton name is "data". If no skeleton name is provided, then this
201
202
  is the skeleton that will be used.
@@ -207,21 +208,44 @@ Unfreezing a skeleton will remove your customized project skeleton from the
207
208
  instead. A copy of your custom skeleton is stored in an archive directory of
208
209
  the ".mrbones" directory before it is removed.
209
210
 
210
- bones --unfreeze
211
+ bones unfreeze
211
212
 
212
213
  You can unfreeze named skeletons, too:
213
214
 
214
- bones --unfreeze foo
215
+ bones unfreeze foo
216
+
217
+ ==== Repository Skeletons
218
+
219
+ You can instantiate a new project from a git or svn repository. For example,
220
+ if you would like to use the "bort" rails template from github, you can type
221
+ in the following:
222
+
223
+ bones create --repository git://github.com/fudgestudios/bort.git foo
224
+
225
+ Typing in the full path to the repository each time is tedious. You can
226
+ create an alias by freezing the repository and giving it an easy to remember
227
+ name.
228
+
229
+ bones freeze --repository git://github.com/fudgestudios/bort.git bort
230
+
231
+ This does not checkout a copy of the repository; it give us an easy to use
232
+ alias when we want to create a new proejct based on the repository. The
233
+ following command will use our new alias to instantiate a new project called
234
+ "foo":
235
+
236
+ bones create --skeleton bort foo
237
+
238
+ If the repository contains '.bns' files they will be filtered through the
239
+ ERb templating system. All the custom modifications described in the next
240
+ section apply to repository based skeletons as well.
215
241
 
216
242
  ==== Custom Modifications
217
243
 
218
244
  Mr Bones will perform a limited set of substitutions on the files in the
219
245
  skeleton when it generates a new project. ERB is used to insert the project
220
246
  name and the derived class name into template files. The file must end in an
221
- ".erb" suffix for ERB substitutions to take place. The ".erb" suffix is
222
- stripped from the file during project generation. Therefore, your ERB files
223
- should have two suffixes -- the ".erb" suffix that will be stripped, and the
224
- suffix you want the resulting project file to have.
247
+ ".bns" suffix for ERB substitutions to take place. The ".bns" suffix is
248
+ stripped from the file during project generation.
225
249
 
226
250
  Only two values can be substituted into files using ERB -- the project name and
227
251
  the derived class name.
data/Rakefile CHANGED
@@ -9,7 +9,7 @@ PROJ.authors = 'Tim Pease'
9
9
  PROJ.email = 'tim.pease@gmail.com'
10
10
  PROJ.url = 'http://codeforpeople.rubyforge.org/bones'
11
11
  PROJ.version = Bones::VERSION
12
- PROJ.release_name = 'Proximal Phalanges'
12
+ PROJ.release_name = 'Distal Phalanges'
13
13
  PROJ.ruby_opts = %w[-W0]
14
14
  PROJ.readme_file = 'README.rdoc'
15
15
 
@@ -35,7 +35,7 @@ PROJ.ann.paragraphs = %w[install synopsis features requirements]
35
35
  PROJ.ann.text = <<-ANN
36
36
  == FUN FACT
37
37
 
38
- A typical adult human skeleton commonly consists of 206, 208 or more bones depending on the method used in counting.
38
+ "Tom Sawyer" was the first novel written on a typewriter.
39
39
 
40
40
  == POST SCRIPT
41
41
 
data/bin/bones CHANGED
@@ -2,6 +2,6 @@
2
2
 
3
3
  require File.expand_path(
4
4
  File.join(File.dirname(__FILE__), '..', 'lib', 'bones'))
5
- Bones::Main.run ARGV
5
+ Bones::App.run ARGV
6
6
 
7
7
  # EOF
@@ -0,0 +1,40 @@
1
+ # -*- encoding: utf-8 -*-
2
+
3
+ Gem::Specification.new do |s|
4
+ s.name = %q{bones}
5
+ s.version = "2.2.0"
6
+
7
+ s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
8
+ s.authors = ["Tim Pease"]
9
+ s.date = %q{2009-01-01}
10
+ s.default_executable = %q{bones}
11
+ s.description = %q{Mr Bones is a handy tool that builds a skeleton for your new Ruby projects. The skeleton contains some starter code and a collection of rake tasks to ease the management and deployment of your source code. Mr Bones is not viral -- all the code your project needs is included in the skeleton (no gem dependency required).}
12
+ s.email = %q{tim.pease@gmail.com}
13
+ s.executables = ["bones"]
14
+ s.extra_rdoc_files = ["History.txt", "README.rdoc", "bin/bones", "lib/bones/tasks/ann.rake", "lib/bones/tasks/bones.rake", "lib/bones/tasks/gem.rake", "lib/bones/tasks/git.rake", "lib/bones/tasks/manifest.rake", "lib/bones/tasks/notes.rake", "lib/bones/tasks/post_load.rake", "lib/bones/tasks/rdoc.rake", "lib/bones/tasks/rubyforge.rake", "lib/bones/tasks/spec.rake", "lib/bones/tasks/svn.rake", "lib/bones/tasks/test.rake", "spec/data/data/README.txt", "spec/data/foo/README.txt"]
15
+ s.files = ["History.txt", "Manifest.txt", "README.rdoc", "Rakefile", "bin/bones", "data/History.txt.bns", "data/Manifest.txt", "data/README.txt.bns", "data/Rakefile.bns", "data/bin/NAME.bns", "data/lib/NAME.rb.bns", "data/spec/NAME_spec.rb.bns", "data/spec/spec_helper.rb.bns", "data/test/test_NAME.rb", "lib/bones.rb", "lib/bones/annotation_extractor.rb", "lib/bones/debug.rb", "lib/bones/main.rb", "lib/bones/smtp_tls.rb", "lib/bones/tasks/ann.rake", "lib/bones/tasks/bones.rake", "lib/bones/tasks/gem.rake", "lib/bones/tasks/git.rake", "lib/bones/tasks/manifest.rake", "lib/bones/tasks/notes.rake", "lib/bones/tasks/post_load.rake", "lib/bones/tasks/rdoc.rake", "lib/bones/tasks/rubyforge.rake", "lib/bones/tasks/setup.rb", "lib/bones/tasks/spec.rake", "lib/bones/tasks/svn.rake", "lib/bones/tasks/test.rake", "spec/bones/main_spec.rb", "spec/bones_spec.rb", "spec/data/data/README.txt", "spec/data/data/Rakefile", "spec/data/foo/README.txt", "spec/data/foo/Rakefile", "spec/spec_helper.rb"]
16
+ s.has_rdoc = true
17
+ s.homepage = %q{http://codeforpeople.rubyforge.org/bones}
18
+ s.post_install_message = %q{--------------------------
19
+ Keep rattlin' dem bones!
20
+ --------------------------
21
+ }
22
+ s.rdoc_options = ["--main", "README.rdoc"]
23
+ s.require_paths = ["lib"]
24
+ s.rubyforge_project = %q{codeforpeople}
25
+ s.rubygems_version = %q{1.3.1}
26
+ s.summary = %q{Mr Bones is a handy tool that builds a skeleton for your new Ruby projects}
27
+
28
+ if s.respond_to? :specification_version then
29
+ current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
30
+ s.specification_version = 2
31
+
32
+ if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
33
+ s.add_runtime_dependency(%q<rake>, [">= 0.8.3"])
34
+ else
35
+ s.add_dependency(%q<rake>, [">= 0.8.3"])
36
+ end
37
+ else
38
+ s.add_dependency(%q<rake>, [">= 0.8.3"])
39
+ end
40
+ end
File without changes
@@ -6,7 +6,11 @@ begin
6
6
  require 'bones'
7
7
  Bones.setup
8
8
  rescue LoadError
9
- load 'tasks/setup.rb'
9
+ begin
10
+ load 'tasks/setup.rb'
11
+ rescue LoadError
12
+ raise RuntimeError, '### please install the "bones" gem ###'
13
+ end
10
14
  end
11
15
 
12
16
  ensure_in_path 'lib'
File without changes
@@ -0,0 +1,49 @@
1
+
2
+ module <%= classname %>
3
+
4
+ # :stopdoc:
5
+ VERSION = '1.0.0'
6
+ LIBPATH = ::File.expand_path(::File.dirname(__FILE__)) + ::File::SEPARATOR
7
+ PATH = ::File.dirname(LIBPATH) + ::File::SEPARATOR
8
+ # :startdoc:
9
+
10
+ # Returns the version string for the library.
11
+ #
12
+ def self.version
13
+ VERSION
14
+ end
15
+
16
+ # Returns the library path for the module. If any arguments are given,
17
+ # they will be joined to the end of the libray path using
18
+ # <tt>File.join</tt>.
19
+ #
20
+ def self.libpath( *args )
21
+ args.empty? ? LIBPATH : ::File.join(LIBPATH, args.flatten)
22
+ end
23
+
24
+ # Returns the lpath for the module. If any arguments are given,
25
+ # they will be joined to the end of the path using
26
+ # <tt>File.join</tt>.
27
+ #
28
+ def self.path( *args )
29
+ args.empty? ? PATH : ::File.join(PATH, args.flatten)
30
+ end
31
+
32
+ # Utility method used to rquire all files ending in .rb that lie in the
33
+ # directory below this file that has the same name as the filename passed
34
+ # in. Optionally, a specific _directory_ name can be passed in such that
35
+ # the _filename_ does not have to be equivalent to the directory.
36
+ #
37
+ def self.require_all_libs_relative_to( fname, dir = nil )
38
+ dir ||= ::File.basename(fname, '.*')
39
+ search_me = ::File.expand_path(
40
+ ::File.join(::File.dirname(fname), dir, '**', '*.rb'))
41
+
42
+ Dir.glob(search_me).sort.each {|rb| require rb}
43
+ end
44
+
45
+ end # module <%= classname %>
46
+
47
+ <%= classname %>.require_all_libs_relative_to(__FILE__)
48
+
49
+ # EOF
@@ -2,7 +2,7 @@
2
2
  module Bones
3
3
 
4
4
  # :stopdoc:
5
- VERSION = '2.1.1'
5
+ VERSION = '2.2.0'
6
6
  PATH = File.expand_path(File.join(File.dirname(__FILE__), '..'))
7
7
  WIN32 = %r/win32/ =~ RUBY_PLATFORM
8
8
  DEV_NULL = WIN32 ? 'NUL:' : '/dev/null'
@@ -32,6 +32,8 @@ module Bones
32
32
  Dir.glob(search_me).sort.each {|rb| require rb}
33
33
  end
34
34
 
35
+ # call-seq:
36
+ # Bones.setup
35
37
  #
36
38
  #
37
39
  def self.setup
@@ -0,0 +1,92 @@
1
+
2
+ require 'fileutils'
3
+ require 'optparse'
4
+ require 'erb'
5
+
6
+ module Bones
7
+ class App
8
+
9
+ # Create a new instance of App, and run the +bones+ application given
10
+ # the command line _args_.
11
+ #
12
+ def self.run( args )
13
+ self.new.run args
14
+ end
15
+
16
+ # Create a new main instance using _io_ for standard output and _err_ for
17
+ # error messages.
18
+ #
19
+ def initialize( out = STDOUT, err = STDERR )
20
+ @out = out
21
+ @err = err
22
+ end
23
+
24
+ # Parse the desired user command and run that command object.
25
+ #
26
+ def run( args )
27
+ cmd_str = args.shift
28
+ cmd = case cmd_str
29
+ when 'create'; CreateCommand.new(@out, @err)
30
+ when 'update'; UpdateCommand.new(@out, @err)
31
+ when 'freeze'; FreezeCommand.new(@out, @err)
32
+ when 'unfreeze'; UnfreezeCommand.new(@out, @err)
33
+ when 'info'; InfoCommand.new(@out, @err)
34
+ when nil, '-h', '--help'
35
+ help
36
+ when '-v', '--version'
37
+ @out.puts "Mr Bones #{::Bones::VERSION}"
38
+ nil
39
+ else
40
+ raise "Unknown command #{cmd_str.inspect}"
41
+ end
42
+
43
+ cmd.run args if cmd
44
+
45
+ rescue StandardError => err
46
+ @err.puts "ERROR: While executing bones ... (#{err.class})"
47
+ @err.puts " #{err.to_s}"
48
+ exit 1
49
+ end
50
+
51
+ # Show the toplevel Mr Bones help message.
52
+ #
53
+ def help
54
+ @out.puts <<-MSG
55
+
56
+ Mr Bones is a handy tool that builds a skeleton for your new Ruby
57
+ projects. The skeleton contains some starter code and a collection of
58
+ rake tasks to ease the management and deployment of your source code.
59
+
60
+ Usage:
61
+ bones -h/--help
62
+ bones -v/--version
63
+ bones command [options] [arguments]
64
+
65
+ Examples:
66
+ bones create new_project
67
+ bones freeze -r git://github.com/fudgestudios/bort.git bort
68
+ bones create -s bort new_rails_project
69
+
70
+ Commands:
71
+ bones create create a new project from a skeleton
72
+ bones update copy Mr Bones tasks to a project
73
+ bones freeze create a new skeleton in ~/.mrbones/
74
+ bones unfreeze remove a skeleton from ~/.mrbones/
75
+ bones info show information about available skeletons
76
+
77
+ Further Help:
78
+ Each command has a '--help' option that will provide detailed
79
+ information for that command.
80
+
81
+ http://codeforpeople.rubyforge.org/bones/
82
+
83
+ MSG
84
+ nil
85
+ end
86
+
87
+ end # class App
88
+ end # module Bones
89
+
90
+ Bones.require_all_libs_relative_to(__FILE__)
91
+
92
+ # EOF
@@ -0,0 +1,130 @@
1
+
2
+ module Bones
3
+ class App
4
+
5
+ class Command
6
+
7
+ attr_reader :options
8
+
9
+ def initialize( out = STDOUT, err = STDERR )
10
+ @out = out
11
+ @err = err
12
+ @options = {
13
+ :skeleton_dir => File.join(mrbones_dir, 'data'),
14
+ :with_tasks => false,
15
+ :verbose => false,
16
+ :name => nil,
17
+ :output_dir => nil
18
+ }
19
+ @options[:skeleton_dir] = ::Bones.path('data') unless test(?d, skeleton_dir)
20
+ end
21
+
22
+ def run( args )
23
+ raise NotImplementedError
24
+ end
25
+
26
+ # The output directory where files will be written.
27
+ #
28
+ def output_dir
29
+ options[:output_dir]
30
+ end
31
+
32
+ # The directory where the project skeleton is located.
33
+ #
34
+ def skeleton_dir
35
+ options[:skeleton_dir]
36
+ end
37
+
38
+ # The project name from the command line.
39
+ #
40
+ def name
41
+ options[:name]
42
+ end
43
+
44
+ # A git or svn repository URL from the command line.
45
+ #
46
+ def repository
47
+ return options[:repository] if options.has_key? :repository
48
+ return IO.read(skeleton_dir).strip if skeleton_dir and test(?f, skeleton_dir)
49
+ nil
50
+ end
51
+
52
+ # Returns +true+ if we are going to copy the Mr Bones tasks into the
53
+ # destination directory. Normally this will return +false+.
54
+ #
55
+ def with_tasks?
56
+ options[:with_tasks]
57
+ end
58
+
59
+ #
60
+ #
61
+ def copy_tasks( to )
62
+ fm = FileManager.new(
63
+ :source => ::Bones.path(%w[lib bones tasks]),
64
+ :destination => to,
65
+ :stdout => @out,
66
+ :stderr => @err,
67
+ :verbose => verbose?
68
+ )
69
+ fm.archive_destination
70
+ fm.copy
71
+ end
72
+
73
+ # Returns +true+ if the user has requested verbose messages.
74
+ #
75
+ def verbose?
76
+ options[:verbose]
77
+ end
78
+
79
+ # Returns the .bones resource directory in the user's home directory.
80
+ #
81
+ def mrbones_dir
82
+ return @mrbones_dir if defined? @mrbones_dir
83
+
84
+ path = (::Bones::WIN32 ? ENV['HOMEPATH'].tr("\\", "/") : ENV['HOME'])
85
+ path = File.join(path, '.mrbones')
86
+ @mrbones_dir = File.expand_path(path)
87
+ end
88
+
89
+ #
90
+ #
91
+ def standard_options
92
+ {
93
+ :verbose => ['-v', '--verbose', 'enable verbose output',
94
+ lambda {
95
+ options[:verbose] = true
96
+ }],
97
+ :directory => ['-d', '--directory DIRECTORY', String,
98
+ 'project directory to create', '(defaults to project_name)',
99
+ lambda { |value|
100
+ options[:output_dir] = value
101
+ }],
102
+ :skeleton => ['-s', '--skeleton NAME', String,
103
+ 'project skeleton to use',
104
+ lambda { |value|
105
+ path = File.join(mrbones_dir, value)
106
+ if test(?e, path)
107
+ options[:skeleton_dir] = path
108
+ elsif test(?e, value)
109
+ options[:skeleton_dir] = value
110
+ else
111
+ raise ArgumentError, "Unknown skeleton '#{value}'"
112
+ end
113
+ }],
114
+ :with_tasks => ['--with-tasks', 'copy rake tasks to the project folder',
115
+ lambda {
116
+ options[:with_tasks] = true
117
+ }],
118
+ :repository => ['-r', '--repository URL', String,
119
+ 'svn or git repository path',
120
+ lambda { |value|
121
+ options[:repository] = value
122
+ }]
123
+ }
124
+ end
125
+
126
+ end # class Command
127
+ end # class App
128
+ end # module Bones
129
+
130
+ # EOF