Class: IDeleteMyTweets::CommandConfig

Inherits:
Thor
  • Object
show all
Includes:
Auth, Thor::Actions
Defined in:
lib/i_delete_my_tweets/cli.rb

Instance Method Summary collapse

Methods included from Auth

#build_headers, #build_path, #consumer, #generate_authorize_url, #get_access_credentials, #get_request_token, #pin_auth_parameters

Instance Method Details

#authorize_with_pin(consumer_key, consumer_secret) ⇒ Object



103
104
105
106
107
108
109
110
111
112
113
114
# File 'lib/i_delete_my_tweets/cli.rb', line 103

def authorize_with_pin(consumer_key, consumer_secret)
  conf = cli_config
  conf.consumer_key, conf.consumer_secret = consumer_key, consumer_secret
  api = IDeleteMyTweets::Api.new(config: conf)

  request_token = get_request_token(api.client)
  auth_url = generate_authorize_url(api.client, request_token)

  pin = ask set_color interactive_pin_message(auth_url), :green, :bold
  credentials = get_access_credentials(request_token, pin)
  update_and_rewrite_conf!(conf, credentials)
end

#checkObject



74
75
76
77
78
79
80
81
82
83
84
85
# File 'lib/i_delete_my_tweets/cli.rb', line 74

def check
  bad_configs = cli_config.empty_values

  if bad_configs.empty?
    api = IDeleteMyTweets::Api.new(logger: method(:say))
    api.verify_credentials
    say set_color " ✅ You're all set! ", :white, :on_green, :bold
    say set_color cli_config.to_table, :green
  else
    say_error set_color " 🚫 Oops, #{bad_configs.join(', ')} #{bad_configs.size == 1 ? 'is' : 'are'} missing! ", :white, :on_red, :bold
  end
end

#store(key, value) ⇒ Object

Raises:

  • (Error)


88
89
90
91
92
93
94
95
96
97
98
99
# File 'lib/i_delete_my_tweets/cli.rb', line 88

def store(key, value)
  raise Error, "ERROR: #{key} does not exist" unless CONFIG_VARS.include?(key.strip)

  conf = cli_config
  conf.send("#{key.downcase.to_sym}=", value);

  if options[:dry_run]
    say set_color conf.to_table, :green, :bold
  else
    dump_to_file!(conf)
  end
end