ruboty-twitter 0.0.3
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.
- checksums.yaml +7 -0
- data/.gitignore +22 -0
- data/CHANGELOG.md +8 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +16 -0
- data/Rakefile +2 -0
- data/lib/ruboty/adapters/twitter.rb +59 -0
- data/lib/ruboty/twitter.rb +3 -0
- data/lib/ruboty/twitter/version.rb +5 -0
- data/ruboty-twitter.gemspec +23 -0
- metadata +111 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 37d7b7943a90da6fa5e64566a3782f17b5252780
|
4
|
+
data.tar.gz: 826f4b5d3e7df9b0884704cba00ed24f96a022a6
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: d71f09429f825c66b9e520a664d359aecb9becfbea368b8b45a75e71029d0ad6e328a6db16daceb783325fbcbf1d940d7fa2eb42be2d3de80be5cbc883714bf8
|
7
|
+
data.tar.gz: 920265e0f8475faa9ac9276f4a93e2c6f60d2102d37028cb4002f87c4d79451b4113f4c054114f9bb4a4c38d77a854f7e890617625473b44b994b2d9ee2a6576
|
data/.gitignore
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
*.gem
|
2
|
+
*.rbc
|
3
|
+
.bundle
|
4
|
+
.config
|
5
|
+
.yardoc
|
6
|
+
Gemfile.lock
|
7
|
+
InstalledFiles
|
8
|
+
_yardoc
|
9
|
+
coverage
|
10
|
+
doc/
|
11
|
+
lib/bundler/man
|
12
|
+
pkg
|
13
|
+
rdoc
|
14
|
+
spec/reports
|
15
|
+
test/tmp
|
16
|
+
test/version_tmp
|
17
|
+
tmp
|
18
|
+
*.bundle
|
19
|
+
*.so
|
20
|
+
*.o
|
21
|
+
*.a
|
22
|
+
mkmf.log
|
data/CHANGELOG.md
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2014 Ryo Nakamura
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
# Ruboty::Twitter
|
2
|
+
An [Ruboty](https://github.com/r7kamura/ruboty) adapter for twitter user-stream API.
|
3
|
+
|
4
|
+
## Usage
|
5
|
+
```ruby
|
6
|
+
# Gemfile
|
7
|
+
gem "ruboty-twitter"
|
8
|
+
```
|
9
|
+
|
10
|
+
## ENV
|
11
|
+
```
|
12
|
+
TWITTER_CONSUMER_KEY - Twitter consumer key (a.k.a. API key)
|
13
|
+
TWITTER_CONSUMER_SECRET - Twitter consumer secret (a.k.a. API secret)
|
14
|
+
TWITTER_ACCESS_TOKEN - Twitter access token
|
15
|
+
TWITTER_ACCESS_TOKEN_SECRET - Twitter access token secret
|
16
|
+
```
|
data/Rakefile
ADDED
@@ -0,0 +1,59 @@
|
|
1
|
+
require "mem"
|
2
|
+
require "twitter"
|
3
|
+
|
4
|
+
module Ruboty
|
5
|
+
module Adapters
|
6
|
+
class Twitter < Base
|
7
|
+
include Mem
|
8
|
+
|
9
|
+
env :TWITTER_CONSUMER_KEY, "Twitter consumer key (a.k.a. API key)"
|
10
|
+
env :TWITTER_CONSUMER_SECRET, "Twitter consumer secret (a.k.a. API secret)"
|
11
|
+
env :TWITTER_ACCESS_TOKEN, "Twitter access token"
|
12
|
+
env :TWITTER_ACCESS_TOKEN_SECRET, "Twitter access token secret"
|
13
|
+
|
14
|
+
def run
|
15
|
+
abortable
|
16
|
+
listen
|
17
|
+
end
|
18
|
+
|
19
|
+
def say(body)
|
20
|
+
client.update(body)
|
21
|
+
end
|
22
|
+
|
23
|
+
private
|
24
|
+
|
25
|
+
def listen
|
26
|
+
stream.user do |tweet|
|
27
|
+
case tweet
|
28
|
+
when ::Twitter::Tweet
|
29
|
+
robot.receive(body: tweet.text)
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
def client
|
35
|
+
::Twitter::REST::Client.new do |config|
|
36
|
+
config.consumer_key = ENV["TWITTER_CONSUMER_KEY"]
|
37
|
+
config.consumer_secret = ENV["TWITTER_CONSUMER_SECRET"]
|
38
|
+
config.access_token = ENV["TWITTER_ACCESS_TOKEN"]
|
39
|
+
config.access_token_secret = ENV["TWITTER_ACCESS_TOKEN_SECRET"]
|
40
|
+
end
|
41
|
+
end
|
42
|
+
memoize :client
|
43
|
+
|
44
|
+
def stream
|
45
|
+
::Twitter::Streaming::Client.new do |config|
|
46
|
+
config.consumer_key = ENV["TWITTER_CONSUMER_KEY"]
|
47
|
+
config.consumer_secret = ENV["TWITTER_CONSUMER_SECRET"]
|
48
|
+
config.access_token = ENV["TWITTER_ACCESS_TOKEN"]
|
49
|
+
config.access_token_secret = ENV["TWITTER_ACCESS_TOKEN_SECRET"]
|
50
|
+
end
|
51
|
+
end
|
52
|
+
memoize :stream
|
53
|
+
|
54
|
+
def abortable
|
55
|
+
Thread.abort_on_exception = true
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
lib = File.expand_path("../lib", __FILE__)
|
2
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
3
|
+
require "ruboty/twitter/version"
|
4
|
+
|
5
|
+
Gem::Specification.new do |spec|
|
6
|
+
spec.name = "ruboty-twitter"
|
7
|
+
spec.version = Ruboty::Twitter::VERSION
|
8
|
+
spec.authors = ["Ryo Nakamura"]
|
9
|
+
spec.email = ["r7kamura@gmail.com"]
|
10
|
+
spec.summary = "An ruboty adapter for twitter."
|
11
|
+
spec.homepage = "https://github.com/r7kamura/ruboty-twitter"
|
12
|
+
spec.license = "MIT"
|
13
|
+
|
14
|
+
spec.files = `git ls-files -z`.split("\x0")
|
15
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
16
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
17
|
+
spec.require_paths = ["lib"]
|
18
|
+
|
19
|
+
spec.add_dependency "ruboty"
|
20
|
+
spec.add_dependency "twitter", ">= 5.0.0"
|
21
|
+
spec.add_development_dependency "bundler", "~> 1.6"
|
22
|
+
spec.add_development_dependency "rake"
|
23
|
+
end
|
metadata
ADDED
@@ -0,0 +1,111 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: ruboty-twitter
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.3
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Ryo Nakamura
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2014-05-31 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: ruboty
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: twitter
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: 5.0.0
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: 5.0.0
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: bundler
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '1.6'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '1.6'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: rake
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
69
|
+
description:
|
70
|
+
email:
|
71
|
+
- r7kamura@gmail.com
|
72
|
+
executables: []
|
73
|
+
extensions: []
|
74
|
+
extra_rdoc_files: []
|
75
|
+
files:
|
76
|
+
- ".gitignore"
|
77
|
+
- CHANGELOG.md
|
78
|
+
- Gemfile
|
79
|
+
- LICENSE.txt
|
80
|
+
- README.md
|
81
|
+
- Rakefile
|
82
|
+
- lib/ruboty/adapters/twitter.rb
|
83
|
+
- lib/ruboty/twitter.rb
|
84
|
+
- lib/ruboty/twitter/version.rb
|
85
|
+
- ruboty-twitter.gemspec
|
86
|
+
homepage: https://github.com/r7kamura/ruboty-twitter
|
87
|
+
licenses:
|
88
|
+
- MIT
|
89
|
+
metadata: {}
|
90
|
+
post_install_message:
|
91
|
+
rdoc_options: []
|
92
|
+
require_paths:
|
93
|
+
- lib
|
94
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
95
|
+
requirements:
|
96
|
+
- - ">="
|
97
|
+
- !ruby/object:Gem::Version
|
98
|
+
version: '0'
|
99
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - ">="
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: '0'
|
104
|
+
requirements: []
|
105
|
+
rubyforge_project:
|
106
|
+
rubygems_version: 2.2.2
|
107
|
+
signing_key:
|
108
|
+
specification_version: 4
|
109
|
+
summary: An ruboty adapter for twitter.
|
110
|
+
test_files: []
|
111
|
+
has_rdoc:
|