Class: ShopifyTransporter::Generate
- Inherits:
-
BaseGroup
- Object
- Thor::Group
- BaseGroup
- ShopifyTransporter::Generate
show all
- Defined in:
- lib/shopify_transporter/generators/generate.rb
Constant Summary
Constants inherited
from BaseGroup
BaseGroup::SUPPORTED_PLATFORMS_MAPPING
Instance Method Summary
collapse
Methods inherited from BaseGroup
#config_filename, #name_components, source_root
Instance Method Details
#add_stage_to_config ⇒ Object
42
43
44
45
46
47
48
49
50
51
52
53
|
# File 'lib/shopify_transporter/generators/generate.rb', line 42
def add_stage_to_config
config_file = YAML.load_file(config_filename)
unless class_included_in?(config_file)
pipeline_class_hash = { @pipeline_class.to_s => nil, 'type' => 'custom' }
config_file['object_types'][@object_type.downcase]['pipeline_stages'] << pipeline_class_hash
File.open(config_filename, 'w') { |f| f.write config_file.to_yaml }
say('Updated config.yml with the new pipeline stage', :green)
return
end
say("Warning: The pipeline stage #{@pipeline_class} already exists in the config.yml", :blue)
end
|
#generate_stage ⇒ Object
35
36
37
38
39
40
|
# File 'lib/shopify_transporter/generators/generate.rb', line 35
def generate_stage
template(
'templates/custom_stage.tt',
"lib/custom_pipeline_stages/#{pipeline_snake_name}.rb"
)
end
|
#object_type ⇒ Object
10
11
12
|
# File 'lib/shopify_transporter/generators/generate.rb', line 10
def object_type
@object_type ||= options[:object].capitalize
end
|
#pipeline_class ⇒ Object
25
26
27
|
# File 'lib/shopify_transporter/generators/generate.rb', line 25
def pipeline_class
@pipeline_class ||= @name_components.map(&:classify).join('')
end
|
#pipeline_snake_name ⇒ Object
21
22
23
|
# File 'lib/shopify_transporter/generators/generate.rb', line 21
def pipeline_snake_name
name_components.map(&:underscore).join('_')
end
|
29
30
31
32
33
|
# File 'lib/shopify_transporter/generators/generate.rb', line 29
def platform
platform_type = YAML.load_file(config_filename)['platform_type']
@platform_file_path ||= SUPPORTED_PLATFORMS_MAPPING[platform_type]
@platform ||= platform_type.underscore
end
|
#validate_config_exists ⇒ Object
14
15
16
17
18
19
|
# File 'lib/shopify_transporter/generators/generate.rb', line 14
def validate_config_exists
unless File.exist?(config_filename)
say('Cannot find config.yml at project root', :red)
exit 1
end
end
|