Class: MiniYard::Copy
- Inherits:
-
Object
- Object
- MiniYard::Copy
- Defined in:
- lib/miniyard/copy.rb
Instance Method Summary collapse
- #cov_dest_path ⇒ Object
- #cov_source_path ⇒ Object
- #doc_dest_path ⇒ Object
- #doc_source_path ⇒ Object
- #folder_path ⇒ Object
-
#initialize(options) ⇒ Copy
constructor
A new instance of Copy.
- #root_path ⇒ Object
- #run ⇒ Object
- #verify_opts(options) ⇒ Object
Constructor Details
#initialize(options) ⇒ Copy
Returns a new instance of Copy.
4 5 6 7 |
# File 'lib/miniyard/copy.rb', line 4 def initialize() verify_opts() @options = end |
Instance Method Details
#cov_dest_path ⇒ Object
44 45 46 |
# File 'lib/miniyard/copy.rb', line 44 def cov_dest_path File.join(folder_path, 'cov') end |
#cov_source_path ⇒ Object
36 37 38 |
# File 'lib/miniyard/copy.rb', line 36 def cov_source_path File.(@options[:cov]) end |
#doc_dest_path ⇒ Object
40 41 42 |
# File 'lib/miniyard/copy.rb', line 40 def doc_dest_path File.join(folder_path, 'doc') end |
#doc_source_path ⇒ Object
32 33 34 |
# File 'lib/miniyard/copy.rb', line 32 def doc_source_path File.(@options[:doc]) end |
#folder_path ⇒ Object
48 49 50 |
# File 'lib/miniyard/copy.rb', line 48 def folder_path File.join(root_path, @options[:name]) end |
#root_path ⇒ Object
52 53 54 |
# File 'lib/miniyard/copy.rb', line 52 def root_path File.(@options[:root]) end |
#run ⇒ Object
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/miniyard/copy.rb', line 9 def run FileUtils.mkdir_p(folder_path) unless File.directory?(folder_path) if @options[:doc] $stdout.puts('Copying docs from %s to %s' % [doc_source_path, doc_dest_path]) FileUtils.rm_rf(doc_dest_path) if File.directory?(doc_dest_path) FileUtils.cp_r(doc_source_path, doc_dest_path) end if @options[:cov] $stdout.puts('Copying coverage from %s to %s' % [cov_source_path, cov_dest_path]) FileUtils.rm_rf(cov_dest_path) if File.directory?(doc_dest_path) FileUtils.cp_r(cov_source_path, cov_dest_path) end end |
#verify_opts(options) ⇒ Object
25 26 27 28 29 30 |
# File 'lib/miniyard/copy.rb', line 25 def verify_opts() raise 'Root directory %s does not exist' % [:root] unless File.directory?([:root]) raise 'Doc source directory %s does not exist' % doc_source_path if [:doc] && !File.directory?([:doc]) raise 'Coverage source directory %s does not exist' % cov_source_path if [:cov] && !File.directory?([:cov]) raise 'Name must be present' % [:name] unless [:name] end |