Bones::Helpers

Constants

DEV_NULL
SUDO
RCOV
RDOC
GEM
HAVE_SVN
HAVE

Public Instance Methods

have?( key, &block ) click to toggle source
    # File lib/bones/helpers.rb, line 15
15:   def have?( key, &block )
16:     return HAVE[key] if block.nil?
17:     HAVE[key] = block.call
18:   end
paragraphs_of( path, *paragraphs ) click to toggle source

Reads a file at path and spits out an array of the paragraphs specified.

   changes = paragraphs_of('History.txt', 0..1).join("\n\n")
   summary, *description = paragraphs_of('README.txt', 3, 3..8)
    # File lib/bones/helpers.rb, line 37
37:   def paragraphs_of( path, *paragraphs )
38:     title = String === paragraphs.first ? paragraphs.shift : nil
39:     ary = File.read(path).delete("\r").split(/\n\n+/)
40: 
41:     result = if title
42:       tmp, matching = [], false
43:       rgxp = /^=+\s*#{Regexp.escape(title)}/
44:       paragraphs << (0..1) if paragraphs.empty?
45: 
46:       ary.each do |val|
47:         if val =~ rgxp
48:           break if matching
49:           matching = true
50:           rgxp = /^=+/
51:         elsif matching
52:           tmp << val
53:         end
54:       end
55:       tmp
56:     else ary end
57: 
58:     result.values_at(*paragraphs)
59:   end
quiet( &block ) click to toggle source
    # File lib/bones/helpers.rb, line 20
20:   def quiet( &block )
21:     io = [STDOUT.dup, STDERR.dup]
22:     STDOUT.reopen DEV_NULL
23:     STDERR.reopen DEV_NULL
24:     block.call
25:   ensure
26:     STDOUT.reopen io.first
27:     STDERR.reopen io.last
28:     io.each {|x| x.close}
29:   end
remove_desc_for_task( names ) click to toggle source

Find a rake task using the task name and remove any description text. This will prevent the task from being displayed in the list of available tasks.

    # File lib/bones/helpers.rb, line 64
64:   def remove_desc_for_task( names )
65:     Array(names).each do |task_name|
66:       task = Rake.application.tasks.find {|t| t.name == task_name}
67:       next if task.nil?
68:       task.instance_variable_set :@comment, nil
69:     end
70:   end

Disabled; run with --debug to generate this.

[Validate]

Generated with the Darkfish Rdoc Generator 1.1.6.