Class: Fastlane::Actions::ReadPodspecAction

Inherits:
Fastlane::Action show all
Defined in:
fastlane/lib/fastlane/actions/read_podspec.rb

Constant Summary

Constants inherited from Fastlane::Action

Fastlane::Action::AVAILABLE_CATEGORIES, Fastlane::Action::RETURN_TYPES

Documentation collapse

Class Method Summary collapse

Methods inherited from Fastlane::Action

action_name, author, deprecated_notes, lane_context, method_missing, other_action, return_value, shell_out_should_use_bundle_exec?, step_text

Class Method Details

.authorsObject


58
59
60
# File 'fastlane/lib/fastlane/actions/read_podspec.rb', line 58

def self.authors
  ["czechboy0"]
end

.available_optionsObject


39
40
41
42
43
44
45
46
47
48
49
50
# File 'fastlane/lib/fastlane/actions/read_podspec.rb', line 39

def self.available_options
  [
    FastlaneCore::ConfigItem.new(key: :path,
                                 env_name: "FL_READ_PODSPEC_PATH",
                                 description: "Path to the podspec to be read",
                                 default_value: Dir['*.podspec*'].first,
                                 default_value_dynamic: true,
                                 verify_block: proc do |value|
                                   UI.user_error!("File #{value} not found") unless File.exist?(value)
                                 end)
  ]
end

.categoryObject


85
86
87
# File 'fastlane/lib/fastlane/actions/read_podspec.rb', line 85

def self.category
  :misc
end

.descriptionObject


26
27
28
# File 'fastlane/lib/fastlane/actions/read_podspec.rb', line 26

def self.description
  "Loads a CocoaPods spec as JSON"
end

.detailsObject


30
31
32
33
34
35
36
37
# File 'fastlane/lib/fastlane/actions/read_podspec.rb', line 30

def self.details
  [
    "This can be used for only specifying a version string in your podspec - and during your release process you'd read it from the podspec by running `version = read_podspec['version']` at the beginning of your lane.",
    "Loads the specified (or the first found) podspec in the folder as JSON, so that you can inspect its `version`, `files` etc.",
    "This can be useful when basing your release process on the version string only stored in one place - in the podspec.",
    "As one of the first steps you'd read the podspec and its version and the rest of the workflow can use that version string (when e.g. creating a new git tag or a GitHub Release)."
  ].join("\n")
end

.example_codeObject


66
67
68
69
70
71
72
73
# File 'fastlane/lib/fastlane/actions/read_podspec.rb', line 66

def self.example_code
  [
    'spec = read_podspec
    version = spec["version"]
    puts "Using Version #{version}"',
    'spec = read_podspec(path: "./XcodeServerSDK.podspec")'
  ]
end

.is_supported?(platform) ⇒ Boolean

Returns:


62
63
64
# File 'fastlane/lib/fastlane/actions/read_podspec.rb', line 62

def self.is_supported?(platform)
  [:ios, :mac].include?(platform)
end

.outputObject


52
53
54
55
56
# File 'fastlane/lib/fastlane/actions/read_podspec.rb', line 52

def self.output
  [
    ['READ_PODSPEC_JSON', 'Podspec JSON payload']
  ]
end

.return_typeObject


81
82
83
# File 'fastlane/lib/fastlane/actions/read_podspec.rb', line 81

def self.return_type
  :hash_of_strings
end

.run(params) ⇒ Object


8
9
10
11
12
13
14
15
16
17
18
19
20
# File 'fastlane/lib/fastlane/actions/read_podspec.rb', line 8

def self.run(params)
  Actions.verify_gem!('cocoapods')

  path = params[:path]

  require 'cocoapods-core'
  spec = Pod::Spec.from_file(path).to_hash

  UI.success("Reading podspec from file #{path}")

  Actions.lane_context[SharedValues::READ_PODSPEC_JSON] = spec
  return spec
end

.sample_return_valueObject


75
76
77
78
79
# File 'fastlane/lib/fastlane/actions/read_podspec.rb', line 75

def self.sample_return_value
  {
    'version' => 1.0
  }
end