fetcher-microdata-twitter 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +17 -0
- data/.travis.yml +7 -0
- data/Gemfile +10 -0
- data/LICENSE +22 -0
- data/README.md +16 -0
- data/Rakefile +11 -0
- data/features/stepdefs/translate_tweet_to_schema.rb +21 -0
- data/features/support/env.rb +4 -0
- data/features/translate_tweet_to_schema.feature +127 -0
- data/features/translate_user_to_schema.feature +79 -0
- data/fetcher-microdata-twitter.gemspec +22 -0
- data/lib/fetcher/microdata/twitter.rb +12 -0
- data/lib/fetcher/microdata/twitter/article_small.rb +36 -0
- data/lib/fetcher/microdata/twitter/person_user.rb +34 -0
- data/lib/fetcher/microdata/twitter/service.rb +22 -0
- data/lib/fetcher/microdata/twitter/version.rb +7 -0
- data/lib/writer/fetcher/microdata/twitter/article_small.rb +43 -0
- data/lib/writer/fetcher/microdata/twitter/person_user.rb +44 -0
- data/spec/fetcher/microdata/twitter/article_small_spec.rb +108 -0
- data/spec/fetcher/microdata/twitter/person_user_spec.rb +97 -0
- data/spec/fetcher/microdata/twitter/service_spec.rb +15 -0
- data/spec/spec_helper.rb +1 -0
- data/spec/tweet.json +61 -0
- data/spec/user.json +40 -0
- data/spec/writer/fetcher/microdata/twitter/article_small_spec.rb +108 -0
- data/spec/writer/fetcher/microdata/twitter/person_user_spec.rb +93 -0
- data/tweet.yaml +59 -0
- metadata +139 -0
data/.gitignore
ADDED
data/.travis.yml
ADDED
data/Gemfile
ADDED
data/LICENSE
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2012 Fetcher
|
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
|
+
Fetcher Microdata adapter for Twitter
|
2
|
+
=====================================
|
3
|
+
|
4
|
+
[![Build Status](https://secure.travis-ci.org/Fetcher/fetcher-microdata-twitter.png)](http://travis-ci.org/Fetcher/fetcher-microdata-twitter) [![Code Climate](https://codeclimate.com/badge.png)](https://codeclimate.com/github/Fetcher/fetcher-microdata-twitter)
|
5
|
+
|
6
|
+
The twitter API data adapter to Fetcher Microdata.
|
7
|
+
|
8
|
+
Fetcher Microdata is a compound of:
|
9
|
+
|
10
|
+
- <http://schema.org/> microdata
|
11
|
+
- <http://schema.org/> microdata extensions, as defined in the specification
|
12
|
+
- Own fetcher vocabulary (domain still to be known)
|
13
|
+
|
14
|
+
It's important to notice that the outgoing data is not legit microdata since the microdata keys are now usable for storage in mongodb (our current storage choice). Please don't use this gem until it reaches a more configurable and standard approach :)
|
15
|
+
|
16
|
+
> Note: Ruby 1.9 only
|
data/Rakefile
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
Given /^the tweet:$/ do |json_tweet|
|
2
|
+
@tweet = JSON.parse json_tweet
|
3
|
+
end
|
4
|
+
|
5
|
+
When /^I convert it into schema.org\/Article\/Small$/ do
|
6
|
+
@translated = Fetcher::Microdata::Twitter::ArticleSmall.new @tweet
|
7
|
+
end
|
8
|
+
|
9
|
+
Then /^I should have:$/ do |json_schema|
|
10
|
+
@schema = JSON.parse json_schema
|
11
|
+
#binding.pry
|
12
|
+
@translated.to.hash.should == @schema
|
13
|
+
end
|
14
|
+
|
15
|
+
Given /^the user:$/ do |json_user|
|
16
|
+
@user = JSON.parse json_user
|
17
|
+
end
|
18
|
+
|
19
|
+
When /^I convert it into schema.org\/Person\/User$/ do
|
20
|
+
@translated = Fetcher::Microdata::Twitter::PersonUser.new @user
|
21
|
+
end
|
@@ -0,0 +1,127 @@
|
|
1
|
+
Feature: Translate Tweet to schema.org/Article/Small + getfetcher.net/Item
|
2
|
+
In order to send a standarized-properties form of the tweet
|
3
|
+
As a developer
|
4
|
+
I want to be able to convert from Twitter API Tweet to
|
5
|
+
schema.org based vocabulary
|
6
|
+
|
7
|
+
Scenario: Converting a json tweet into a json schema
|
8
|
+
Given the tweet:
|
9
|
+
"""
|
10
|
+
{
|
11
|
+
"contributors": null,
|
12
|
+
"coordinates": null,
|
13
|
+
"created_at": "Tue Feb 21 21:29:07 +0000 2012",
|
14
|
+
"favorited": false,
|
15
|
+
"geo": null,
|
16
|
+
"id": 172070369035956224,
|
17
|
+
"id_str": "172070369035956224",
|
18
|
+
"in_reply_to_screen_name": null,
|
19
|
+
"in_reply_to_status_id": null,
|
20
|
+
"in_reply_to_status_id_str": null,
|
21
|
+
"in_reply_to_user_id": null,
|
22
|
+
"in_reply_to_user_id_str": null,
|
23
|
+
"place": null,
|
24
|
+
"retweet_count": 2181,
|
25
|
+
"retweeted": false,
|
26
|
+
"source": "web",
|
27
|
+
"text": "The \"http://\" at the beginning of URLs is a command to the browser. It stands for \"head to this place:\" followed by two laser-gun noises.",
|
28
|
+
"truncated": false,
|
29
|
+
"user": {
|
30
|
+
"contributors_enabled": false,
|
31
|
+
"created_at": "Fri Aug 07 22:49:15 +0000 2009",
|
32
|
+
"default_profile": false,
|
33
|
+
"default_profile_image": false,
|
34
|
+
"description": "Every day I wake up and put on my gym shorts one leg at a time.",
|
35
|
+
"favourites_count": 395,
|
36
|
+
"follow_request_sent": null,
|
37
|
+
"followers_count": 2390,
|
38
|
+
"following": null,
|
39
|
+
"friends_count": 78,
|
40
|
+
"geo_enabled": false,
|
41
|
+
"id": 63846421,
|
42
|
+
"id_str": "63846421",
|
43
|
+
"is_translator": false,
|
44
|
+
"lang": "en",
|
45
|
+
"listed_count": 98,
|
46
|
+
"location": "",
|
47
|
+
"name": "Brian Sutorius",
|
48
|
+
"notifications": null,
|
49
|
+
"profile_background_color": "FFFFFF",
|
50
|
+
"profile_background_image_url": "http://a0.twimg.com/profile_background_images/315830622/bg.png",
|
51
|
+
"profile_background_image_url_https": "https://si0.twimg.com/profile_background_images/315830622/bg.png",
|
52
|
+
"profile_background_tile": false,
|
53
|
+
"profile_banner_url": "https://si0.twimg.com/profile_banners/63846421/1350482543",
|
54
|
+
"profile_image_url": "http://a0.twimg.com/profile_images/2596248603/c7mhg7vxl601vcst6jap_normal.jpeg",
|
55
|
+
"profile_image_url_https": "https://si0.twimg.com/profile_images/2596248603/c7mhg7vxl601vcst6jap_normal.jpeg",
|
56
|
+
"profile_link_color": "004080",
|
57
|
+
"profile_sidebar_border_color": "FFFFFF",
|
58
|
+
"profile_sidebar_fill_color": "FFFFFF",
|
59
|
+
"profile_text_color": "222222",
|
60
|
+
"profile_use_background_image": false,
|
61
|
+
"protected": false,
|
62
|
+
"screen_name": "bsuto",
|
63
|
+
"statuses_count": 668,
|
64
|
+
"time_zone": "Eastern Time (US & Canada)",
|
65
|
+
"url": null,
|
66
|
+
"utc_offset": -18000,
|
67
|
+
"verified": false
|
68
|
+
}
|
69
|
+
}
|
70
|
+
"""
|
71
|
+
When I convert it into schema.org/Article/Small
|
72
|
+
Then I should have:
|
73
|
+
"""
|
74
|
+
{
|
75
|
+
"type": [
|
76
|
+
"http://schema.org/Article/Small"
|
77
|
+
],
|
78
|
+
"properties": {
|
79
|
+
"additionalType": [
|
80
|
+
"http://getfetcher.net/Item"
|
81
|
+
],
|
82
|
+
"Item#id": [
|
83
|
+
172070369035956224
|
84
|
+
],
|
85
|
+
"articleBody": [
|
86
|
+
"The \"http://\" at the beginning of URLs is a command to the browser. It stands for \"head to this place:\" followed by two laser-gun noises."
|
87
|
+
],
|
88
|
+
"author": [
|
89
|
+
{
|
90
|
+
"type": [
|
91
|
+
"http://schema.org/Person/User"
|
92
|
+
],
|
93
|
+
"properties": {
|
94
|
+
"additionalType": [
|
95
|
+
"http://getfetcher.net/Item"
|
96
|
+
],
|
97
|
+
"Item#id": [
|
98
|
+
63846421
|
99
|
+
],
|
100
|
+
"name": [
|
101
|
+
"Brian Sutorius"
|
102
|
+
],
|
103
|
+
"User#dateRegistered": [
|
104
|
+
1249685355
|
105
|
+
],
|
106
|
+
"description": [
|
107
|
+
"Every day I wake up and put on my gym shorts one leg at a time."
|
108
|
+
],
|
109
|
+
"url": [
|
110
|
+
"https://twitter.com/bsuto"
|
111
|
+
]
|
112
|
+
}
|
113
|
+
}
|
114
|
+
],
|
115
|
+
"dateCreated": [
|
116
|
+
1329859747
|
117
|
+
],
|
118
|
+
"provider": [
|
119
|
+
"twitter",
|
120
|
+
"web"
|
121
|
+
],
|
122
|
+
"url": [
|
123
|
+
"https://twitter.com/bsuto/status/172070369035956224"
|
124
|
+
]
|
125
|
+
}
|
126
|
+
}
|
127
|
+
"""
|
@@ -0,0 +1,79 @@
|
|
1
|
+
Feature: Translate Twitter User to schema.org/Person + getfetcher.net/Item
|
2
|
+
In order to send a standarized-properties form of the tweet
|
3
|
+
As a developer
|
4
|
+
I want to be able to convert from Twitter API User to
|
5
|
+
schema.org based vocabulary
|
6
|
+
|
7
|
+
Scenario: Converting a json twitter user into a json schema
|
8
|
+
Given the user:
|
9
|
+
"""
|
10
|
+
{
|
11
|
+
"contributors_enabled": false,
|
12
|
+
"created_at": "Fri Aug 07 22:49:15 +0000 2009",
|
13
|
+
"default_profile": false,
|
14
|
+
"default_profile_image": false,
|
15
|
+
"description": "Every day I wake up and put on my gym shorts one leg at a time.",
|
16
|
+
"favourites_count": 395,
|
17
|
+
"follow_request_sent": null,
|
18
|
+
"followers_count": 2390,
|
19
|
+
"following": null,
|
20
|
+
"friends_count": 78,
|
21
|
+
"geo_enabled": false,
|
22
|
+
"id": 63846421,
|
23
|
+
"id_str": "63846421",
|
24
|
+
"is_translator": false,
|
25
|
+
"lang": "en",
|
26
|
+
"listed_count": 98,
|
27
|
+
"location": "",
|
28
|
+
"name": "Brian Sutorius",
|
29
|
+
"notifications": null,
|
30
|
+
"profile_background_color": "FFFFFF",
|
31
|
+
"profile_background_image_url": "http://a0.twimg.com/profile_background_images/315830622/bg.png",
|
32
|
+
"profile_background_image_url_https": "https://si0.twimg.com/profile_background_images/315830622/bg.png",
|
33
|
+
"profile_background_tile": false,
|
34
|
+
"profile_banner_url": "https://si0.twimg.com/profile_banners/63846421/1350482543",
|
35
|
+
"profile_image_url": "http://a0.twimg.com/profile_images/2596248603/c7mhg7vxl601vcst6jap_normal.jpeg",
|
36
|
+
"profile_image_url_https": "https://si0.twimg.com/profile_images/2596248603/c7mhg7vxl601vcst6jap_normal.jpeg",
|
37
|
+
"profile_link_color": "004080",
|
38
|
+
"profile_sidebar_border_color": "FFFFFF",
|
39
|
+
"profile_sidebar_fill_color": "FFFFFF",
|
40
|
+
"profile_text_color": "222222",
|
41
|
+
"profile_use_background_image": false,
|
42
|
+
"protected": false,
|
43
|
+
"screen_name": "bsuto",
|
44
|
+
"statuses_count": 668,
|
45
|
+
"time_zone": "Eastern Time (US & Canada)",
|
46
|
+
"url": null,
|
47
|
+
"utc_offset": -18000,
|
48
|
+
"verified": false
|
49
|
+
}
|
50
|
+
"""
|
51
|
+
When I convert it into schema.org/Person/User
|
52
|
+
Then I should have:
|
53
|
+
"""
|
54
|
+
{
|
55
|
+
"type": [
|
56
|
+
"http://schema.org/Person/User"
|
57
|
+
],
|
58
|
+
"properties": {
|
59
|
+
"additionalType": [
|
60
|
+
"http://getfetcher.net/Item"
|
61
|
+
],
|
62
|
+
"Item#id": [
|
63
|
+
63846421
|
64
|
+
],
|
65
|
+
"name": [
|
66
|
+
"Brian Sutorius"
|
67
|
+
],
|
68
|
+
"User#dateRegistered": [
|
69
|
+
1249685355
|
70
|
+
],
|
71
|
+
"description": [
|
72
|
+
"Every day I wake up and put on my gym shorts one leg at a time."
|
73
|
+
],
|
74
|
+
"url": [
|
75
|
+
"https://twitter.com/bsuto"
|
76
|
+
]
|
77
|
+
}
|
78
|
+
}
|
79
|
+
"""
|
@@ -0,0 +1,22 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
require File.expand_path('../lib/fetcher/microdata/twitter/version', __FILE__)
|
3
|
+
|
4
|
+
Gem::Specification.new do |gem|
|
5
|
+
gem.authors = ["Xavier Via"]
|
6
|
+
gem.email = ["xavier.via.canel@gmail.com"]
|
7
|
+
gem.description = %q{Fetcher Microdata adapter for Twitter}
|
8
|
+
gem.summary = %q{Fetcher Microdata adapter for Twitter}
|
9
|
+
gem.homepage = "http://github.com/Fetcher/fetcher-microdata-twitter"
|
10
|
+
|
11
|
+
gem.add_dependency 'discoverer'
|
12
|
+
gem.add_dependency 'virtus'
|
13
|
+
|
14
|
+
gem.add_development_dependency 'rspec'
|
15
|
+
|
16
|
+
gem.files = `git ls-files`.split($\)
|
17
|
+
gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
|
18
|
+
gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
|
19
|
+
gem.name = "fetcher-microdata-twitter"
|
20
|
+
gem.require_paths = ["lib"]
|
21
|
+
gem.version = Fetcher::Microdata::Twitter::VERSION
|
22
|
+
end
|
@@ -0,0 +1,12 @@
|
|
1
|
+
require 'discoverer'
|
2
|
+
require 'virtus'
|
3
|
+
require 'json'
|
4
|
+
require 'singleton'
|
5
|
+
|
6
|
+
require 'writer/fetcher/microdata/twitter/article_small'
|
7
|
+
require 'writer/fetcher/microdata/twitter/person_user'
|
8
|
+
|
9
|
+
require 'fetcher/microdata/twitter/article_small'
|
10
|
+
require 'fetcher/microdata/twitter/person_user'
|
11
|
+
|
12
|
+
require 'fetcher/microdata/twitter/service'
|
@@ -0,0 +1,36 @@
|
|
1
|
+
module Fetcher
|
2
|
+
module Microdata
|
3
|
+
module Twitter
|
4
|
+
class ArticleSmall
|
5
|
+
include Virtus
|
6
|
+
include Discoverer::Writer
|
7
|
+
|
8
|
+
attr_accessor :_type
|
9
|
+
|
10
|
+
attribute :additionalType
|
11
|
+
attribute :id
|
12
|
+
attribute :articleBody
|
13
|
+
attribute :author
|
14
|
+
attribute :dateCreated
|
15
|
+
attribute :provider
|
16
|
+
attribute :url
|
17
|
+
|
18
|
+
def initialize original_tweet
|
19
|
+
@_type = 'http://schema.org/Article/Small'
|
20
|
+
@additionalType = 'http://getfetcher.net/Item'
|
21
|
+
|
22
|
+
coerce original_tweet
|
23
|
+
end
|
24
|
+
|
25
|
+
def coerce original_tweet
|
26
|
+
@id = original_tweet["id"]
|
27
|
+
@articleBody = original_tweet["text"]
|
28
|
+
@author = PersonUser.new original_tweet["user"]
|
29
|
+
@dateCreated = Service.instance.created_at_to_timestamp original_tweet["created_at"]
|
30
|
+
@provider = ["twitter", original_tweet["source"]]
|
31
|
+
@url = "https://twitter.com/#{original_tweet["user"]["screen_name"]}/status/#{original_tweet["id"]}"
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
@@ -0,0 +1,34 @@
|
|
1
|
+
module Fetcher
|
2
|
+
module Microdata
|
3
|
+
module Twitter
|
4
|
+
class PersonUser
|
5
|
+
include Virtus
|
6
|
+
include Discoverer::Writer
|
7
|
+
|
8
|
+
attr_reader :_type
|
9
|
+
|
10
|
+
attribute :additionalType
|
11
|
+
attribute :id
|
12
|
+
attribute :name
|
13
|
+
attribute :dateRegistered
|
14
|
+
attribute :description
|
15
|
+
attribute :url
|
16
|
+
|
17
|
+
def initialize twitter_user
|
18
|
+
@_type = "http://schema.org/Person/User"
|
19
|
+
|
20
|
+
coerce twitter_user
|
21
|
+
end
|
22
|
+
|
23
|
+
def coerce twitter_user
|
24
|
+
@additionalType = "http://getfetcher.net/Item"
|
25
|
+
@id = twitter_user["id"]
|
26
|
+
@name = twitter_user["name"]
|
27
|
+
@dateRegistered = Service.instance.created_at_to_timestamp twitter_user["created_at"]
|
28
|
+
@description = twitter_user["description"]
|
29
|
+
@url = "https://twitter.com/#{twitter_user["screen_name"]}"
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
module Fetcher
|
2
|
+
module Microdata
|
3
|
+
module Twitter
|
4
|
+
class Service
|
5
|
+
include Singleton
|
6
|
+
|
7
|
+
def created_at_to_timestamp created_at
|
8
|
+
year = created_at[-4..-1].to_i
|
9
|
+
month = created_at[4..6].downcase
|
10
|
+
day = created_at[8..9].to_i
|
11
|
+
|
12
|
+
time_fractioned = created_at[10..18].split ":"
|
13
|
+
hour = time_fractioned.shift.to_i
|
14
|
+
minute = time_fractioned.shift.to_i
|
15
|
+
second = time_fractioned.first.to_i
|
16
|
+
|
17
|
+
Time.gm(year, month, day, hour, minute, second).to_i
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
@@ -0,0 +1,43 @@
|
|
1
|
+
module Writer
|
2
|
+
module Fetcher
|
3
|
+
module Microdata
|
4
|
+
module Twitter
|
5
|
+
class ArticleSmall
|
6
|
+
attr_accessor :source
|
7
|
+
|
8
|
+
def initialize the_source
|
9
|
+
@source = the_source
|
10
|
+
end
|
11
|
+
|
12
|
+
def hash
|
13
|
+
@attributes = @source.attributes
|
14
|
+
{
|
15
|
+
"type" => [@source._type],
|
16
|
+
"properties" => {
|
17
|
+
"additionalType" => [
|
18
|
+
@attributes[:additionalType]
|
19
|
+
],
|
20
|
+
"Item#id" => [
|
21
|
+
@attributes[:id]
|
22
|
+
],
|
23
|
+
"articleBody" => [
|
24
|
+
@attributes[:articleBody]
|
25
|
+
],
|
26
|
+
"author" => [
|
27
|
+
@attributes[:author].to.hash
|
28
|
+
],
|
29
|
+
"dateCreated" => [
|
30
|
+
@attributes[:dateCreated]
|
31
|
+
],
|
32
|
+
"provider" => @attributes[:provider],
|
33
|
+
"url" => [
|
34
|
+
@attributes[:url]
|
35
|
+
]
|
36
|
+
}
|
37
|
+
}
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
@@ -0,0 +1,44 @@
|
|
1
|
+
module Writer
|
2
|
+
module Fetcher
|
3
|
+
module Microdata
|
4
|
+
module Twitter
|
5
|
+
class PersonUser
|
6
|
+
attr_reader :source
|
7
|
+
|
8
|
+
def initialize the_source
|
9
|
+
@source = the_source
|
10
|
+
end
|
11
|
+
|
12
|
+
def hash
|
13
|
+
@attributes = @source.attributes
|
14
|
+
{
|
15
|
+
"type" => [
|
16
|
+
@source._type
|
17
|
+
],
|
18
|
+
"properties" => {
|
19
|
+
"additionalType" => [
|
20
|
+
@attributes[:additionalType]
|
21
|
+
],
|
22
|
+
"Item#id" => [
|
23
|
+
@attributes[:id]
|
24
|
+
],
|
25
|
+
"name" => [
|
26
|
+
@attributes[:name]
|
27
|
+
],
|
28
|
+
"User#dateRegistered" => [
|
29
|
+
@attributes[:dateRegistered]
|
30
|
+
],
|
31
|
+
"description" => [
|
32
|
+
@attributes[:description]
|
33
|
+
],
|
34
|
+
"url" => [
|
35
|
+
@attributes[:url]
|
36
|
+
]
|
37
|
+
}
|
38
|
+
}
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
@@ -0,0 +1,108 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Fetcher::Microdata::Twitter::ArticleSmall do
|
4
|
+
describe '.new' do
|
5
|
+
before do
|
6
|
+
@argument_stub = stub 'arg'
|
7
|
+
end
|
8
|
+
it 'should receive an argument' do
|
9
|
+
Fetcher::Microdata::Twitter::ArticleSmall.any_instance.stub :coerce
|
10
|
+
Fetcher::Microdata::Twitter::ArticleSmall.new @argument_stub
|
11
|
+
end
|
12
|
+
|
13
|
+
it 'should set up the additionalType' do
|
14
|
+
Fetcher::Microdata::Twitter::ArticleSmall.any_instance.stub :coerce
|
15
|
+
adapter = Fetcher::Microdata::Twitter::ArticleSmall.new @argument_stub
|
16
|
+
adapter.additionalType.should == 'http://getfetcher.net/Item'
|
17
|
+
end
|
18
|
+
|
19
|
+
it 'should call coerce to coerce the values the argument values into the final form' do
|
20
|
+
Fetcher::Microdata::Twitter::ArticleSmall.any_instance.should_receive(:coerce).with @argument_stub
|
21
|
+
Fetcher::Microdata::Twitter::ArticleSmall.new @argument_stub
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
describe '#_type' do
|
26
|
+
it 'should return the schema.org type' do
|
27
|
+
Fetcher::Microdata::Twitter::ArticleSmall.any_instance.stub :coerce
|
28
|
+
argument_stub = stub 'argument'
|
29
|
+
adapter = Fetcher::Microdata::Twitter::ArticleSmall.new argument_stub
|
30
|
+
adapter._type.should == 'http://schema.org/Article/Small'
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
describe '#coerce' do
|
35
|
+
context 'the adapter receives a valid tweet' do
|
36
|
+
before do
|
37
|
+
@tweet = JSON.parse File.read 'spec/tweet.json'
|
38
|
+
@adapter = Fetcher::Microdata::Twitter::ArticleSmall.new @tweet
|
39
|
+
end
|
40
|
+
|
41
|
+
it 'should set #id with the value of "id"' do
|
42
|
+
@adapter.id.should == @tweet["id"]
|
43
|
+
end
|
44
|
+
|
45
|
+
it 'should set #articleBody with the value of "text"' do
|
46
|
+
@adapter.articleBody.should == @tweet["text"]
|
47
|
+
end
|
48
|
+
|
49
|
+
it 'should set #author with the Person from the value of "user" > "name"' do
|
50
|
+
@adapter.author.attributes.should == Fetcher::Microdata::Twitter::PersonUser.new(@tweet["user"]).attributes
|
51
|
+
end
|
52
|
+
|
53
|
+
it 'should set #dateCreated with the timestamp obtained from "created_at"' do
|
54
|
+
@adapter.dateCreated.should == 1329859747
|
55
|
+
end
|
56
|
+
|
57
|
+
it 'should set #provider as an array, coming Twitter first and then the "source"' do
|
58
|
+
@adapter.provider.should == ["twitter", @tweet["source"]]
|
59
|
+
end
|
60
|
+
|
61
|
+
it 'should set #url compiling the basic url with the "id" and the "user" > "screen_name"' do
|
62
|
+
@adapter.url.should == "https://twitter.com/#{@tweet["user"]["screen_name"]}/status/#{@tweet["id"]}"
|
63
|
+
end
|
64
|
+
end
|
65
|
+
end
|
66
|
+
|
67
|
+
it 'should include Discoverer::Writer' do
|
68
|
+
Fetcher::Microdata::Twitter::ArticleSmall.ancestors.should include Discoverer::Writer
|
69
|
+
end
|
70
|
+
|
71
|
+
it 'should include Virtus' do
|
72
|
+
Fetcher::Microdata::Twitter::ArticleSmall.ancestors.should include Virtus
|
73
|
+
end
|
74
|
+
|
75
|
+
describe 'attributes' do
|
76
|
+
before do
|
77
|
+
Fetcher::Microdata::Twitter::ArticleSmall.any_instance.stub :coerce
|
78
|
+
end
|
79
|
+
|
80
|
+
it 'should set attribute additionalType' do
|
81
|
+
Fetcher::Microdata::Twitter::ArticleSmall.new(@argument_stub).attributes.should have_key :additionalType
|
82
|
+
end
|
83
|
+
|
84
|
+
it 'should set attribute id' do
|
85
|
+
Fetcher::Microdata::Twitter::ArticleSmall.new(@argument_stub).attributes.should have_key :id
|
86
|
+
end
|
87
|
+
|
88
|
+
it 'should set attribute articleBody' do
|
89
|
+
Fetcher::Microdata::Twitter::ArticleSmall.new(@argument_stub).attributes.should have_key :articleBody
|
90
|
+
end
|
91
|
+
|
92
|
+
it 'should set attribute author' do
|
93
|
+
Fetcher::Microdata::Twitter::ArticleSmall.new(@argument_stub).attributes.should have_key :author
|
94
|
+
end
|
95
|
+
|
96
|
+
it 'should set attribute dateCreated' do
|
97
|
+
Fetcher::Microdata::Twitter::ArticleSmall.new(@argument_stub).attributes.should have_key :dateCreated
|
98
|
+
end
|
99
|
+
|
100
|
+
it 'should set attribute provider' do
|
101
|
+
Fetcher::Microdata::Twitter::ArticleSmall.new(@argument_stub).attributes.should have_key :provider
|
102
|
+
end
|
103
|
+
|
104
|
+
it 'should set attribute url' do
|
105
|
+
Fetcher::Microdata::Twitter::ArticleSmall.new(@argument_stub).attributes.should have_key :url
|
106
|
+
end
|
107
|
+
end
|
108
|
+
end
|
@@ -0,0 +1,97 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Fetcher::Microdata::Twitter::PersonUser do
|
4
|
+
describe '.new' do
|
5
|
+
before do
|
6
|
+
@argument = stub 'argument'
|
7
|
+
end
|
8
|
+
|
9
|
+
it 'should accept an argument' do
|
10
|
+
Fetcher::Microdata::Twitter::PersonUser.any_instance.stub :coerce
|
11
|
+
Fetcher::Microdata::Twitter::PersonUser.new @argument
|
12
|
+
end
|
13
|
+
|
14
|
+
it 'should set the _type to schema.org/Person/User' do
|
15
|
+
Fetcher::Microdata::Twitter::PersonUser.any_instance.stub :coerce
|
16
|
+
person = Fetcher::Microdata::Twitter::PersonUser.new @argument
|
17
|
+
person._type.should == "http://schema.org/Person/User"
|
18
|
+
end
|
19
|
+
|
20
|
+
it 'should call coerce with the argument' do
|
21
|
+
Fetcher::Microdata::Twitter::PersonUser.any_instance.should_receive(:coerce).with @argument
|
22
|
+
Fetcher::Microdata::Twitter::PersonUser.new @argument
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
describe '#coerce' do
|
27
|
+
context 'a valid twitter user hash is passed' do
|
28
|
+
before do
|
29
|
+
@user = JSON.parse File.read 'spec/user.json'
|
30
|
+
@person_user = Fetcher::Microdata::Twitter::PersonUser.new @user
|
31
|
+
end
|
32
|
+
|
33
|
+
it 'should initialize the additionalType as getfetcher.net/Item' do
|
34
|
+
@person_user.additionalType.should == "http://getfetcher.net/Item"
|
35
|
+
end
|
36
|
+
|
37
|
+
it 'should assign to :id the "id"' do
|
38
|
+
@person_user.id.should == @user["id"]
|
39
|
+
end
|
40
|
+
|
41
|
+
it 'should assign to :name the "name"' do
|
42
|
+
@person_user.name.should == @user["name"]
|
43
|
+
end
|
44
|
+
|
45
|
+
it 'should assign to :dateRegistered the timestamp corresponding to "created_at"' do
|
46
|
+
@person_user.dateRegistered.should == 1249685355
|
47
|
+
end
|
48
|
+
|
49
|
+
it 'should assign to :description the "description"' do
|
50
|
+
@person_user.description.should == @user["description"]
|
51
|
+
end
|
52
|
+
|
53
|
+
it 'should assign to :url the "screen_name" after the twitter url' do
|
54
|
+
@person_user.url.should == "https://twitter.com/#{@user["screen_name"]}"
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
59
|
+
it 'should include Discoverer::Writer' do
|
60
|
+
Fetcher::Microdata::Twitter::PersonUser.ancestors.should include Discoverer::Writer
|
61
|
+
end
|
62
|
+
|
63
|
+
it 'should include Virtus' do
|
64
|
+
Fetcher::Microdata::Twitter::PersonUser.ancestors.should include Virtus
|
65
|
+
end
|
66
|
+
|
67
|
+
describe 'attributes' do
|
68
|
+
before do
|
69
|
+
@argument_stub = stub 'argument'
|
70
|
+
Fetcher::Microdata::Twitter::PersonUser.any_instance.stub :coerce
|
71
|
+
end
|
72
|
+
|
73
|
+
it 'should have the attribute additionalType' do
|
74
|
+
Fetcher::Microdata::Twitter::PersonUser.new(@argument_stub).attributes.should have_key :additionalType
|
75
|
+
end
|
76
|
+
|
77
|
+
it 'should have the attribute id' do
|
78
|
+
Fetcher::Microdata::Twitter::PersonUser.new(@argument_stub).attributes.should have_key :id
|
79
|
+
end
|
80
|
+
|
81
|
+
it 'should have the attribute name' do
|
82
|
+
Fetcher::Microdata::Twitter::PersonUser.new(@argument_stub).attributes.should have_key :name
|
83
|
+
end
|
84
|
+
|
85
|
+
it 'should have the attribute dateRegistered' do
|
86
|
+
Fetcher::Microdata::Twitter::PersonUser.new(@argument_stub).attributes.should have_key :dateRegistered
|
87
|
+
end
|
88
|
+
|
89
|
+
it 'should have the attribute description' do
|
90
|
+
Fetcher::Microdata::Twitter::PersonUser.new(@argument_stub).attributes.should have_key :description
|
91
|
+
end
|
92
|
+
|
93
|
+
it 'should have the attribute url' do
|
94
|
+
Fetcher::Microdata::Twitter::PersonUser.new(@argument_stub).attributes.should have_key :url
|
95
|
+
end
|
96
|
+
end
|
97
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Fetcher::Microdata::Twitter::Service do
|
4
|
+
it 'should be a Singleton' do
|
5
|
+
Fetcher::Microdata::Twitter::Service.ancestors.should include Singleton
|
6
|
+
end
|
7
|
+
|
8
|
+
describe 'created_at_to_timestamp' do
|
9
|
+
it 'should adapt a twitter date to a long integer timestamp' do
|
10
|
+
twitter_date = 'Tue Feb 21 21:29:07 +0000 2012'
|
11
|
+
timestamp = 1329859747
|
12
|
+
Fetcher::Microdata::Twitter::Service.instance.created_at_to_timestamp(twitter_date).should == timestamp
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require 'fetcher/microdata/twitter'
|
data/spec/tweet.json
ADDED
@@ -0,0 +1,61 @@
|
|
1
|
+
{
|
2
|
+
"contributors": null,
|
3
|
+
"coordinates": null,
|
4
|
+
"created_at": "Tue Feb 21 21:29:07 +0000 2012",
|
5
|
+
"favorited": false,
|
6
|
+
"geo": null,
|
7
|
+
"id": 172070369035956224,
|
8
|
+
"id_str": "172070369035956224",
|
9
|
+
"in_reply_to_screen_name": null,
|
10
|
+
"in_reply_to_status_id": null,
|
11
|
+
"in_reply_to_status_id_str": null,
|
12
|
+
"in_reply_to_user_id": null,
|
13
|
+
"in_reply_to_user_id_str": null,
|
14
|
+
"place": null,
|
15
|
+
"retweet_count": 2181,
|
16
|
+
"retweeted": false,
|
17
|
+
"source": "web",
|
18
|
+
"text": "The \"http://\" at the beginning of URLs is a command to the browser. It stands for \"head to this place:\" followed by two laser-gun noises.",
|
19
|
+
"truncated": false,
|
20
|
+
"user": {
|
21
|
+
"contributors_enabled": false,
|
22
|
+
"created_at": "Fri Aug 07 22:49:15 +0000 2009",
|
23
|
+
"default_profile": false,
|
24
|
+
"default_profile_image": false,
|
25
|
+
"description": "Every day I wake up and put on my gym shorts one leg at a time.",
|
26
|
+
"favourites_count": 395,
|
27
|
+
"follow_request_sent": null,
|
28
|
+
"followers_count": 2390,
|
29
|
+
"following": null,
|
30
|
+
"friends_count": 78,
|
31
|
+
"geo_enabled": false,
|
32
|
+
"id": 63846421,
|
33
|
+
"id_str": "63846421",
|
34
|
+
"is_translator": false,
|
35
|
+
"lang": "en",
|
36
|
+
"listed_count": 98,
|
37
|
+
"location": "",
|
38
|
+
"name": "Brian Sutorius",
|
39
|
+
"notifications": null,
|
40
|
+
"profile_background_color": "FFFFFF",
|
41
|
+
"profile_background_image_url": "http://a0.twimg.com/profile_background_images/315830622/bg.png",
|
42
|
+
"profile_background_image_url_https": "https://si0.twimg.com/profile_background_images/315830622/bg.png",
|
43
|
+
"profile_background_tile": false,
|
44
|
+
"profile_banner_url": "https://si0.twimg.com/profile_banners/63846421/1350482543",
|
45
|
+
"profile_image_url": "http://a0.twimg.com/profile_images/2596248603/c7mhg7vxl601vcst6jap_normal.jpeg",
|
46
|
+
"profile_image_url_https": "https://si0.twimg.com/profile_images/2596248603/c7mhg7vxl601vcst6jap_normal.jpeg",
|
47
|
+
"profile_link_color": "004080",
|
48
|
+
"profile_sidebar_border_color": "FFFFFF",
|
49
|
+
"profile_sidebar_fill_color": "FFFFFF",
|
50
|
+
"profile_text_color": "222222",
|
51
|
+
"profile_use_background_image": false,
|
52
|
+
"protected": false,
|
53
|
+
"screen_name": "bsuto",
|
54
|
+
"statuses_count": 668,
|
55
|
+
"time_zone": "Eastern Time (US & Canada)",
|
56
|
+
"url": null,
|
57
|
+
"utc_offset": -18000,
|
58
|
+
"verified": false
|
59
|
+
}
|
60
|
+
}
|
61
|
+
|
data/spec/user.json
ADDED
@@ -0,0 +1,40 @@
|
|
1
|
+
{
|
2
|
+
"contributors_enabled": false,
|
3
|
+
"created_at": "Fri Aug 07 22:49:15 +0000 2009",
|
4
|
+
"default_profile": false,
|
5
|
+
"default_profile_image": false,
|
6
|
+
"description": "Every day I wake up and put on my gym shorts one leg at a time.",
|
7
|
+
"favourites_count": 395,
|
8
|
+
"follow_request_sent": null,
|
9
|
+
"followers_count": 2390,
|
10
|
+
"following": null,
|
11
|
+
"friends_count": 78,
|
12
|
+
"geo_enabled": false,
|
13
|
+
"id": 63846421,
|
14
|
+
"id_str": "63846421",
|
15
|
+
"is_translator": false,
|
16
|
+
"lang": "en",
|
17
|
+
"listed_count": 98,
|
18
|
+
"location": "",
|
19
|
+
"name": "Brian Sutorius",
|
20
|
+
"notifications": null,
|
21
|
+
"profile_background_color": "FFFFFF",
|
22
|
+
"profile_background_image_url": "http://a0.twimg.com/profile_background_images/315830622/bg.png",
|
23
|
+
"profile_background_image_url_https": "https://si0.twimg.com/profile_background_images/315830622/bg.png",
|
24
|
+
"profile_background_tile": false,
|
25
|
+
"profile_banner_url": "https://si0.twimg.com/profile_banners/63846421/1350482543",
|
26
|
+
"profile_image_url": "http://a0.twimg.com/profile_images/2596248603/c7mhg7vxl601vcst6jap_normal.jpeg",
|
27
|
+
"profile_image_url_https": "https://si0.twimg.com/profile_images/2596248603/c7mhg7vxl601vcst6jap_normal.jpeg",
|
28
|
+
"profile_link_color": "004080",
|
29
|
+
"profile_sidebar_border_color": "FFFFFF",
|
30
|
+
"profile_sidebar_fill_color": "FFFFFF",
|
31
|
+
"profile_text_color": "222222",
|
32
|
+
"profile_use_background_image": false,
|
33
|
+
"protected": false,
|
34
|
+
"screen_name": "bsuto",
|
35
|
+
"statuses_count": 668,
|
36
|
+
"time_zone": "Eastern Time (US & Canada)",
|
37
|
+
"url": null,
|
38
|
+
"utc_offset": -18000,
|
39
|
+
"verified": false
|
40
|
+
}
|
@@ -0,0 +1,108 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Writer::Fetcher::Microdata::Twitter::ArticleSmall do
|
4
|
+
describe '#hash' do
|
5
|
+
before do
|
6
|
+
@schema_stub = stub 'schema'
|
7
|
+
@author_stub = stub 'author', :to => stub( :hash => nil)
|
8
|
+
end
|
9
|
+
|
10
|
+
it 'should return a hash with the type' do
|
11
|
+
final_hash = {
|
12
|
+
"type" => [
|
13
|
+
'the type'
|
14
|
+
]
|
15
|
+
}
|
16
|
+
@schema_stub.should_receive(:_type).and_return "the type"
|
17
|
+
@schema_stub.should_receive(:attributes).and_return stub('the hash', :[] => @author_stub)
|
18
|
+
|
19
|
+
writer = Writer::Fetcher::Microdata::Twitter::ArticleSmall.new @schema_stub
|
20
|
+
writer.hash.should include final_hash
|
21
|
+
end
|
22
|
+
|
23
|
+
describe 'properties hash' do
|
24
|
+
before do
|
25
|
+
@schema_stub.should_receive(:_type).and_return nil
|
26
|
+
end
|
27
|
+
|
28
|
+
it 'should include the additionalType' do
|
29
|
+
@properties_hash = {
|
30
|
+
"additionalType" => [
|
31
|
+
"http://getfetcher.net/Item"
|
32
|
+
]
|
33
|
+
}
|
34
|
+
@schema_stub.should_receive(:attributes).and_return :additionalType => "http://getfetcher.net/Item", :author => @author_stub
|
35
|
+
end
|
36
|
+
|
37
|
+
it 'should include the Item#id' do
|
38
|
+
@properties_hash = {
|
39
|
+
"Item#id" => [
|
40
|
+
234536234
|
41
|
+
]
|
42
|
+
}
|
43
|
+
|
44
|
+
@schema_stub.should_receive(:attributes).and_return :id => 234536234, :author => @author_stub
|
45
|
+
end
|
46
|
+
|
47
|
+
it 'should include the articleBody' do
|
48
|
+
@properties_hash = {
|
49
|
+
"articleBody" => [
|
50
|
+
"some body"
|
51
|
+
]
|
52
|
+
}
|
53
|
+
|
54
|
+
@schema_stub.should_receive(:attributes).and_return :articleBody => "some body", :author => @author_stub
|
55
|
+
end
|
56
|
+
|
57
|
+
it 'should include the author' do
|
58
|
+
@author = stub 'author'
|
59
|
+
@author_writer = stub 'author writer'
|
60
|
+
@author_writer.should_receive(:hash).and_return "hi Im the author"
|
61
|
+
@author.should_receive(:to).and_return @author_writer
|
62
|
+
@properties_hash = {
|
63
|
+
"author" => [
|
64
|
+
"hi Im the author"
|
65
|
+
]
|
66
|
+
}
|
67
|
+
|
68
|
+
@schema_stub.should_receive(:attributes).and_return :author => @author
|
69
|
+
end
|
70
|
+
|
71
|
+
it 'should include the dateCreated' do
|
72
|
+
@properties_hash = {
|
73
|
+
"dateCreated" => [
|
74
|
+
23456235
|
75
|
+
]
|
76
|
+
}
|
77
|
+
|
78
|
+
@schema_stub.should_receive(:attributes).and_return :dateCreated => 23456235, :author => @author_stub
|
79
|
+
end
|
80
|
+
|
81
|
+
it 'should include the provider' do
|
82
|
+
@properties_hash = {
|
83
|
+
"provider" => [
|
84
|
+
"twitter",
|
85
|
+
"fetcher"
|
86
|
+
]
|
87
|
+
}
|
88
|
+
|
89
|
+
@schema_stub.should_receive(:attributes).and_return :provider => ["twitter", "fetcher"], :author => @author_stub
|
90
|
+
end
|
91
|
+
|
92
|
+
it 'should include the url' do
|
93
|
+
@properties_hash = {
|
94
|
+
"url" => [
|
95
|
+
"http://myurl.info"
|
96
|
+
]
|
97
|
+
}
|
98
|
+
|
99
|
+
@schema_stub.should_receive(:attributes).and_return :url => "http://myurl.info", :author => @author_stub
|
100
|
+
end
|
101
|
+
|
102
|
+
after :each do
|
103
|
+
writer = Writer::Fetcher::Microdata::Twitter::ArticleSmall.new @schema_stub
|
104
|
+
writer.hash["properties"].should include @properties_hash
|
105
|
+
end
|
106
|
+
end
|
107
|
+
end
|
108
|
+
end
|
@@ -0,0 +1,93 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Writer::Fetcher::Microdata::Twitter::PersonUser do
|
4
|
+
it 'should have a proper initializer to a Writer' do
|
5
|
+
user_stub = stub 'user'
|
6
|
+
writer = Writer::Fetcher::Microdata::Twitter::PersonUser.new user_stub
|
7
|
+
writer.source.should == user_stub
|
8
|
+
end
|
9
|
+
|
10
|
+
describe '#hash' do
|
11
|
+
before do
|
12
|
+
@user_stub = stub 'user'
|
13
|
+
end
|
14
|
+
|
15
|
+
it 'should return the type' do
|
16
|
+
final_hash = {
|
17
|
+
"type" => [
|
18
|
+
"some type"
|
19
|
+
]
|
20
|
+
}
|
21
|
+
|
22
|
+
@user_stub.should_receive(:_type).and_return "some type"
|
23
|
+
@user_stub.should_receive(:attributes).and_return stub :[] => nil
|
24
|
+
writer = Writer::Fetcher::Microdata::Twitter::PersonUser.new @user_stub
|
25
|
+
writer.hash.should include final_hash
|
26
|
+
end
|
27
|
+
|
28
|
+
describe 'properties hash' do
|
29
|
+
before do
|
30
|
+
@user_stub.should_receive :_type
|
31
|
+
end
|
32
|
+
|
33
|
+
it 'should include the additionalType' do
|
34
|
+
@properties_hash = {
|
35
|
+
"additionalType" => [
|
36
|
+
"http://getfetcher.net/Item"
|
37
|
+
]
|
38
|
+
}
|
39
|
+
@user_stub.should_receive(:attributes).and_return :additionalType => "http://getfetcher.net/Item"
|
40
|
+
end
|
41
|
+
|
42
|
+
it 'should include the Item#id' do
|
43
|
+
@properties_hash = {
|
44
|
+
"Item#id" => [
|
45
|
+
234525
|
46
|
+
]
|
47
|
+
}
|
48
|
+
@user_stub.should_receive(:attributes).and_return :id => 234525
|
49
|
+
end
|
50
|
+
|
51
|
+
it 'should include the name' do
|
52
|
+
@properties_hash = {
|
53
|
+
"name" => [
|
54
|
+
"Marcus"
|
55
|
+
]
|
56
|
+
}
|
57
|
+
@user_stub.should_receive(:attributes).and_return :name => "Marcus"
|
58
|
+
end
|
59
|
+
|
60
|
+
it 'should include the dateRegistered' do
|
61
|
+
@properties_hash = {
|
62
|
+
"User#dateRegistered" => [
|
63
|
+
456468768
|
64
|
+
]
|
65
|
+
}
|
66
|
+
@user_stub.should_receive(:attributes).and_return :dateRegistered => 456468768
|
67
|
+
end
|
68
|
+
|
69
|
+
it 'should include the description' do
|
70
|
+
@properties_hash = {
|
71
|
+
"description" => [
|
72
|
+
456468768
|
73
|
+
]
|
74
|
+
}
|
75
|
+
@user_stub.should_receive(:attributes).and_return :description => 456468768
|
76
|
+
end
|
77
|
+
|
78
|
+
it 'should include the url' do
|
79
|
+
@properties_hash = {
|
80
|
+
"url" => [
|
81
|
+
456468768
|
82
|
+
]
|
83
|
+
}
|
84
|
+
@user_stub.should_receive(:attributes).and_return :url => 456468768
|
85
|
+
end
|
86
|
+
|
87
|
+
after :each do
|
88
|
+
writer = Writer::Fetcher::Microdata::Twitter::PersonUser.new @user_stub
|
89
|
+
writer.hash["properties"].should include @properties_hash
|
90
|
+
end
|
91
|
+
end
|
92
|
+
end
|
93
|
+
end
|
data/tweet.yaml
ADDED
@@ -0,0 +1,59 @@
|
|
1
|
+
---
|
2
|
+
contributors:
|
3
|
+
coordinates:
|
4
|
+
created_at: Tue Feb 21 21:29:07 +0000 2012
|
5
|
+
favorited: false
|
6
|
+
geo:
|
7
|
+
id: 172070369035956224
|
8
|
+
id_str: '172070369035956224'
|
9
|
+
in_reply_to_screen_name:
|
10
|
+
in_reply_to_status_id:
|
11
|
+
in_reply_to_status_id_str:
|
12
|
+
in_reply_to_user_id:
|
13
|
+
in_reply_to_user_id_str:
|
14
|
+
place:
|
15
|
+
retweet_count: 2181
|
16
|
+
retweeted: false
|
17
|
+
source: web
|
18
|
+
text: The "http://" at the beginning of URLs is a command to the browser. It stands
|
19
|
+
for "head to this place:" followed by two laser-gun noises.
|
20
|
+
truncated: false
|
21
|
+
user:
|
22
|
+
contributors_enabled: false
|
23
|
+
created_at: Fri Aug 07 22:49:15 +0000 2009
|
24
|
+
default_profile: false
|
25
|
+
default_profile_image: false
|
26
|
+
description: Every day I wake up and put on my gym shorts one leg at a time.
|
27
|
+
favourites_count: 395
|
28
|
+
follow_request_sent:
|
29
|
+
followers_count: 2390
|
30
|
+
following:
|
31
|
+
friends_count: 78
|
32
|
+
geo_enabled: false
|
33
|
+
id: 63846421
|
34
|
+
id_str: '63846421'
|
35
|
+
is_translator: false
|
36
|
+
lang: en
|
37
|
+
listed_count: 98
|
38
|
+
location: ''
|
39
|
+
name: Brian Sutorius
|
40
|
+
notifications:
|
41
|
+
profile_background_color: FFFFFF
|
42
|
+
profile_background_image_url: http://a0.twimg.com/profile_background_images/315830622/bg.png
|
43
|
+
profile_background_image_url_https: https://si0.twimg.com/profile_background_images/315830622/bg.png
|
44
|
+
profile_background_tile: false
|
45
|
+
profile_banner_url: https://si0.twimg.com/profile_banners/63846421/1350482543
|
46
|
+
profile_image_url: http://a0.twimg.com/profile_images/2596248603/c7mhg7vxl601vcst6jap_normal.jpeg
|
47
|
+
profile_image_url_https: https://si0.twimg.com/profile_images/2596248603/c7mhg7vxl601vcst6jap_normal.jpeg
|
48
|
+
profile_link_color: 004080
|
49
|
+
profile_sidebar_border_color: FFFFFF
|
50
|
+
profile_sidebar_fill_color: FFFFFF
|
51
|
+
profile_text_color: '222222'
|
52
|
+
profile_use_background_image: false
|
53
|
+
protected: false
|
54
|
+
screen_name: bsuto
|
55
|
+
statuses_count: 668
|
56
|
+
time_zone: Eastern Time (US & Canada)
|
57
|
+
url:
|
58
|
+
utc_offset: -18000
|
59
|
+
verified: false
|
metadata
ADDED
@@ -0,0 +1,139 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: fetcher-microdata-twitter
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Xavier Via
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2012-10-31 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: discoverer
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ! '>='
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: '0'
|
22
|
+
type: :runtime
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ! '>='
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: '0'
|
30
|
+
- !ruby/object:Gem::Dependency
|
31
|
+
name: virtus
|
32
|
+
requirement: !ruby/object:Gem::Requirement
|
33
|
+
none: false
|
34
|
+
requirements:
|
35
|
+
- - ! '>='
|
36
|
+
- !ruby/object:Gem::Version
|
37
|
+
version: '0'
|
38
|
+
type: :runtime
|
39
|
+
prerelease: false
|
40
|
+
version_requirements: !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
42
|
+
requirements:
|
43
|
+
- - ! '>='
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
version: '0'
|
46
|
+
- !ruby/object:Gem::Dependency
|
47
|
+
name: rspec
|
48
|
+
requirement: !ruby/object:Gem::Requirement
|
49
|
+
none: false
|
50
|
+
requirements:
|
51
|
+
- - ! '>='
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
version: '0'
|
54
|
+
type: :development
|
55
|
+
prerelease: false
|
56
|
+
version_requirements: !ruby/object:Gem::Requirement
|
57
|
+
none: false
|
58
|
+
requirements:
|
59
|
+
- - ! '>='
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
description: Fetcher Microdata adapter for Twitter
|
63
|
+
email:
|
64
|
+
- xavier.via.canel@gmail.com
|
65
|
+
executables: []
|
66
|
+
extensions: []
|
67
|
+
extra_rdoc_files: []
|
68
|
+
files:
|
69
|
+
- .gitignore
|
70
|
+
- .travis.yml
|
71
|
+
- Gemfile
|
72
|
+
- Gemfile.lock
|
73
|
+
- LICENSE
|
74
|
+
- README.md
|
75
|
+
- Rakefile
|
76
|
+
- features/stepdefs/translate_tweet_to_schema.rb
|
77
|
+
- features/support/env.rb
|
78
|
+
- features/translate_tweet_to_schema.feature
|
79
|
+
- features/translate_user_to_schema.feature
|
80
|
+
- fetcher-microdata-twitter.gemspec
|
81
|
+
- lib/fetcher/microdata/twitter.rb
|
82
|
+
- lib/fetcher/microdata/twitter/article_small.rb
|
83
|
+
- lib/fetcher/microdata/twitter/person_user.rb
|
84
|
+
- lib/fetcher/microdata/twitter/service.rb
|
85
|
+
- lib/fetcher/microdata/twitter/version.rb
|
86
|
+
- lib/writer/fetcher/microdata/twitter/article_small.rb
|
87
|
+
- lib/writer/fetcher/microdata/twitter/person_user.rb
|
88
|
+
- spec/fetcher/microdata/twitter/article_small_spec.rb
|
89
|
+
- spec/fetcher/microdata/twitter/person_user_spec.rb
|
90
|
+
- spec/fetcher/microdata/twitter/service_spec.rb
|
91
|
+
- spec/spec_helper.rb
|
92
|
+
- spec/tweet.json
|
93
|
+
- spec/user.json
|
94
|
+
- spec/writer/fetcher/microdata/twitter/article_small_spec.rb
|
95
|
+
- spec/writer/fetcher/microdata/twitter/person_user_spec.rb
|
96
|
+
- tweet.yaml
|
97
|
+
homepage: http://github.com/Fetcher/fetcher-microdata-twitter
|
98
|
+
licenses: []
|
99
|
+
post_install_message:
|
100
|
+
rdoc_options: []
|
101
|
+
require_paths:
|
102
|
+
- lib
|
103
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
104
|
+
none: false
|
105
|
+
requirements:
|
106
|
+
- - ! '>='
|
107
|
+
- !ruby/object:Gem::Version
|
108
|
+
version: '0'
|
109
|
+
segments:
|
110
|
+
- 0
|
111
|
+
hash: 273088467
|
112
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
113
|
+
none: false
|
114
|
+
requirements:
|
115
|
+
- - ! '>='
|
116
|
+
- !ruby/object:Gem::Version
|
117
|
+
version: '0'
|
118
|
+
segments:
|
119
|
+
- 0
|
120
|
+
hash: 273088467
|
121
|
+
requirements: []
|
122
|
+
rubyforge_project:
|
123
|
+
rubygems_version: 1.8.24
|
124
|
+
signing_key:
|
125
|
+
specification_version: 3
|
126
|
+
summary: Fetcher Microdata adapter for Twitter
|
127
|
+
test_files:
|
128
|
+
- features/stepdefs/translate_tweet_to_schema.rb
|
129
|
+
- features/support/env.rb
|
130
|
+
- features/translate_tweet_to_schema.feature
|
131
|
+
- features/translate_user_to_schema.feature
|
132
|
+
- spec/fetcher/microdata/twitter/article_small_spec.rb
|
133
|
+
- spec/fetcher/microdata/twitter/person_user_spec.rb
|
134
|
+
- spec/fetcher/microdata/twitter/service_spec.rb
|
135
|
+
- spec/spec_helper.rb
|
136
|
+
- spec/tweet.json
|
137
|
+
- spec/user.json
|
138
|
+
- spec/writer/fetcher/microdata/twitter/article_small_spec.rb
|
139
|
+
- spec/writer/fetcher/microdata/twitter/person_user_spec.rb
|