-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #38 from zaikio/Add-workstep
Add Workstep
- Loading branch information
Showing
4 changed files
with
81 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
Ctp: | ||
plate: | ||
required: true | ||
Cutting: | ||
product: | ||
required: true | ||
Folding: | ||
fold: | ||
required: true | ||
Lamination: | ||
laminated_sheet: | ||
required: true | ||
Printing: | ||
sheet: | ||
required: false | ||
roll: | ||
required: false | ||
ThreadSewing: | ||
book_block: | ||
required: true | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
module Zaikio | ||
module MissionControl | ||
module Worksteps | ||
class Base < Zaikio::MissionControl::Base | ||
require "yaml" | ||
RELATIVE_PATH_TO_JOBS_YML = "../../../../config/data/worksteps.yml" | ||
worksteps = YAML.safe_load_file(File.join(File.dirname(__FILE__), RELATIVE_PATH_TO_JOBS_YML), symbolize_names: true) | ||
worksteps.each do |klass_name, intermediate_products| | ||
Zaikio::MissionControl::Worksteps.const_set(klass_name.to_s.classify, Class.new(Base)) | ||
Zaikio::MissionControl::Worksteps.const_get(klass_name.to_s.classify).instance_variable_set(:@intermediate_products, intermediate_products) | ||
end | ||
|
||
class << self | ||
def intermediate_products | ||
@intermediate_products.flat_map do |product, option| | ||
return [product] if option[:required] | ||
|
||
product.to_s.concat("_maybe").to_sym | ||
end | ||
end | ||
end | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
require_relative "../../../test_helper" | ||
|
||
class Zaikio::MissionControl::WorkstepsTest < ActiveSupport::TestCase | ||
test "@parts, return what it should" do | ||
expected = { | ||
Ctp: { | ||
plate: { required: true } | ||
}, | ||
Cutting: { | ||
product: { required: true } | ||
}, | ||
Folding: { | ||
fold: { required: true } | ||
}, | ||
Lamination: { | ||
laminated_sheet: { required: true } | ||
}, | ||
Printing: { | ||
sheet: { required: false }, | ||
roll: { required: false } | ||
}, | ||
ThreadSewing: { | ||
book_block: { required: true } | ||
} | ||
} | ||
|
||
Zaikio::MissionControl::Worksteps.constants.reject { _1 == Base } .each do |job_klass| | ||
assert_equal expected[job_klass], | ||
Zaikio::MissionControl::Worksteps.const_get(job_klass).instance_variable_get(:@intermediate_products) | ||
end | ||
end | ||
end |