Class: Fastlane::Actions::TwitterAction

Inherits:
Fastlane::Action show all
Defined in:
fastlane/lib/fastlane/actions/twitter.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, output, return_type, return_value, sample_return_value, shell_out_should_use_bundle_exec?, step_text

Class Method Details

.authorsObject



59
60
61
# File 'fastlane/lib/fastlane/actions/twitter.rb', line 59

def self.authors
  ["hjanuschka"]
end

.available_optionsObject



29
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
# File 'fastlane/lib/fastlane/actions/twitter.rb', line 29

def self.available_options
  [
    FastlaneCore::ConfigItem.new(key: :consumer_key,
                                 env_name: "FL_TW_CONSUMER_KEY",
                                 description: "Consumer Key",
                                 sensitive: true,
                                 optional: false),
    FastlaneCore::ConfigItem.new(key: :consumer_secret,
                                 env_name: "FL_TW_CONSUMER_SECRET",
                                 sensitive: true,
                                 description: "Consumer Secret",
                                 optional: false),
    FastlaneCore::ConfigItem.new(key: :access_token,
                                 env_name: "FL_TW_ACCESS_TOKEN",
                                 sensitive: true,
                                 description: "Access Token",
                                 optional: false),
    FastlaneCore::ConfigItem.new(key: :access_token_secret,
                                 env_name: "FL_TW_ACCESS_TOKEN_SECRET",
                                 sensitive: true,
                                 description: "Access Token Secret",
                                 optional: false),
    FastlaneCore::ConfigItem.new(key: :message,
                                 env_name: "FL_TW_MESSAGE",
                                 description: "The tweet",
                                 optional: false)

  ]
end

.categoryObject



79
80
81
# File 'fastlane/lib/fastlane/actions/twitter.rb', line 79

def self.category
  :notifications
end

.descriptionObject



21
22
23
# File 'fastlane/lib/fastlane/actions/twitter.rb', line 21

def self.description
  "Post a tweet on [Twitter.com](https://twitter.com)"
end

.detailsObject



25
26
27
# File 'fastlane/lib/fastlane/actions/twitter.rb', line 25

def self.details
  "Post a tweet on Twitter. Requires you to setup an app on [twitter.com](https://twitter.com) and obtain `consumer` and `access_token`."
end

.example_codeObject



67
68
69
70
71
72
73
74
75
76
77
# File 'fastlane/lib/fastlane/actions/twitter.rb', line 67

def self.example_code
  [
    'twitter(
      access_token: "XXXX",
      access_token_secret: "xxx",
      consumer_key: "xxx",
      consumer_secret: "xxx",
      message: "You rock!"
    )'
  ]
end

.is_supported?(platform) ⇒ Boolean

Returns:



63
64
65
# File 'fastlane/lib/fastlane/actions/twitter.rb', line 63

def self.is_supported?(platform)
  true
end

.run(params) ⇒ Object



4
5
6
7
8
9
10
11
12
13
14
15
# File 'fastlane/lib/fastlane/actions/twitter.rb', line 4

def self.run(params)
  Actions.verify_gem!("twitter")
  require 'twitter'
  client = Twitter::REST::Client.new do |config|
    config.consumer_key        = params[:consumer_key]
    config.consumer_secret     = params[:consumer_secret]
    config.access_token        = params[:access_token]
    config.access_token_secret = params[:access_token_secret]
  end
  client.update(params[:message])
  UI.message(['[TWITTER]', "Successfully tweeted ", params[:message]].join(': '))
end