Class: CIAT::Cargo
- Inherits:
-
Object
- Object
- CIAT::Cargo
- Defined in:
- lib/ciat/cargo.rb
Overview
:nodoc:all
Constant Summary collapse
- OUTPUT_FOLDER =
"temp"- REPORT_FILENAME =
"report.html"
Instance Attribute Summary collapse
-
#crates ⇒ Object
readonly
Returns the value of attribute crates.
-
#output_folder ⇒ Object
readonly
Returns the value of attribute output_folder.
-
#report_filename ⇒ Object
readonly
Returns the value of attribute report_filename.
Class Method Summary collapse
Instance Method Summary collapse
- #copy_suite_data ⇒ Object
-
#initialize(options = {}) ⇒ Cargo
constructor
A new instance of Cargo.
-
#read_file(filename) ⇒ Object
TODO: get rid of this in favor of the class method.
- #size ⇒ Object
-
#write_file(filename, content) ⇒ Object
TODO: get rid of this in favor of the class method.
Constructor Details
#initialize(options = {}) ⇒ Cargo
Returns a new instance of Cargo.
9 10 11 12 13 14 15 16 17 18 19 20 |
# File 'lib/ciat/cargo.rb', line 9 def initialize(={}) @output_folder = [:output_folder] || OUTPUT_FOLDER if [:files] filenames = [:files] else folder = [:folder] || "ciat" pattern = [:pattern] || "*.ciat" filenames = Dir[File.join(folder, "**", pattern)] end @crates = filenames.map { |filename| CIAT::Crate.new(filename, @output_folder) } @report_filename = File.join(@output_folder, [:report_filename] || REPORT_FILENAME) end |
Instance Attribute Details
#crates ⇒ Object (readonly)
Returns the value of attribute crates.
6 7 8 |
# File 'lib/ciat/cargo.rb', line 6 def crates @crates end |
#output_folder ⇒ Object (readonly)
Returns the value of attribute output_folder.
5 6 7 |
# File 'lib/ciat/cargo.rb', line 5 def output_folder @output_folder end |
#report_filename ⇒ Object (readonly)
Returns the value of attribute report_filename.
7 8 9 |
# File 'lib/ciat/cargo.rb', line 7 def report_filename @report_filename end |
Class Method Details
.read_file(filename) ⇒ Object
52 53 54 |
# File 'lib/ciat/cargo.rb', line 52 def self.read_file(filename) File.read(filename) end |
.write_file(filename, content) ⇒ Object
45 46 47 48 49 50 |
# File 'lib/ciat/cargo.rb', line 45 def self.write_file(filename, content) FileUtils.mkdir_p(File.dirname(filename)) File.open(filename, "w") do |file| file.write content end end |
Instance Method Details
#copy_suite_data ⇒ Object
26 27 28 29 30 |
# File 'lib/ciat/cargo.rb', line 26 def copy_suite_data FileUtils.mkdir_p(output_folder) FileUtils.cp(File.join(File.dirname(__FILE__), "..", "data", "ciat.css"), output_folder) FileUtils.cp(File.join(File.dirname(__FILE__), "..", "data", "prototype.js"), output_folder) end |
#read_file(filename) ⇒ Object
TODO: get rid of this in favor of the class method
41 42 43 |
# File 'lib/ciat/cargo.rb', line 41 def read_file(filename) File.read(filename) end |
#size ⇒ Object
22 23 24 |
# File 'lib/ciat/cargo.rb', line 22 def size crates.size end |
#write_file(filename, content) ⇒ Object
TODO: get rid of this in favor of the class method
33 34 35 36 37 38 |
# File 'lib/ciat/cargo.rb', line 33 def write_file(filename, content) FileUtils.mkdir_p(File.dirname(filename)) File.open(filename, "w") do |file| file.write content end end |