Class: Flow::Cli::FlowYamlBuilder
- Inherits:
-
Object
- Object
- Flow::Cli::FlowYamlBuilder
- Defined in:
- lib/flow/cli/flow_yaml_builder.rb
Instance Attribute Summary collapse
-
#flow_cli_config ⇒ Object
Returns the value of attribute flow_cli_config.
Instance Method Summary collapse
- #build_yaml ⇒ Object
- #build_yaml_hash ⇒ Object
- #create_default_flow_dict ⇒ Object
-
#generate_custom_build_step ⇒ Object
生成编译脚本.
-
#generate_normal_steps ⇒ Object
创建一些标准的steps.
- #generate_step_dict(name, plugin_config = nil) ⇒ Object
- #generate_steps ⇒ Object
-
#initialize(flow_cli_config = {}) ⇒ FlowYamlBuilder
constructor
A new instance of FlowYamlBuilder.
Constructor Details
#initialize(flow_cli_config = {}) ⇒ FlowYamlBuilder
Returns a new instance of FlowYamlBuilder.
5 6 7 |
# File 'lib/flow/cli/flow_yaml_builder.rb', line 5 def initialize(flow_cli_config = {}) self.flow_cli_config = flow_cli_config end |
Instance Attribute Details
#flow_cli_config ⇒ Object
Returns the value of attribute flow_cli_config.
4 5 6 |
# File 'lib/flow/cli/flow_yaml_builder.rb', line 4 def flow_cli_config @flow_cli_config end |
Instance Method Details
#build_yaml ⇒ Object
9 10 11 |
# File 'lib/flow/cli/flow_yaml_builder.rb', line 9 def build_yaml build_yaml_hash.deep_stringify_keys.to_yaml end |
#build_yaml_hash ⇒ Object
13 14 15 16 17 18 19 |
# File 'lib/flow/cli/flow_yaml_builder.rb', line 13 def build_yaml_hash yaml_hash = { env: ["FLOW_YAML_FROM=flow-cli"], flows: [create_default_flow_dict] } yaml_hash end |
#create_default_flow_dict ⇒ Object
21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/flow/cli/flow_yaml_builder.rb', line 21 def create_default_flow_dict flow = {} flow[:name] = flow_cli_config[:flow_name] || 'default_flow_by_cli' flow[:language] = flow_cli_config[:language] flow[:env] = flow_cli_config[:env] flow[:trigger] = { push: %w[develop master] } flow[:steps] = generate_steps flow end |
#generate_custom_build_step ⇒ Object
生成编译脚本
51 52 53 54 55 56 57 |
# File 'lib/flow/cli/flow_yaml_builder.rb', line 51 def generate_custom_build_step script = IosBuildStepGenerator.new(flow_cli_config).generate_gym_script { name: "build", scripts: [script] } end |
#generate_normal_steps ⇒ Object
创建一些标准的steps
42 43 44 45 46 47 48 |
# File 'lib/flow/cli/flow_yaml_builder.rb', line 42 def generate_normal_steps steps = [] steps << generate_step_dict("init", name: "#{flow_cli_config[:flow_language]}_init") steps << generate_step_dict("git") steps end |
#generate_step_dict(name, plugin_config = nil) ⇒ Object
59 60 61 62 63 64 65 66 67 68 |
# File 'lib/flow/cli/flow_yaml_builder.rb', line 59 def generate_step_dict(name, plugin_config = nil) step_dict = { name: name, plugin: { name: name } } step_dict[:plugin].merge!(plugin_config) if plugin_config step_dict end |
#generate_steps ⇒ Object
35 36 37 38 39 |
# File 'lib/flow/cli/flow_yaml_builder.rb', line 35 def generate_steps steps = [] generate_normal_steps.each { |step| steps << step } steps << generate_custom_build_step end |