jumpstart_auth 0.4.0 → 0.6.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +13 -0
- data/Gemfile +6 -1
- data/LICENSE.txt +1 -1
- data/README.md +4 -2
- data/Rakefile +15 -0
- data/VERSION +1 -0
- data/jumpstart_auth.gemspec +9 -7
- data/lib/jumpstart_auth.rb +6 -73
- data/lib/jumpstart_auth/twitter_client.rb +89 -0
- data/lib/jumpstart_auth/version.rb +1 -1
- data/test/helper.rb +18 -0
- data/test/test_jumpstart_auth.rb +7 -0
- metadata +47 -28
- data/.document +0 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 564c382e6966f37f70bb71a8152427ba5ff2858b
|
4
|
+
data.tar.gz: 7f2ab6a710f2e73133a33bed88ae050c19d8dc52
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fa7572ce36e3fb11fe1ab88166bd507956035eca1572c39cc6cf852d1bf385edc129061496c8993bb6daa72b313d59aef389357e295b74b7268b91bd8bbf97be
|
7
|
+
data.tar.gz: 69b3a3f86cf1344263d24cb07e5c6076ef812f8d51deaf76940bd71efa9b443fa2d98b0fd9e92a02a39e0c9dde969aba07b53b65f92aca46e645a6aabb28b2a1
|
data/.gitignore
CHANGED
@@ -1,3 +1,4 @@
|
|
1
|
+
|
1
2
|
*.gem
|
2
3
|
*.rbc
|
3
4
|
.bundle
|
@@ -15,3 +16,15 @@ spec/reports
|
|
15
16
|
test/tmp
|
16
17
|
test/version_tmp
|
17
18
|
tmp
|
19
|
+
*.bundle
|
20
|
+
*.so
|
21
|
+
*.o
|
22
|
+
*.a
|
23
|
+
mkmf.log
|
24
|
+
|
25
|
+
# files generated when using the gem
|
26
|
+
twitter_settings.yml
|
27
|
+
|
28
|
+
# common bundler paths for bundled gems
|
29
|
+
vendor/ruby/
|
30
|
+
vendor/cache/
|
data/Gemfile
CHANGED
data/LICENSE.txt
CHANGED
data/README.md
CHANGED
@@ -1,5 +1,7 @@
|
|
1
1
|
# JumpstartAuth
|
2
2
|
|
3
|
+
TODO: Write a gem description
|
4
|
+
|
3
5
|
## Installation
|
4
6
|
|
5
7
|
Add this line to your application's Gemfile:
|
@@ -20,8 +22,8 @@ TODO: Write usage instructions here
|
|
20
22
|
|
21
23
|
## Contributing
|
22
24
|
|
23
|
-
1. Fork it
|
25
|
+
1. Fork it ( https://github.com/jumpstartlab/jumpstart_auth/fork )
|
24
26
|
2. Create your feature branch (`git checkout -b my-new-feature`)
|
25
27
|
3. Commit your changes (`git commit -am 'Add some feature'`)
|
26
28
|
4. Push to the branch (`git push origin my-new-feature`)
|
27
|
-
5. Create new Pull Request
|
29
|
+
5. Create a new Pull Request
|
data/Rakefile
CHANGED
@@ -1 +1,16 @@
|
|
1
1
|
require "bundler/gem_tasks"
|
2
|
+
|
3
|
+
require 'rake/testtask'
|
4
|
+
Rake::TestTask.new(:test) do |test|
|
5
|
+
test.libs << 'lib' << 'test'
|
6
|
+
test.pattern = 'test/**/test_*.rb'
|
7
|
+
test.verbose = true
|
8
|
+
end
|
9
|
+
|
10
|
+
desc "Code coverage detail"
|
11
|
+
task :simplecov do
|
12
|
+
ENV['COVERAGE'] = "true"
|
13
|
+
Rake::Task['test'].execute
|
14
|
+
end
|
15
|
+
|
16
|
+
task :default => :test
|
data/VERSION
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
0.5.0
|
data/jumpstart_auth.gemspec
CHANGED
@@ -7,20 +7,22 @@ Gem::Specification.new do |spec|
|
|
7
7
|
spec.name = "jumpstart_auth"
|
8
8
|
spec.version = JumpstartAuth::VERSION
|
9
9
|
spec.authors = ["Jeff Casimir"]
|
10
|
-
spec.email = ["jeff@
|
10
|
+
spec.email = ["jeff@jumpstartlab.com"]
|
11
|
+
spec.summary = "Authentication library support for JumpstartLab projects"
|
11
12
|
spec.description = "Simplifies authenticating to online services."
|
12
|
-
spec.summary = "Simplifies authenticating to online services."
|
13
13
|
spec.homepage = "http://github.com/jumpstartlab/jumpstart_auth"
|
14
14
|
spec.license = "MIT"
|
15
15
|
|
16
|
-
spec.files = `git ls-files`.split(
|
16
|
+
spec.files = `git ls-files -z`.split("\x0")
|
17
17
|
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
18
18
|
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
19
|
spec.require_paths = ["lib"]
|
20
20
|
|
21
|
-
spec.add_development_dependency "bundler", "~> 1.
|
21
|
+
spec.add_development_dependency "bundler", "~> 1.6"
|
22
22
|
spec.add_development_dependency "rake"
|
23
|
-
spec.
|
24
|
-
|
25
|
-
spec.
|
23
|
+
spec.add_development_dependency "shoulda"
|
24
|
+
|
25
|
+
spec.add_runtime_dependency 'oauth', '~> 0.4'
|
26
|
+
spec.add_runtime_dependency 'twitter', '~> 5.6'
|
27
|
+
spec.add_runtime_dependency 'launchy', '~> 2.4'
|
26
28
|
end
|
data/lib/jumpstart_auth.rb
CHANGED
@@ -1,78 +1,11 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
require 'launchy'
|
4
|
-
require 'yaml'
|
1
|
+
require_relative 'jumpstart_auth/twitter_client'
|
2
|
+
require_relative 'jumpstart_auth/version'
|
5
3
|
|
6
|
-
|
7
|
-
|
8
|
-
:consumer_key => "mJ5otbhPGNoDCgCL7j5g",
|
9
|
-
:consumer_secret => "M0XkT6GeBnjxdlWHcSGYX1JutMVS9D5ISlkqRfShg"
|
10
|
-
}
|
4
|
+
module JumpstartAuth
|
5
|
+
class << self
|
11
6
|
|
12
|
-
|
13
|
-
|
14
|
-
def followers
|
15
|
-
Twitter.followers.all
|
16
|
-
end
|
17
|
-
|
18
|
-
def friends
|
19
|
-
Twitter.friends.all
|
20
|
-
end
|
21
|
-
|
22
|
-
def update(message)
|
23
|
-
if message.match(/^d\s/i) then
|
24
|
-
d, name, *rest = message.chomp.split
|
25
|
-
message.sub!(/.*#{name}\s/, '')
|
26
|
-
|
27
|
-
begin
|
28
|
-
Twitter.direct_message_create(name, message)
|
29
|
-
rescue Twitter::Error::Forbidden
|
30
|
-
end
|
31
|
-
else
|
32
|
-
super(message)
|
33
|
-
end
|
34
|
-
end
|
35
|
-
end
|
36
|
-
end
|
37
|
-
private_class_method :client_class
|
38
|
-
|
39
|
-
def self.twitter
|
40
|
-
setup_oauth unless load_settings
|
41
|
-
client = Twitter::REST::Client.new do |config|
|
42
|
-
config.consumer_key = @@credentials[:consumer_key]
|
43
|
-
config.consumer_secret = @@credentials[:consumer_secret]
|
44
|
-
config.oauth_token = @@credentials[:oauth_token]
|
45
|
-
config.oauth_token_secret = @@credentials[:oauth_secret]
|
7
|
+
def twitter
|
8
|
+
TwitterClient.twitter
|
46
9
|
end
|
47
|
-
|
48
|
-
return client
|
49
|
-
end
|
50
|
-
|
51
|
-
private
|
52
|
-
|
53
|
-
def self.load_settings
|
54
|
-
begin
|
55
|
-
@@credentials = YAML.load(File.open("settings.yml", "r"))
|
56
|
-
rescue
|
57
|
-
false
|
58
|
-
end
|
59
|
-
end
|
60
|
-
|
61
|
-
def self.write_settings
|
62
|
-
settings = File.open("settings.yml", "w")
|
63
|
-
settings << @@credentials.to_yaml
|
64
|
-
settings.close
|
65
|
-
end
|
66
|
-
|
67
|
-
def self.setup_oauth
|
68
|
-
consumer = OAuth::Consumer.new( @@credentials[:consumer_key], @@credentials[:consumer_secret], :site => "https://twitter.com")
|
69
|
-
request_token = consumer.get_request_token
|
70
|
-
printf "Enter the supplied pin: "
|
71
|
-
Launchy.open(request_token.authorize_url)
|
72
|
-
pin = gets.chomp
|
73
|
-
access_token = request_token.get_access_token(:oauth_verifier => pin)
|
74
|
-
@@credentials[:oauth_token] = access_token.token
|
75
|
-
@@credentials[:oauth_secret] = access_token.secret
|
76
|
-
write_settings
|
77
10
|
end
|
78
11
|
end
|
@@ -0,0 +1,89 @@
|
|
1
|
+
require 'oauth'
|
2
|
+
require 'twitter'
|
3
|
+
require 'launchy'
|
4
|
+
require 'yaml'
|
5
|
+
|
6
|
+
module JumpstartAuth
|
7
|
+
class TwitterClient < Twitter::REST::Client
|
8
|
+
@@credentials = {
|
9
|
+
:consumer_key => "mJ5otbhPGNoDCgCL7j5g",
|
10
|
+
:consumer_secret => "M0XkT6GeBnjxdlWHcSGYX1JutMVS9D5ISlkqRfShg"
|
11
|
+
}
|
12
|
+
|
13
|
+
SETTINGS_FILE = "twitter_settings.yml"
|
14
|
+
|
15
|
+
def followers
|
16
|
+
users(follower_ids)
|
17
|
+
end
|
18
|
+
|
19
|
+
def friends
|
20
|
+
users(friend_ids)
|
21
|
+
end
|
22
|
+
|
23
|
+
def update(message)
|
24
|
+
if message.match(/^d\s/i) then
|
25
|
+
_, name, * = message.chomp.split
|
26
|
+
message.sub!(/.*#{name}\s/, '')
|
27
|
+
|
28
|
+
begin
|
29
|
+
create_direct_message(name, message)
|
30
|
+
rescue Twitter::Error::Forbidden
|
31
|
+
end
|
32
|
+
else
|
33
|
+
super(message)
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
def self.twitter
|
38
|
+
credentials = (load_settings or setup_oauth)
|
39
|
+
|
40
|
+
new do |config|
|
41
|
+
config.consumer_key = credentials[:consumer_key]
|
42
|
+
config.consumer_secret = credentials[:consumer_secret]
|
43
|
+
config.access_token = credentials[:access_token]
|
44
|
+
config.access_token_secret = credentials[:access_token_secret]
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
private
|
49
|
+
|
50
|
+
def self.write_settings
|
51
|
+
settings = File.open(SETTINGS_FILE, "w")
|
52
|
+
settings << @@credentials.to_yaml
|
53
|
+
settings.close
|
54
|
+
|
55
|
+
@@credentials
|
56
|
+
end
|
57
|
+
|
58
|
+
def self.load_settings
|
59
|
+
return unless File.exist?(SETTINGS_FILE)
|
60
|
+
|
61
|
+
@@credentials = YAML.load(File.open(SETTINGS_FILE, "r"))
|
62
|
+
end
|
63
|
+
|
64
|
+
def self.setup_oauth
|
65
|
+
consumer = OAuth::Consumer.new( @@credentials[:consumer_key], @@credentials[:consumer_secret], :site => "https://twitter.com")
|
66
|
+
request_token = consumer.get_request_token
|
67
|
+
printf "Enter the supplied pin: "
|
68
|
+
Launchy.open(request_token.authorize_url)
|
69
|
+
pin = gets.chomp
|
70
|
+
access_token = request_token.get_access_token(:oauth_verifier => pin)
|
71
|
+
@@credentials[:access_token] = access_token.token
|
72
|
+
@@credentials[:access_token_secret] = access_token.secret
|
73
|
+
|
74
|
+
write_settings
|
75
|
+
end
|
76
|
+
|
77
|
+
|
78
|
+
|
79
|
+
def users(ids)
|
80
|
+
ids. each do |id|
|
81
|
+
begin
|
82
|
+
user(id)
|
83
|
+
rescue Twitter::Error::NotFound
|
84
|
+
puts "Twitter user #{id}, seems to not exist. Don't worry, we'll keep going"
|
85
|
+
end
|
86
|
+
end
|
87
|
+
end
|
88
|
+
end
|
89
|
+
end
|
data/test/helper.rb
ADDED
@@ -0,0 +1,18 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'bundler'
|
3
|
+
begin
|
4
|
+
Bundler.setup(:default, :development)
|
5
|
+
rescue Bundler::BundlerError => e
|
6
|
+
$stderr.puts e.message
|
7
|
+
$stderr.puts "Run `bundle install` to install missing gems"
|
8
|
+
exit e.status_code
|
9
|
+
end
|
10
|
+
require 'test/unit'
|
11
|
+
require 'shoulda'
|
12
|
+
|
13
|
+
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
|
14
|
+
$LOAD_PATH.unshift(File.dirname(__FILE__))
|
15
|
+
require 'jumpstart_auth'
|
16
|
+
|
17
|
+
class Test::Unit::TestCase
|
18
|
+
end
|
metadata
CHANGED
@@ -1,102 +1,119 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: jumpstart_auth
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.6.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jeff Casimir
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
11
|
+
date: 2014-09-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- - ~>
|
17
|
+
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: '1.
|
19
|
+
version: '1.6'
|
20
20
|
type: :development
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- - ~>
|
24
|
+
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: '1.
|
26
|
+
version: '1.6'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: rake
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
|
-
- -
|
31
|
+
- - ">="
|
32
32
|
- !ruby/object:Gem::Version
|
33
33
|
version: '0'
|
34
34
|
type: :development
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
|
-
- -
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: shoulda
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
39
53
|
- !ruby/object:Gem::Version
|
40
54
|
version: '0'
|
41
55
|
- !ruby/object:Gem::Dependency
|
42
56
|
name: oauth
|
43
57
|
requirement: !ruby/object:Gem::Requirement
|
44
58
|
requirements:
|
45
|
-
- - ~>
|
59
|
+
- - "~>"
|
46
60
|
- !ruby/object:Gem::Version
|
47
|
-
version: 0.4
|
61
|
+
version: '0.4'
|
48
62
|
type: :runtime
|
49
63
|
prerelease: false
|
50
64
|
version_requirements: !ruby/object:Gem::Requirement
|
51
65
|
requirements:
|
52
|
-
- - ~>
|
66
|
+
- - "~>"
|
53
67
|
- !ruby/object:Gem::Version
|
54
|
-
version: 0.4
|
68
|
+
version: '0.4'
|
55
69
|
- !ruby/object:Gem::Dependency
|
56
70
|
name: twitter
|
57
71
|
requirement: !ruby/object:Gem::Requirement
|
58
72
|
requirements:
|
59
|
-
- - ~>
|
73
|
+
- - "~>"
|
60
74
|
- !ruby/object:Gem::Version
|
61
|
-
version: 5.
|
75
|
+
version: '5.6'
|
62
76
|
type: :runtime
|
63
77
|
prerelease: false
|
64
78
|
version_requirements: !ruby/object:Gem::Requirement
|
65
79
|
requirements:
|
66
|
-
- - ~>
|
80
|
+
- - "~>"
|
67
81
|
- !ruby/object:Gem::Version
|
68
|
-
version: 5.
|
82
|
+
version: '5.6'
|
69
83
|
- !ruby/object:Gem::Dependency
|
70
84
|
name: launchy
|
71
85
|
requirement: !ruby/object:Gem::Requirement
|
72
86
|
requirements:
|
73
|
-
- - ~>
|
87
|
+
- - "~>"
|
74
88
|
- !ruby/object:Gem::Version
|
75
|
-
version: 2.4
|
89
|
+
version: '2.4'
|
76
90
|
type: :runtime
|
77
91
|
prerelease: false
|
78
92
|
version_requirements: !ruby/object:Gem::Requirement
|
79
93
|
requirements:
|
80
|
-
- - ~>
|
94
|
+
- - "~>"
|
81
95
|
- !ruby/object:Gem::Version
|
82
|
-
version: 2.4
|
96
|
+
version: '2.4'
|
83
97
|
description: Simplifies authenticating to online services.
|
84
98
|
email:
|
85
|
-
- jeff@
|
99
|
+
- jeff@jumpstartlab.com
|
86
100
|
executables: []
|
87
101
|
extensions: []
|
88
102
|
extra_rdoc_files: []
|
89
103
|
files:
|
90
|
-
- .
|
91
|
-
- .gitignore
|
104
|
+
- ".gitignore"
|
92
105
|
- Gemfile
|
93
106
|
- Gemfile.lock
|
94
107
|
- LICENSE.txt
|
95
108
|
- README.md
|
96
109
|
- Rakefile
|
110
|
+
- VERSION
|
97
111
|
- jumpstart_auth.gemspec
|
98
112
|
- lib/jumpstart_auth.rb
|
113
|
+
- lib/jumpstart_auth/twitter_client.rb
|
99
114
|
- lib/jumpstart_auth/version.rb
|
115
|
+
- test/helper.rb
|
116
|
+
- test/test_jumpstart_auth.rb
|
100
117
|
homepage: http://github.com/jumpstartlab/jumpstart_auth
|
101
118
|
licenses:
|
102
119
|
- MIT
|
@@ -107,18 +124,20 @@ require_paths:
|
|
107
124
|
- lib
|
108
125
|
required_ruby_version: !ruby/object:Gem::Requirement
|
109
126
|
requirements:
|
110
|
-
- -
|
127
|
+
- - ">="
|
111
128
|
- !ruby/object:Gem::Version
|
112
129
|
version: '0'
|
113
130
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
114
131
|
requirements:
|
115
|
-
- -
|
132
|
+
- - ">="
|
116
133
|
- !ruby/object:Gem::Version
|
117
134
|
version: '0'
|
118
135
|
requirements: []
|
119
136
|
rubyforge_project:
|
120
|
-
rubygems_version: 2.
|
137
|
+
rubygems_version: 2.2.2
|
121
138
|
signing_key:
|
122
139
|
specification_version: 4
|
123
|
-
summary:
|
124
|
-
test_files:
|
140
|
+
summary: Authentication library support for JumpstartLab projects
|
141
|
+
test_files:
|
142
|
+
- test/helper.rb
|
143
|
+
- test/test_jumpstart_auth.rb
|