twitter_search_photos 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +15 -0
- checksums.yaml.gz.sig +3 -0
- data/.gitignore +18 -0
- data/Gemfile +6 -0
- data/LICENSE.txt +22 -0
- data/README.md +60 -0
- data/Rakefile +14 -0
- data/lib/twitter_search_photos/version.rb +3 -0
- data/lib/twitter_search_photos.rb +44 -0
- data/test/helper.rb +10 -0
- data/test/twitter_search_photos_test.rb +36 -0
- data/twitter_search_photos.gemspec +28 -0
- data.tar.gz.sig +1 -0
- metadata +142 -0
- metadata.gz.sig +3 -0
checksums.yaml
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
---
|
2
|
+
!binary "U0hBMQ==":
|
3
|
+
metadata.gz: !binary |-
|
4
|
+
MjExNWNlYTY2YWIwNWMwOTBlNmM2NTI2YzRkNjk3OGZmNzZkYmYxOQ==
|
5
|
+
data.tar.gz: !binary |-
|
6
|
+
Y2Q4ZGVkZTljNWU5YWZlYWZjODI5NzRhZmYxYmFhYjBlZGIyMjlmZQ==
|
7
|
+
!binary "U0hBNTEy":
|
8
|
+
metadata.gz: !binary |-
|
9
|
+
NzU0YTI3MzRhYTA0YzJmYzJlYzBjMGFiMjk2YTlkYTNiZjBlYjQzMzdiOGJi
|
10
|
+
YzViZWYyZDA4NTU2YzlmMjY1ODRiZWVlNzMxMjgyYzhmNTM2NTdlZDg2NTBm
|
11
|
+
MWFhNmVlM2RjNjY2NzEwY2I5ZWNlMzM2MjkwZDA4MTI1ZTM3YjU=
|
12
|
+
data.tar.gz: !binary |-
|
13
|
+
OWIyZDE1ZGIxODRjYTE4MDU0ODk1NTgwY2FjMTM3ZGNmMTk3ODA4MGI1YWQ2
|
14
|
+
YTE1Y2ZjYzQ1ZWM5NmYyZTE4ZTAzYmE3MDc2MDk4MzI1ODJjNDBhNTA3OTli
|
15
|
+
NjdkODU1OTE4ZTZmNjE1ZjZkYzFlNzQwNjRiMGJlMzJkYTgwZGM=
|
checksums.yaml.gz.sig
ADDED
data/.gitignore
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2013 Barry Hoggard
|
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,60 @@
|
|
1
|
+
# TwitterSearchPhotos
|
2
|
+
|
3
|
+
## Installation
|
4
|
+
|
5
|
+
Add this line to your application's Gemfile:
|
6
|
+
|
7
|
+
gem 'twitter_search_photos'
|
8
|
+
|
9
|
+
And then execute:
|
10
|
+
|
11
|
+
$ bundle
|
12
|
+
|
13
|
+
Or install it yourself as:
|
14
|
+
|
15
|
+
$ gem install twitter_search_photos
|
16
|
+
|
17
|
+
## Usage
|
18
|
+
|
19
|
+
require 'twitter_search_photos'
|
20
|
+
|
21
|
+
Set up the following keys for ENV:
|
22
|
+
|
23
|
+
TWITTER_CONSUMER_KEY
|
24
|
+
TWITTER_CONSUMER_SECRET
|
25
|
+
TWITTER_OAUTH_TOKEN
|
26
|
+
TWITTER_OAUTH_TOKEN_SECRET
|
27
|
+
|
28
|
+
# look for photos with #art in tweet
|
29
|
+
response = TwitterSearchPhotos.search('#art')
|
30
|
+
|
31
|
+
# get ID we can use when we search again to only get new ones
|
32
|
+
max_id = response.max_id
|
33
|
+
|
34
|
+
# get list of results
|
35
|
+
results = response.results
|
36
|
+
|
37
|
+
# get first result
|
38
|
+
first = results.first
|
39
|
+
|
40
|
+
# individual elements of the result
|
41
|
+
first.media_url
|
42
|
+
first.display_url
|
43
|
+
first.screen_name
|
44
|
+
|
45
|
+
# do another call, passing in the since ID:
|
46
|
+
response = TwitterSearchPhotos('#art', since_id: max_id)
|
47
|
+
|
48
|
+
|
49
|
+
## Contributing
|
50
|
+
|
51
|
+
1. Fork it
|
52
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
53
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
54
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
55
|
+
5. Create new Pull Request
|
56
|
+
|
57
|
+
## Thanks
|
58
|
+
|
59
|
+
Some of the code is based on https://github.com/scottwb/twitter-image-search.
|
60
|
+
|
data/Rakefile
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
require 'bundler/gem_tasks'
|
2
|
+
require 'rake/testtask'
|
3
|
+
require 'dotenv/tasks'
|
4
|
+
require 'dotenv'
|
5
|
+
Dotenv.load
|
6
|
+
|
7
|
+
Rake::TestTask.new do |t|
|
8
|
+
t.test_files = FileList['test/*_test.rb']
|
9
|
+
t.ruby_opts = ['-rubygems'] if defined? Gem
|
10
|
+
t.ruby_opts << '-I.'
|
11
|
+
t.verbose = true
|
12
|
+
end
|
13
|
+
|
14
|
+
task :default => :test
|
@@ -0,0 +1,44 @@
|
|
1
|
+
require "twitter_search_photos/version"
|
2
|
+
require "ostruct"
|
3
|
+
require "twitter"
|
4
|
+
|
5
|
+
module TwitterSearchPhotos
|
6
|
+
|
7
|
+
Twitter.configure do |config|
|
8
|
+
config.consumer_key = ENV["TWITTER_CONSUMER_KEY"]
|
9
|
+
config.consumer_secret = ENV["TWITTER_CONSUMER_SECRET"]
|
10
|
+
config.oauth_token = ENV["TWITTER_OAUTH_TOKEN"]
|
11
|
+
config.oauth_token_secret = ENV["TWITTER_OAUTH_TOKEN_SECRET"]
|
12
|
+
end
|
13
|
+
|
14
|
+
# Can be optionally called with since_id: max_id
|
15
|
+
def self.search(query, options = {})
|
16
|
+
options.merge!(include_entities: 1, result_type: 'recent')
|
17
|
+
search = Twitter.search(query, options)
|
18
|
+
results = make_results(search.results)
|
19
|
+
response = OpenStruct.new(max_id: search.max_id, results: results)
|
20
|
+
end
|
21
|
+
|
22
|
+
# make our results structure
|
23
|
+
def self.make_results(tweets)
|
24
|
+
|
25
|
+
results = []
|
26
|
+
|
27
|
+
tweets.each do |tweet|
|
28
|
+
tweet.media.each do |media|
|
29
|
+
if media.is_a?(Twitter::Media::Photo)
|
30
|
+
result = OpenStruct.new(
|
31
|
+
media_url: media.media_url,
|
32
|
+
display_url: "https://#{media.display_url}",
|
33
|
+
screen_name: tweet.user.screen_name
|
34
|
+
)
|
35
|
+
results << result
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
results
|
41
|
+
|
42
|
+
end
|
43
|
+
|
44
|
+
end
|
data/test/helper.rb
ADDED
@@ -0,0 +1,10 @@
|
|
1
|
+
ENV['RACK_ENV'] = 'test'
|
2
|
+
require 'minitest/autorun'
|
3
|
+
|
4
|
+
testdir = File.dirname(__FILE__)
|
5
|
+
$LOAD_PATH.unshift testdir unless $LOAD_PATH.include?(testdir)
|
6
|
+
|
7
|
+
libdir = File.dirname(File.dirname(__FILE__)) + '/lib'
|
8
|
+
$LOAD_PATH.unshift libdir unless $LOAD_PATH.include?(libdir)
|
9
|
+
|
10
|
+
require "twitter_search_photos"
|
@@ -0,0 +1,36 @@
|
|
1
|
+
require File.expand_path('../helper', __FILE__)
|
2
|
+
|
3
|
+
describe TwitterSearchPhotos do
|
4
|
+
|
5
|
+
def setup
|
6
|
+
@response = TwitterSearchPhotos.search('#art')
|
7
|
+
@photo = @response.results.first
|
8
|
+
end
|
9
|
+
|
10
|
+
it "has a version" do
|
11
|
+
TwitterSearchPhotos::VERSION.wont_be_nil
|
12
|
+
end
|
13
|
+
|
14
|
+
it 'returns a response for #art' do
|
15
|
+
@response.wont_be_nil
|
16
|
+
end
|
17
|
+
|
18
|
+
it 'provides a max_id' do
|
19
|
+
@response.max_id.wont_be_nil
|
20
|
+
end
|
21
|
+
|
22
|
+
it 'returns at least one image' do
|
23
|
+
@photo.media_url.must_match /^http/
|
24
|
+
end
|
25
|
+
|
26
|
+
it 'returns display_url for image' do
|
27
|
+
@photo.display_url.must_match /^http/
|
28
|
+
end
|
29
|
+
|
30
|
+
it 'returns a responce when called with since_id' do
|
31
|
+
@max_id = @response.max_id
|
32
|
+
@since_response = TwitterSearchPhotos.search('#art', since_id: @max_id)
|
33
|
+
@since_response.max_id.wont_equal @max_id
|
34
|
+
end
|
35
|
+
|
36
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'twitter_search_photos/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "twitter_search_photos"
|
8
|
+
spec.version = TwitterSearchPhotos::VERSION
|
9
|
+
spec.authors = ["Barry Hoggard"]
|
10
|
+
spec.email = ["barry@tristanmedia.com"]
|
11
|
+
spec.description = %q{Ruby gem to find photos on Twitter with a search query}
|
12
|
+
spec.summary = spec.description
|
13
|
+
spec.homepage = "https://github.com/bhoggard/twitter_search_photos"
|
14
|
+
spec.license = "MIT"
|
15
|
+
|
16
|
+
spec.files = `git ls-files`.split($/)
|
17
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
18
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
|
+
spec.require_paths = ["lib"]
|
20
|
+
|
21
|
+
spec.signing_key = File.expand_path("~/.gem/gem-private_key.pem")
|
22
|
+
spec.cert_chain = [ File.expand_path("~/.gem/gem-public_cert.pem") ]
|
23
|
+
|
24
|
+
spec.add_development_dependency "bundler", "~> 1.3"
|
25
|
+
spec.add_development_dependency "rake"
|
26
|
+
spec.add_development_dependency "fakeweb", "~> 1.3.0"
|
27
|
+
spec.add_development_dependency "dotenv-rails"
|
28
|
+
end
|
data.tar.gz.sig
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
>��a�sA�qk�g_�b�婀�[:l�,��Q<�a��ͨ�7�`۫�1&Q�V��RX! ?мx���cb�8Y�`44o��G����� o�|��y��aK��J��K�f���ŋ�Y�Bh-�5��j��Q�9N.�4L2�i��,�iJk�U�Y���)�I���`�a�g�����6{��z�3��|+ٴ(�Vw�܆�"H8
|
metadata
ADDED
@@ -0,0 +1,142 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: twitter_search_photos
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Barry Hoggard
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain:
|
11
|
+
- !binary |-
|
12
|
+
LS0tLS1CRUdJTiBDRVJUSUZJQ0FURS0tLS0tCk1JSURnRENDQW1pZ0F3SUJB
|
13
|
+
Z0lCQVRBTkJna3Foa2lHOXcwQkFRVUZBREJETVE0d0RBWURWUVFEREFWaVlY
|
14
|
+
SnkKZVRFY01Cb0dDZ21TSm9tVDhpeGtBUmtXREhSeWFYTjBZVzV0WldScFlU
|
15
|
+
RVR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tTnZiVEFoQmdOVkhSSUVHakFZZ1JaaVlYSnllVUIwY21s
|
31
|
+
emRHRnViV1ZrYVdFdVkyOXQKTUEwR0NTcUdTSWIzRFFFQkJRVUFBNElCQVFC
|
32
|
+
Q0sxRTVkSUhIUDc0R01FY3BQQUswWFhkb3FacVRuRkRXcnd4VwpEKzZ2SjdQ
|
33
|
+
M0drVE1PZExrNXdlTGpqNnRhSi9zZS80YVI4T211d1RUQVhMMnZ1cWlRVUZn
|
34
|
+
YnlpT000ZnVYSC8vClFqZXBnOEQxQWtvTCsrc2c1ZEJrN1I0ODRUdVdlSDBx
|
35
|
+
U29yWVlvN1RjSitwV2xDWVRoS3BTSktZeFBOSzRCZVUKcGlSTHBsSjluelpW
|
36
|
+
RW9nOW5hNFNaTlZ6ZHlyZHVmYytOWjJFMnlJSk54anZFenliYU05dkxwZjc1
|
37
|
+
R0Nya1VPMwp6K0FMcXc1a1FrZWdhL0dtQVZicklwVkkrZ0p4RDQwQ3Y3VmZ1
|
38
|
+
azhUM0MzbExRejNkWWFVSWViWDF5Z25JdzFrClg0STNvMVlHdTJRMUJpL3hC
|
39
|
+
Ri93MGhMeTY3MGgrNHA1MFlxMDgvSEkxN0JPbVlXcwotLS0tLUVORCBDRVJU
|
40
|
+
SUZJQ0FURS0tLS0tCg==
|
41
|
+
date: 2013-04-15 00:00:00.000000000 Z
|
42
|
+
dependencies:
|
43
|
+
- !ruby/object:Gem::Dependency
|
44
|
+
name: bundler
|
45
|
+
requirement: !ruby/object:Gem::Requirement
|
46
|
+
requirements:
|
47
|
+
- - ~>
|
48
|
+
- !ruby/object:Gem::Version
|
49
|
+
version: '1.3'
|
50
|
+
type: :development
|
51
|
+
prerelease: false
|
52
|
+
version_requirements: !ruby/object:Gem::Requirement
|
53
|
+
requirements:
|
54
|
+
- - ~>
|
55
|
+
- !ruby/object:Gem::Version
|
56
|
+
version: '1.3'
|
57
|
+
- !ruby/object:Gem::Dependency
|
58
|
+
name: rake
|
59
|
+
requirement: !ruby/object:Gem::Requirement
|
60
|
+
requirements:
|
61
|
+
- - ! '>='
|
62
|
+
- !ruby/object:Gem::Version
|
63
|
+
version: '0'
|
64
|
+
type: :development
|
65
|
+
prerelease: false
|
66
|
+
version_requirements: !ruby/object:Gem::Requirement
|
67
|
+
requirements:
|
68
|
+
- - ! '>='
|
69
|
+
- !ruby/object:Gem::Version
|
70
|
+
version: '0'
|
71
|
+
- !ruby/object:Gem::Dependency
|
72
|
+
name: fakeweb
|
73
|
+
requirement: !ruby/object:Gem::Requirement
|
74
|
+
requirements:
|
75
|
+
- - ~>
|
76
|
+
- !ruby/object:Gem::Version
|
77
|
+
version: 1.3.0
|
78
|
+
type: :development
|
79
|
+
prerelease: false
|
80
|
+
version_requirements: !ruby/object:Gem::Requirement
|
81
|
+
requirements:
|
82
|
+
- - ~>
|
83
|
+
- !ruby/object:Gem::Version
|
84
|
+
version: 1.3.0
|
85
|
+
- !ruby/object:Gem::Dependency
|
86
|
+
name: dotenv-rails
|
87
|
+
requirement: !ruby/object:Gem::Requirement
|
88
|
+
requirements:
|
89
|
+
- - ! '>='
|
90
|
+
- !ruby/object:Gem::Version
|
91
|
+
version: '0'
|
92
|
+
type: :development
|
93
|
+
prerelease: false
|
94
|
+
version_requirements: !ruby/object:Gem::Requirement
|
95
|
+
requirements:
|
96
|
+
- - ! '>='
|
97
|
+
- !ruby/object:Gem::Version
|
98
|
+
version: '0'
|
99
|
+
description: Ruby gem to find photos on Twitter with a search query
|
100
|
+
email:
|
101
|
+
- barry@tristanmedia.com
|
102
|
+
executables: []
|
103
|
+
extensions: []
|
104
|
+
extra_rdoc_files: []
|
105
|
+
files:
|
106
|
+
- .gitignore
|
107
|
+
- Gemfile
|
108
|
+
- LICENSE.txt
|
109
|
+
- README.md
|
110
|
+
- Rakefile
|
111
|
+
- lib/twitter_search_photos.rb
|
112
|
+
- lib/twitter_search_photos/version.rb
|
113
|
+
- test/helper.rb
|
114
|
+
- test/twitter_search_photos_test.rb
|
115
|
+
- twitter_search_photos.gemspec
|
116
|
+
homepage: https://github.com/bhoggard/twitter_search_photos
|
117
|
+
licenses:
|
118
|
+
- MIT
|
119
|
+
metadata: {}
|
120
|
+
post_install_message:
|
121
|
+
rdoc_options: []
|
122
|
+
require_paths:
|
123
|
+
- lib
|
124
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
125
|
+
requirements:
|
126
|
+
- - ! '>='
|
127
|
+
- !ruby/object:Gem::Version
|
128
|
+
version: '0'
|
129
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
130
|
+
requirements:
|
131
|
+
- - ! '>='
|
132
|
+
- !ruby/object:Gem::Version
|
133
|
+
version: '0'
|
134
|
+
requirements: []
|
135
|
+
rubyforge_project:
|
136
|
+
rubygems_version: 2.0.3
|
137
|
+
signing_key:
|
138
|
+
specification_version: 4
|
139
|
+
summary: Ruby gem to find photos on Twitter with a search query
|
140
|
+
test_files:
|
141
|
+
- test/helper.rb
|
142
|
+
- test/twitter_search_photos_test.rb
|
metadata.gz.sig
ADDED