oauth-cli-twitter 0.0.2 → 0.0.4
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +2 -2
- data/Rakefile +4 -7
- data/VERSION +1 -1
- data/lib/oauth/cli/twitter.rb +19 -8
- data/oauth-cli-twitter.gemspec +4 -19
- data/spec/oauth_cli_twitter_spec.rb +28 -14
- data/spec/spec_helper.rb +2 -6
- metadata +54 -88
- data/.gitignore +0 -21
data/README.md
CHANGED
data/Rakefile
CHANGED
@@ -21,17 +21,14 @@ rescue LoadError
|
|
21
21
|
puts "Jeweler (or a dependency) not available. Install it with: gem install jeweler"
|
22
22
|
end
|
23
23
|
|
24
|
-
require '
|
25
|
-
|
26
|
-
spec.
|
27
|
-
spec.spec_files = FileList['spec/**/*_spec.rb']
|
24
|
+
require 'rspec/core/rake_task'
|
25
|
+
RSpec::Core::RakeTask.new(:spec) do |spec|
|
26
|
+
spec.pattern = FileList['spec/**/*_spec.rb']
|
28
27
|
end
|
29
28
|
|
30
|
-
|
31
|
-
spec.libs << 'lib' << 'spec'
|
29
|
+
RSpec::Core::RakeTask.new(:rcov) do |spec|
|
32
30
|
spec.pattern = 'spec/**/*_spec.rb'
|
33
31
|
spec.rcov = true
|
34
|
-
spec.rcov_opts = ["--gcc"]
|
35
32
|
end
|
36
33
|
|
37
34
|
task :spec => :check_dependencies
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.0.
|
1
|
+
0.0.4
|
data/lib/oauth/cli/twitter.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
|
2
|
+
require 'readline'
|
2
3
|
require 'rubygems'
|
3
4
|
require 'oauth'
|
4
|
-
require 'readline'
|
5
5
|
require 'termtter/system_extensions'
|
6
6
|
require 'pit'
|
7
7
|
|
@@ -16,14 +16,23 @@ module OAuth
|
|
16
16
|
def self.included(includer)
|
17
17
|
@includer = includer
|
18
18
|
end
|
19
|
-
|
19
|
+
|
20
|
+
def self.extended(extender)
|
21
|
+
@extender = extender
|
22
|
+
end
|
23
|
+
|
24
|
+
attr_accessor :includer, :extender
|
20
25
|
|
21
26
|
def get_access_token(*args)
|
22
27
|
case args.size
|
23
28
|
when 1
|
24
29
|
@options = args[0]
|
25
|
-
|
26
|
-
|
30
|
+
if Twitter.extender &&
|
31
|
+
Twitter.extender.const_defined?(:CONSUMER_TOKEN) &&
|
32
|
+
Twitter.extender.const_defined?(:CONSUMER_SECRET)
|
33
|
+
@consumer_token = Twitter.extender::CONSUMER_TOKEN
|
34
|
+
@consumer_secret = Twitter.extender::CONSUMER_SECRET
|
35
|
+
elsif Twitter.includer &&
|
27
36
|
Twitter.includer.const_defined?(:CONSUMER_TOKEN) &&
|
28
37
|
Twitter.includer.const_defined?(:CONSUMER_SECRET)
|
29
38
|
@consumer_token = Twitter.includer::CONSUMER_TOKEN
|
@@ -55,7 +64,7 @@ module OAuth
|
|
55
64
|
@access_token.params = config
|
56
65
|
else
|
57
66
|
@access_token = authorize
|
58
|
-
save_config(
|
67
|
+
save_config(@access_token)
|
59
68
|
end
|
60
69
|
@access_token
|
61
70
|
end
|
@@ -68,9 +77,11 @@ module OAuth
|
|
68
77
|
end
|
69
78
|
end
|
70
79
|
|
71
|
-
def save_config(
|
72
|
-
config = {}
|
73
|
-
|
80
|
+
def save_config(access_token)
|
81
|
+
config = {}
|
82
|
+
access_token.params.each do |k, v|
|
83
|
+
config[k] = v if k.is_a?(String)
|
84
|
+
end
|
74
85
|
if @options[:pit]
|
75
86
|
Pit.set(@options[:pit], :data => config)
|
76
87
|
elsif @options[:file]
|
data/oauth-cli-twitter.gemspec
CHANGED
@@ -5,30 +5,24 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{oauth-cli-twitter}
|
8
|
-
s.version = "0.0.
|
8
|
+
s.version = "0.0.0"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["tily"]
|
12
|
-
s.date = %q{2010-10-
|
12
|
+
s.date = %q{2010-10-29}
|
13
13
|
s.description = %q{Twitter OAuth Interface for CLI Applications}
|
14
14
|
s.email = %q{tily05@gmail.com}
|
15
15
|
s.extra_rdoc_files = [
|
16
16
|
"LICENSE",
|
17
|
-
"README.
|
17
|
+
"README.rdoc"
|
18
18
|
]
|
19
19
|
s.files = [
|
20
20
|
".document",
|
21
21
|
".gitignore",
|
22
22
|
"LICENSE",
|
23
|
-
"README.
|
23
|
+
"README.rdoc",
|
24
24
|
"Rakefile",
|
25
25
|
"VERSION",
|
26
|
-
"example/define_constant.rb",
|
27
|
-
"example/inclusion.rb",
|
28
|
-
"example/simple.rb",
|
29
|
-
"lib/oauth/cli/twitter.rb",
|
30
|
-
"oauth-cli-twitter.gemspec",
|
31
|
-
"spec/oauth_cli_twitter_spec.rb",
|
32
26
|
"spec/spec.opts",
|
33
27
|
"spec/spec_helper.rb"
|
34
28
|
]
|
@@ -48,20 +42,11 @@ Gem::Specification.new do |s|
|
|
48
42
|
|
49
43
|
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
50
44
|
s.add_development_dependency(%q<rspec>, [">= 1.2.9"])
|
51
|
-
s.add_runtime_dependency(%q<oauth>, [">= 0"])
|
52
|
-
s.add_runtime_dependency(%q<termtter>, [">= 0"])
|
53
|
-
s.add_runtime_dependency(%q<pit>, [">= 0"])
|
54
45
|
else
|
55
46
|
s.add_dependency(%q<rspec>, [">= 1.2.9"])
|
56
|
-
s.add_dependency(%q<oauth>, [">= 0"])
|
57
|
-
s.add_dependency(%q<termtter>, [">= 0"])
|
58
|
-
s.add_dependency(%q<pit>, [">= 0"])
|
59
47
|
end
|
60
48
|
else
|
61
49
|
s.add_dependency(%q<rspec>, [">= 1.2.9"])
|
62
|
-
s.add_dependency(%q<oauth>, [">= 0"])
|
63
|
-
s.add_dependency(%q<termtter>, [">= 0"])
|
64
|
-
s.add_dependency(%q<pit>, [">= 0"])
|
65
50
|
end
|
66
51
|
end
|
67
52
|
|
@@ -2,7 +2,9 @@ require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
|
|
2
2
|
|
3
3
|
describe OAuth::CLI::Twitter do
|
4
4
|
before do
|
5
|
-
@
|
5
|
+
@klass = Class.new
|
6
|
+
@klass.send(:include, OAuth::CLI::Twitter)
|
7
|
+
@twitter = @klass.new
|
6
8
|
end
|
7
9
|
|
8
10
|
describe 'taking arguments' do
|
@@ -49,11 +51,11 @@ describe OAuth::CLI::Twitter do
|
|
49
51
|
|
50
52
|
it '#get_access_token gets constants of Object' do
|
51
53
|
@twitter.should_receive(:execute).and_return(@access_token)
|
52
|
-
|
53
|
-
|
54
|
+
@klass::CONSUMER_TOKEN = 'object consumer token'
|
55
|
+
@klass::CONSUMER_SECRET = 'object consumer secret'
|
54
56
|
@twitter.get_access_token(@options)
|
55
|
-
@twitter.instance_variable_get('@consumer_token').should ==
|
56
|
-
@twitter.instance_variable_get('@consumer_secret').should ==
|
57
|
+
@twitter.instance_variable_get('@consumer_token').should == @klass::CONSUMER_TOKEN
|
58
|
+
@twitter.instance_variable_get('@consumer_secret').should == @klass::CONSUMER_SECRET
|
57
59
|
end
|
58
60
|
|
59
61
|
it '#get_access_token gets constants of includer' do
|
@@ -66,6 +68,17 @@ describe OAuth::CLI::Twitter do
|
|
66
68
|
@twitter.instance_variable_get('@consumer_token').should == @klass::CONSUMER_TOKEN
|
67
69
|
@twitter.instance_variable_get('@consumer_secret').should == @klass::CONSUMER_SECRET
|
68
70
|
end
|
71
|
+
|
72
|
+
it '#get_access_token gets constants of extender' do
|
73
|
+
@twitter.should_receive(:execute).and_return(@access_token)
|
74
|
+
@obj = Class.new
|
75
|
+
@obj::CONSUMER_TOKEN = 'extender consumer token'
|
76
|
+
@obj::CONSUMER_SECRET = 'extender consumer secret'
|
77
|
+
@obj.send(:extend, OAuth::CLI::Twitter)
|
78
|
+
@twitter.get_access_token(@options)
|
79
|
+
@twitter.instance_variable_get('@consumer_token').should == @obj::CONSUMER_TOKEN
|
80
|
+
@twitter.instance_variable_get('@consumer_secret').should == @obj::CONSUMER_SECRET
|
81
|
+
end
|
69
82
|
end
|
70
83
|
|
71
84
|
describe 'execution' do
|
@@ -76,6 +89,7 @@ describe OAuth::CLI::Twitter do
|
|
76
89
|
it '#execute and config loaded' do
|
77
90
|
config = {'oauth_token' => 'dummy oauth token', 'oauth_token_secret' => 'dummy oauth token secret'}
|
78
91
|
consumer = 'dummy consumer'
|
92
|
+
@access_token.should_receive(:params=).with(config)
|
79
93
|
@twitter.should_receive(:load_config).and_return(config)
|
80
94
|
@twitter.should_receive(:consumer).and_return(consumer)
|
81
95
|
OAuth::AccessToken.should_receive(:new).with(consumer, config['oauth_token'], config['oauth_token_secret']).and_return(@access_token)
|
@@ -86,7 +100,7 @@ describe OAuth::CLI::Twitter do
|
|
86
100
|
config = {}
|
87
101
|
@twitter.should_receive(:load_config).and_return(config)
|
88
102
|
@twitter.should_receive(:authorize).and_return(@access_token)
|
89
|
-
@twitter.should_receive(:save_config).with(
|
103
|
+
@twitter.should_receive(:save_config).with(@access_token)
|
90
104
|
@twitter.execute.should == @access_token
|
91
105
|
end
|
92
106
|
end
|
@@ -109,6 +123,7 @@ describe OAuth::CLI::Twitter do
|
|
109
123
|
file = '/path/to/.conf'
|
110
124
|
yaml = '- dummy yaml'
|
111
125
|
|
126
|
+
File.should_receive(:exist?).with(file).and_return(true)
|
112
127
|
File.should_receive(:read).with(file).and_return(yaml)
|
113
128
|
YAML.should_receive(:load).with(yaml).and_return(@config)
|
114
129
|
|
@@ -119,34 +134,33 @@ describe OAuth::CLI::Twitter do
|
|
119
134
|
|
120
135
|
describe 'saving config' do
|
121
136
|
before do
|
122
|
-
@
|
123
|
-
|
124
|
-
|
125
|
-
@config = mock.tap {|m| m.should_receive(:update).with('dummy access token params') }
|
137
|
+
@config = {'string_key' => 'value', :symbol_key => :value}
|
138
|
+
@access_token = mock.tap {|m| m.should_receive(:params).and_return(@config) }
|
139
|
+
@twitter.instance_variable_set('@access_token', @access_token)
|
126
140
|
end
|
127
141
|
|
128
142
|
it '#save_config to pit' do
|
129
143
|
pit = 'pit key'
|
144
|
+
data = {'string_key' => 'value'}
|
130
145
|
|
131
|
-
Pit.should_receive(:set).with(pit, :data =>
|
146
|
+
Pit.should_receive(:set).with(pit, :data => data)
|
132
147
|
|
133
148
|
@twitter.instance_variable_set('@options', {:pit => pit})
|
134
149
|
end
|
135
150
|
|
136
151
|
it '#save_config to file' do
|
137
152
|
file = '/path/to/.conf'
|
138
|
-
yaml =
|
153
|
+
yaml = "--- \nstring_key: value\n"
|
139
154
|
|
140
155
|
File.should_receive(:open).with(file, 'w').and_yield(
|
141
156
|
mock.tap {|m| m.should_receive(:write).with(yaml) }
|
142
157
|
)
|
143
|
-
@config.should_receive(:to_yaml).and_return(yaml)
|
144
158
|
|
145
159
|
@twitter.instance_variable_set('@options', {:file => file})
|
146
160
|
end
|
147
161
|
|
148
162
|
after do
|
149
|
-
@twitter.save_config(@
|
163
|
+
@twitter.save_config(@access_token)
|
150
164
|
end
|
151
165
|
end
|
152
166
|
|
data/spec/spec_helper.rb
CHANGED
@@ -1,9 +1,5 @@
|
|
1
1
|
$LOAD_PATH.unshift(File.dirname(__FILE__))
|
2
2
|
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
|
3
3
|
require 'oauth/cli/twitter'
|
4
|
-
require '
|
5
|
-
require '
|
6
|
-
|
7
|
-
Spec::Runner.configure do |config|
|
8
|
-
|
9
|
-
end
|
4
|
+
require 'rspec'
|
5
|
+
require 'rspec/autorun'
|
metadata
CHANGED
@@ -1,93 +1,70 @@
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
2
|
name: oauth-cli-twitter
|
3
|
-
version: !ruby/object:Gem::Version
|
4
|
-
|
5
|
-
prerelease:
|
6
|
-
segments:
|
7
|
-
- 0
|
8
|
-
- 0
|
9
|
-
- 2
|
10
|
-
version: 0.0.2
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.4
|
5
|
+
prerelease:
|
11
6
|
platform: ruby
|
12
|
-
authors:
|
7
|
+
authors:
|
13
8
|
- tily
|
14
9
|
autorequire:
|
15
10
|
bindir: bin
|
16
11
|
cert_chain: []
|
17
|
-
|
18
|
-
date: 2010-10-31 00:00:00 +09:00
|
12
|
+
date: 2011-10-06 00:00:00.000000000 +09:00
|
19
13
|
default_executable:
|
20
|
-
dependencies:
|
21
|
-
- !ruby/object:Gem::Dependency
|
14
|
+
dependencies:
|
15
|
+
- !ruby/object:Gem::Dependency
|
22
16
|
name: rspec
|
23
|
-
|
24
|
-
requirement: &id001 !ruby/object:Gem::Requirement
|
17
|
+
requirement: &209398320 !ruby/object:Gem::Requirement
|
25
18
|
none: false
|
26
|
-
requirements:
|
27
|
-
- -
|
28
|
-
- !ruby/object:Gem::Version
|
29
|
-
hash: 13
|
30
|
-
segments:
|
31
|
-
- 1
|
32
|
-
- 2
|
33
|
-
- 9
|
19
|
+
requirements:
|
20
|
+
- - ! '>='
|
21
|
+
- !ruby/object:Gem::Version
|
34
22
|
version: 1.2.9
|
35
23
|
type: :development
|
36
|
-
version_requirements: *id001
|
37
|
-
- !ruby/object:Gem::Dependency
|
38
|
-
name: oauth
|
39
24
|
prerelease: false
|
40
|
-
|
25
|
+
version_requirements: *209398320
|
26
|
+
- !ruby/object:Gem::Dependency
|
27
|
+
name: oauth
|
28
|
+
requirement: &209397700 !ruby/object:Gem::Requirement
|
41
29
|
none: false
|
42
|
-
requirements:
|
43
|
-
- -
|
44
|
-
- !ruby/object:Gem::Version
|
45
|
-
|
46
|
-
segments:
|
47
|
-
- 0
|
48
|
-
version: "0"
|
30
|
+
requirements:
|
31
|
+
- - ! '>='
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
49
34
|
type: :runtime
|
50
|
-
version_requirements: *id002
|
51
|
-
- !ruby/object:Gem::Dependency
|
52
|
-
name: termtter
|
53
35
|
prerelease: false
|
54
|
-
|
36
|
+
version_requirements: *209397700
|
37
|
+
- !ruby/object:Gem::Dependency
|
38
|
+
name: termtter
|
39
|
+
requirement: &209396800 !ruby/object:Gem::Requirement
|
55
40
|
none: false
|
56
|
-
requirements:
|
57
|
-
- -
|
58
|
-
- !ruby/object:Gem::Version
|
59
|
-
|
60
|
-
segments:
|
61
|
-
- 0
|
62
|
-
version: "0"
|
41
|
+
requirements:
|
42
|
+
- - ! '>='
|
43
|
+
- !ruby/object:Gem::Version
|
44
|
+
version: '0'
|
63
45
|
type: :runtime
|
64
|
-
version_requirements: *id003
|
65
|
-
- !ruby/object:Gem::Dependency
|
66
|
-
name: pit
|
67
46
|
prerelease: false
|
68
|
-
|
47
|
+
version_requirements: *209396800
|
48
|
+
- !ruby/object:Gem::Dependency
|
49
|
+
name: pit
|
50
|
+
requirement: &209396000 !ruby/object:Gem::Requirement
|
69
51
|
none: false
|
70
|
-
requirements:
|
71
|
-
- -
|
72
|
-
- !ruby/object:Gem::Version
|
73
|
-
|
74
|
-
segments:
|
75
|
-
- 0
|
76
|
-
version: "0"
|
52
|
+
requirements:
|
53
|
+
- - ! '>='
|
54
|
+
- !ruby/object:Gem::Version
|
55
|
+
version: '0'
|
77
56
|
type: :runtime
|
78
|
-
|
57
|
+
prerelease: false
|
58
|
+
version_requirements: *209396000
|
79
59
|
description: Twitter OAuth Interface for CLI Applications
|
80
60
|
email: tily05@gmail.com
|
81
61
|
executables: []
|
82
|
-
|
83
62
|
extensions: []
|
84
|
-
|
85
|
-
extra_rdoc_files:
|
63
|
+
extra_rdoc_files:
|
86
64
|
- LICENSE
|
87
65
|
- README.md
|
88
|
-
files:
|
66
|
+
files:
|
89
67
|
- .document
|
90
|
-
- .gitignore
|
91
68
|
- LICENSE
|
92
69
|
- README.md
|
93
70
|
- Rakefile
|
@@ -103,37 +80,26 @@ files:
|
|
103
80
|
has_rdoc: true
|
104
81
|
homepage: http://github.com/tily/ruby-oauth-cli-twitter
|
105
82
|
licenses: []
|
106
|
-
|
107
83
|
post_install_message:
|
108
|
-
rdoc_options:
|
109
|
-
|
110
|
-
require_paths:
|
84
|
+
rdoc_options: []
|
85
|
+
require_paths:
|
111
86
|
- lib
|
112
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
87
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
113
88
|
none: false
|
114
|
-
requirements:
|
115
|
-
- -
|
116
|
-
- !ruby/object:Gem::Version
|
117
|
-
|
118
|
-
|
119
|
-
- 0
|
120
|
-
version: "0"
|
121
|
-
required_rubygems_version: !ruby/object:Gem::Requirement
|
89
|
+
requirements:
|
90
|
+
- - ! '>='
|
91
|
+
- !ruby/object:Gem::Version
|
92
|
+
version: '0'
|
93
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
122
94
|
none: false
|
123
|
-
requirements:
|
124
|
-
- -
|
125
|
-
- !ruby/object:Gem::Version
|
126
|
-
|
127
|
-
segments:
|
128
|
-
- 0
|
129
|
-
version: "0"
|
95
|
+
requirements:
|
96
|
+
- - ! '>='
|
97
|
+
- !ruby/object:Gem::Version
|
98
|
+
version: '0'
|
130
99
|
requirements: []
|
131
|
-
|
132
100
|
rubyforge_project:
|
133
|
-
rubygems_version: 1.
|
101
|
+
rubygems_version: 1.6.2
|
134
102
|
signing_key:
|
135
103
|
specification_version: 3
|
136
104
|
summary: Twitter OAuth Interface for CLI Applications
|
137
|
-
test_files:
|
138
|
-
- spec/oauth_cli_twitter_spec.rb
|
139
|
-
- spec/spec_helper.rb
|
105
|
+
test_files: []
|