activitystreams 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
data/.gitignore ADDED
@@ -0,0 +1,5 @@
1
+ *.gem
2
+ .bundle
3
+ Gemfile.lock
4
+ pkg/*
5
+ coverage/*
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source "http://rubygems.org"
2
+
3
+ # Specify your gem's dependencies in activitystreams.gemspec
4
+ gemspec
data/LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2011 nov matake
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/Rakefile ADDED
@@ -0,0 +1,11 @@
1
+ require 'bundler/gem_tasks'
2
+
3
+ require 'rspec/core/rake_task'
4
+ RSpec::Core::RakeTask.new(:spec)
5
+
6
+ RSpec::Core::RakeTask.new(:rcov) do |spec|
7
+ spec.rcov = true
8
+ spec.rcov_opts = ['-Ilib -Ispec --exclude spec,gems']
9
+ end
10
+
11
+ task :default => :spec
data/VERSION ADDED
@@ -0,0 +1 @@
1
+ 0.0.1
@@ -0,0 +1,21 @@
1
+ Gem::Specification.new do |s|
2
+ s.name = "activitystreams"
3
+ s.version = File.read("VERSION")
4
+ s.authors = ["nov matake"]
5
+ s.email = ["nov@matake.jp"]
6
+ s.homepage = "http://github.com/nov/activitystreams"
7
+ s.summary = %q{A RubyGem for ActivityStreams Publishers}
8
+ s.description = %q{A RubyGem for ActivityStreams Publishers}
9
+ s.files = `git ls-files`.split("\n")
10
+ s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
11
+ s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
12
+ s.require_paths = ["lib"]
13
+ s.add_runtime_dependency "json", ">= 1.4.3"
14
+ s.add_runtime_dependency "activesupport", ">= 2.3"
15
+ s.add_runtime_dependency "i18n"
16
+ s.add_runtime_dependency "attr_required", ">= 0.0.3"
17
+ s.add_runtime_dependency "addressable"
18
+ s.add_development_dependency "rake", ">= 0.8"
19
+ s.add_development_dependency "rcov", ">= 0.9"
20
+ s.add_development_dependency "rspec", ">= 2"
21
+ end
@@ -0,0 +1,15 @@
1
+ require 'json'
2
+ require 'active_support/core_ext'
3
+ require 'attr_required'
4
+ require 'attr_optional'
5
+ require 'addressable/uri'
6
+
7
+ require 'activitystreams/validator'
8
+ require 'activitystreams/exception'
9
+ require 'activitystreams/base'
10
+ require 'activitystreams/collection'
11
+ require 'activitystreams/stream'
12
+ require 'activitystreams/activity'
13
+ require 'activitystreams/object'
14
+ require 'activitystreams/verb'
15
+ require 'activitystreams/media_link'
@@ -0,0 +1,39 @@
1
+ module ActivityStreams
2
+ class Activity < Base
3
+ attr_required :actor, :verb, :published
4
+ attr_optional(
5
+ # SHOULD
6
+ :id,
7
+ :object,
8
+ # MAY
9
+ :target,
10
+ :title,
11
+ :content,
12
+ :provider,
13
+ :generator,
14
+ :icon,
15
+ :updated,
16
+ :url
17
+ )
18
+
19
+ def initialize(attributes = {})
20
+ attributes[:verb] ||= Verb.new
21
+ super
22
+ end
23
+
24
+ def validate_attributes!
25
+ super
26
+ [:id, :url].each do |_attr_|
27
+ to_iri _attr_
28
+ end
29
+ [:published, :updated].each do |_attr_|
30
+ to_time _attr_
31
+ end
32
+ [:actor, :object, :target, :provider, :generator].each do |_attr_|
33
+ validate_attribute! _attr_, Object
34
+ end
35
+ validate_attribute! :verb, Verb
36
+ validate_attribute! :icon, MediaLink
37
+ end
38
+ end
39
+ end
@@ -0,0 +1,34 @@
1
+ module ActivityStreams
2
+ class Base
3
+ include AttrRequired, AttrOptional, Validator
4
+
5
+ def initialize(attributes = {})
6
+ (required_attributes + optional_attributes).each do |_attr_|
7
+ self.send :"#{_attr_}=", attributes[_attr_]
8
+ end
9
+ validate_attributes!
10
+ end
11
+
12
+ def validate_attributes!
13
+ attr_missing!
14
+ end
15
+
16
+ def as_json(options = {})
17
+ (required_attributes + optional_attributes).inject({}) do |hash, _attr_|
18
+ _value_ = self.send _attr_
19
+ hash.merge!(
20
+ _attr_ => case _value_
21
+ when Symbol, Addressable::URI
22
+ _value_.to_s
23
+ when Time
24
+ _value_.iso8601
25
+ else
26
+ _value_
27
+ end
28
+ )
29
+ end.delete_if do |k,v|
30
+ v.blank?
31
+ end
32
+ end
33
+ end
34
+ end
@@ -0,0 +1,18 @@
1
+ module ActivityStreams
2
+ class Collection < Base
3
+ attr_optional :total_count, :items, :url
4
+
5
+ def validate_attributes!
6
+ super
7
+ if items.blank? && url.blank?
8
+ raise AttrMissing.new('Either "items" or "url" is required')
9
+ end
10
+ to_iri :url
11
+ validate_attribute! :items, item_class, :arrayed!
12
+ end
13
+
14
+ def item_class
15
+ Object
16
+ end
17
+ end
18
+ end
@@ -0,0 +1,7 @@
1
+ module ActivityStreams
2
+ class Exception < StandardError
3
+ end
4
+
5
+ class InvalidAttribute < Exception
6
+ end
7
+ end
@@ -0,0 +1,19 @@
1
+ module ActivityStreams
2
+ class MediaLink < Base
3
+ attr_required :url
4
+ attr_optional(
5
+ # MAY
6
+ :duration,
7
+ :height,
8
+ :width
9
+ )
10
+
11
+ def validate_attributes!
12
+ super
13
+ to_iri :url
14
+ [:duration, :height, :width].each do |_attr_|
15
+ to_integer _attr_
16
+ end
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,38 @@
1
+ module ActivityStreams
2
+ class Object < Base
3
+ attr_optional(
4
+ # SHOULD
5
+ :id,
6
+ :downstream_duplicates,
7
+ :upstream_duplicates,
8
+ # MAY
9
+ :attachments,
10
+ :author,
11
+ :content,
12
+ :display_name,
13
+ :image,
14
+ :type,
15
+ :published,
16
+ :summary,
17
+ :updated,
18
+ :url
19
+ )
20
+
21
+ def validate_attributes!
22
+ super
23
+ [:id, :type, :url].each do |_attr_|
24
+ to_iri _attr_
25
+ end
26
+ [:published, :updated].each do |_attr_|
27
+ to_time _attr_
28
+ end
29
+ validate_attribute! :author, Object
30
+ validate_attribute! :image, MediaLink
31
+ validate_attribute! :attachments, Object, :arrayed!
32
+ [:downstream_duplicates, :upstream_duplicates].each do |_attr_|
33
+ to_iri _attr_, :arrayed!
34
+ end
35
+ # TODO: display_name MUST NOT include HTML
36
+ end
37
+ end
38
+ end
@@ -0,0 +1,9 @@
1
+ module ActivityStreams
2
+ class Stream < Collection
3
+ attr_required :items
4
+
5
+ def item_class
6
+ Activity
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,54 @@
1
+ module ActivityStreams
2
+ module Validator
3
+ def validate_attribute!(attribute, klass, arrayed = false)
4
+ _value_ = self.send attribute
5
+ return if _value_.blank?
6
+ if arrayed
7
+ _value_.all? do |_v_|
8
+ _v_.is_a?(klass)
9
+ end or
10
+ raise InvalidAttribute.new("#{attribute} should be an array of #{klass}")
11
+ else
12
+ _value_.is_a?(klass) or
13
+ raise InvalidAttribute.new("#{attribute} should be a #{klass}")
14
+ end
15
+ end
16
+
17
+ def to_iri(attribute, arrayed = false)
18
+ _value_ = self.send attribute
19
+ _value_ = if arrayed
20
+ Array(_value_).collect do |_v_|
21
+ Addressable::URI.parse(_v_)
22
+ end
23
+ else
24
+ Addressable::URI.parse(_value_)
25
+ end
26
+ self.send :"#{attribute}=", _value_
27
+ rescue Addressable::URI::InvalidURIError => e
28
+ message = if arrayed
29
+ "#{attribute} should be an array of valid IRI"
30
+ else
31
+ "#{attribute} should be a valid IRI"
32
+ end
33
+ raise InvalidAttribute.new(message)
34
+ end
35
+
36
+ def to_time(attribute)
37
+ _value_ = self.send attribute
38
+ _value_ = case _value_
39
+ when String
40
+ Time.parse _value_, :raise_me
41
+ else
42
+ _value_
43
+ end
44
+ self.send :"#{attribute}=", _value_
45
+ rescue ArgumentError, NoMethodError => e
46
+ raise InvalidAttribute.new("#{attribute} ")
47
+ end
48
+
49
+ def to_integer(attribute)
50
+ _value_ = self.send attribute
51
+ self.send :"#{attribute}=", _value_.try(:to_i)
52
+ end
53
+ end
54
+ end
@@ -0,0 +1,14 @@
1
+ module ActivityStreams
2
+ class Verb < Base
3
+ attr_required :verb
4
+
5
+ def initialize(attributes = {})
6
+ attributes[:verb] ||= :post
7
+ super
8
+ end
9
+
10
+ def as_json(options = {})
11
+ verb.to_s
12
+ end
13
+ end
14
+ end
@@ -0,0 +1,51 @@
1
+ require 'spec_helper'
2
+
3
+ describe ActivityStreams::Activity do
4
+ let :required_attributes do
5
+ {
6
+ :actor => ActivityStreams::Object.new(:display_name => 'Nov Matake'),
7
+ :published => Time.now
8
+ }
9
+ end
10
+ let :optional_attributes do
11
+ {
12
+ :id => 'activitystrea.ms/activity/foo',
13
+ :object => ActivityStreams::Object.new,
14
+ :target => ActivityStreams::Object.new,
15
+ :title => '<b>Title</b>',
16
+ :content => '<b>Content</b>',
17
+ :provider => ActivityStreams::Object.new,
18
+ :generator => ActivityStreams::Object.new,
19
+ :icon => ActivityStreams::MediaLink.new(:url => 'http://example.com/images/icon.png'),
20
+ :updated => Time.now,
21
+ :url => 'activitystrea.ms/activity/bar'
22
+ }
23
+ end
24
+ let(:valid_attributes) { required_attributes.merge(optional_attributes) }
25
+
26
+ context 'when missing attributes' do
27
+ it do
28
+ expect { ActivityStreams::Activity.new }.should raise_error AttrRequired::AttrMissing
29
+ end
30
+ end
31
+
32
+ context 'otherwise' do
33
+ it do
34
+ expect { ActivityStreams::Activity.new required_attributes }.should_not raise_error AttrRequired::AttrMissing
35
+ end
36
+ end
37
+
38
+ context 'when invalid attributes given' do
39
+ it do
40
+ expect do
41
+ ActivityStreams::Activity.new valid_attributes.merge(:icon => 'http://example.com/images/icon.png')
42
+ end.should raise_error ActivityStreams::InvalidAttribute
43
+ end
44
+ end
45
+
46
+ context 'otherwise' do
47
+ it do
48
+ expect { ActivityStreams::Activity.new valid_attributes }.should_not raise_error AttrRequired::AttrMissing
49
+ end
50
+ end
51
+ end
@@ -0,0 +1,42 @@
1
+ require 'spec_helper'
2
+
3
+ describe ActivityStreams::Base do
4
+ class SubClass < ActivityStreams::Base
5
+ attr_required :required
6
+ attr_optional :optional
7
+ end
8
+
9
+ context 'when missing attributes' do
10
+ it do
11
+ expect { SubClass.new }.should raise_error AttrRequired::AttrMissing
12
+ end
13
+ end
14
+
15
+ context 'otherwise' do
16
+ it 'should setup attributes' do
17
+ obj = SubClass.new(
18
+ :required => 'REQ',
19
+ :optional => 'OPT'
20
+ )
21
+ obj.required.should == 'REQ'
22
+ obj.optional.should == 'OPT'
23
+ end
24
+ end
25
+
26
+ describe '#as_json' do
27
+ let(:time) { Time.parse('1981-12-13') }
28
+ let(:iri) { Addressable::URI.parse('activitystrea.ms') }
29
+ subject do
30
+ SubClass.new(
31
+ :required => time,
32
+ :optional => iri
33
+ )
34
+ end
35
+ its(:as_json) do
36
+ should == {
37
+ :required => time.iso8601,
38
+ :optional => iri.to_s
39
+ }
40
+ end
41
+ end
42
+ end
@@ -0,0 +1,44 @@
1
+ require 'spec_helper'
2
+
3
+ describe ActivityStreams::Collection do
4
+ let(:collection) { ActivityStreams::Collection.new(:items => items) }
5
+
6
+ context 'when array of Activity given' do
7
+ let :items do
8
+ [
9
+ ActivityStreams::Activity.new(
10
+ :actor => ActivityStreams::Object.new(:display_name => 'Nov'),
11
+ :published => Time.now
12
+ )
13
+ ]
14
+ end
15
+
16
+ it do
17
+ expect { collection }.should raise_error(
18
+ ActivityStreams::InvalidAttribute,
19
+ 'items should be an array of ActivityStreams::Object'
20
+ )
21
+ end
22
+ end
23
+
24
+ context 'when array of Object given' do
25
+ let :items do
26
+ [
27
+ ActivityStreams::Object.new
28
+ ]
29
+ end
30
+
31
+ it do
32
+ expect { collection }.should_not raise_error
33
+ end
34
+ end
35
+
36
+ context 'when missing both items and url' do
37
+ it do
38
+ expect { ActivityStreams::Collection.new }.should raise_error(
39
+ AttrRequired::AttrMissing,
40
+ 'Either "items" or "url" is required'
41
+ )
42
+ end
43
+ end
44
+ end
@@ -0,0 +1,53 @@
1
+ require 'spec_helper'
2
+
3
+ describe ActivityStreams::MediaLink do
4
+ let :required_attributes do
5
+ {
6
+ :url => 'http://example.com/images/icon.png'
7
+ }
8
+ end
9
+ let :optional_attributes do
10
+ {
11
+ :duration => 100.0,
12
+ :height => '200',
13
+ :width => '300.0'
14
+ }
15
+ end
16
+
17
+ context 'when missing attributes' do
18
+ it do
19
+ expect { ActivityStreams::MediaLink.new }.should raise_error AttrRequired::AttrMissing
20
+ end
21
+ end
22
+
23
+ context 'otherwise' do
24
+ subject { ActivityStreams::MediaLink.new required_attributes }
25
+ its(:url) { should be_a Addressable::URI }
26
+
27
+ context 'when optional attributes given' do
28
+ subject { ActivityStreams::MediaLink.new required_attributes.merge(optional_attributes) }
29
+ its(:duration) { should be_a Integer }
30
+ its(:height) { should be_a Integer }
31
+ its(:width) { should be_a Integer }
32
+ end
33
+
34
+ context 'otherwise' do
35
+ its(:duration) { should be_nil }
36
+ its(:height) { should be_nil }
37
+ its(:width) { should be_nil }
38
+ end
39
+ end
40
+
41
+ describe '#as_json' do
42
+ let(:attributes) { required_attributes.merge(optional_attributes) }
43
+ subject { ActivityStreams::MediaLink.new required_attributes.merge(optional_attributes) }
44
+ its(:as_json) do
45
+ should == {
46
+ :url => required_attributes[:url],
47
+ :duration => optional_attributes[:duration].to_i,
48
+ :height => optional_attributes[:height].to_i,
49
+ :width => optional_attributes[:width].to_i
50
+ }
51
+ end
52
+ end
53
+ end
@@ -0,0 +1,47 @@
1
+ require 'spec_helper'
2
+
3
+ describe ActivityStreams::Object do
4
+ let :valid_attributes do
5
+ {
6
+ :id => 'activitystrea.ms/activity/foo',
7
+ :url => 'activitystrea.ms/activity/bar',
8
+ :type => 'activitystrea.ms/activity/custom',
9
+ :downstream_duplicates => [
10
+ 'activitystrea.ms/activity/123',
11
+ 'activitystrea.ms/activity/234'
12
+ ],
13
+ :upstream_duplicates => [
14
+ 'activitystrea.ms/activity/987',
15
+ 'activitystrea.ms/activity/876'
16
+ ],
17
+ :attachments => [
18
+ ActivityStreams::Object.new
19
+ ],
20
+ :author => ActivityStreams::Object.new(:display_name => 'Nov Matake'),
21
+ :content => '<b>NOTE:</b> Foo bar',
22
+ :display_name => 'Nov',
23
+ :image => ActivityStreams::MediaLink.new(:url => 'http://example.com/images/icon.png'),
24
+ :published => Time.now,
25
+ :summary => '<b>NOTE:</b> Foo bar',
26
+ :updated => Time.now
27
+ }
28
+ end
29
+
30
+ it 'should not any attributes' do
31
+ expect { ActivityStreams::Object.new }.should_not raise_error AttrRequired::AttrMissing
32
+ end
33
+
34
+ context 'when invalid attributes given' do
35
+ it do
36
+ expect do
37
+ ActivityStreams::Object.new valid_attributes.merge(:image => 'http://example.com/images/icon.png')
38
+ end.should raise_error ActivityStreams::InvalidAttribute
39
+ end
40
+ end
41
+
42
+ context 'otherwise' do
43
+ it do
44
+ expect { ActivityStreams::Object.new valid_attributes }.should_not raise_error AttrRequired::AttrMissing
45
+ end
46
+ end
47
+ end
@@ -0,0 +1,35 @@
1
+ require 'spec_helper'
2
+
3
+ describe ActivityStreams::Stream do
4
+ let(:stream) { ActivityStreams::Stream.new(:items => items) }
5
+
6
+ context 'when array of Activity given' do
7
+ let :items do
8
+ [
9
+ ActivityStreams::Activity.new(
10
+ :actor => ActivityStreams::Object.new(:display_name => 'Nov'),
11
+ :published => Time.now
12
+ )
13
+ ]
14
+ end
15
+
16
+ it do
17
+ expect { stream }.should_not raise_error
18
+ end
19
+ end
20
+
21
+ context 'when array of Object given' do
22
+ let :items do
23
+ [
24
+ ActivityStreams::Object.new
25
+ ]
26
+ end
27
+
28
+ it do
29
+ expect { stream }.should raise_error(
30
+ ActivityStreams::InvalidAttribute,
31
+ 'items should be an array of ActivityStreams::Activity'
32
+ )
33
+ end
34
+ end
35
+ end
@@ -0,0 +1,150 @@
1
+ require 'spec_helper'
2
+
3
+ describe ActivityStreams::Validator do
4
+ class Foo
5
+ include ActivityStreams::Validator
6
+ attr_accessor :foo
7
+
8
+ def initialize(foo = nil)
9
+ @foo = foo
10
+ end
11
+ end
12
+
13
+ describe '#validate_attribute!' do
14
+ context 'when blank' do
15
+ it do
16
+ expect do
17
+ Foo.new.validate_attribute!(:foo, String)
18
+ Foo.new('').validate_attribute! :foo, String
19
+ Foo.new([]).validate_attribute! :foo, String
20
+ end.should_not raise_error
21
+ end
22
+ end
23
+
24
+ context 'when valid' do
25
+ it do
26
+ expect { Foo.new(Time.now).validate_attribute! :foo, Time }.should_not raise_error
27
+ end
28
+ end
29
+
30
+ context 'when invalid' do
31
+ it do
32
+ expect { Foo.new('foo').validate_attribute! :foo, Time }.should raise_error(
33
+ ActivityStreams::InvalidAttribute,
34
+ 'foo should be a Time'
35
+ )
36
+ end
37
+ end
38
+
39
+ context 'when arrayed' do
40
+ context 'when valid' do
41
+ it do
42
+ expect { Foo.new([Time.now]).validate_attribute! :foo, Time, :arrayed }.should_not raise_error
43
+ end
44
+ end
45
+
46
+ context 'when invalid' do
47
+ it do
48
+ expect { Foo.new(['foo']).validate_attribute! :foo, Time, :arrayed }.should raise_error(
49
+ ActivityStreams::InvalidAttribute,
50
+ 'foo should be an array of Time'
51
+ )
52
+ end
53
+ end
54
+ end
55
+ end
56
+
57
+ describe '#to_iri' do
58
+ let(:foo) { Foo.new(iri) }
59
+ let(:to_iri) { foo.to_iri :foo }
60
+ subject { to_iri }
61
+
62
+ context 'when nil' do
63
+ let(:iri) { nil }
64
+ it { should be_nil }
65
+ end
66
+
67
+ context 'when valid' do
68
+ let(:iri) { 'activitystrea.ms,2011/foo' }
69
+ it { should be_a Addressable::URI }
70
+ end
71
+
72
+ context 'when invalid' do
73
+ let(:iri) { 'http:' }
74
+ it do
75
+ expect { to_iri }.should raise_error(
76
+ ActivityStreams::InvalidAttribute,
77
+ 'foo should be a valid IRI'
78
+ )
79
+ end
80
+ end
81
+
82
+ context 'when arrayed' do
83
+ let(:to_iri) { foo.to_iri :foo, :arrayed! }
84
+
85
+ context 'when valid' do
86
+ let(:iri) { ['activitystrea.ms,2011/foo'] }
87
+ it { should be_a Array }
88
+ it 'should be an array of Addressable::URI' do
89
+ to_iri.each do |iri|
90
+ iri.should be_a Addressable::URI
91
+ end
92
+ end
93
+ end
94
+
95
+ context 'when valid' do
96
+ let(:iri) { ['http:'] }
97
+ it do
98
+ expect { to_iri }.should raise_error(
99
+ ActivityStreams::InvalidAttribute,
100
+ 'foo should be an array of valid IRI'
101
+ )
102
+ end
103
+ end
104
+ end
105
+ end
106
+
107
+ describe '#to_time' do
108
+ let(:foo) { Foo.new(time) }
109
+ let(:to_time) { foo.to_time :foo }
110
+ subject { to_time }
111
+
112
+ context 'when nil' do
113
+ let(:time) { nil }
114
+ it { should be_nil }
115
+ end
116
+
117
+ context 'when valid IRI' do
118
+ let(:time) { '1981-12-13' }
119
+ it { should be_a Time }
120
+ end
121
+
122
+ context 'when invalid IRI' do
123
+ let(:time) { 'invalid-date' }
124
+ it do
125
+ expect { to_time }.should raise_error ActivityStreams::InvalidAttribute
126
+ end
127
+ end
128
+ end
129
+
130
+ describe '#to_integer' do
131
+ let(:foo) { Foo.new(integer) }
132
+ let(:to_integer) { foo.to_integer :foo }
133
+ subject { to_integer }
134
+
135
+ context 'when nil' do
136
+ let(:integer) { nil }
137
+ it { should be_nil }
138
+ end
139
+
140
+ context 'when String' do
141
+ let(:integer) { '100' }
142
+ it { should be_a Integer }
143
+ end
144
+
145
+ context 'when Float' do
146
+ let(:integer) { 10.5 }
147
+ it { should be_a Integer }
148
+ end
149
+ end
150
+ end
@@ -0,0 +1,18 @@
1
+ require 'spec_helper'
2
+
3
+ describe ActivityStreams::Verb do
4
+ context 'when missing attributes' do
5
+ subject { ActivityStreams::Verb.new }
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
18
+ end
@@ -0,0 +1,5 @@
1
+ $LOAD_PATH.unshift(File.dirname(__FILE__))
2
+ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
3
+
4
+ require 'activitystreams'
5
+ require 'rspec'
metadata ADDED
@@ -0,0 +1,216 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: activitystreams
3
+ version: !ruby/object:Gem::Version
4
+ hash: 29
5
+ prerelease:
6
+ segments:
7
+ - 0
8
+ - 0
9
+ - 1
10
+ version: 0.0.1
11
+ platform: ruby
12
+ authors:
13
+ - nov matake
14
+ autorequire:
15
+ bindir: bin
16
+ cert_chain: []
17
+
18
+ date: 2011-07-05 00:00:00 Z
19
+ dependencies:
20
+ - !ruby/object:Gem::Dependency
21
+ name: json
22
+ prerelease: false
23
+ requirement: &id001 !ruby/object:Gem::Requirement
24
+ none: false
25
+ requirements:
26
+ - - ">="
27
+ - !ruby/object:Gem::Version
28
+ hash: 1
29
+ segments:
30
+ - 1
31
+ - 4
32
+ - 3
33
+ version: 1.4.3
34
+ type: :runtime
35
+ version_requirements: *id001
36
+ - !ruby/object:Gem::Dependency
37
+ name: activesupport
38
+ prerelease: false
39
+ requirement: &id002 !ruby/object:Gem::Requirement
40
+ none: false
41
+ requirements:
42
+ - - ">="
43
+ - !ruby/object:Gem::Version
44
+ hash: 5
45
+ segments:
46
+ - 2
47
+ - 3
48
+ version: "2.3"
49
+ type: :runtime
50
+ version_requirements: *id002
51
+ - !ruby/object:Gem::Dependency
52
+ name: i18n
53
+ prerelease: false
54
+ requirement: &id003 !ruby/object:Gem::Requirement
55
+ none: false
56
+ requirements:
57
+ - - ">="
58
+ - !ruby/object:Gem::Version
59
+ hash: 3
60
+ segments:
61
+ - 0
62
+ version: "0"
63
+ type: :runtime
64
+ version_requirements: *id003
65
+ - !ruby/object:Gem::Dependency
66
+ name: attr_required
67
+ prerelease: false
68
+ requirement: &id004 !ruby/object:Gem::Requirement
69
+ none: false
70
+ requirements:
71
+ - - ">="
72
+ - !ruby/object:Gem::Version
73
+ hash: 25
74
+ segments:
75
+ - 0
76
+ - 0
77
+ - 3
78
+ version: 0.0.3
79
+ type: :runtime
80
+ version_requirements: *id004
81
+ - !ruby/object:Gem::Dependency
82
+ name: addressable
83
+ prerelease: false
84
+ requirement: &id005 !ruby/object:Gem::Requirement
85
+ none: false
86
+ requirements:
87
+ - - ">="
88
+ - !ruby/object:Gem::Version
89
+ hash: 3
90
+ segments:
91
+ - 0
92
+ version: "0"
93
+ type: :runtime
94
+ version_requirements: *id005
95
+ - !ruby/object:Gem::Dependency
96
+ name: rake
97
+ prerelease: false
98
+ requirement: &id006 !ruby/object:Gem::Requirement
99
+ none: false
100
+ requirements:
101
+ - - ">="
102
+ - !ruby/object:Gem::Version
103
+ hash: 27
104
+ segments:
105
+ - 0
106
+ - 8
107
+ version: "0.8"
108
+ type: :development
109
+ version_requirements: *id006
110
+ - !ruby/object:Gem::Dependency
111
+ name: rcov
112
+ prerelease: false
113
+ requirement: &id007 !ruby/object:Gem::Requirement
114
+ none: false
115
+ requirements:
116
+ - - ">="
117
+ - !ruby/object:Gem::Version
118
+ hash: 25
119
+ segments:
120
+ - 0
121
+ - 9
122
+ version: "0.9"
123
+ type: :development
124
+ version_requirements: *id007
125
+ - !ruby/object:Gem::Dependency
126
+ name: rspec
127
+ prerelease: false
128
+ requirement: &id008 !ruby/object:Gem::Requirement
129
+ none: false
130
+ requirements:
131
+ - - ">="
132
+ - !ruby/object:Gem::Version
133
+ hash: 7
134
+ segments:
135
+ - 2
136
+ version: "2"
137
+ type: :development
138
+ version_requirements: *id008
139
+ description: A RubyGem for ActivityStreams Publishers
140
+ email:
141
+ - nov@matake.jp
142
+ executables: []
143
+
144
+ extensions: []
145
+
146
+ extra_rdoc_files: []
147
+
148
+ files:
149
+ - .gitignore
150
+ - Gemfile
151
+ - LICENSE
152
+ - Rakefile
153
+ - VERSION
154
+ - activitystreams.gemspec
155
+ - lib/activitystreams.rb
156
+ - lib/activitystreams/activity.rb
157
+ - lib/activitystreams/base.rb
158
+ - lib/activitystreams/collection.rb
159
+ - lib/activitystreams/exception.rb
160
+ - lib/activitystreams/media_link.rb
161
+ - lib/activitystreams/object.rb
162
+ - lib/activitystreams/stream.rb
163
+ - lib/activitystreams/validator.rb
164
+ - lib/activitystreams/verb.rb
165
+ - spec/activitystreams/activity_spec.rb
166
+ - spec/activitystreams/base_spec.rb
167
+ - spec/activitystreams/collection_spec.rb
168
+ - spec/activitystreams/media_link_spec.rb
169
+ - spec/activitystreams/object_spec.rb
170
+ - spec/activitystreams/stream_spec.rb
171
+ - spec/activitystreams/validator_spec.rb
172
+ - spec/activitystreams/verb_spec.rb
173
+ - spec/spec_helper.rb
174
+ homepage: http://github.com/nov/activitystreams
175
+ licenses: []
176
+
177
+ post_install_message:
178
+ rdoc_options: []
179
+
180
+ require_paths:
181
+ - lib
182
+ required_ruby_version: !ruby/object:Gem::Requirement
183
+ none: false
184
+ requirements:
185
+ - - ">="
186
+ - !ruby/object:Gem::Version
187
+ hash: 3
188
+ segments:
189
+ - 0
190
+ version: "0"
191
+ required_rubygems_version: !ruby/object:Gem::Requirement
192
+ none: false
193
+ requirements:
194
+ - - ">="
195
+ - !ruby/object:Gem::Version
196
+ hash: 3
197
+ segments:
198
+ - 0
199
+ version: "0"
200
+ requirements: []
201
+
202
+ rubyforge_project:
203
+ rubygems_version: 1.7.2
204
+ signing_key:
205
+ specification_version: 3
206
+ summary: A RubyGem for ActivityStreams Publishers
207
+ test_files:
208
+ - spec/activitystreams/activity_spec.rb
209
+ - spec/activitystreams/base_spec.rb
210
+ - spec/activitystreams/collection_spec.rb
211
+ - spec/activitystreams/media_link_spec.rb
212
+ - spec/activitystreams/object_spec.rb
213
+ - spec/activitystreams/stream_spec.rb
214
+ - spec/activitystreams/validator_spec.rb
215
+ - spec/activitystreams/verb_spec.rb
216
+ - spec/spec_helper.rb