krl 0.1.1 → 0.1.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. data/bin/krl-connect +40 -35
  2. metadata +2 -2
@@ -1,52 +1,57 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
3
  require "rubygems"
4
- require "sinatra"
4
+ require "sinatra/base"
5
5
  require "yaml"
6
6
  require "kynetx_am_api"
7
7
 
8
- set :environment, :production
9
- set :sessions, :false
10
- set :logging, :false
11
- set :port, 3009
12
8
 
13
- CONFIG_FILE = ENV["HOME"] + "/.krl/credentials.yml"
9
+ class KRLConnect < Sinatra::Base
10
+ set :environment, :production
11
+ set :sessions, :false
12
+ set :logging, :false
13
+ set :port, 3009
14
14
 
15
- puts "#{"\n"*10}Go to the following url to authorize. Press ctrl+c when finished.\n http://localhost:3009#{"\n"*10}"
15
+ CONFIG_FILE = ENV["HOME"] + "/.krl/credentials.yml"
16
16
 
17
- get '/authorize' do
18
- rt = YAML::load_file(CONFIG_FILE)
19
- api = setup_api(rt.merge({:oauth_verifier => params[:oauth_verifier]}))
20
- @oauth_user = api.get_user_info
21
- File.open(CONFIG_FILE, "w") {|f| f.print @oauth_user.to_h.to_yaml}
22
- erb :success
23
- end
17
+ puts "#{"\n"*10}Go to the following url to authorize. Press ctrl+c when finished.\n http://localhost:3009#{"\n"*10}"
24
18
 
25
- get '/' do
26
- FileUtils.mkdir_p ENV["HOME"] + "/.krl" unless File.exist?(CONFIG_FILE)
27
- rt = get_request_token
28
- config = {}
29
- config[:request_token] = rt[:request_token]
30
- config[:request_secret] = rt[:request_secret]
31
- File.open(CONFIG_FILE, "w") {|f| f.print config.to_yaml}
19
+ get '/authorize' do
20
+ rt = YAML::load_file(CONFIG_FILE)
21
+ api = setup_api(rt.merge({:oauth_verifier => params[:oauth_verifier]}))
22
+ @oauth_user = api.get_user_info
23
+ File.open(CONFIG_FILE, "w") {|f| f.print @oauth_user.to_h.to_yaml}
24
+ erb :success
25
+ end
32
26
 
33
- @auth_url = rt[:url]
27
+ get '/' do
28
+ FileUtils.mkdir_p ENV["HOME"] + "/.krl" unless File.exist?(CONFIG_FILE)
29
+ rt = get_request_token
30
+ config = {}
31
+ config[:request_token] = rt[:request_token]
32
+ config[:request_secret] = rt[:request_secret]
33
+ File.open(CONFIG_FILE, "w") {|f| f.print config.to_yaml}
34
34
 
35
- erb :index
36
- end
35
+ @auth_url = rt[:url]
37
36
 
37
+ erb :index
38
+ end
38
39
 
39
40
 
40
- def get_request_token
41
- api = setup_api
42
- rt = api.get_request_token
43
- return {:request_token => rt.token, :request_secret => rt.secret, :url => api.get_authorize_url}
44
- end
45
41
 
46
- def setup_api(opts={})
47
- KynetxAmApi::Oauth.api_server_url = "http://amapi.kynetx.com"
48
- KynetxAmApi::Oauth.accounts_server_url = "https://accounts.kynetx.com"
49
- KynetxAmApi::Oauth.consumer_key = "1j54YDLUcLW9ERBKalNm"
50
- KynetxAmApi::Oauth.consumer_secret = "QiWCbvTpCAejoceV3f6dD8ycifEkSumFAW1VSmwC"
51
- return KynetxAmApi::DirectApi.new(opts)
42
+ def get_request_token
43
+ api = setup_api
44
+ rt = api.get_request_token
45
+ return {:request_token => rt.token, :request_secret => rt.secret, :url => api.get_authorize_url}
46
+ end
47
+
48
+ def setup_api(opts={})
49
+ KynetxAmApi::Oauth.api_server_url = "http://amapi.kynetx.com"
50
+ KynetxAmApi::Oauth.accounts_server_url = "https://accounts.kynetx.com"
51
+ KynetxAmApi::Oauth.consumer_key = "1j54YDLUcLW9ERBKalNm"
52
+ KynetxAmApi::Oauth.consumer_secret = "QiWCbvTpCAejoceV3f6dD8ycifEkSumFAW1VSmwC"
53
+ return KynetxAmApi::DirectApi.new(opts)
54
+ end
52
55
  end
56
+
57
+ KRLConnect.run!
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 1
8
- - 1
9
- version: 0.1.1
8
+ - 2
9
+ version: 0.1.2
10
10
  platform: ruby
11
11
  authors:
12
12
  - Michael Farmer, Cid Dennis