Class: Koboldy::Run
- Inherits:
-
Object
- Object
- Koboldy::Run
- Defined in:
- lib/koboldy/run.rb
Instance Method Summary collapse
- #additional_option(command) ⇒ Self
- #approved(expected_folder) ⇒ Self
- #base_uri(path) ⇒ Object
- #build(test_target_folder) ⇒ Self
-
#check_and_save(in_file_path = %(./tmp/kobold.txt)) ⇒ String
File path which is saved results.
- #clear_cmd(kobold_cmd = "kobold") ⇒ Object
- #config(file) ⇒ Self
-
#fail_additions ⇒ Self
Add “–fail-additions” option.
-
#fail_orphans ⇒ Self
Add “–fail-orphans” option.
- #highlight(compared_folder) ⇒ Self
-
#initialize(kobold_cmd = "kobold") ⇒ Run
constructor
A new instance of Run.
-
#results(from_path, into_file = "") ⇒ String
Into_file A path to saved result file.
Constructor Details
#initialize(kobold_cmd = "kobold") ⇒ Run
Returns a new instance of Run.
7 8 9 |
# File 'lib/koboldy/run.rb', line 7 def initialize(kobold_cmd = "kobold") @cmd = kobold_cmd end |
Instance Method Details
#additional_option(command) ⇒ Self
59 60 61 62 |
# File 'lib/koboldy/run.rb', line 59 def additional_option(command) @cmd.concat(%( #{command})) self end |
#approved(expected_folder) ⇒ Self
24 25 26 27 |
# File 'lib/koboldy/run.rb', line 24 def approved(expected_folder) @cmd.concat(%( --approved-folder "#{expected_folder}")) self end |
#base_uri(path) ⇒ Object
65 66 67 |
# File 'lib/koboldy/run.rb', line 65 def base_uri(path) @cmd.concat(%( "#{path}")) end |
#build(test_target_folder) ⇒ Self
38 39 40 41 |
# File 'lib/koboldy/run.rb', line 38 def build(test_target_folder) @cmd.concat(%( --build-folder "#{test_target_folder}")) self end |
#check_and_save(in_file_path = %(./tmp/kobold.txt)) ⇒ String
Returns File path which is saved results.
71 72 73 74 75 76 |
# File 'lib/koboldy/run.rb', line 71 def check_and_save(in_file_path = %(./tmp/kobold.txt)) fail "no command: #{@cmd}" if @cmd.nil? FileUtils.mkdir_p(File::dirname(in_file_path)) unless Dir.exist?(File::dirname(in_file_path)) Koboldy::Io.capture(@cmd, in_file_path) in_file_path end |
#clear_cmd(kobold_cmd = "kobold") ⇒ Object
11 12 13 |
# File 'lib/koboldy/run.rb', line 11 def clear_cmd(kobold_cmd = "kobold") @cmd = kobold_cmd end |
#config(file) ⇒ Self
17 18 19 20 |
# File 'lib/koboldy/run.rb', line 17 def config(file) @cmd.concat(%( --config "#{file}")) self end |
#fail_additions ⇒ Self
Add “–fail-additions” option
52 53 54 55 |
# File 'lib/koboldy/run.rb', line 52 def fail_additions @cmd.concat(%( --fail-additions)) self end |
#fail_orphans ⇒ Self
Add “–fail-orphans” option
45 46 47 48 |
# File 'lib/koboldy/run.rb', line 45 def fail_orphans @cmd.concat(%( --fail-orphans)) self end |
#highlight(compared_folder) ⇒ Self
31 32 33 34 |
# File 'lib/koboldy/run.rb', line 31 def highlight(compared_folder) @cmd.concat(%( --highlight-folder "#{compared_folder}")) self end |
#results(from_path, into_file = "") ⇒ String
Returns into_file A path to saved result file.
81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 |
# File 'lib/koboldy/run.rb', line 81 def results(from_path, into_file = "") fail ArgumentError, "no #{from_path}" unless File.exist? from_path result = File.read(from_path) add, orp, dif = additions(result), orphans(result), different(result) hash = { :passing => passing(result), :failing => failing(result), :pending => pending(result), :additions => { count: add.length, messages: add }, # 期待結果に無い :orphans => { count: orp.length, messages: orp }, # 比較対象に無い :different => { count: dif.length, messages: dif }, # 比較結果が異なる } return JSON.pretty_generate(hash) if into_file.empty? File.write(into_file, JSON.pretty_generate(hash)) into_file end |