tjplurk 1.1.0 → 1.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/tjplurk/api.rb +6 -2
- data/lib/tjplurk/cli.rb +2 -2
- data/lib/tjplurk/version.rb +1 -1
- data/lib/tjplurk.rb +0 -2
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3cd527e15ff2998cc0897451a689ba1d17af2dae
|
4
|
+
data.tar.gz: 3068e2f15710797cbb42eac67b4772077c1f7da8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0aa55b54ea3c90f442255effca2bd515b2ed08b136c3b59ca54853a9befed3261d134f657f304095593a0a4ca73e4dea4d16792267461e71e73b71a6e4ebf53a
|
7
|
+
data.tar.gz: 6f8fe3cf757e4a79929b1b24d71ac3e439e68b91593ecd75b10a7f87f3d4771f27fdf96fd7b267b30baefe186c0e469106f48a9de484ec400cb3ea72831c057f
|
data/lib/tjplurk/api.rb
CHANGED
@@ -5,10 +5,14 @@ module Tjplurk
|
|
5
5
|
class API
|
6
6
|
attr_reader :consumer, :request_token, :access_token
|
7
7
|
|
8
|
+
def self.config_file_path
|
9
|
+
ENV['TJPLURK_FILE'] || File.join(ENV['HOME'], '.tjplurk')
|
10
|
+
end
|
11
|
+
|
8
12
|
def initialize(consumer_key = nil, consumer_secret = nil, token_key = nil, token_secret = nil)
|
9
13
|
if consumer_key.nil? || consumer_secret.nil?
|
10
|
-
raise 'Consumer key & secret are not found.' unless File.exist?
|
11
|
-
consumer_key, consumer_secret, token_key, token_secret = File.readlines(
|
14
|
+
raise 'Consumer key & secret are not found.' unless File.exist? Tjplurk::API.config_file_path
|
15
|
+
consumer_key, consumer_secret, token_key, token_secret = File.readlines(Tjplurk::API.config_file_path).map(&:strip!).delete_if(&:empty?)
|
12
16
|
end
|
13
17
|
@consumer = OAuth::Consumer.new(consumer_key, consumer_secret, Tjplurk::OAUTH_OPTIONS)
|
14
18
|
@access_token = OAuth::AccessToken.new(@consumer, token_key, token_secret) if token_key && token_secret
|
data/lib/tjplurk/cli.rb
CHANGED
@@ -13,13 +13,13 @@ module Tjplurk
|
|
13
13
|
Launchy.open(api.request_token.authorize_url)
|
14
14
|
oauth_verifier = ask 'Enter Verification Number:'
|
15
15
|
access_token = api.request_token.get_access_token oauth_verifier: oauth_verifier
|
16
|
-
File.open(Tjplurk::
|
16
|
+
File.open(Tjplurk::API.config_file_path, 'w') do |f|
|
17
17
|
f.puts consumer_key
|
18
18
|
f.puts consumer_secret
|
19
19
|
f.puts access_token.token
|
20
20
|
f.puts access_token.secret
|
21
21
|
end
|
22
|
-
puts "Key & secret successfully saved to \"#{Tjplurk::
|
22
|
+
puts "Key & secret successfully saved to \"#{Tjplurk::API.config_file_path}\"."
|
23
23
|
end
|
24
24
|
|
25
25
|
desc 'api PATH ["FOO=BAR" ...]', 'send an API request.'
|
data/lib/tjplurk/version.rb
CHANGED
data/lib/tjplurk.rb
CHANGED