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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 9ac34043b00ddd1c0dc2d9d297e7460c749d72a2
4
- data.tar.gz: befc587e195b943abea9ca1861cffe945b635d49
3
+ metadata.gz: 3cd527e15ff2998cc0897451a689ba1d17af2dae
4
+ data.tar.gz: 3068e2f15710797cbb42eac67b4772077c1f7da8
5
5
  SHA512:
6
- metadata.gz: df110d6342c4a97754e158e81fa6e2de582bcdbecfc5be50b4eeefc6d236e81bf9ff15087173e1fc4c2df82f0654b7ce048b8650be48ac40cd965528027d3775
7
- data.tar.gz: 40426c0b8d284fc0bd4515599638fef14a31cdbe654db2ac70ad874a159338a78d76a7ba62f5559d9165bcd82c4f46c0e9d1a86f820a0710b5468e8070a66c43
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? TJPLURK_FILE
11
- consumer_key, consumer_secret, token_key, token_secret = File.readlines(TJPLURK_FILE).map(&:strip!).delete_if(&:empty?)
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::TJPLURK_FILE, 'w') do |f|
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::TJPLURK_FILE}\"."
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.'
@@ -1,3 +1,3 @@
1
1
  module Tjplurk
2
- VERSION = '1.1.0'
2
+ VERSION = '1.2.0'
3
3
  end
data/lib/tjplurk.rb CHANGED
@@ -7,6 +7,4 @@ module Tjplurk
7
7
  access_token_path: '/OAuth/access_token',
8
8
  authorize_path: '/OAuth/authorize'
9
9
  }
10
-
11
- TJPLURK_FILE = File.join(ENV['HOME'], '.tjplurk')
12
10
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: tjplurk
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.0
4
+ version: 1.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tony Jian