activitystreams 0.0.1 → 0.0.2
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.
- data/VERSION +1 -1
- data/lib/activitystreams.rb +12 -0
- data/lib/activitystreams/activity.rb +14 -0
- data/lib/activitystreams/base.rb +1 -1
- data/lib/activitystreams/ext_properties.rb +26 -0
- data/lib/activitystreams/object.rb +25 -2
- data/lib/activitystreams/object/article.rb +4 -0
- data/lib/activitystreams/object/audio.rb +10 -0
- data/lib/activitystreams/object/badge.rb +4 -0
- data/lib/activitystreams/object/bookmark.rb +11 -0
- data/lib/activitystreams/object/collection.rb +10 -0
- data/lib/activitystreams/object/comment.rb +10 -0
- data/lib/activitystreams/object/event.rb +15 -0
- data/lib/activitystreams/object/file.rb +10 -0
- data/lib/activitystreams/object/group.rb +4 -0
- data/lib/activitystreams/object/image.rb +10 -0
- data/lib/activitystreams/object/note.rb +4 -0
- data/lib/activitystreams/object/person.rb +4 -0
- data/lib/activitystreams/object/place.rb +25 -0
- data/lib/activitystreams/object/product.rb +10 -0
- data/lib/activitystreams/object/question.rb +10 -0
- data/lib/activitystreams/object/review.rb +16 -0
- data/lib/activitystreams/object/service.rb +4 -0
- data/lib/activitystreams/object/video.rb +10 -0
- data/lib/activitystreams/validator.rb +11 -1
- data/lib/activitystreams/verb.rb +17 -3
- data/lib/activitystreams/verb/add.rb +4 -0
- data/lib/activitystreams/verb/cancel.rb +4 -0
- data/lib/activitystreams/verb/checkin.rb +4 -0
- data/lib/activitystreams/verb/delete.rb +4 -0
- data/lib/activitystreams/verb/favorite.rb +4 -0
- data/lib/activitystreams/verb/follow.rb +4 -0
- data/lib/activitystreams/verb/give.rb +4 -0
- data/lib/activitystreams/verb/ignore.rb +4 -0
- data/lib/activitystreams/verb/invite.rb +4 -0
- data/lib/activitystreams/verb/join.rb +4 -0
- data/lib/activitystreams/verb/leave.rb +4 -0
- data/lib/activitystreams/verb/like.rb +4 -0
- data/lib/activitystreams/verb/make_friend.rb +4 -0
- data/lib/activitystreams/verb/play.rb +4 -0
- data/lib/activitystreams/verb/receive.rb +4 -0
- data/lib/activitystreams/verb/remove.rb +4 -0
- data/lib/activitystreams/verb/remove_friend.rb +4 -0
- data/lib/activitystreams/verb/request_friend.rb +4 -0
- data/lib/activitystreams/verb/rsvp_maybe.rb +4 -0
- data/lib/activitystreams/verb/rsvp_no.rb +4 -0
- data/lib/activitystreams/verb/rsvp_yes.rb +4 -0
- data/lib/activitystreams/verb/save.rb +4 -0
- data/lib/activitystreams/verb/share.rb +4 -0
- data/lib/activitystreams/verb/stop_following.rb +4 -0
- data/lib/activitystreams/verb/tag.rb +4 -0
- data/lib/activitystreams/verb/unfavorite.rb +4 -0
- data/lib/activitystreams/verb/unlike.rb +4 -0
- data/lib/activitystreams/verb/unsave.rb +4 -0
- data/lib/activitystreams/verb/update.rb +4 -0
- data/spec/activitystreams/activity_spec.rb +31 -0
- data/spec/activitystreams/base_spec.rb +2 -2
- data/spec/activitystreams/media_link_spec.rb +2 -2
- data/spec/activitystreams/object/article_spec.rb +6 -0
- data/spec/activitystreams/object/audio_spec.rb +13 -0
- data/spec/activitystreams/object/bookmark_spec.rb +15 -0
- data/spec/activitystreams/object/collection_spec.rb +13 -0
- data/spec/activitystreams/object/comment_spec.rb +13 -0
- data/spec/activitystreams/object/event_spec.rb +17 -0
- data/spec/activitystreams/object/file_spec.rb +13 -0
- data/spec/activitystreams/object/image_spec.rb +13 -0
- data/spec/activitystreams/object/place_spec.rb +52 -0
- data/spec/activitystreams/object/product_spec.rb +13 -0
- data/spec/activitystreams/object/question_spec.rb +13 -0
- data/spec/activitystreams/object/review_spec.rb +32 -0
- data/spec/activitystreams/object/video_spec.rb +13 -0
- data/spec/activitystreams/object_spec.rb +9 -0
- data/spec/activitystreams/verb/add_spec.rb +6 -0
- data/spec/activitystreams/verb/make_friend_spec.rb +6 -0
- data/spec/activitystreams/verb/rsvp_maybe_spec.rb +6 -0
- data/spec/activitystreams/verb_spec.rb +2 -14
- data/spec/activitystreams_spec.rb +14 -0
- metadata +87 -5
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.0.
|
1
|
+
0.0.2
|
data/lib/activitystreams.rb
CHANGED
@@ -4,11 +4,23 @@ require 'attr_required'
|
|
4
4
|
require 'attr_optional'
|
5
5
|
require 'addressable/uri'
|
6
6
|
|
7
|
+
module ActivityStreams
|
8
|
+
def self.logger
|
9
|
+
@@logger
|
10
|
+
end
|
11
|
+
def self.logger=(logger)
|
12
|
+
@@logger = logger
|
13
|
+
end
|
14
|
+
@@logger = Logger.new(STDERR)
|
15
|
+
@@logger.progname = 'ActivityStreams'
|
16
|
+
end
|
17
|
+
|
7
18
|
require 'activitystreams/validator'
|
8
19
|
require 'activitystreams/exception'
|
9
20
|
require 'activitystreams/base'
|
10
21
|
require 'activitystreams/collection'
|
11
22
|
require 'activitystreams/stream'
|
23
|
+
require 'activitystreams/ext_properties'
|
12
24
|
require 'activitystreams/activity'
|
13
25
|
require 'activitystreams/object'
|
14
26
|
require 'activitystreams/verb'
|
@@ -1,5 +1,7 @@
|
|
1
1
|
module ActivityStreams
|
2
2
|
class Activity < Base
|
3
|
+
include ExtProperties
|
4
|
+
|
3
5
|
attr_required :actor, :verb, :published
|
4
6
|
attr_optional(
|
5
7
|
# SHOULD
|
@@ -34,6 +36,18 @@ module ActivityStreams
|
|
34
36
|
end
|
35
37
|
validate_attribute! :verb, Verb
|
36
38
|
validate_attribute! :icon, MediaLink
|
39
|
+
unless recommended_verb?
|
40
|
+
ActivityStreams.logger.warn "\"#{verb.to_s}\" is not recommended. \"#{recommended_verbs.join('", "')}\" are recommended."
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
def recommended_verb?
|
45
|
+
recommended_verbs.blank? ||
|
46
|
+
recommended_verbs.include?(verb.to_s)
|
47
|
+
end
|
48
|
+
|
49
|
+
def recommended_verbs
|
50
|
+
(object.try(:recommended_verbs) || []).collect(&:to_s)
|
37
51
|
end
|
38
52
|
end
|
39
53
|
end
|
data/lib/activitystreams/base.rb
CHANGED
@@ -17,7 +17,7 @@ module ActivityStreams
|
|
17
17
|
(required_attributes + optional_attributes).inject({}) do |hash, _attr_|
|
18
18
|
_value_ = self.send _attr_
|
19
19
|
hash.merge!(
|
20
|
-
_attr_ => case _value_
|
20
|
+
_attr_.to_s.camelize(:lower).to_sym => case _value_
|
21
21
|
when Symbol, Addressable::URI
|
22
22
|
_value_.to_s
|
23
23
|
when Time
|
@@ -0,0 +1,26 @@
|
|
1
|
+
module ActivityStreams
|
2
|
+
module ExtProperties
|
3
|
+
class Mood < Base
|
4
|
+
attr_optional :display_name, :image
|
5
|
+
end
|
6
|
+
|
7
|
+
def self.included(klass)
|
8
|
+
klass.attr_optional(
|
9
|
+
:location,
|
10
|
+
:mood,
|
11
|
+
:rating,
|
12
|
+
:source,
|
13
|
+
:tags
|
14
|
+
)
|
15
|
+
end
|
16
|
+
|
17
|
+
def validate_attributes!
|
18
|
+
super
|
19
|
+
validate_attribute! :location, Object::Place
|
20
|
+
validate_attribute! :mood, Mood
|
21
|
+
validate_attribute! :rating, Object::Review
|
22
|
+
validate_attribute! :source, Object
|
23
|
+
validate_attribute! :tags, Object, :arrayed!
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
@@ -1,5 +1,7 @@
|
|
1
1
|
module ActivityStreams
|
2
2
|
class Object < Base
|
3
|
+
include ExtProperties
|
4
|
+
|
3
5
|
attr_optional(
|
4
6
|
# SHOULD
|
5
7
|
:id,
|
@@ -11,16 +13,24 @@ module ActivityStreams
|
|
11
13
|
:content,
|
12
14
|
:display_name,
|
13
15
|
:image,
|
14
|
-
:
|
16
|
+
:object_type,
|
15
17
|
:published,
|
16
18
|
:summary,
|
17
19
|
:updated,
|
18
20
|
:url
|
19
21
|
)
|
20
22
|
|
23
|
+
def initialize(attributes = {})
|
24
|
+
_type_ = if self.class.superclass == Object
|
25
|
+
self.class.name.demodulize.underscore
|
26
|
+
end
|
27
|
+
attributes = {:object_type => _type_}.merge(attributes)
|
28
|
+
super attributes
|
29
|
+
end
|
30
|
+
|
21
31
|
def validate_attributes!
|
22
32
|
super
|
23
|
-
[:id, :
|
33
|
+
[:id, :object_type, :url].each do |_attr_|
|
24
34
|
to_iri _attr_
|
25
35
|
end
|
26
36
|
[:published, :updated].each do |_attr_|
|
@@ -34,5 +44,18 @@ module ActivityStreams
|
|
34
44
|
end
|
35
45
|
# TODO: display_name MUST NOT include HTML
|
36
46
|
end
|
47
|
+
|
48
|
+
def recommended_verbs
|
49
|
+
self.class.recommended_verbs
|
50
|
+
end
|
51
|
+
|
52
|
+
def self.recommended_verbs(*verbs)
|
53
|
+
@recommended_verbs ||= []
|
54
|
+
@recommended_verbs += verbs
|
55
|
+
end
|
37
56
|
end
|
38
57
|
end
|
58
|
+
|
59
|
+
Dir[File.dirname(__FILE__) + '/object/*.rb'].each do |file|
|
60
|
+
require file
|
61
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
module ActivityStreams
|
2
|
+
class Object::Event < Object
|
3
|
+
attr_optional :attending, :maybe_attending, :not_attending, :start_time, :end_time
|
4
|
+
|
5
|
+
def validate_attributes!
|
6
|
+
super
|
7
|
+
[:attending, :maybe_attending, :not_attending].each do |_attr_|
|
8
|
+
validate_attribute! _attr_, Object::Collection
|
9
|
+
end
|
10
|
+
[:start_time, :end_time].each do |_attr_|
|
11
|
+
to_time _attr_
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
module ActivityStreams
|
2
|
+
class Object::Place < Object
|
3
|
+
attr_optional :position, :address
|
4
|
+
|
5
|
+
class GeoLocation < Base
|
6
|
+
attr_required :latitude, :longitude
|
7
|
+
attr_optional :altitude
|
8
|
+
|
9
|
+
def to_s
|
10
|
+
"+" + [latitude, longitude, altitude].compact.join('+')
|
11
|
+
end
|
12
|
+
alias_method :as_json, :to_s
|
13
|
+
end
|
14
|
+
|
15
|
+
class Address < Base
|
16
|
+
attr_optional :formatted, :street_address, :locality, :region, :postal_code, :country
|
17
|
+
end
|
18
|
+
|
19
|
+
def validate_attributes!
|
20
|
+
super
|
21
|
+
validate_attribute! :position, GeoLocation
|
22
|
+
validate_attribute! :address, Address
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
module ActivityStreams
|
2
|
+
class Object::Review < Object
|
3
|
+
attr_optional :_rating_
|
4
|
+
|
5
|
+
def validate_attributes!
|
6
|
+
super
|
7
|
+
to_float :_rating_, :precision => 1, :range => 1.0..5.0
|
8
|
+
end
|
9
|
+
|
10
|
+
def as_json
|
11
|
+
hash = super
|
12
|
+
hash[:rating] = hash.delete(:_rating_)
|
13
|
+
hash
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
@@ -43,12 +43,22 @@ module ActivityStreams
|
|
43
43
|
end
|
44
44
|
self.send :"#{attribute}=", _value_
|
45
45
|
rescue ArgumentError, NoMethodError => e
|
46
|
-
raise InvalidAttribute.new("#{attribute} ")
|
46
|
+
raise InvalidAttribute.new("#{attribute} should be a valid date-time")
|
47
47
|
end
|
48
48
|
|
49
49
|
def to_integer(attribute)
|
50
50
|
_value_ = self.send attribute
|
51
51
|
self.send :"#{attribute}=", _value_.try(:to_i)
|
52
52
|
end
|
53
|
+
|
54
|
+
def to_float(attribute, options = {})
|
55
|
+
_value_ = self.send attribute
|
56
|
+
return unless _value_
|
57
|
+
_value_ = BigDecimal.new(_value_.to_s).round(options[:precision]) if options[:precision]
|
58
|
+
if options[:range] && !options[:range].include?(_value_)
|
59
|
+
raise InvalidAttribute.new("#{attribute} should be within #{options[:range]}")
|
60
|
+
end
|
61
|
+
self.send :"#{attribute}=", _value_.to_f
|
62
|
+
end
|
53
63
|
end
|
54
64
|
end
|
data/lib/activitystreams/verb.rb
CHANGED
@@ -2,13 +2,27 @@ module ActivityStreams
|
|
2
2
|
class Verb < Base
|
3
3
|
attr_required :verb
|
4
4
|
|
5
|
-
def initialize
|
6
|
-
|
5
|
+
def initialize
|
6
|
+
_verb_ = if self.class.superclass == Verb
|
7
|
+
self.class.name.demodulize.underscore.dasherize
|
8
|
+
else
|
9
|
+
'post'
|
10
|
+
end
|
11
|
+
super :verb => _verb_
|
12
|
+
end
|
13
|
+
|
14
|
+
def validate_attributes!
|
7
15
|
super
|
16
|
+
to_iri :verb
|
8
17
|
end
|
9
18
|
|
10
|
-
def
|
19
|
+
def to_s(options = {})
|
11
20
|
verb.to_s
|
12
21
|
end
|
22
|
+
alias_method :as_json, :to_s
|
13
23
|
end
|
14
24
|
end
|
25
|
+
|
26
|
+
Dir[File.dirname(__FILE__) + '/verb/*.rb'].each do |file|
|
27
|
+
require file
|
28
|
+
end
|
@@ -48,4 +48,35 @@ describe ActivityStreams::Activity do
|
|
48
48
|
expect { ActivityStreams::Activity.new valid_attributes }.should_not raise_error AttrRequired::AttrMissing
|
49
49
|
end
|
50
50
|
end
|
51
|
+
|
52
|
+
describe '#recommended_verb?' do
|
53
|
+
let(:activity) do
|
54
|
+
ActivityStreams::Activity.new valid_attributes.merge(
|
55
|
+
:object => object,
|
56
|
+
:verb => verb
|
57
|
+
)
|
58
|
+
end
|
59
|
+
|
60
|
+
context 'when object is Bookmark' do
|
61
|
+
let(:object) { ActivityStreams::Object::Bookmark.new }
|
62
|
+
|
63
|
+
context 'when recommended verb used' do
|
64
|
+
let(:verb) { ActivityStreams::Verb.new }
|
65
|
+
it 'should not warn' do
|
66
|
+
ActivityStreams.logger.should_not_receive(:warn)
|
67
|
+
activity
|
68
|
+
end
|
69
|
+
end
|
70
|
+
|
71
|
+
context 'otherwise' do
|
72
|
+
let(:verb) { ActivityStreams::Verb::Add.new }
|
73
|
+
it 'should warn' do
|
74
|
+
ActivityStreams.logger.should_receive(:warn).with(
|
75
|
+
"\"#{verb.to_s}\" is not recommended. \"#{object.recommended_verbs.collect(&:to_s).join('", "')}\" are recommended."
|
76
|
+
)
|
77
|
+
activity
|
78
|
+
end
|
79
|
+
end
|
80
|
+
end
|
81
|
+
end
|
51
82
|
end
|
@@ -40,8 +40,8 @@ describe ActivityStreams::MediaLink do
|
|
40
40
|
|
41
41
|
describe '#as_json' do
|
42
42
|
let(:attributes) { required_attributes.merge(optional_attributes) }
|
43
|
-
subject { ActivityStreams::MediaLink.new
|
44
|
-
|
43
|
+
subject { ActivityStreams::MediaLink.new(required_attributes.merge(optional_attributes)).as_json }
|
44
|
+
it do
|
45
45
|
should == {
|
46
46
|
:url => required_attributes[:url],
|
47
47
|
:duration => optional_attributes[:duration].to_i,
|
@@ -0,0 +1,13 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe ActivityStreams::Object::Audio do
|
4
|
+
context 'when invalid attributes given' do
|
5
|
+
let(:invalid_attributes) do
|
6
|
+
{:stream => 'invalid'}
|
7
|
+
end
|
8
|
+
|
9
|
+
it do
|
10
|
+
expect { ActivityStreams::Object::Audio.new invalid_attributes }.should raise_error ActivityStreams::InvalidAttribute
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe ActivityStreams::Object::Bookmark do
|
4
|
+
its(:recommended_verbs) { should == [:post, :favorite] }
|
5
|
+
|
6
|
+
context 'when invalid attributes given' do
|
7
|
+
let(:invalid_attributes) do
|
8
|
+
{:target_url => 'http://'}
|
9
|
+
end
|
10
|
+
|
11
|
+
it do
|
12
|
+
expect { ActivityStreams::Object::Bookmark.new invalid_attributes }.should raise_error ActivityStreams::InvalidAttribute
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe ActivityStreams::Object::Collection do
|
4
|
+
context 'when invalid attributes given' do
|
5
|
+
let(:invalid_attributes) do
|
6
|
+
{:object_types => 'bookmark,person'}
|
7
|
+
end
|
8
|
+
|
9
|
+
it do
|
10
|
+
expect { ActivityStreams::Object::Collection.new invalid_attributes }.should raise_error ActivityStreams::InvalidAttribute
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe ActivityStreams::Object::Comment do
|
4
|
+
context 'when invalid attributes given' do
|
5
|
+
let(:invalid_attributes) do
|
6
|
+
{:in_reply_to => ['object_a', 'object_b']}
|
7
|
+
end
|
8
|
+
|
9
|
+
it do
|
10
|
+
expect { ActivityStreams::Object::Comment.new invalid_attributes }.should raise_error ActivityStreams::InvalidAttribute
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe ActivityStreams::Object::Event do
|
4
|
+
context 'when invalid attributes given' do
|
5
|
+
[:attending, :maybe_attending, :not_attending, :start_time, :end_time].each do |_attr_|
|
6
|
+
context "when #{_attr_} is invalid" do
|
7
|
+
let(:invalid_attributes) do
|
8
|
+
{_attr_ => 'invalid'}
|
9
|
+
end
|
10
|
+
|
11
|
+
it do
|
12
|
+
expect { ActivityStreams::Object::Event.new invalid_attributes }.should raise_error ActivityStreams::InvalidAttribute
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe ActivityStreams::Object::File do
|
4
|
+
context 'when invalid attributes given' do
|
5
|
+
let(:invalid_attributes) do
|
6
|
+
{:file_url => 'http://'}
|
7
|
+
end
|
8
|
+
|
9
|
+
it do
|
10
|
+
expect { ActivityStreams::Object::File.new invalid_attributes }.should raise_error ActivityStreams::InvalidAttribute
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe ActivityStreams::Object::Image do
|
4
|
+
context 'when invalid attributes given' do
|
5
|
+
let(:invalid_attributes) do
|
6
|
+
{:full_image => 'invalid'}
|
7
|
+
end
|
8
|
+
|
9
|
+
it do
|
10
|
+
expect { ActivityStreams::Object::Image.new invalid_attributes }.should raise_error ActivityStreams::InvalidAttribute
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
@@ -0,0 +1,52 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe ActivityStreams::Object::Place do
|
4
|
+
context 'when invalid attributes given' do
|
5
|
+
[:position, :address].each do |_attr_|
|
6
|
+
context "when #{_attr_} is invalid" do
|
7
|
+
let(:invalid_attributes) do
|
8
|
+
{_attr_ => 'invalid'}
|
9
|
+
end
|
10
|
+
|
11
|
+
it do
|
12
|
+
expect { ActivityStreams::Object::Place.new invalid_attributes }.should raise_error ActivityStreams::InvalidAttribute
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
describe ActivityStreams::Object::Place::GeoLocation do
|
19
|
+
context 'when missing attributes' do
|
20
|
+
it do
|
21
|
+
expect { ActivityStreams::Object::Place::GeoLocation.new }.should raise_error AttrRequired::AttrMissing
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
describe '#as_json' do
|
26
|
+
let(:latitude) { 35.0 }
|
27
|
+
let(:longitude) { 140.0 }
|
28
|
+
let(:altitude) { 100 }
|
29
|
+
subject { ActivityStreams::Object::Place::GeoLocation.new attributes }
|
30
|
+
context 'when altitude given' do
|
31
|
+
let(:attributes) do
|
32
|
+
{
|
33
|
+
:latitude => latitude,
|
34
|
+
:longitude => longitude
|
35
|
+
}
|
36
|
+
end
|
37
|
+
its(:as_json) { should == "+#{latitude}+#{longitude}" }
|
38
|
+
end
|
39
|
+
|
40
|
+
context 'otherwise' do
|
41
|
+
let(:attributes) do
|
42
|
+
{
|
43
|
+
:latitude => latitude,
|
44
|
+
:longitude => longitude,
|
45
|
+
:altitude => altitude
|
46
|
+
}
|
47
|
+
end
|
48
|
+
its(:as_json) { should == "+#{latitude}+#{longitude}+#{altitude}" }
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe ActivityStreams::Object::Product do
|
4
|
+
context 'when invalid attributes given' do
|
5
|
+
let(:invalid_attributes) do
|
6
|
+
{:full_image => 'invalid'}
|
7
|
+
end
|
8
|
+
|
9
|
+
it do
|
10
|
+
expect { ActivityStreams::Object::Product.new invalid_attributes }.should raise_error ActivityStreams::InvalidAttribute
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe ActivityStreams::Object::Question do
|
4
|
+
context 'when invalid attributes given' do
|
5
|
+
let(:invalid_attributes) do
|
6
|
+
{:options => ['invalid']}
|
7
|
+
end
|
8
|
+
|
9
|
+
it do
|
10
|
+
expect { ActivityStreams::Object::Question.new invalid_attributes }.should raise_error ActivityStreams::InvalidAttribute
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
@@ -0,0 +1,32 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe ActivityStreams::Object::Review do
|
4
|
+
context 'when invalid attributes given' do
|
5
|
+
let(:invalid_attributes) do
|
6
|
+
{:_rating_ => 0}
|
7
|
+
end
|
8
|
+
|
9
|
+
it do
|
10
|
+
expect { ActivityStreams::Object::Review.new invalid_attributes }.should raise_error ActivityStreams::InvalidAttribute
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
describe '#rating' do
|
15
|
+
subject { ActivityStreams::Object::Review.new(:_rating_ => rate) }
|
16
|
+
context 'when integer' do
|
17
|
+
let(:rate) { 3 }
|
18
|
+
its(:_rating_) { should be_a Float }
|
19
|
+
end
|
20
|
+
|
21
|
+
context 'when float' do
|
22
|
+
let(:rate) { 1.36 }
|
23
|
+
its(:_rating_) { should == rate.round(1) }
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
describe '#as_json' do
|
28
|
+
subject { ActivityStreams::Object::Review.new(:_rating_ => 1).as_json }
|
29
|
+
its(:keys) { should include :rating }
|
30
|
+
its(:keys) { should_not include :_rating_ }
|
31
|
+
end
|
32
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe ActivityStreams::Object::Video do
|
4
|
+
context 'when invalid attributes given' do
|
5
|
+
let(:invalid_attributes) do
|
6
|
+
{:stream => 'invalid'}
|
7
|
+
end
|
8
|
+
|
9
|
+
it do
|
10
|
+
expect { ActivityStreams::Object::Video.new invalid_attributes }.should raise_error ActivityStreams::InvalidAttribute
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
@@ -44,4 +44,13 @@ describe ActivityStreams::Object do
|
|
44
44
|
expect { ActivityStreams::Object.new valid_attributes }.should_not raise_error AttrRequired::AttrMissing
|
45
45
|
end
|
46
46
|
end
|
47
|
+
|
48
|
+
describe '#as_json' do
|
49
|
+
subject { ActivityStreams::Object.new(:display_name => 'Nov').as_json }
|
50
|
+
it do
|
51
|
+
should == {
|
52
|
+
:displayName => 'Nov'
|
53
|
+
}
|
54
|
+
end
|
55
|
+
end
|
47
56
|
end
|
@@ -1,18 +1,6 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
describe ActivityStreams::Verb do
|
4
|
-
|
5
|
-
|
6
|
-
its(:verb) { should == :post }
|
7
|
-
end
|
8
|
-
|
9
|
-
context 'otherwise' do
|
10
|
-
subject { ActivityStreams::Verb.new(:verb => :my_verb) }
|
11
|
-
its(:verb) { should == :my_verb }
|
12
|
-
end
|
13
|
-
|
14
|
-
describe '#as_json' do
|
15
|
-
subject { ActivityStreams::Verb.new(:verb => :my_verb) }
|
16
|
-
its(:as_json) { should == 'my_verb' }
|
17
|
-
end
|
4
|
+
its(:verb) { should == Addressable::URI.parse('post') }
|
5
|
+
its(:as_json) { should == 'post' }
|
18
6
|
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe ActivityStreams do
|
4
|
+
its(:logger) { should be_a Logger}
|
5
|
+
|
6
|
+
describe '.logger=' do
|
7
|
+
class CustomLogger < Logger; end
|
8
|
+
|
9
|
+
it 'should set custom logger' do
|
10
|
+
ActivityStreams.logger = CustomLogger.new(STDERR)
|
11
|
+
ActivityStreams.logger.should be_a CustomLogger
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: activitystreams
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 27
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 0
|
9
|
-
-
|
10
|
-
version: 0.0.
|
9
|
+
- 2
|
10
|
+
version: 0.0.2
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- nov matake
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2011-07-
|
18
|
+
date: 2011-07-08 00:00:00 Z
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|
21
21
|
name: json
|
@@ -157,19 +157,84 @@ files:
|
|
157
157
|
- lib/activitystreams/base.rb
|
158
158
|
- lib/activitystreams/collection.rb
|
159
159
|
- lib/activitystreams/exception.rb
|
160
|
+
- lib/activitystreams/ext_properties.rb
|
160
161
|
- lib/activitystreams/media_link.rb
|
161
162
|
- lib/activitystreams/object.rb
|
163
|
+
- lib/activitystreams/object/article.rb
|
164
|
+
- lib/activitystreams/object/audio.rb
|
165
|
+
- lib/activitystreams/object/badge.rb
|
166
|
+
- lib/activitystreams/object/bookmark.rb
|
167
|
+
- lib/activitystreams/object/collection.rb
|
168
|
+
- lib/activitystreams/object/comment.rb
|
169
|
+
- lib/activitystreams/object/event.rb
|
170
|
+
- lib/activitystreams/object/file.rb
|
171
|
+
- lib/activitystreams/object/group.rb
|
172
|
+
- lib/activitystreams/object/image.rb
|
173
|
+
- lib/activitystreams/object/note.rb
|
174
|
+
- lib/activitystreams/object/person.rb
|
175
|
+
- lib/activitystreams/object/place.rb
|
176
|
+
- lib/activitystreams/object/product.rb
|
177
|
+
- lib/activitystreams/object/question.rb
|
178
|
+
- lib/activitystreams/object/review.rb
|
179
|
+
- lib/activitystreams/object/service.rb
|
180
|
+
- lib/activitystreams/object/video.rb
|
162
181
|
- lib/activitystreams/stream.rb
|
163
182
|
- lib/activitystreams/validator.rb
|
164
183
|
- lib/activitystreams/verb.rb
|
184
|
+
- lib/activitystreams/verb/add.rb
|
185
|
+
- lib/activitystreams/verb/cancel.rb
|
186
|
+
- lib/activitystreams/verb/checkin.rb
|
187
|
+
- lib/activitystreams/verb/delete.rb
|
188
|
+
- lib/activitystreams/verb/favorite.rb
|
189
|
+
- lib/activitystreams/verb/follow.rb
|
190
|
+
- lib/activitystreams/verb/give.rb
|
191
|
+
- lib/activitystreams/verb/ignore.rb
|
192
|
+
- lib/activitystreams/verb/invite.rb
|
193
|
+
- lib/activitystreams/verb/join.rb
|
194
|
+
- lib/activitystreams/verb/leave.rb
|
195
|
+
- lib/activitystreams/verb/like.rb
|
196
|
+
- lib/activitystreams/verb/make_friend.rb
|
197
|
+
- lib/activitystreams/verb/play.rb
|
198
|
+
- lib/activitystreams/verb/receive.rb
|
199
|
+
- lib/activitystreams/verb/remove.rb
|
200
|
+
- lib/activitystreams/verb/remove_friend.rb
|
201
|
+
- lib/activitystreams/verb/request_friend.rb
|
202
|
+
- lib/activitystreams/verb/rsvp_maybe.rb
|
203
|
+
- lib/activitystreams/verb/rsvp_no.rb
|
204
|
+
- lib/activitystreams/verb/rsvp_yes.rb
|
205
|
+
- lib/activitystreams/verb/save.rb
|
206
|
+
- lib/activitystreams/verb/share.rb
|
207
|
+
- lib/activitystreams/verb/stop_following.rb
|
208
|
+
- lib/activitystreams/verb/tag.rb
|
209
|
+
- lib/activitystreams/verb/unfavorite.rb
|
210
|
+
- lib/activitystreams/verb/unlike.rb
|
211
|
+
- lib/activitystreams/verb/unsave.rb
|
212
|
+
- lib/activitystreams/verb/update.rb
|
165
213
|
- spec/activitystreams/activity_spec.rb
|
166
214
|
- spec/activitystreams/base_spec.rb
|
167
215
|
- spec/activitystreams/collection_spec.rb
|
168
216
|
- spec/activitystreams/media_link_spec.rb
|
217
|
+
- spec/activitystreams/object/article_spec.rb
|
218
|
+
- spec/activitystreams/object/audio_spec.rb
|
219
|
+
- spec/activitystreams/object/bookmark_spec.rb
|
220
|
+
- spec/activitystreams/object/collection_spec.rb
|
221
|
+
- spec/activitystreams/object/comment_spec.rb
|
222
|
+
- spec/activitystreams/object/event_spec.rb
|
223
|
+
- spec/activitystreams/object/file_spec.rb
|
224
|
+
- spec/activitystreams/object/image_spec.rb
|
225
|
+
- spec/activitystreams/object/place_spec.rb
|
226
|
+
- spec/activitystreams/object/product_spec.rb
|
227
|
+
- spec/activitystreams/object/question_spec.rb
|
228
|
+
- spec/activitystreams/object/review_spec.rb
|
229
|
+
- spec/activitystreams/object/video_spec.rb
|
169
230
|
- spec/activitystreams/object_spec.rb
|
170
231
|
- spec/activitystreams/stream_spec.rb
|
171
232
|
- spec/activitystreams/validator_spec.rb
|
233
|
+
- spec/activitystreams/verb/add_spec.rb
|
234
|
+
- spec/activitystreams/verb/make_friend_spec.rb
|
235
|
+
- spec/activitystreams/verb/rsvp_maybe_spec.rb
|
172
236
|
- spec/activitystreams/verb_spec.rb
|
237
|
+
- spec/activitystreams_spec.rb
|
173
238
|
- spec/spec_helper.rb
|
174
239
|
homepage: http://github.com/nov/activitystreams
|
175
240
|
licenses: []
|
@@ -200,7 +265,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
200
265
|
requirements: []
|
201
266
|
|
202
267
|
rubyforge_project:
|
203
|
-
rubygems_version: 1.
|
268
|
+
rubygems_version: 1.8.5
|
204
269
|
signing_key:
|
205
270
|
specification_version: 3
|
206
271
|
summary: A RubyGem for ActivityStreams Publishers
|
@@ -209,8 +274,25 @@ test_files:
|
|
209
274
|
- spec/activitystreams/base_spec.rb
|
210
275
|
- spec/activitystreams/collection_spec.rb
|
211
276
|
- spec/activitystreams/media_link_spec.rb
|
277
|
+
- spec/activitystreams/object/article_spec.rb
|
278
|
+
- spec/activitystreams/object/audio_spec.rb
|
279
|
+
- spec/activitystreams/object/bookmark_spec.rb
|
280
|
+
- spec/activitystreams/object/collection_spec.rb
|
281
|
+
- spec/activitystreams/object/comment_spec.rb
|
282
|
+
- spec/activitystreams/object/event_spec.rb
|
283
|
+
- spec/activitystreams/object/file_spec.rb
|
284
|
+
- spec/activitystreams/object/image_spec.rb
|
285
|
+
- spec/activitystreams/object/place_spec.rb
|
286
|
+
- spec/activitystreams/object/product_spec.rb
|
287
|
+
- spec/activitystreams/object/question_spec.rb
|
288
|
+
- spec/activitystreams/object/review_spec.rb
|
289
|
+
- spec/activitystreams/object/video_spec.rb
|
212
290
|
- spec/activitystreams/object_spec.rb
|
213
291
|
- spec/activitystreams/stream_spec.rb
|
214
292
|
- spec/activitystreams/validator_spec.rb
|
293
|
+
- spec/activitystreams/verb/add_spec.rb
|
294
|
+
- spec/activitystreams/verb/make_friend_spec.rb
|
295
|
+
- spec/activitystreams/verb/rsvp_maybe_spec.rb
|
215
296
|
- spec/activitystreams/verb_spec.rb
|
297
|
+
- spec/activitystreams_spec.rb
|
216
298
|
- spec/spec_helper.rb
|