twitter-vine 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +15 -0
- data/.gitignore +18 -0
- data/.travis.yml +3 -0
- data/Gemfile +4 -0
- data/Gemfile.lock +57 -0
- data/LICENSE +20 -0
- data/README.md +4 -0
- data/Rakefile +9 -0
- data/lib/twitter-vine/client.rb +67 -0
- data/lib/twitter-vine/version.rb +3 -0
- data/lib/twitter-vine.rb +26 -0
- data/spec/spec_helper.rb +22 -0
- data/spec/twitter-vine_spec.rb +19 -0
- data/twitter-vine.gemspec +28 -0
- metadata +98 -0
checksums.yaml
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
---
|
2
|
+
!binary "U0hBMQ==":
|
3
|
+
metadata.gz: !binary |-
|
4
|
+
YWI3MjEzZmM0YjUyMjhiNTBlODMyNDdkOTA3NTJlMWM4ZmY4Nzk3Mw==
|
5
|
+
data.tar.gz: !binary |-
|
6
|
+
MDQ2NDM2ZjcyNTEyMzExYjA1NGNmZDhjNDEyNjEyN2ZhZDZjNDdlMA==
|
7
|
+
SHA512:
|
8
|
+
metadata.gz: !binary |-
|
9
|
+
MWRkZTRjNjNlMDdhMTRmODU5MGVhM2U5ZmZhMjEzNGNlMDdmYjZlYzlkOGEz
|
10
|
+
YWE2ZTEyYzM5OGVlOTQxYTczY2U4N2M0MGRjNzYzM2QwNjhkYzgzNzI1Mzk1
|
11
|
+
ZjNiYTc5YTdiZmNkMzczZGViNDRhOTQ1NTkxODZhZjQwNGU1N2I=
|
12
|
+
data.tar.gz: !binary |-
|
13
|
+
MDAzZDdhNDNhNjE4YTc3YzRhNjU1MDI4Y2RlMTE5MWFlMDJkZjY4MDg1ODY5
|
14
|
+
MTFiOTBiYWQ0ZjMxMjQwM2VjOWMzMTdlYmVkZWY4ZDY0MmY0MThjNGFmY2E1
|
15
|
+
NzEzYmQ2YmI2MzlkOWRkMDcwYjIwYjlmMjE2NzM2MTM4YmZjOWU=
|
data/.gitignore
ADDED
data/.travis.yml
ADDED
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,57 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
twitter-vine (0.0.1)
|
5
|
+
nokogiri (>= 1.4.0)
|
6
|
+
twitter (~> 5.0.0)
|
7
|
+
|
8
|
+
GEM
|
9
|
+
remote: http://rubygems.org/
|
10
|
+
specs:
|
11
|
+
addressable (2.3.5)
|
12
|
+
atomic (1.1.14)
|
13
|
+
buftok (0.2.0)
|
14
|
+
descendants_tracker (0.0.3)
|
15
|
+
diff-lcs (1.2.5)
|
16
|
+
equalizer (0.0.7)
|
17
|
+
faraday (0.8.8)
|
18
|
+
multipart-post (~> 1.2.0)
|
19
|
+
http (0.5.0)
|
20
|
+
http_parser.rb
|
21
|
+
http_parser.rb (0.5.3)
|
22
|
+
json (1.8.1)
|
23
|
+
memoizable (0.2.0)
|
24
|
+
thread_safe (~> 0.1.3)
|
25
|
+
mini_portile (0.5.2)
|
26
|
+
multipart-post (1.2.0)
|
27
|
+
nokogiri (1.6.0)
|
28
|
+
mini_portile (~> 0.5.0)
|
29
|
+
rspec (2.14.1)
|
30
|
+
rspec-core (~> 2.14.0)
|
31
|
+
rspec-expectations (~> 2.14.0)
|
32
|
+
rspec-mocks (~> 2.14.0)
|
33
|
+
rspec-core (2.14.7)
|
34
|
+
rspec-expectations (2.14.4)
|
35
|
+
diff-lcs (>= 1.1.3, < 2.0)
|
36
|
+
rspec-mocks (2.14.4)
|
37
|
+
simple_oauth (0.2.0)
|
38
|
+
thread_safe (0.1.3)
|
39
|
+
atomic
|
40
|
+
twitter (5.0.1)
|
41
|
+
addressable (~> 2.3)
|
42
|
+
buftok (~> 0.2.0)
|
43
|
+
descendants_tracker (~> 0.0.1)
|
44
|
+
equalizer (~> 0.0.7)
|
45
|
+
faraday (>= 0.8, < 0.10)
|
46
|
+
http (~> 0.5.0)
|
47
|
+
http_parser.rb (~> 0.5.0)
|
48
|
+
json (~> 1.8)
|
49
|
+
memoizable (~> 0.2.0)
|
50
|
+
simple_oauth (~> 0.2.0)
|
51
|
+
|
52
|
+
PLATFORMS
|
53
|
+
ruby
|
54
|
+
|
55
|
+
DEPENDENCIES
|
56
|
+
rspec (>= 2.7.0)
|
57
|
+
twitter-vine!
|
data/LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2013 deevis
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
6
|
+
this software and associated documentation files (the "Software"), to deal in
|
7
|
+
the Software without restriction, including without limitation the rights to
|
8
|
+
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
9
|
+
the Software, and to permit persons to whom the Software is furnished to do so,
|
10
|
+
subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
13
|
+
copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
17
|
+
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
18
|
+
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
19
|
+
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
20
|
+
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
data/Rakefile
ADDED
@@ -0,0 +1,67 @@
|
|
1
|
+
require 'open-uri'
|
2
|
+
|
3
|
+
module TwitterVine
|
4
|
+
module Client
|
5
|
+
DEBUG = false
|
6
|
+
|
7
|
+
#
|
8
|
+
# OPTIONS:
|
9
|
+
# :api_key (required)
|
10
|
+
# :api_secret (required)
|
11
|
+
# :oauth_token (required)
|
12
|
+
# :oauth_secret (required)
|
13
|
+
# :count (optional - default: 10)
|
14
|
+
# :lang (optional - default: "en")
|
15
|
+
#
|
16
|
+
def self.search(q, opts={})
|
17
|
+
# Always use a new client for Thread safety - is this necessary?
|
18
|
+
tc = ::Twitter::REST::Client.new do |config|
|
19
|
+
config.consumer_key = opts.delete(:api_key) || TwitterVine.api_key
|
20
|
+
config.consumer_secret = opts.delete(:api_secret) || TwitterVine.api_secret
|
21
|
+
config.access_token = opts.delete(:oauth_tokn) || TwitterVine.oauth_key
|
22
|
+
config.access_token_secret = opts.delete(:oauth_secret) || TwitterVine.oauth_secret
|
23
|
+
end
|
24
|
+
opts[:include_entities] = true
|
25
|
+
opts[:lang] ||= "en"
|
26
|
+
opts[:count] ||= 10
|
27
|
+
vine_criteria = "\"vine.co/v/\" #{q}"
|
28
|
+
puts "Using search criteria [#{vine_criteria}]" if DEBUG
|
29
|
+
_normalize(tc.search(vine_criteria, opts))
|
30
|
+
end
|
31
|
+
|
32
|
+
private
|
33
|
+
# Does the processing inplace...
|
34
|
+
def self._normalize(results)
|
35
|
+
results.entries.map do |r|
|
36
|
+
vine_url = r.urls.map do |u|
|
37
|
+
if u[:display_url] =~ /vine\.co\/v/
|
38
|
+
u[:expanded_url].to_s
|
39
|
+
end
|
40
|
+
end.compact.first
|
41
|
+
doc = Nokogiri::HTML(open(vine_url))
|
42
|
+
{
|
43
|
+
time: r.created_at,
|
44
|
+
# This is Vine-centric - leaving out the other parts of the tweet...
|
45
|
+
# id: r.id,
|
46
|
+
# url: r.url.to_s,
|
47
|
+
# author_id: r.user.id,
|
48
|
+
# author: r.user.name,
|
49
|
+
# screenname: r.user.screen_name,
|
50
|
+
# author_thumbnail: r.user.profile_image_url.to_s.gsub("normal","bigger"),
|
51
|
+
# text: r.text,
|
52
|
+
# friends_count: r.user.friends_count,
|
53
|
+
# followers_count: r.user.followers_count,
|
54
|
+
# media: r.media.map{|m| m.media_uri.to_s},
|
55
|
+
vine_url: vine_url,
|
56
|
+
vine_author_thumbnail: doc.css(".avatar-container img").first[:src],
|
57
|
+
vine_author: doc.css("p.username").text,
|
58
|
+
vine_description: doc.css("p.description").text.gsub(/\s+/," ").strip,
|
59
|
+
vine_src: doc.css("video source").first[:src],
|
60
|
+
vine_type: doc.css("video source").first[:type]
|
61
|
+
}
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
65
|
+
end
|
66
|
+
end
|
67
|
+
|
data/lib/twitter-vine.rb
ADDED
@@ -0,0 +1,26 @@
|
|
1
|
+
require 'twitter-vine/version'
|
2
|
+
require 'twitter'
|
3
|
+
require 'nokogiri'
|
4
|
+
|
5
|
+
module TwitterVine
|
6
|
+
|
7
|
+
def self.api_key; @@api_key; end
|
8
|
+
def self.api_key=(val); @@api_key=val; end
|
9
|
+
|
10
|
+
def self.api_secret; @@api_secret; end
|
11
|
+
def self.api_secret=(val); @@api_secret=val; end
|
12
|
+
|
13
|
+
def self.oauth_key; @@oauth_key; end
|
14
|
+
def self.oauth_key=(val); @@oauth_key=val; end
|
15
|
+
|
16
|
+
def self.oauth_secret; @@oauth_secret; end
|
17
|
+
def self.oauth_secret=(val); @@oauth_secret=val; end
|
18
|
+
|
19
|
+
|
20
|
+
# Call setup to set global defaults
|
21
|
+
def self.setup
|
22
|
+
yield self
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
require 'twitter-vine/client'
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
# Load support files
|
2
|
+
require 'twitter-vine'
|
3
|
+
|
4
|
+
Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each { |f| require f }
|
5
|
+
|
6
|
+
RSpec.configure do |config|
|
7
|
+
# Remove this line if you don't want RSpec's should and should_not
|
8
|
+
# methods or matchers
|
9
|
+
require 'rspec/expectations'
|
10
|
+
config.include RSpec::Matchers
|
11
|
+
|
12
|
+
# == Mock Framework
|
13
|
+
config.mock_with :rspec
|
14
|
+
end
|
15
|
+
|
16
|
+
TwitterVine.setup do |c|
|
17
|
+
c.api_key = ENV["BT_TWITTER_API_KEY"]
|
18
|
+
c.api_secret = ENV["BT_TWITTER_API_SECRET"]
|
19
|
+
c.oauth_key = ENV["BT_TWITTER_OAUTH_TOKEN"]
|
20
|
+
c.oauth_secret = ENV["BT_TWITTER_OAUTH_TOKEN_SECRET"]
|
21
|
+
end
|
22
|
+
|
@@ -0,0 +1,19 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'twitter-vine'
|
3
|
+
|
4
|
+
TwitterVine::Client::DEBUG=true
|
5
|
+
|
6
|
+
describe TwitterVine do
|
7
|
+
it "should be valid" do
|
8
|
+
TwitterVine.should be_a(Module)
|
9
|
+
end
|
10
|
+
|
11
|
+
# Commented out until I set environment variables out on travis-ci
|
12
|
+
#
|
13
|
+
# it "should return results" do
|
14
|
+
# l = TwitterVine::Client.search("Prank")
|
15
|
+
# puts l
|
16
|
+
# expect(l.size).to be > 0
|
17
|
+
# end
|
18
|
+
|
19
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
$:.push File.expand_path("../lib", __FILE__)
|
3
|
+
require "twitter-vine/version"
|
4
|
+
|
5
|
+
Gem::Specification.new do |s|
|
6
|
+
s.name = "twitter-vine"
|
7
|
+
s.version = TwitterVine::VERSION
|
8
|
+
s.authors = ["Darren Hicks"]
|
9
|
+
s.email = ["darren.hicks@gmail.com"]
|
10
|
+
s.homepage = "https://github.com/deevis/twitter-vine"
|
11
|
+
s.summary = "A simple API to search and retrieve information about Vines"
|
12
|
+
s.description = "Uses the existing Twitter API and Nokogiri to get the job done"
|
13
|
+
|
14
|
+
# s.rubyforge_project = "linkser"
|
15
|
+
|
16
|
+
s.files = `git ls-files`.split("\n")
|
17
|
+
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
18
|
+
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
19
|
+
s.require_paths = ["lib"]
|
20
|
+
|
21
|
+
# Gem dependencies
|
22
|
+
#
|
23
|
+
s.add_runtime_dependency('twitter', '~>5.0.0')
|
24
|
+
s.add_runtime_dependency('nokogiri', '>= 1.4.0')
|
25
|
+
|
26
|
+
# Specs
|
27
|
+
s.add_development_dependency('rspec', '>= 2.7.0')
|
28
|
+
end
|
metadata
ADDED
@@ -0,0 +1,98 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: twitter-vine
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Darren Hicks
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2013-12-02 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: twitter
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ~>
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: 5.0.0
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ~>
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: 5.0.0
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: nokogiri
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ! '>='
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: 1.4.0
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ! '>='
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: 1.4.0
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rspec
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ! '>='
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: 2.7.0
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ! '>='
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: 2.7.0
|
55
|
+
description: Uses the existing Twitter API and Nokogiri to get the job done
|
56
|
+
email:
|
57
|
+
- darren.hicks@gmail.com
|
58
|
+
executables: []
|
59
|
+
extensions: []
|
60
|
+
extra_rdoc_files: []
|
61
|
+
files:
|
62
|
+
- .gitignore
|
63
|
+
- .travis.yml
|
64
|
+
- Gemfile
|
65
|
+
- Gemfile.lock
|
66
|
+
- LICENSE
|
67
|
+
- README.md
|
68
|
+
- Rakefile
|
69
|
+
- lib/twitter-vine.rb
|
70
|
+
- lib/twitter-vine/client.rb
|
71
|
+
- lib/twitter-vine/version.rb
|
72
|
+
- spec/spec_helper.rb
|
73
|
+
- spec/twitter-vine_spec.rb
|
74
|
+
- twitter-vine.gemspec
|
75
|
+
homepage: https://github.com/deevis/twitter-vine
|
76
|
+
licenses: []
|
77
|
+
metadata: {}
|
78
|
+
post_install_message:
|
79
|
+
rdoc_options: []
|
80
|
+
require_paths:
|
81
|
+
- lib
|
82
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
83
|
+
requirements:
|
84
|
+
- - ! '>='
|
85
|
+
- !ruby/object:Gem::Version
|
86
|
+
version: '0'
|
87
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
88
|
+
requirements:
|
89
|
+
- - ! '>='
|
90
|
+
- !ruby/object:Gem::Version
|
91
|
+
version: '0'
|
92
|
+
requirements: []
|
93
|
+
rubyforge_project:
|
94
|
+
rubygems_version: 2.1.11
|
95
|
+
signing_key:
|
96
|
+
specification_version: 4
|
97
|
+
summary: A simple API to search and retrieve information about Vines
|
98
|
+
test_files: []
|