sheep 0.0.1a → 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/sheep/activity.rb +30 -0
- data/lib/sheep/user.rb +14 -1
- data/lib/sheep/version.rb +1 -1
- data/lib/sheep.rb +1 -0
- data/spec/app_helper.rb +4 -0
- data/spec/sheep/activity_spec.rb +8 -0
- data/spec/sheep/user_spec.rb +10 -0
- metadata +9 -8
@@ -0,0 +1,30 @@
|
|
1
|
+
module Sheep
|
2
|
+
class Activity
|
3
|
+
def initialize(data)
|
4
|
+
@data = {}
|
5
|
+
data.each do |key, value|
|
6
|
+
self[key] = value
|
7
|
+
end
|
8
|
+
end
|
9
|
+
|
10
|
+
def method_missing(attribute, value = nil)
|
11
|
+
if attribute =~/\=$/
|
12
|
+
self[attribute.to_s.gsub(/\=$/, '')] = value
|
13
|
+
else
|
14
|
+
self[attribute]
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
def [](attribute)
|
19
|
+
@data[attribute.to_s]
|
20
|
+
end
|
21
|
+
|
22
|
+
def []=(attribute, value)
|
23
|
+
@data[attribute.to_s] = value
|
24
|
+
end
|
25
|
+
|
26
|
+
def ==(other)
|
27
|
+
self.data == other.data
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
data/lib/sheep/user.rb
CHANGED
@@ -24,12 +24,25 @@ module Sheep
|
|
24
24
|
request.params['client_secret'] = Sheep.client_secret
|
25
25
|
request.params['grant_type'] = 'password'
|
26
26
|
end
|
27
|
+
# TODO: access_token should be in user object, not global
|
27
28
|
Sheep.access_token = response.body['access_token']
|
28
29
|
end
|
29
30
|
end
|
30
31
|
|
32
|
+
def activities
|
33
|
+
response = Sheep.connection.get('/v1/activities') do |request|
|
34
|
+
request.headers['Authorization'] = "Bearer #{Sheep.access_token}"
|
35
|
+
end
|
36
|
+
response.body.map do |activity|
|
37
|
+
Sheep::Activity.new(activity['activity'])
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
31
41
|
def initialize(data)
|
32
|
-
@data =
|
42
|
+
@data = {}
|
43
|
+
data.each do |key, value|
|
44
|
+
self[key] = value
|
45
|
+
end
|
33
46
|
end
|
34
47
|
|
35
48
|
def method_missing(attribute, value = nil)
|
data/lib/sheep/version.rb
CHANGED
data/lib/sheep.rb
CHANGED
data/spec/app_helper.rb
CHANGED
data/spec/sheep/user_spec.rb
CHANGED
@@ -58,4 +58,14 @@ describe Sheep::User do
|
|
58
58
|
Sheep.access_token.should == 'access_token'
|
59
59
|
end
|
60
60
|
end
|
61
|
+
|
62
|
+
context 'activities' do
|
63
|
+
before do
|
64
|
+
@user = Sheep::User.find('krekoten')
|
65
|
+
end
|
66
|
+
|
67
|
+
it 'returns array of activities' do
|
68
|
+
@user.activities.should == [Sheep::Activity.new(:id => 1, :title => 'Hello World', :text => 'Very funny story')]
|
69
|
+
end
|
70
|
+
end
|
61
71
|
end
|
metadata
CHANGED
@@ -1,8 +1,8 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sheep
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
prerelease:
|
5
|
-
version: 0.0
|
4
|
+
prerelease:
|
5
|
+
version: 0.1.0
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- "Marjan Krekoten' (\xD0\x9C\xD0\xB0\xD1\x80'\xD1\x8F\xD0\xBD \xD0\x9A\xD1\x80\xD0\xB5\xD0\xBA\xD0\xBE\xD1\x82\xD0\xB5\xD0\xBD\xD1\x8C)"
|
@@ -10,8 +10,7 @@ autorequire:
|
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
12
|
|
13
|
-
date: 2011-
|
14
|
-
default_executable:
|
13
|
+
date: 2011-04-12 00:00:00 Z
|
15
14
|
dependencies:
|
16
15
|
- !ruby/object:Gem::Dependency
|
17
16
|
name: rspec
|
@@ -94,17 +93,18 @@ files:
|
|
94
93
|
- README.md
|
95
94
|
- Rakefile
|
96
95
|
- lib/sheep.rb
|
96
|
+
- lib/sheep/activity.rb
|
97
97
|
- lib/sheep/error.rb
|
98
98
|
- lib/sheep/user.rb
|
99
99
|
- lib/sheep/version.rb
|
100
100
|
- sheep.gemspec
|
101
101
|
- spec/app_helper.rb
|
102
102
|
- spec/quality_spec.rb
|
103
|
+
- spec/sheep/activity_spec.rb
|
103
104
|
- spec/sheep/error_spec.rb
|
104
105
|
- spec/sheep/user_spec.rb
|
105
106
|
- spec/sheep_spec.rb
|
106
107
|
- spec/spec_helper.rb
|
107
|
-
has_rdoc: true
|
108
108
|
homepage: ""
|
109
109
|
licenses: []
|
110
110
|
|
@@ -122,19 +122,20 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
122
122
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
123
123
|
none: false
|
124
124
|
requirements:
|
125
|
-
- - "
|
125
|
+
- - ">="
|
126
126
|
- !ruby/object:Gem::Version
|
127
|
-
version:
|
127
|
+
version: "0"
|
128
128
|
requirements: []
|
129
129
|
|
130
130
|
rubyforge_project: "[none]"
|
131
|
-
rubygems_version: 1.
|
131
|
+
rubygems_version: 1.7.2
|
132
132
|
signing_key:
|
133
133
|
specification_version: 3
|
134
134
|
summary: Funny sheep Tuppy
|
135
135
|
test_files:
|
136
136
|
- spec/app_helper.rb
|
137
137
|
- spec/quality_spec.rb
|
138
|
+
- spec/sheep/activity_spec.rb
|
138
139
|
- spec/sheep/error_spec.rb
|
139
140
|
- spec/sheep/user_spec.rb
|
140
141
|
- spec/sheep_spec.rb
|