myoack 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +3 -0
- data/Gemfile +5 -0
- data/Gemfile.lock +31 -0
- data/NOTE.rdoc +17 -0
- data/README.rdoc +28 -0
- data/VERSION +1 -0
- data/bin/myoack-local-authorization-server.rb +4 -0
- data/bin/myoack.rb +5 -0
- data/examples/get_gists_from_github.rb +13 -0
- data/examples/get_mentions_from_twitter.rb +15 -0
- data/examples/get_posts_from_tumblr.rb +18 -0
- data/lib/myoack/as_cli.rb +5 -0
- data/lib/myoack/as_lib.rb +10 -0
- data/lib/myoack/config_manager.rb +99 -0
- data/lib/myoack/github.rb +13 -0
- data/lib/myoack/key_config.rb +165 -0
- data/lib/myoack/local_authorization.rb +71 -0
- data/lib/myoack/tumblr.rb +14 -0
- data/lib/myoack/twitter.rb +11 -0
- data/lib/myoack.rb +1 -0
- data/myoack.gemspec +20 -0
- data/spec/config_manager_spec.rb +52 -0
- data/spec/myoack_home_example/keys.yml +21 -0
- data/spec/spec_helper.rb +3 -0
- metadata +132 -0
data/.gitignore
ADDED
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,31 @@
|
|
1
|
+
GEM
|
2
|
+
remote: http://rubygems.org/
|
3
|
+
specs:
|
4
|
+
faraday (0.8.0)
|
5
|
+
multipart-post (~> 1.1)
|
6
|
+
httpauth (0.1)
|
7
|
+
multi_json (1.3.2)
|
8
|
+
multi_xml (0.4.4)
|
9
|
+
multipart-post (1.1.5)
|
10
|
+
oauth (0.4.6)
|
11
|
+
oauth2 (0.6.1)
|
12
|
+
faraday (~> 0.7)
|
13
|
+
httpauth (~> 0.1)
|
14
|
+
multi_json (~> 1.3)
|
15
|
+
rack (1.4.1)
|
16
|
+
rack-protection (1.2.0)
|
17
|
+
rack
|
18
|
+
sinatra (1.3.2)
|
19
|
+
rack (~> 1.3, >= 1.3.6)
|
20
|
+
rack-protection (~> 1.2)
|
21
|
+
tilt (~> 1.3, >= 1.3.3)
|
22
|
+
tilt (1.3.3)
|
23
|
+
|
24
|
+
PLATFORMS
|
25
|
+
ruby
|
26
|
+
|
27
|
+
DEPENDENCIES
|
28
|
+
multi_xml
|
29
|
+
oauth
|
30
|
+
oauth2
|
31
|
+
sinatra
|
data/NOTE.rdoc
ADDED
@@ -0,0 +1,17 @@
|
|
1
|
+
|
2
|
+
== About Twitter
|
3
|
+
|
4
|
+
* API Document: https://dev.twitter.com/docs
|
5
|
+
* Application Registration: https://dev.twitter.com/apps
|
6
|
+
* You should set "http://www.example.com/dummy/oauth/callback" into the callback URL. (You can set any URL unless it is empty. But maybe "www.example.com" will be better.)
|
7
|
+
|
8
|
+
== About Tumblr
|
9
|
+
|
10
|
+
* API Document: http://www.tumblr.com/docs/en/api/v2
|
11
|
+
* Application Registration: http://www.tumblr.com/oauth/apps
|
12
|
+
* You MUST set "http://localhost:13480/oauth/callback" into the default callback URL.
|
13
|
+
|
14
|
+
== About GitHub
|
15
|
+
|
16
|
+
* API Document: http://developer.github.com/v3/
|
17
|
+
* Application Registration: https://github.com/settings/applications
|
data/README.rdoc
ADDED
@@ -0,0 +1,28 @@
|
|
1
|
+
= Myoack
|
2
|
+
|
3
|
+
* http://github.com/pasberth/Myoack
|
4
|
+
|
5
|
+
== Description
|
6
|
+
|
7
|
+
Defaults on the authorization to scribbled script by My OAuth Consumer Key
|
8
|
+
|
9
|
+
== Usage
|
10
|
+
|
11
|
+
=== Only a authorize on the web service at first.
|
12
|
+
|
13
|
+
Get a your consumer key from OAuth authorization wbe service.
|
14
|
+
for example, take it from https://dev.twitter.com/apps when you like the twitter.
|
15
|
+
|
16
|
+
Set the consumer key into "$HOME/.myoack/keys.yml".
|
17
|
+
|
18
|
+
twitter:
|
19
|
+
consumer_key: YOUR_CONSUMER_KEY
|
20
|
+
consumer_secret: YOUR_CONSUMER_SECRET
|
21
|
+
|
22
|
+
Run command "myoack-local-authorization-server.rb". this command will use 13480 port.
|
23
|
+
|
24
|
+
Run command "myoack.rb --auth <ID>"
|
25
|
+
|
26
|
+
$ myoack.rb --auth twitter
|
27
|
+
|
28
|
+
Let's scribble some short and simple script, and use consumer key and access token in the script.
|
data/VERSION
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
0.0.1
|
data/bin/myoack.rb
ADDED
@@ -0,0 +1,13 @@
|
|
1
|
+
require 'myoack'
|
2
|
+
require 'oauth2'
|
3
|
+
require 'json'
|
4
|
+
require 'pp'
|
5
|
+
|
6
|
+
cfg = Myoack::Config.require_config(:github)
|
7
|
+
client = OAuth2::Client.new( cfg.client_id,
|
8
|
+
cfg.client_secret,
|
9
|
+
:site => cfg.site,
|
10
|
+
:authorize_url => cfg.authorize_url,
|
11
|
+
:token_url => cfg.access_token_url )
|
12
|
+
acs = OAuth2::AccessToken.new( client, cfg.access_token )
|
13
|
+
pp JSON.parse(acs.get('/gists').body)
|
@@ -0,0 +1,15 @@
|
|
1
|
+
require 'myoack'
|
2
|
+
require 'oauth'
|
3
|
+
require 'json'
|
4
|
+
require 'pp'
|
5
|
+
|
6
|
+
cfg = Myoack::Config.require_config(:twitter)
|
7
|
+
consumer = OAuth::Consumer.new(
|
8
|
+
cfg.consumer_key,
|
9
|
+
cfg.consumer_secret,
|
10
|
+
:site => cfg.site)
|
11
|
+
acs = OAuth::AccessToken.new(
|
12
|
+
consumer,
|
13
|
+
cfg.access_token,
|
14
|
+
cfg.access_token_secret)
|
15
|
+
pp JSON.parse(acs.get('/statuses/mentions.json').body)
|
@@ -0,0 +1,18 @@
|
|
1
|
+
require 'tumblife'
|
2
|
+
require 'myoack'
|
3
|
+
require 'oauth'
|
4
|
+
require 'json'
|
5
|
+
require 'pp'
|
6
|
+
|
7
|
+
cfg = Myoack::Config.require_config(:tumblr)
|
8
|
+
consumer = OAuth::Consumer.new(
|
9
|
+
cfg.consumer_key,
|
10
|
+
cfg.consumer_secret,
|
11
|
+
:site => cfg.site)
|
12
|
+
acs = OAuth::AccessToken.new(
|
13
|
+
consumer,
|
14
|
+
cfg.access_token,
|
15
|
+
cfg.access_token_secret)
|
16
|
+
|
17
|
+
tumb = Tumblife.new acs
|
18
|
+
pp tumb.dashboard.posts
|
@@ -0,0 +1,99 @@
|
|
1
|
+
require 'optparse'
|
2
|
+
|
3
|
+
module Myoack
|
4
|
+
|
5
|
+
MYOACK_HOME = File.join(ENV["HOME"], '.myoack')
|
6
|
+
|
7
|
+
class ConfigManager
|
8
|
+
|
9
|
+
def initialize home=MYOACK_HOME
|
10
|
+
@home = home
|
11
|
+
@init_file_path = File.join(@home, 'init.rb')
|
12
|
+
@keys_file_path = File.join(@home, 'keys.yml')
|
13
|
+
@configs = {}
|
14
|
+
@config_types = {}
|
15
|
+
@config_classes = {}
|
16
|
+
end
|
17
|
+
|
18
|
+
def option_parser
|
19
|
+
OptionParser.new.tap do |opts|
|
20
|
+
opts.on('--authorize ID', 'Try authorize me on the <ID> which is in "$HOME/.myoack/keys.yml".') { |id| authorize(id) }
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
def main *argv
|
25
|
+
init_as_cli
|
26
|
+
option_parser.parse! argv
|
27
|
+
end
|
28
|
+
|
29
|
+
def init_as_cli
|
30
|
+
configure_all
|
31
|
+
if File.exist? @init_file_path
|
32
|
+
load @init_file_path
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
def authorize! id
|
37
|
+
cfg = require_config(id)
|
38
|
+
cfg.authorize!
|
39
|
+
end
|
40
|
+
|
41
|
+
alias authorize authorize!
|
42
|
+
|
43
|
+
def << cfgclass
|
44
|
+
cfg = cfgclass.new(self)
|
45
|
+
add_config(cfgclass.id, cfg) if cfgclass.id
|
46
|
+
add_config_type(cfgclass.type, cfgclass) if cfgclass.type
|
47
|
+
configure cfgclass.id
|
48
|
+
end
|
49
|
+
|
50
|
+
attr_reader :init_file_path
|
51
|
+
attr_reader :keys_file_path
|
52
|
+
attr_reader :configs
|
53
|
+
attr_reader :config_types
|
54
|
+
attr_reader :config_classes
|
55
|
+
|
56
|
+
def load_keys_file
|
57
|
+
YAML.load_file @keys_file_path
|
58
|
+
end
|
59
|
+
|
60
|
+
def dump_config_file cfg
|
61
|
+
open @keys_file_path, 'w' do |f|
|
62
|
+
f.write YAML.dump(cfg)
|
63
|
+
end
|
64
|
+
end
|
65
|
+
|
66
|
+
def configure_all
|
67
|
+
cfg = load_keys_file
|
68
|
+
cfg.each do |id, sitecfg|
|
69
|
+
configure(id, sitecfg) if configs.key? id or sitecfg["site"] && sitecfg["type"]
|
70
|
+
end
|
71
|
+
true
|
72
|
+
end
|
73
|
+
|
74
|
+
def configure id, sitecfg=nil, cfg=nil
|
75
|
+
return nil unless id
|
76
|
+
sitecfg ||= load_keys_file[id.to_s] or return nil
|
77
|
+
cfg ||= configs[id.to_s] ||
|
78
|
+
( cfgclass = config_types[sitecfg["type"]];
|
79
|
+
cfgclass and cfgclass.new(self)) or return nil
|
80
|
+
sitecfg.each { |k,v| cfg.send(:"#{k}=", v) }
|
81
|
+
add_config id, cfg
|
82
|
+
cfg
|
83
|
+
end
|
84
|
+
|
85
|
+
def add_config id, cfg
|
86
|
+
configs[id.to_s] = cfg
|
87
|
+
end
|
88
|
+
|
89
|
+
def add_config_type type, cfgclass
|
90
|
+
config_types[type.to_s] = cfgclass
|
91
|
+
end
|
92
|
+
|
93
|
+
def require_config id
|
94
|
+
configs[id.to_s] or (configure id; configs[id.to_s]) or raise "Myoack don't know '#{id}'."
|
95
|
+
end
|
96
|
+
end
|
97
|
+
|
98
|
+
Config = ConfigManager.new(MYOACK_HOME)
|
99
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
require 'myoack/as_lib'
|
2
|
+
|
3
|
+
module Myoack
|
4
|
+
class GitHubConfig < OAuth2Config
|
5
|
+
|
6
|
+
auto_config :github
|
7
|
+
default :site, "https://api.github.com"
|
8
|
+
default :authorize_url, "https://github.com/login/oauth/authorize"
|
9
|
+
default :access_token_url, "https://github.com/login/oauth/access_token"
|
10
|
+
end
|
11
|
+
|
12
|
+
Config << GitHubConfig
|
13
|
+
end
|
@@ -0,0 +1,165 @@
|
|
1
|
+
require 'yaml'
|
2
|
+
require 'myoack/config_manager'
|
3
|
+
|
4
|
+
module Myoack
|
5
|
+
|
6
|
+
class KeyConfig
|
7
|
+
attr_accessor :id
|
8
|
+
attr_accessor :type
|
9
|
+
|
10
|
+
def self.id *a
|
11
|
+
if a.empty?
|
12
|
+
@id
|
13
|
+
else
|
14
|
+
@id = a[0].to_s
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
def self.type *a
|
19
|
+
if a.empty?
|
20
|
+
@type
|
21
|
+
else
|
22
|
+
@type = a[0].to_s
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
def self.config_defaults
|
27
|
+
@config_defaults ||= {}
|
28
|
+
end
|
29
|
+
|
30
|
+
def self.default key, value
|
31
|
+
config_defaults[key.to_s] = value
|
32
|
+
end
|
33
|
+
|
34
|
+
class << self
|
35
|
+
alias auto_config id
|
36
|
+
alias config_type type
|
37
|
+
end
|
38
|
+
|
39
|
+
def initialize config=Config
|
40
|
+
@config = config
|
41
|
+
self.id = self.class.id
|
42
|
+
self.type = self.class.type
|
43
|
+
self.class.config_defaults.each { |k, v| send(:"#{k}=", v) }
|
44
|
+
end
|
45
|
+
|
46
|
+
attr_accessor :config
|
47
|
+
end
|
48
|
+
|
49
|
+
class OAuthConfig < KeyConfig
|
50
|
+
|
51
|
+
config_type :OAuth
|
52
|
+
|
53
|
+
# *Required*
|
54
|
+
# *Example*: "https://api.twitter.com"
|
55
|
+
attr_accessor :site
|
56
|
+
|
57
|
+
# *Optional*
|
58
|
+
# *Example*: "http://api.twitter.com/oauth/request_token"
|
59
|
+
# *Default*: "#@site/oauth/request_token"
|
60
|
+
attr_accessor :request_token_url
|
61
|
+
def request_token_url
|
62
|
+
@request_token_url ||= "#@site/oauth/request_token"
|
63
|
+
end
|
64
|
+
|
65
|
+
# *Optional*
|
66
|
+
# *Example*: "http://api.twitter.com/oauth/authorize"
|
67
|
+
# *Default*: "#@site/oauth/authorize"
|
68
|
+
attr_accessor :authorize_url
|
69
|
+
def authorize_url
|
70
|
+
@authorize_url ||= "#@site/oauth/authorize"
|
71
|
+
end
|
72
|
+
|
73
|
+
# *Optional*
|
74
|
+
# *Example*: "http://api.twitter.com/oauth/access_token"
|
75
|
+
# *Default*: "#@site/oauth/access_token"
|
76
|
+
attr_accessor :access_token_url
|
77
|
+
def access_token_url
|
78
|
+
@access_token_url ||= "#@site/oauth/access_token"
|
79
|
+
end
|
80
|
+
|
81
|
+
attr_accessor :consumer_key
|
82
|
+
attr_accessor :consumer_secret
|
83
|
+
attr_accessor :access_token
|
84
|
+
attr_accessor :access_token_secret
|
85
|
+
|
86
|
+
def authorize!
|
87
|
+
url = "http://%s:%s/oauth/authorize?id=#{id}" % [LocalAuthorization::HOST, LocalAuthorization::PORT]
|
88
|
+
`open "#{url}"`
|
89
|
+
end
|
90
|
+
|
91
|
+
def save
|
92
|
+
cfg = config.load_keys_file
|
93
|
+
cfg[id] = {
|
94
|
+
'site' => site,
|
95
|
+
'request_token_url' => request_token_url,
|
96
|
+
'authorize_url' => authorize_url,
|
97
|
+
'access_token_url' => access_token_url,
|
98
|
+
'consumer_key' => consumer_key,
|
99
|
+
'consumer_secret' => consumer_secret,
|
100
|
+
'access_token' => access_token,
|
101
|
+
'access_token_secret' => access_token_secret
|
102
|
+
}
|
103
|
+
config.dump_config_file cfg
|
104
|
+
end
|
105
|
+
|
106
|
+
def save!
|
107
|
+
save
|
108
|
+
end
|
109
|
+
end
|
110
|
+
|
111
|
+
Config << OAuthConfig
|
112
|
+
|
113
|
+
class OAuth2Config < KeyConfig
|
114
|
+
|
115
|
+
config_type :OAuth2
|
116
|
+
|
117
|
+
# *Required*
|
118
|
+
# *Example*: "https://github.com/login"
|
119
|
+
attr_accessor :site
|
120
|
+
|
121
|
+
# *Optional*
|
122
|
+
# *Example*: "https://github.com/login/oauth/authorize"
|
123
|
+
# *Default*: "#@site/oauth/authorize"
|
124
|
+
attr_accessor :authorize_url
|
125
|
+
def authorize_url
|
126
|
+
@authorize_url ||= "#@site/oauth/authorize"
|
127
|
+
end
|
128
|
+
|
129
|
+
# *Optional*
|
130
|
+
# *Example*: "https://github.com/login/oauth/access_token"
|
131
|
+
# *Default*: "#@site/oauth/access_token"
|
132
|
+
attr_accessor :access_token_url
|
133
|
+
def access_token_url
|
134
|
+
@access_token_url ||= "#@site/oauth/access_token"
|
135
|
+
end
|
136
|
+
|
137
|
+
def authorize!
|
138
|
+
url = "http://%s:%s/oauth2/authorize?id=#{id}" % [LocalAuthorization::HOST, LocalAuthorization::PORT]
|
139
|
+
`open "#{url}"`
|
140
|
+
end
|
141
|
+
|
142
|
+
def save
|
143
|
+
cfg = config.load_keys_file
|
144
|
+
cfg[id] = {
|
145
|
+
'site' => site,
|
146
|
+
'authorize_url' => authorize_url,
|
147
|
+
'access_token_url' => access_token_url,
|
148
|
+
'client_id' => client_id,
|
149
|
+
'client_secret' => client_secret,
|
150
|
+
'access_token' => access_token
|
151
|
+
}
|
152
|
+
config.dump_config_file cfg
|
153
|
+
end
|
154
|
+
|
155
|
+
def save!
|
156
|
+
save
|
157
|
+
end
|
158
|
+
|
159
|
+
attr_accessor :client_id
|
160
|
+
attr_accessor :client_secret
|
161
|
+
attr_accessor :access_token
|
162
|
+
end
|
163
|
+
|
164
|
+
Config << OAuth2Config
|
165
|
+
end
|
@@ -0,0 +1,71 @@
|
|
1
|
+
require 'sinatra/base'
|
2
|
+
require 'oauth'
|
3
|
+
require 'oauth2'
|
4
|
+
|
5
|
+
module Myoack
|
6
|
+
|
7
|
+
class LocalAuthorization < Sinatra::Base
|
8
|
+
enable :sessions
|
9
|
+
HOST = "localhost"
|
10
|
+
PORT = 13480
|
11
|
+
|
12
|
+
get '/oauth/authorize' do
|
13
|
+
cfg = Config.require_config(params[:id])
|
14
|
+
consumer_key = cfg.consumer_key
|
15
|
+
consumer_secret = cfg.consumer_secret
|
16
|
+
consumer = OAuth::Consumer.new( consumer_key,
|
17
|
+
consumer_secret,
|
18
|
+
:site => cfg.site,
|
19
|
+
:request_token_url => cfg.request_token_url,
|
20
|
+
:authorize_url => cfg.authorize_url,
|
21
|
+
:access_token_url => cfg.access_token_url )
|
22
|
+
req = consumer.get_request_token :oauth_callback => "http://#{HOST}:#{PORT}/oauth/callback"
|
23
|
+
session['config_id'] = params[:id]
|
24
|
+
session['request_token'] = req.token
|
25
|
+
session['request_token_secret'] = req.secret
|
26
|
+
redirect req.authorize_url
|
27
|
+
end
|
28
|
+
|
29
|
+
get '/oauth/callback' do
|
30
|
+
cfg = Config.require_config(session['config_id'])
|
31
|
+
consumer_key = cfg.consumer_key
|
32
|
+
consumer_secret = cfg.consumer_secret
|
33
|
+
consumer = OAuth::Consumer.new( consumer_key,
|
34
|
+
consumer_secret,
|
35
|
+
:site => cfg.site,
|
36
|
+
:request_token_url => cfg.request_token_url,
|
37
|
+
:authorize_url => cfg.authorize_url,
|
38
|
+
:access_token_url => cfg.access_token_url )
|
39
|
+
req = OAuth::RequestToken.new consumer, session['request_token'], session['request_token_secret']
|
40
|
+
acs = req.get_access_token :oauth_token => params[:oauth_token], :oauth_verifier => params[:oauth_verifier]
|
41
|
+
cfg.access_token = acs.token
|
42
|
+
cfg.access_token_secret = acs.secret
|
43
|
+
cfg.save!
|
44
|
+
"Configured successful!"
|
45
|
+
end
|
46
|
+
|
47
|
+
get '/oauth2/authorize' do
|
48
|
+
cfg = Config.require_config(params[:id])
|
49
|
+
client = OAuth2::Client.new( cfg.client_id,
|
50
|
+
cfg.client_secret,
|
51
|
+
:site => cfg.site,
|
52
|
+
:authorize_url => cfg.authorize_url,
|
53
|
+
:token_url => cfg.access_token_url )
|
54
|
+
session['config_id'] = params[:id]
|
55
|
+
redirect client.auth_code.authorize_url :redirect_uri => "http://#{HOST}:#{PORT}/oauth2/callback"
|
56
|
+
end
|
57
|
+
|
58
|
+
get '/oauth2/callback' do
|
59
|
+
cfg = Config.require_config(session['config_id'])
|
60
|
+
client = OAuth2::Client.new( cfg.client_id,
|
61
|
+
cfg.client_secret,
|
62
|
+
:site => cfg.site,
|
63
|
+
:authorize_url => cfg.authorize_url,
|
64
|
+
:token_url => cfg.access_token_url )
|
65
|
+
token = client.auth_code.get_token params[:code], :redirect_uri => "http://#{HOST}:#{PORT}/oauth2/callback"
|
66
|
+
cfg.access_token = token.token
|
67
|
+
cfg.save!
|
68
|
+
"Configured successful!"
|
69
|
+
end
|
70
|
+
end
|
71
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
require 'myoack/as_lib'
|
2
|
+
|
3
|
+
module Myoack
|
4
|
+
class TumblrConfig < OAuthConfig
|
5
|
+
|
6
|
+
auto_config :tumblr
|
7
|
+
default :site, "http://api.tumblr.com/v2"
|
8
|
+
default :request_token_url, "http://www.tumblr.com/oauth/request_token"
|
9
|
+
default :authorize_url, "http://www.tumblr.com/oauth/authorize"
|
10
|
+
default :access_token_url, "http://www.tumblr.com/oauth/access_token"
|
11
|
+
end
|
12
|
+
|
13
|
+
Config << TumblrConfig
|
14
|
+
end
|
data/lib/myoack.rb
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require 'myoack/as_cli'
|
data/myoack.gemspec
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Gem::Specification.new do |s|
|
2
|
+
s.name = "myoack"
|
3
|
+
s.version = File.read("VERSION")
|
4
|
+
s.authors = ["pasberth"]
|
5
|
+
s.description = %{Defaults on the authorization to scribbled script by My OAuth Consumer Key}
|
6
|
+
s.summary = %q{first release}
|
7
|
+
s.email = "pasberth@gmail.com"
|
8
|
+
s.extra_rdoc_files = ["README.rdoc"]
|
9
|
+
s.rdoc_options = ["--charset=UTF-8"]
|
10
|
+
s.homepage = "http://github.com/pasberth/Myoack"
|
11
|
+
s.require_paths = ["lib"]
|
12
|
+
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
13
|
+
s.files = `git ls-files`.split("\n")
|
14
|
+
s.test_files = `git ls-files -- spec/*`.split("\n")
|
15
|
+
s.add_development_dependency "rake"
|
16
|
+
s.add_development_dependency "rspec"
|
17
|
+
s.add_development_dependency "sinatra", "~> 1.3.0"
|
18
|
+
s.add_development_dependency "oauth"
|
19
|
+
s.add_development_dependency "yaml"
|
20
|
+
end
|
@@ -0,0 +1,52 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Myoack::ConfigManager do
|
4
|
+
let(:cm) { described_class.new(File.dirname(__FILE__) + '/myoack_home_example') }
|
5
|
+
subject { cm }
|
6
|
+
its(:configs) { should_not be_nil }
|
7
|
+
its(:config_types) { should_not be_nil }
|
8
|
+
|
9
|
+
describe "#require_config(:twitter)" do
|
10
|
+
let(:cfg) { cm << Myoack::TwitterConfig; cm.require_config(:twitter) }
|
11
|
+
subject { cfg }
|
12
|
+
its(:site) { should == "https://api.twitter.com" }
|
13
|
+
its(:consumer_key) { should == "YOUR_CONSUMER_KEY" }
|
14
|
+
its(:consumer_secret) { should == "YOUR_CONSUMER_SECRET" }
|
15
|
+
its(:access_token) { should == "YOUR_ACCESS_TOKEN" }
|
16
|
+
its(:access_token_secret) { should == "YOUR_ACCESS_TOKEN_SECRET" }
|
17
|
+
end
|
18
|
+
|
19
|
+
describe "#require_config(:tumblr)" do
|
20
|
+
let(:cfg) { cm << Myoack::TumblrConfig; cm.require_config(:tumblr) }
|
21
|
+
subject { cfg }
|
22
|
+
its(:site) { should == "http://api.tumblr.com/v2" }
|
23
|
+
its(:request_token_url) { should == "http://www.tumblr.com/oauth/request_token" }
|
24
|
+
its(:authorize_url) { should == "http://www.tumblr.com/oauth/authorize" }
|
25
|
+
its(:access_token_url) { should == "http://www.tumblr.com/oauth/access_token" }
|
26
|
+
its(:consumer_key) { should == "YOUR_CONSUMER_KEY" }
|
27
|
+
its(:consumer_secret) { should == "YOUR_CONSUMER_SECRET" }
|
28
|
+
its(:access_token) { should == "YOUR_ACCESS_TOKEN" }
|
29
|
+
its(:access_token_secret) { should == "YOUR_ACCESS_TOKEN_SECRET" }
|
30
|
+
end
|
31
|
+
|
32
|
+
describe "#require_config(:tumblr)" do
|
33
|
+
let(:cfg) { cm << Myoack::GitHubConfig; cm.require_config(:github) }
|
34
|
+
subject { cfg }
|
35
|
+
its(:site) { should == "https://api.github.com" }
|
36
|
+
its(:authorize_url) { should == "https://github.com/login/oauth/authorize" }
|
37
|
+
its(:access_token_url) { should == "https://github.com/login/oauth/access_token" }
|
38
|
+
its(:client_id) { should == "YOUR_CLIENT_ID" }
|
39
|
+
its(:client_secret) { should == "YOUR_CLIENT_SECRET" }
|
40
|
+
its(:access_token) { should == "YOUR_ACCESS_TOKEN" }
|
41
|
+
end
|
42
|
+
|
43
|
+
describe "#require_config(:somesite_example)" do
|
44
|
+
let(:cfg) { cm << Myoack::OAuthConfig; cm.require_config(:somesite_example) }
|
45
|
+
subject { cfg }
|
46
|
+
its(:site) { should == "https://www.example.com" }
|
47
|
+
its(:consumer_key) { should == "SOMESITE_CONSUMER_KEY_EXAMPLE" }
|
48
|
+
its(:consumer_secret) { should == "SOMESITE_CONSUMER_KEY_EXAMPLE" }
|
49
|
+
its(:access_token) { should == "SOMESITE_ACCESS_TOKEN_EXAMPL" }
|
50
|
+
its(:access_token_secret) { should == "SOMESITE_ACCESS_TOKEN_SECRET_EXAMPLE" }
|
51
|
+
end
|
52
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
twitter:
|
2
|
+
consumer_key: YOUR_CONSUMER_KEY
|
3
|
+
consumer_secret: YOUR_CONSUMER_SECRET
|
4
|
+
access_token: YOUR_ACCESS_TOKEN
|
5
|
+
access_token_secret: YOUR_ACCESS_TOKEN_SECRET
|
6
|
+
tumblr:
|
7
|
+
consumer_key: YOUR_CONSUMER_KEY
|
8
|
+
consumer_secret: YOUR_CONSUMER_SECRET
|
9
|
+
access_token: YOUR_ACCESS_TOKEN
|
10
|
+
access_token_secret: YOUR_ACCESS_TOKEN_SECRET
|
11
|
+
github:
|
12
|
+
client_id: YOUR_CLIENT_ID
|
13
|
+
client_secret: YOUR_CLIENT_SECRET
|
14
|
+
access_token: YOUR_ACCESS_TOKEN
|
15
|
+
somesite_example:
|
16
|
+
type: OAuth
|
17
|
+
site: https://www.example.com
|
18
|
+
consumer_key: SOMESITE_CONSUMER_KEY_EXAMPLE
|
19
|
+
consumer_secret: SOMESITE_CONSUMER_KEY_EXAMPLE
|
20
|
+
access_token: SOMESITE_ACCESS_TOKEN_EXAMPL
|
21
|
+
access_token_secret: SOMESITE_ACCESS_TOKEN_SECRET_EXAMPLE
|
data/spec/spec_helper.rb
ADDED
metadata
ADDED
@@ -0,0 +1,132 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: myoack
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- pasberth
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2012-04-23 00:00:00.000000000Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: rake
|
16
|
+
requirement: &70225170158420 !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ! '>='
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: '0'
|
22
|
+
type: :development
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: *70225170158420
|
25
|
+
- !ruby/object:Gem::Dependency
|
26
|
+
name: rspec
|
27
|
+
requirement: &70225170157380 !ruby/object:Gem::Requirement
|
28
|
+
none: false
|
29
|
+
requirements:
|
30
|
+
- - ! '>='
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: '0'
|
33
|
+
type: :development
|
34
|
+
prerelease: false
|
35
|
+
version_requirements: *70225170157380
|
36
|
+
- !ruby/object:Gem::Dependency
|
37
|
+
name: sinatra
|
38
|
+
requirement: &70225170155900 !ruby/object:Gem::Requirement
|
39
|
+
none: false
|
40
|
+
requirements:
|
41
|
+
- - ~>
|
42
|
+
- !ruby/object:Gem::Version
|
43
|
+
version: 1.3.0
|
44
|
+
type: :development
|
45
|
+
prerelease: false
|
46
|
+
version_requirements: *70225170155900
|
47
|
+
- !ruby/object:Gem::Dependency
|
48
|
+
name: oauth
|
49
|
+
requirement: &70225170155060 !ruby/object:Gem::Requirement
|
50
|
+
none: false
|
51
|
+
requirements:
|
52
|
+
- - ! '>='
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
type: :development
|
56
|
+
prerelease: false
|
57
|
+
version_requirements: *70225170155060
|
58
|
+
- !ruby/object:Gem::Dependency
|
59
|
+
name: yaml
|
60
|
+
requirement: &70225170154440 !ruby/object:Gem::Requirement
|
61
|
+
none: false
|
62
|
+
requirements:
|
63
|
+
- - ! '>='
|
64
|
+
- !ruby/object:Gem::Version
|
65
|
+
version: '0'
|
66
|
+
type: :development
|
67
|
+
prerelease: false
|
68
|
+
version_requirements: *70225170154440
|
69
|
+
description: Defaults on the authorization to scribbled script by My OAuth Consumer
|
70
|
+
Key
|
71
|
+
email: pasberth@gmail.com
|
72
|
+
executables:
|
73
|
+
- myoack-local-authorization-server.rb
|
74
|
+
- myoack.rb
|
75
|
+
extensions: []
|
76
|
+
extra_rdoc_files:
|
77
|
+
- README.rdoc
|
78
|
+
files:
|
79
|
+
- .gitignore
|
80
|
+
- Gemfile
|
81
|
+
- Gemfile.lock
|
82
|
+
- NOTE.rdoc
|
83
|
+
- README.rdoc
|
84
|
+
- VERSION
|
85
|
+
- bin/myoack-local-authorization-server.rb
|
86
|
+
- bin/myoack.rb
|
87
|
+
- examples/get_gists_from_github.rb
|
88
|
+
- examples/get_mentions_from_twitter.rb
|
89
|
+
- examples/get_posts_from_tumblr.rb
|
90
|
+
- lib/myoack.rb
|
91
|
+
- lib/myoack/as_cli.rb
|
92
|
+
- lib/myoack/as_lib.rb
|
93
|
+
- lib/myoack/config_manager.rb
|
94
|
+
- lib/myoack/github.rb
|
95
|
+
- lib/myoack/key_config.rb
|
96
|
+
- lib/myoack/local_authorization.rb
|
97
|
+
- lib/myoack/tumblr.rb
|
98
|
+
- lib/myoack/twitter.rb
|
99
|
+
- myoack.gemspec
|
100
|
+
- spec/config_manager_spec.rb
|
101
|
+
- spec/myoack_home_example/keys.yml
|
102
|
+
- spec/spec_helper.rb
|
103
|
+
homepage: http://github.com/pasberth/Myoack
|
104
|
+
licenses: []
|
105
|
+
post_install_message:
|
106
|
+
rdoc_options:
|
107
|
+
- --charset=UTF-8
|
108
|
+
require_paths:
|
109
|
+
- lib
|
110
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
111
|
+
none: false
|
112
|
+
requirements:
|
113
|
+
- - ! '>='
|
114
|
+
- !ruby/object:Gem::Version
|
115
|
+
version: '0'
|
116
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
117
|
+
none: false
|
118
|
+
requirements:
|
119
|
+
- - ! '>='
|
120
|
+
- !ruby/object:Gem::Version
|
121
|
+
version: '0'
|
122
|
+
requirements: []
|
123
|
+
rubyforge_project:
|
124
|
+
rubygems_version: 1.8.10
|
125
|
+
signing_key:
|
126
|
+
specification_version: 3
|
127
|
+
summary: first release
|
128
|
+
test_files:
|
129
|
+
- spec/config_manager_spec.rb
|
130
|
+
- spec/myoack_home_example/keys.yml
|
131
|
+
- spec/spec_helper.rb
|
132
|
+
has_rdoc:
|