Class: RakeFly::OptionResolver
- Inherits:
-
Object
- Object
- RakeFly::OptionResolver
- Defined in:
- lib/rake_fly.rb
Instance Attribute Summary collapse
-
#opts ⇒ Object
readonly
Returns the value of attribute opts.
Instance Method Summary collapse
- #dependency ⇒ Object
- #file_name_template ⇒ Object
-
#fly_binary_path ⇒ Object
rubocop:enable Metrics/MethodLength.
-
#initialize(opts) ⇒ OptionResolver
constructor
A new instance of OptionResolver.
-
#installation_task_set_options ⇒ Object
rubocop:disable Metrics/MethodLength.
- #namespace ⇒ Object
- #needs_fetch_check_lambda ⇒ Object
- #new_format? ⇒ Boolean
- #path ⇒ Object
- #platform_os_names ⇒ Object
- #source_binary_name_template ⇒ Object
- #target_binary_name_template ⇒ Object
- #type ⇒ Object
- #uri_template ⇒ Object
- #version ⇒ Object
Constructor Details
#initialize(opts) ⇒ OptionResolver
Returns a new instance of OptionResolver.
42 43 44 |
# File 'lib/rake_fly.rb', line 42 def initialize(opts) @opts = opts end |
Instance Attribute Details
#opts ⇒ Object (readonly)
Returns the value of attribute opts.
40 41 42 |
# File 'lib/rake_fly.rb', line 40 def opts @opts end |
Instance Method Details
#dependency ⇒ Object
79 80 81 |
# File 'lib/rake_fly.rb', line 79 def dependency 'fly' end |
#file_name_template ⇒ Object
114 115 116 117 118 119 120 |
# File 'lib/rake_fly.rb', line 114 def file_name_template if new_format? 'fly-<%= @version %>-<%= @platform_os_name %>-amd64<%= @ext %>' else 'fly_<%= @platform_os_name %>_amd64' end end |
#fly_binary_path ⇒ Object
rubocop:enable Metrics/MethodLength
71 72 73 |
# File 'lib/rake_fly.rb', line 71 def fly_binary_path File.join(path, 'bin', 'fly') end |
#installation_task_set_options ⇒ Object
rubocop:disable Metrics/MethodLength
47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 |
# File 'lib/rake_fly.rb', line 47 def task_set_opts = { namespace:, dependency:, version:, path:, type:, platform_os_names:, uri_template:, file_name_template:, needs_fetch: needs_fetch_check_lambda } unless new_format? task_set_opts[:source_binary_name_template] = source_binary_name_template task_set_opts[:target_binary_name_template] = target_binary_name_template end task_set_opts end |
#namespace ⇒ Object
75 76 77 |
# File 'lib/rake_fly.rb', line 75 def namespace opts[:namespace] || :fly end |
#needs_fetch_check_lambda ⇒ Object
130 131 132 133 134 135 136 |
# File 'lib/rake_fly.rb', line 130 def needs_fetch_check_lambda lambda { |t| fly_binary = File.join(t.path, t.binary_directory, 'fly') !(File.exist?(fly_binary) && RubyFly.version == version) } end |
#new_format? ⇒ Boolean
138 139 140 141 |
# File 'lib/rake_fly.rb', line 138 def new_format? Semantic::Version.new(version) >= Semantic::Version.new(ARTIFACT_FORMAT_CHANGE_VERSION) end |
#path ⇒ Object
87 88 89 |
# File 'lib/rake_fly.rb', line 87 def path opts[:path] || File.join('vendor', 'fly') end |
#platform_os_names ⇒ Object
99 100 101 |
# File 'lib/rake_fly.rb', line 99 def platform_os_names { darwin: 'darwin', linux: 'linux' } end |
#source_binary_name_template ⇒ Object
126 127 128 |
# File 'lib/rake_fly.rb', line 126 def source_binary_name_template 'fly_<%= @platform_os_name %>_amd64' end |
#target_binary_name_template ⇒ Object
122 123 124 |
# File 'lib/rake_fly.rb', line 122 def target_binary_name_template 'fly' end |
#type ⇒ Object
91 92 93 94 95 96 97 |
# File 'lib/rake_fly.rb', line 91 def type if new_format? :tgz else :uncompressed end end |
#uri_template ⇒ Object
103 104 105 106 107 108 109 110 111 112 |
# File 'lib/rake_fly.rb', line 103 def uri_template if new_format? 'https://github.com/concourse/concourse/releases/download' \ '/v<%= @version %>' \ '/fly-<%= @version %>-<%= @platform_os_name %>-amd64<%= @ext %>' else 'https://github.com/concourse/concourse/releases/' \ 'download/v<%= @version %>/fly_<%= @platform_os_name %>_amd64' end end |
#version ⇒ Object
83 84 85 |
# File 'lib/rake_fly.rb', line 83 def version opts[:version] || '2.7.0' end |