Class: GemThis
- Inherits:
-
Object
- Object
- GemThis
- Defined in:
- lib/gem_this.rb
Constant Summary collapse
- SUMMARY =
"Creates a Rakefile suitable for turning the current project into a gem."
- DEBUG_MESSAGE =
"debug, only prints out the generated Rakefile."
Class Attribute Summary collapse
-
.custom_task_file ⇒ Object
Returns the value of attribute custom_task_file.
Instance Attribute Summary collapse
-
#debug ⇒ Object
readonly
Returns the value of attribute debug.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
Instance Method Summary collapse
- #create_rakefile ⇒ Object
-
#initialize(name, options = {}) ⇒ GemThis
constructor
A new instance of GemThis.
Constructor Details
#initialize(name, options = {}) ⇒ GemThis
Returns a new instance of GemThis.
16 17 18 19 20 21 |
# File 'lib/gem_this.rb', line 16 def initialize(name, ={}) @name = name = {:default => false, :silent => false}.update() @debug = [:debug] @silent = [:silent] end |
Class Attribute Details
.custom_task_file ⇒ Object
Returns the value of attribute custom_task_file.
10 11 12 |
# File 'lib/gem_this.rb', line 10 def custom_task_file @custom_task_file end |
Instance Attribute Details
#debug ⇒ Object (readonly)
Returns the value of attribute debug.
14 15 16 |
# File 'lib/gem_this.rb', line 14 def debug @debug end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
14 15 16 |
# File 'lib/gem_this.rb', line 14 def name @name end |
Instance Method Details
#create_rakefile ⇒ Object
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/gem_this.rb', line 23 def create_rakefile template = ERB.new File.read(File.join(File.dirname(__FILE__), '..', 'Rakefile.erb')), nil, '<>' rakefile = template.result(binding) if self.class.custom_task_file && File.exist?(self.class.custom_task_file) rakefile += "\n" + File.read(self.class.custom_task_file) end if debug puts rakefile else if File.exist?('Rakefile') log "Appended to existing Rakefile" File.open('Rakefile', 'a') { |f| 2.times { f.puts }; f.write rakefile } else log "Writing new Rakefile" File.open('Rakefile', 'w') { |f| f.write rakefile } end add_to_gitignore if using_git? end unless has_lib_directory? log "You don't seem to have a lib directory - please edit the Rakefile to set where your code is." false end end |