Class: Fastlane::Actions::ErbAction
- Inherits:
-
Fastlane::Action
- Object
- Fastlane::Action
- Fastlane::Actions::ErbAction
- Defined in:
- fastlane/lib/fastlane/actions/erb.rb
Constant Summary
Constants inherited from Fastlane::Action
Fastlane::Action::AVAILABLE_CATEGORIES, Fastlane::Action::RETURN_TYPES
Documentation collapse
- .authors ⇒ Object
- .available_options ⇒ Object
- .category ⇒ Object
- .description ⇒ Object
- .details ⇒ Object
- .example_code ⇒ Object
- .is_supported?(platform) ⇒ Boolean
Class Method Summary collapse
Methods inherited from Fastlane::Action
action_name, author, deprecated_notes, lane_context, method_missing, other_action, output, return_type, return_value, sample_return_value, shell_out_should_use_bundle_exec?, step_text
Class Method Details
.authors ⇒ Object
61 62 63 |
# File 'fastlane/lib/fastlane/actions/erb.rb', line 61 def self. ["hjanuschka"] end |
.available_options ⇒ Object
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 |
# File 'fastlane/lib/fastlane/actions/erb.rb', line 30 def self. [ FastlaneCore::ConfigItem.new(key: :template, short_option: "-T", env_name: "FL_ERB_SRC", description: "ERB Template File", optional: false, is_string: true), FastlaneCore::ConfigItem.new(key: :destination, short_option: "-D", env_name: "FL_ERB_DST", description: "Destination file", optional: true, is_string: true), FastlaneCore::ConfigItem.new(key: :placeholders, short_option: "-p", env_name: "FL_ERB_PLACEHOLDERS", description: "Placeholders given as a hash", default_value: {}, is_string: false, type: Hash), FastlaneCore::ConfigItem.new(key: :trim_mode, short_option: "-t", env_name: "FL_ERB_TRIM_MODE", description: "Trim mode applied to the ERB", optional: true) ] end |
.category ⇒ Object
87 88 89 |
# File 'fastlane/lib/fastlane/actions/erb.rb', line 87 def self.category :misc end |
.description ⇒ Object
19 20 21 |
# File 'fastlane/lib/fastlane/actions/erb.rb', line 19 def self.description "Allows to Generate output files based on ERB templates" end |
.details ⇒ Object
23 24 25 26 27 28 |
# File 'fastlane/lib/fastlane/actions/erb.rb', line 23 def self.details [ "Renders an ERB template with `:placeholders` given as a hash via parameter.", "If no `:destination` is set, it returns the rendered template as string." ].join("\n") end |
.example_code ⇒ Object
65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 |
# File 'fastlane/lib/fastlane/actions/erb.rb', line 65 def self.example_code [ '# Example `erb` template: # Variable1 <%= var1 %> # Variable2 <%= var2 %> # <% for item in var3 %> # <%= item %> # <% end %> erb( template: "1.erb", destination: "/tmp/rendered.out", placeholders: { :var1 => 123, :var2 => "string", :var3 => ["element1", "element2"] } )' ] end |
.is_supported?(platform) ⇒ Boolean
91 92 93 |
# File 'fastlane/lib/fastlane/actions/erb.rb', line 91 def self.is_supported?(platform) true end |
.run(params) ⇒ Object
4 5 6 7 8 9 10 11 12 13 |
# File 'fastlane/lib/fastlane/actions/erb.rb', line 4 def self.run(params) template = File.read(params[:template]) trim_mode = params[:trim_mode] result = Fastlane::ErbTemplateHelper.render(template, params[:placeholders], trim_mode) File.open(params[:destination], 'w') { |file| file.write(result) } if params[:destination] UI.("Successfully parsed template: '#{params[:template]}' and rendered output to: #{params[:destination]}") if params[:destination] result end |