bones 2.5.1 → 3.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.
Files changed (75) hide show
  1. data/History.txt +2 -0
  2. data/README.rdoc +54 -306
  3. data/Rakefile +28 -37
  4. data/bin/bones +10 -3
  5. data/{spec/data/data → default}/.bnsignore +3 -1
  6. data/{data → default}/History.txt.bns +0 -0
  7. data/{data → default}/README.txt.bns +0 -0
  8. data/default/Rakefile.bns +21 -0
  9. data/{data → default}/bin/NAME.bns +0 -0
  10. data/{data → default}/lib/NAME.rb.bns +0 -0
  11. data/{data → default}/spec/NAME_spec.rb.bns +0 -0
  12. data/{data → default}/spec/spec_helper.rb.bns +0 -0
  13. data/{data → default}/test/test_NAME.rb +0 -0
  14. data/lib/bones.rb +73 -31
  15. data/lib/bones/annotation_extractor.rb +16 -26
  16. data/lib/bones/app.rb +87 -58
  17. data/lib/bones/app/command.rb +143 -64
  18. data/lib/bones/app/create.rb +93 -0
  19. data/lib/bones/app/file_manager.rb +7 -8
  20. data/lib/bones/app/freeze.rb +59 -0
  21. data/lib/bones/app/info.rb +39 -0
  22. data/lib/bones/app/unfreeze.rb +44 -0
  23. data/lib/bones/colors.rb +54 -0
  24. data/lib/bones/gem_package_task.rb +71 -0
  25. data/lib/bones/helpers.rb +93 -0
  26. data/lib/bones/plugins/ann.rb +166 -0
  27. data/lib/bones/plugins/bones_plugin.rb +193 -0
  28. data/lib/bones/plugins/gem.rb +274 -0
  29. data/lib/bones/plugins/notes.rb +45 -0
  30. data/lib/bones/plugins/rdoc.rb +93 -0
  31. data/lib/bones/plugins/test.rb +57 -0
  32. data/lib/bones/smtp_tls.rb +1 -0
  33. data/spec/bones/app/file_manager_spec.rb +6 -6
  34. data/spec/bones/app_spec.rb +14 -18
  35. data/spec/bones_spec.rb +9 -4
  36. data/{data → spec/data/default}/.bnsignore +0 -0
  37. data/spec/data/{data → default}/History +0 -0
  38. data/spec/data/{data → default}/NAME/NAME.rb.bns +0 -0
  39. data/spec/data/{data → default}/README.txt.bns +0 -0
  40. data/{data → spec/data/default}/Rakefile.bns +0 -0
  41. data/spec/data/{data → default}/lib/NAME.rb.bns +0 -0
  42. metadata +94 -68
  43. data/lib/bones/app/create_command.rb +0 -86
  44. data/lib/bones/app/freeze_command.rb +0 -73
  45. data/lib/bones/app/info_command.rb +0 -58
  46. data/lib/bones/app/unfreeze_command.rb +0 -53
  47. data/lib/bones/app/update_command.rb +0 -47
  48. data/lib/bones/debug.rb +0 -72
  49. data/lib/bones/tasks/ann.rake +0 -80
  50. data/lib/bones/tasks/bones.rake +0 -20
  51. data/lib/bones/tasks/gem.rake +0 -201
  52. data/lib/bones/tasks/git.rake +0 -40
  53. data/lib/bones/tasks/notes.rake +0 -27
  54. data/lib/bones/tasks/post_load.rake +0 -34
  55. data/lib/bones/tasks/rdoc.rake +0 -51
  56. data/lib/bones/tasks/rubyforge.rake +0 -55
  57. data/lib/bones/tasks/setup.rb +0 -292
  58. data/lib/bones/tasks/spec.rake +0 -54
  59. data/lib/bones/tasks/svn.rake +0 -47
  60. data/lib/bones/tasks/test.rake +0 -40
  61. data/lib/bones/tasks/zentest.rake +0 -36
  62. data/spec/data/data/Rakefile.bns +0 -30
  63. data/tasks/ann.rake +0 -80
  64. data/tasks/bones.rake +0 -20
  65. data/tasks/gem.rake +0 -201
  66. data/tasks/git.rake +0 -40
  67. data/tasks/notes.rake +0 -27
  68. data/tasks/post_load.rake +0 -34
  69. data/tasks/rdoc.rake +0 -51
  70. data/tasks/rubyforge.rake +0 -55
  71. data/tasks/setup.rb +0 -292
  72. data/tasks/spec.rake +0 -54
  73. data/tasks/svn.rake +0 -47
  74. data/tasks/test.rake +0 -40
  75. data/tasks/zentest.rake +0 -36
data/bin/bones CHANGED
@@ -1,7 +1,14 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
- require File.expand_path(
4
- File.join(File.dirname(__FILE__), '..', 'lib', 'bones'))
5
- Bones::App.run ARGV
3
+ root = File.expand_path(File.join(File.dirname(__FILE__), '..'))
4
+
5
+ begin
6
+ require File.join(root, %w[lib bones])
7
+ rescue LoadError
8
+ require 'bones'
9
+ end
10
+
11
+ Bones::App.initialize_plugins
12
+ Bones::App.run
6
13
 
7
14
  # EOF
@@ -4,7 +4,9 @@
4
4
  # A .gitignore file can be used instead by setting it as the ignore
5
5
  # file in your Rakefile:
6
6
  #
7
- # PROJ.ignore_file = '.gitignore'
7
+ # Bones {
8
+ # ignore_file '.gitignore'
9
+ # }
8
10
  #
9
11
  # For a project with a C extension, the following would be a good set of
10
12
  # exclude patterns (uncomment them if you want to use them):
File without changes
File without changes
@@ -0,0 +1,21 @@
1
+
2
+ begin
3
+ require 'bones'
4
+ rescue LoadError
5
+ abort '### Please install the "bones" gem ###'
6
+ end
7
+
8
+ ensure_in_path 'lib'
9
+ require '<%= name %>'
10
+
11
+ task :default => 'test:run'
12
+
13
+ Bones {
14
+ name '<%= name %>'
15
+ authors 'FIXME (who is writing this software)'
16
+ email 'FIXME (your e-mail)'
17
+ url 'FIXME (project homepage)'
18
+ version <%= classname %>::VERSION
19
+ }
20
+
21
+ # EOF
File without changes
File without changes
File without changes
File without changes
File without changes
data/lib/bones.rb CHANGED
@@ -1,68 +1,110 @@
1
1
 
2
+ require 'rubygems'
3
+ require 'rake'
4
+ require 'rake/clean'
5
+ require 'fileutils'
6
+ require 'find'
2
7
  require 'rbconfig'
8
+ require 'little-plugger'
9
+ require 'loquacious'
10
+ require 'git'
3
11
 
4
12
  module Bones
13
+ extend LittlePlugger
5
14
 
6
15
  # :stopdoc:
7
- VERSION = '2.5.1'
16
+ VERSION = '3.0.0'
8
17
  PATH = File.expand_path(File.join(File.dirname(__FILE__), '..'))
18
+ LIBPATH = File.expand_path(File.join(PATH, 'lib'))
9
19
  HOME = File.expand_path(ENV['HOME'] || ENV['USERPROFILE'])
10
- DEV_NULL = File.exist?('/dev/null') ? '/dev/null' : 'NUL:'
11
20
 
12
21
  # Ruby Interpreter location - taken from Rake source code
13
22
  RUBY = File.join(Config::CONFIG['bindir'],
14
23
  Config::CONFIG['ruby_install_name']).sub(/.*\s.*/m, '"\&"')
24
+
25
+ module Plugins; end
15
26
  # :startdoc:
16
27
 
17
28
  # Returns the path for Mr Bones. If any arguments are given,
18
- # they will be joined to the end of the path using
19
- # <tt>File.join</tt>.
29
+ # they will be joined to the end of the path using <tt>File.join</tt>.
20
30
  #
21
31
  def self.path( *args )
22
32
  args.empty? ? PATH : File.join(PATH, args.flatten)
23
33
  end
24
34
 
35
+ # Returns the lib path for Mr Bones. If any arguments are given,
36
+ # they will be joined to the end of the path using <tt>File.join</tt>.
37
+ #
38
+ def self.libpath( *args )
39
+ args.empty? ? LIBPATH : File.join(LIBPATH, args.flatten)
40
+ end
41
+
25
42
  # call-seq:
26
- # Bones.require_all_libs_relative_to( filename, directory = nil )
43
+ # Bones.config
44
+ # Bones.config { block }
27
45
  #
28
- # Utility method used to rquire all files ending in .rb that lie in the
29
- # directory below this file that has the same name as the filename passed
30
- # in. Optionally, a specific _directory_ name can be passed in such that
31
- # the _filename_ does not have to be equivalent to the directory.
46
+ # Returns the configuration object for setting up Mr Bones options.
32
47
  #
33
- def self.require_all_libs_relative_to( fname, dir = nil )
34
- dir ||= File.basename(fname, '.*')
35
- search_me = File.expand_path(
36
- File.join(File.dirname(fname), dir, '*.rb'))
48
+ def self.config( &block )
49
+ Loquacious.configuration_for('Bones', &block)
50
+ end
37
51
 
38
- Dir.glob(search_me).sort.each {|rb| require rb}
52
+ # call-seq:
53
+ # Bones.help
54
+ #
55
+ # Returns a help object that can be used to show the current Mr Bones
56
+ # configuration and descriptions for the various configuration attributes.
57
+ #
58
+ def self.help
59
+ Loquacious.help_for('Bones', :colorize => config.colorize, :nesting_nodes => false)
39
60
  end
61
+ end # module Bones
62
+
63
+ begin
64
+ $LOAD_PATH.unshift Bones.libpath
65
+ %w[colors helpers gem_package_task annotation_extractor smtp_tls app app/command app/file_manager].
66
+ each { |fn| require File.join('bones', fn) }
40
67
 
68
+ Bones.config {}
69
+ Loquacious.remove :gem, :file, :test
70
+ ensure
71
+ $LOAD_PATH.shift
72
+ end
73
+
74
+ module Kernel
41
75
  # call-seq:
42
- # Bones.setup
76
+ # Bones { block }
43
77
  #
78
+ # Configure Mr Bones using the given _block_ of code. If a block is not
79
+ # given, the Bones module is returned.
44
80
  #
45
- def self.setup
46
- local_setup = File.join(Dir.pwd, %w[tasks setup.rb])
81
+ def Bones( &block )
47
82
 
48
- if test(?e, local_setup)
49
- load local_setup
50
- return
51
- end
83
+ # we absolutely have to have the bones plugin
84
+ plugin_names = ::Bones.plugin_names
85
+ ::Bones.plugin :bones_plugin unless plugin_names.empty? or plugin_names.include? :bones_plugin
52
86
 
53
- bones_setup = ::Bones.path %w[lib bones tasks setup.rb]
54
- load bones_setup
87
+ plugins = ::Bones.initialize_plugins.values
88
+ return ::Bones unless block
55
89
 
56
- rakefiles = Dir.glob(File.join(Dir.pwd, %w[tasks *.rake])).sort
57
- rakefiles.each {|fn| Rake.application.add_import(fn)}
58
- end
90
+ config = ::Bones.config
91
+ extend_method = Object.new.method(:extend).unbind.bind(config)
92
+ instance_eval_method = Object.new.method(:instance_eval).unbind.bind(config)
59
93
 
60
- # TODO: fix file lists for Test::Unit and RSpec
61
- # these guys are just grabbing whatever is there and not pulling
62
- # the filenames from the manifest
94
+ plugins.each { |plugin|
95
+ ps = plugin.const_get :Syntax rescue next
96
+ extend_method.call ps
97
+ }
98
+ instance_eval_method.call(&block)
63
99
 
64
- end # module Bones
100
+ # config.exclude << "^#{Regexp.escape(config.rcov.dir)}/"
65
101
 
66
- Bones.require_all_libs_relative_to(__FILE__)
102
+ plugins.each { |plugin| plugin.post_load if plugin.respond_to? :post_load }
103
+ plugins.each { |plugin| plugin.define_tasks if plugin.respond_to? :define_tasks }
104
+
105
+ rakefiles = Dir.glob(File.join(Dir.pwd, %w[tasks *.rake])).sort
106
+ rakefiles.each {|fn| Rake.application.add_import(fn)}
107
+ end
108
+ end
67
109
 
68
110
  # EOF
@@ -1,19 +1,10 @@
1
1
 
2
- begin
3
- require 'facets/ansicode'
4
- HAVE_COLOR = true
5
- rescue LoadError
6
- HAVE_COLOR = false
7
- end
8
-
9
- module Bones
10
-
11
2
  # A helper class used to find and display any annotations in a collection of
12
3
  # project files.
13
4
  #
14
- class AnnotationExtractor
5
+ class Bones::AnnotationExtractor
15
6
 
16
- class Annotation < Struct.new(:line, :tag, :text)
7
+ Annotation = Struct.new(:line, :tag, :text) {
17
8
  # Returns a string representation of the annotation. If the
18
9
  # <tt>:tag</tt> parameter is given as +true+, then the annotation tag
19
10
  # will be included in the string.
@@ -23,25 +14,25 @@ class AnnotationExtractor
23
14
  s << "[#{tag}] " if opts[:tag]
24
15
  s << text
25
16
  end
26
- end
17
+ }
27
18
 
28
- # Enumerate all the annoations for the given _project_ and _tag_. This
19
+ # Enumerate all the annoations for the given _config_ and _tag_. This
29
20
  # will search for all athe annotations and display them on standard
30
21
  # output.
31
22
  #
32
- def self.enumerate( project, tag, id = nil, opts = {} )
33
- extractor = new(project, tag, id)
23
+ def self.enumerate( config, tag, id = nil, opts = {} )
24
+ extractor = new(config, tag, id)
34
25
  extractor.display(extractor.find, opts)
35
26
  end
36
27
 
37
- attr_reader :tag, :project, :id
28
+ attr_reader :tag, :config, :id
38
29
 
39
- # Creates a new annotation extractor configured to use the _project_ open
30
+ # Creates a new annotation extractor configured to use the _config_ open
40
31
  # strcut and to search for the given _tag_ (which can be more than one tag
41
32
  # via a regular expression 'or' operation -- i.e. THIS|THAT|OTHER)
42
33
  #
43
- def initialize( project, tag, id)
44
- @project = project
34
+ def initialize( config, tag, id)
35
+ @config = config
45
36
  @tag = tag
46
37
  @id = @id_rgxp = nil
47
38
 
@@ -58,11 +49,11 @@ class AnnotationExtractor
58
49
  results = {}
59
50
  rgxp = %r/(#{tag}):?\s*(.*?)(?:\s*(?:-?%>|\*+\/))?$/o
60
51
 
61
- extensions = project.notes.extensions.dup
62
- exclude = if project.notes.exclude.empty? then nil
63
- else Regexp.new(project.notes.exclude.join('|')) end
52
+ extensions = config.notes.extensions.dup
53
+ exclude = if config.notes.exclude.empty? then nil
54
+ else Regexp.new(config.notes.exclude.join('|')) end
64
55
 
65
- project.gem.files.each do |fn|
56
+ config.gem.files.each do |fn|
66
57
  next if exclude && exclude =~ fn
67
58
  next unless extensions.include? File.extname(fn)
68
59
  results.update(extract_annotations_from(fn, rgxp))
@@ -83,7 +74,7 @@ class AnnotationExtractor
83
74
 
84
75
  text = m[2]
85
76
  if text =~ @id_rgxp
86
- text.gsub!(@id_rgxp) {|str| ANSICode.green(str)} if HAVE_COLOR
77
+ text.gsub!(@id_rgxp) {|str| ::Bones::Colors.green(str)} if config.colorize
87
78
  list << Annotation.new(lineno, m[1], text)
88
79
  end
89
80
  list
@@ -105,7 +96,6 @@ class AnnotationExtractor
105
96
  end
106
97
  end
107
98
 
108
- end # class AnnotationExtractor
109
- end # module Bones
99
+ end # class Bones::AnnotationExtractor
110
100
 
111
101
  # EOF
data/lib/bones/app.rb CHANGED
@@ -1,58 +1,80 @@
1
1
 
2
- require 'fileutils'
3
- require 'optparse'
4
- require 'erb'
2
+ require 'net/http'
3
+ require 'uri'
5
4
 
6
- module Bones
7
- class App
5
+ module Bones::App
6
+ extend LittlePlugger(:path => 'bones/app', :module => Bones::App)
7
+ disregard_plugins :error, :main, :command, :file_manager
8
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
9
+ Error = Class.new(StandardError)
15
10
 
16
- # Create a new main instance using _io_ for standard output and _err_ for
17
- # error messages.
11
+ # Create a new instance of Main, and run the +bones+ application given
12
+ # the command line _args_.
18
13
  #
19
- def initialize( out = STDOUT, err = STDERR )
20
- @out = out
21
- @err = err
14
+ def self.run( args = nil )
15
+ args ||= ARGV.dup.map! { |v| v.dup }
16
+ ::Bones::App::Main.new.run args
22
17
  end
23
18
 
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}"
19
+ class Main
20
+ attr_reader :stdout
21
+ attr_reader :stderr
22
+
23
+ # Create a new Main application instance. Options can be passed to
24
+ # configuret he stdout and stderr IO streams (very useful for testing).
25
+ #
26
+ def initialize( opts = {} )
27
+ opts[:stdout] ||= $stdout
28
+ opts[:stderr] ||= $stderr
29
+
30
+ @opts = opts
31
+ @stdout = opts[:stdout]
32
+ @stderr = opts[:stderr]
33
+ end
34
+
35
+ # Parse the desired user command and run that command object.
36
+ #
37
+ def run( args )
38
+ commands = []
39
+ @plugins = ::Bones::App.plugins
40
+ @plugins.each { |k,v| commands << k.to_s if v < ::Bones::App::Command }
41
+
42
+ cmd_str = args.shift
43
+ cmd = case cmd_str
44
+ when *commands
45
+ key = cmd_str.to_sym
46
+ @plugins[key].new @opts
47
+ when nil, '-h', '--help'
48
+ help
49
+ when '-v', '--version'
50
+ stdout.puts "Mr Bones v#{::Bones::VERSION}"
51
+ else
52
+ raise Error, "Unknown command #{cmd_str.inspect}"
53
+ end
54
+
55
+ if cmd
56
+ cmd.parse args
57
+ cmd.run
41
58
  end
42
59
 
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
-
60
+ rescue Bones::App::Error => err
61
+ stderr.puts "ERROR: While executing bones ..."
62
+ stderr.puts " #{err.message}"
63
+ exit 1
64
+ rescue StandardError => err
65
+ stderr.puts "ERROR: While executing bones ... (#{err.class})"
66
+ stderr.puts " #{err.to_s}"
67
+ exit 1
68
+ end
69
+
70
+ # Show the toplevel Mr Bones help message.
71
+ #
72
+ def help
73
+ msg = <<-MSG
74
+ NAME
75
+ bones v#{::Bones::VERSION}
76
+
77
+ DESCRIPTION
56
78
  Mr Bones is a handy tool that builds a skeleton for your new Ruby
57
79
  projects. The skeleton contains some starter code and a collection of
58
80
  rake tasks to ease the management and deployment of your source code.
@@ -68,25 +90,32 @@ class App
68
90
  bones create -s bort new_rails_project
69
91
 
70
92
  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
93
+ MSG
94
+
95
+ fmt = lambda { |cmd|
96
+ if @plugins[cmd] < ::Bones::App::Command
97
+ msg << " bones %-15s %s\n" % [cmd, @plugins[cmd].summary]
98
+ end
99
+ }
100
+
101
+ ary = [:create, :freeze, :unfreeze, :info]
102
+ ary.each(&fmt)
103
+ (@plugins.keys - ary).each(&fmt)
104
+
105
+ msg.concat <<-MSG
76
106
 
77
107
  Further Help:
78
108
  Each command has a '--help' option that will provide detailed
79
109
  information for that command.
80
110
 
81
- http://codeforpeople.rubyforge.org/bones/
111
+ http://github.com/TwP/bones
82
112
 
83
- MSG
84
- nil
85
- end
113
+ MSG
86
114
 
87
- end # class App
88
- end # module Bones
115
+ stdout.puts msg
116
+ end
89
117
 
90
- Bones.require_all_libs_relative_to(__FILE__)
118
+ end # class Main
119
+ end # module Bones::App
91
120
 
92
121
  # EOF