Class: CIAT::Cargo

Inherits:
Object
  • Object
show all
Defined in:
lib/ciat/cargo.rb

Overview

:nodoc:all

Constant Summary collapse

OUTPUT_FOLDER =
"temp"
REPORT_FILENAME =
"report.html"

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

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(options={})
  @output_folder = options[:output_folder] || OUTPUT_FOLDER
  if options[:files]
    filenames = options[:files]
  else  
    folder = options[:folder] || "ciat"
    pattern = options[: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, options[:report_filename] || REPORT_FILENAME)
end

Instance Attribute Details

#cratesObject (readonly)

Returns the value of attribute crates.



6
7
8
# File 'lib/ciat/cargo.rb', line 6

def crates
  @crates
end

#output_folderObject (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_filenameObject (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_dataObject



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

#sizeObject



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