restpack_activity_service 0.0.10 → 0.0.11
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +16 -2
- data/lib/restpack_activity_service.rb +2 -15
- data/lib/restpack_activity_service/commands/activity/create.rb +42 -0
- data/lib/restpack_activity_service/commands/activity/destroy.rb +24 -0
- data/lib/restpack_activity_service/commands/activity/get.rb +23 -0
- data/lib/restpack_activity_service/commands/activity/list.rb +30 -0
- data/lib/restpack_activity_service/commands/activity/update.rb +36 -0
- data/lib/restpack_activity_service/serializers/{activity_serializer.rb → activity.rb} +2 -2
- data/lib/restpack_activity_service/{tasks.rb → tasks/tasks.rb} +0 -0
- data/lib/restpack_activity_service/version.rb +1 -1
- data/restpack_activity_service.gemspec +0 -4
- data/spec/factories/activity_factory.rb +1 -1
- metadata +10 -66
- data/lib/restpack_activity_service/services/activity/create.rb +0 -40
- data/lib/restpack_activity_service/services/activity/destroy.rb +0 -22
- data/lib/restpack_activity_service/services/activity/get.rb +0 -21
- data/lib/restpack_activity_service/services/activity/list.rb +0 -28
- data/lib/restpack_activity_service/services/activity/update.rb +0 -32
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e09bdad0ec250540f53fba875ba0373330d96b87
|
4
|
+
data.tar.gz: 3ea93c0cc8c832d6a485aec4e12017a60c4cd8d5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9bd634abf3779e46c5f088e97bed4c3189c617cd5a787f9076ba749d39c02945a06278d8721018bf95394eb50411e52c6eb3a5a1b6657223d3cf56aa88fd08ed
|
7
|
+
data.tar.gz: 8fe40b5310e7a0ab1409c7b90c3639ea89da0589cd7336e9dd2e863415d9510935c5ece805f0aa8f23a9acbb65c157f877333bb3e86b0bb6c1d956384d21b8d6
|
data/.travis.yml
CHANGED
@@ -1,6 +1,20 @@
|
|
1
1
|
language: ruby
|
2
2
|
rvm:
|
3
3
|
- 2.0.0
|
4
|
-
|
5
|
-
|
4
|
+
#http://reefpoints.dockyard.com/ruby/2013/03/29/running-postgresql-9-2-on-travis-ci.html
|
5
|
+
before_script:
|
6
|
+
- sudo /etc/init.d/postgresql stop
|
7
|
+
- sudo cp /etc/postgresql/9.1/main/pg_hba.conf ./
|
8
|
+
- sudo apt-get remove postgresql postgresql-9.1 -qq --purge
|
9
|
+
- source /etc/lsb-release
|
10
|
+
- echo "deb http://apt.postgresql.org/pub/repos/apt/ $DISTRIB_CODENAME-pgdg main" > pgdg.list
|
11
|
+
- sudo mv pgdg.list /etc/apt/sources.list.d/
|
12
|
+
- wget --quiet -O - http://apt.postgresql.org/pub/repos/apt/ACCC4CF8.asc | sudo apt-key add -
|
13
|
+
- sudo apt-get update
|
14
|
+
- sudo apt-get -o Dpkg::Options::="--force-confdef" -o Dpkg::Options::="--force-confnew" install postgresql-9.2 postgresql-contrib-9.2 -qq
|
15
|
+
- sudo /etc/init.d/postgresql stop
|
16
|
+
- sudo cp ./pg_hba.conf /etc/postgresql/9.2/main
|
17
|
+
- sudo /etc/init.d/postgresql start
|
18
|
+
- psql -c 'create database restpack_activity_service_test;' -U postgres
|
19
|
+
- psql -c 'create role travis login;' -U postgres
|
6
20
|
script: bundle exec rake test
|
@@ -1,17 +1,4 @@
|
|
1
|
-
require
|
2
|
-
|
3
|
-
require "restpack_serializer"
|
4
|
-
|
5
|
-
require "restpack_activity_service/version"
|
6
|
-
require "restpack_activity_service/configuration"
|
7
|
-
require "restpack_activity_service/models/activity"
|
8
|
-
|
9
|
-
require "restpack_activity_service/serializers/activity_serializer"
|
10
|
-
require "restpack_activity_service/services"
|
11
|
-
require "restpack_activity_service/tasks"
|
1
|
+
require 'restpack_service'
|
2
|
+
RestPack::Service::Loader.load 'activity', Dir.pwd
|
12
3
|
|
13
4
|
require "restpack_activity_service/api/activity"
|
14
|
-
|
15
|
-
Models = RestPack::Activity::Service::Models
|
16
|
-
Commands = RestPack::Activity::Service::Commands
|
17
|
-
Serializers = RestPack::Activity::Service::Serializers
|
@@ -0,0 +1,42 @@
|
|
1
|
+
module RestPack::Activity::Service::Commands
|
2
|
+
module Activity
|
3
|
+
class Create < RestPack::Service::Command
|
4
|
+
required do
|
5
|
+
integer :application_id
|
6
|
+
integer :user_id
|
7
|
+
string :content
|
8
|
+
end
|
9
|
+
|
10
|
+
optional do
|
11
|
+
string :title, empty: true
|
12
|
+
string :tags, empty: true
|
13
|
+
string :access, empty: true
|
14
|
+
float :latitude
|
15
|
+
float :longitude
|
16
|
+
end
|
17
|
+
|
18
|
+
def init
|
19
|
+
inputs[:data] = raw_inputs[:data] if raw_inputs[:data]
|
20
|
+
|
21
|
+
if latitude.present? || longitude.present?
|
22
|
+
if latitude.present? != longitude.present?
|
23
|
+
service_error "Both Latitude and Longitude are required"
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
if title == "error"
|
28
|
+
service_error "This is a service error"
|
29
|
+
end
|
30
|
+
|
31
|
+
if title == "custom"
|
32
|
+
field_error :title, "Title should not be 'custom'"
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
def execute
|
37
|
+
activity = Models::Activity.create(inputs)
|
38
|
+
Serializers::Activity.as_json(activity)
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
module RestPack::Activity::Service::Commands
|
2
|
+
module Activity
|
3
|
+
class Destroy < RestPack::Service::Command
|
4
|
+
required do
|
5
|
+
integer :id
|
6
|
+
integer :application_id
|
7
|
+
end
|
8
|
+
|
9
|
+
def execute
|
10
|
+
activity = Models::Activity.find_by_id_and_application_id(
|
11
|
+
inputs[:id],
|
12
|
+
inputs[:application_id]
|
13
|
+
)
|
14
|
+
|
15
|
+
if activity
|
16
|
+
activity.destroy
|
17
|
+
nil
|
18
|
+
else
|
19
|
+
status :not_found
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
module RestPack::Activity::Service::Commands
|
2
|
+
module Activity
|
3
|
+
class Get < RestPack::Service::Command
|
4
|
+
required do
|
5
|
+
integer :id
|
6
|
+
integer :application_id
|
7
|
+
end
|
8
|
+
|
9
|
+
def execute
|
10
|
+
activity = Models::Activity.find_by_id_and_application_id(
|
11
|
+
inputs[:id],
|
12
|
+
inputs[:application_id]
|
13
|
+
)
|
14
|
+
|
15
|
+
if activity
|
16
|
+
Serializers::Activity.as_json(activity)
|
17
|
+
else
|
18
|
+
status :not_found
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
module RestPack::Activity::Service::Commands
|
2
|
+
module Activity
|
3
|
+
class List < RestPack::Service::Command
|
4
|
+
required do
|
5
|
+
integer :application_id
|
6
|
+
end
|
7
|
+
|
8
|
+
optional do
|
9
|
+
integer :user_id
|
10
|
+
integer :page
|
11
|
+
integer :page_size
|
12
|
+
string :tags
|
13
|
+
string :access
|
14
|
+
string :query
|
15
|
+
end
|
16
|
+
|
17
|
+
def execute
|
18
|
+
scope = Models::Activity.all
|
19
|
+
scope = scope.where(application_id: application_id)
|
20
|
+
|
21
|
+
scope = scope.where(user_id: user_id) if user_id
|
22
|
+
scope = scope.all_tags_csv(tags) if tags
|
23
|
+
scope = scope.any_tags_csv(access, :access) if access
|
24
|
+
scope = scope.search(query) if query
|
25
|
+
|
26
|
+
Serializers::Activity.resource(inputs, scope)
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
@@ -0,0 +1,36 @@
|
|
1
|
+
module RestPack::Activity::Service::Commands
|
2
|
+
module Activity
|
3
|
+
class Update < RestPack::Service::Command
|
4
|
+
required do
|
5
|
+
integer :id
|
6
|
+
integer :application_id
|
7
|
+
end
|
8
|
+
|
9
|
+
optional do
|
10
|
+
string :title, empty: true
|
11
|
+
string :content
|
12
|
+
string :tags, empty: true
|
13
|
+
string :access, empty: true
|
14
|
+
float :latitude
|
15
|
+
float :longitude
|
16
|
+
end
|
17
|
+
|
18
|
+
def init
|
19
|
+
inputs[:data] = raw_inputs[:data] if raw_inputs[:data]
|
20
|
+
end
|
21
|
+
|
22
|
+
def execute
|
23
|
+
activity = Models::Activity.find_by_id_and_application_id(
|
24
|
+
inputs[:id], inputs[:application_id]
|
25
|
+
)
|
26
|
+
|
27
|
+
if activity
|
28
|
+
activity.update_attributes(inputs)
|
29
|
+
Serializers::Activity.as_json(activity)
|
30
|
+
else
|
31
|
+
status :not_found
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
@@ -1,8 +1,8 @@
|
|
1
1
|
module RestPack::Activity::Service::Serializers
|
2
|
-
class
|
2
|
+
class Activity
|
3
3
|
include RestPack::Serializer
|
4
4
|
|
5
|
-
self.model_class =
|
5
|
+
self.model_class = Models::Activity
|
6
6
|
self.key = :activities
|
7
7
|
|
8
8
|
attributes :id, :application_id, :user_id, :title, :content, :latitude, :longitude,
|
File without changes
|
@@ -19,10 +19,6 @@ Gem::Specification.new do |spec|
|
|
19
19
|
spec.require_paths = ["lib"]
|
20
20
|
|
21
21
|
spec.add_dependency "restpack_service"
|
22
|
-
spec.add_dependency "restpack_serializer"
|
23
|
-
spec.add_dependency "restpack_gem"
|
24
|
-
spec.add_dependency "sinatra", "~> 1.4.3"
|
25
|
-
spec.add_dependency "pg", "~> 0.16"
|
26
22
|
|
27
23
|
spec.add_development_dependency "bundler", "~> 1.3"
|
28
24
|
spec.add_development_dependency "database_cleaner", "~> 1.0.1"
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: restpack_activity_service
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.11
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Gavin Joyce
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-
|
11
|
+
date: 2013-09-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: restpack_service
|
@@ -24,62 +24,6 @@ dependencies:
|
|
24
24
|
- - '>='
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '0'
|
27
|
-
- !ruby/object:Gem::Dependency
|
28
|
-
name: restpack_serializer
|
29
|
-
requirement: !ruby/object:Gem::Requirement
|
30
|
-
requirements:
|
31
|
-
- - '>='
|
32
|
-
- !ruby/object:Gem::Version
|
33
|
-
version: '0'
|
34
|
-
type: :runtime
|
35
|
-
prerelease: false
|
36
|
-
version_requirements: !ruby/object:Gem::Requirement
|
37
|
-
requirements:
|
38
|
-
- - '>='
|
39
|
-
- !ruby/object:Gem::Version
|
40
|
-
version: '0'
|
41
|
-
- !ruby/object:Gem::Dependency
|
42
|
-
name: restpack_gem
|
43
|
-
requirement: !ruby/object:Gem::Requirement
|
44
|
-
requirements:
|
45
|
-
- - '>='
|
46
|
-
- !ruby/object:Gem::Version
|
47
|
-
version: '0'
|
48
|
-
type: :runtime
|
49
|
-
prerelease: false
|
50
|
-
version_requirements: !ruby/object:Gem::Requirement
|
51
|
-
requirements:
|
52
|
-
- - '>='
|
53
|
-
- !ruby/object:Gem::Version
|
54
|
-
version: '0'
|
55
|
-
- !ruby/object:Gem::Dependency
|
56
|
-
name: sinatra
|
57
|
-
requirement: !ruby/object:Gem::Requirement
|
58
|
-
requirements:
|
59
|
-
- - ~>
|
60
|
-
- !ruby/object:Gem::Version
|
61
|
-
version: 1.4.3
|
62
|
-
type: :runtime
|
63
|
-
prerelease: false
|
64
|
-
version_requirements: !ruby/object:Gem::Requirement
|
65
|
-
requirements:
|
66
|
-
- - ~>
|
67
|
-
- !ruby/object:Gem::Version
|
68
|
-
version: 1.4.3
|
69
|
-
- !ruby/object:Gem::Dependency
|
70
|
-
name: pg
|
71
|
-
requirement: !ruby/object:Gem::Requirement
|
72
|
-
requirements:
|
73
|
-
- - ~>
|
74
|
-
- !ruby/object:Gem::Version
|
75
|
-
version: '0.16'
|
76
|
-
type: :runtime
|
77
|
-
prerelease: false
|
78
|
-
version_requirements: !ruby/object:Gem::Requirement
|
79
|
-
requirements:
|
80
|
-
- - ~>
|
81
|
-
- !ruby/object:Gem::Version
|
82
|
-
version: '0.16'
|
83
27
|
- !ruby/object:Gem::Dependency
|
84
28
|
name: bundler
|
85
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -195,17 +139,17 @@ files:
|
|
195
139
|
- db/migrate/20130630145408_create_activity_table.rb
|
196
140
|
- lib/restpack_activity_service.rb
|
197
141
|
- lib/restpack_activity_service/api/activity.rb
|
142
|
+
- lib/restpack_activity_service/commands/activity/create.rb
|
143
|
+
- lib/restpack_activity_service/commands/activity/destroy.rb
|
144
|
+
- lib/restpack_activity_service/commands/activity/get.rb
|
145
|
+
- lib/restpack_activity_service/commands/activity/list.rb
|
146
|
+
- lib/restpack_activity_service/commands/activity/update.rb
|
198
147
|
- lib/restpack_activity_service/configuration.rb
|
199
148
|
- lib/restpack_activity_service/models/activity.rb
|
200
|
-
- lib/restpack_activity_service/serializers/
|
149
|
+
- lib/restpack_activity_service/serializers/activity.rb
|
201
150
|
- lib/restpack_activity_service/services.rb
|
202
|
-
- lib/restpack_activity_service/services/activity/create.rb
|
203
|
-
- lib/restpack_activity_service/services/activity/destroy.rb
|
204
|
-
- lib/restpack_activity_service/services/activity/get.rb
|
205
|
-
- lib/restpack_activity_service/services/activity/list.rb
|
206
|
-
- lib/restpack_activity_service/services/activity/update.rb
|
207
|
-
- lib/restpack_activity_service/tasks.rb
|
208
151
|
- lib/restpack_activity_service/tasks/db.rake
|
152
|
+
- lib/restpack_activity_service/tasks/tasks.rb
|
209
153
|
- lib/restpack_activity_service/version.rb
|
210
154
|
- restpack_activity_service.gemspec
|
211
155
|
- spec/factories/activity_factory.rb
|
@@ -234,7 +178,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
234
178
|
version: '0'
|
235
179
|
requirements: []
|
236
180
|
rubyforge_project:
|
237
|
-
rubygems_version: 2.0.
|
181
|
+
rubygems_version: 2.0.5
|
238
182
|
signing_key:
|
239
183
|
specification_version: 4
|
240
184
|
summary: Simple Activity Streams
|
@@ -1,40 +0,0 @@
|
|
1
|
-
module RestPack::Activity::Service::Commands::Activity
|
2
|
-
class Create < RestPack::Service::Command
|
3
|
-
required do
|
4
|
-
integer :application_id
|
5
|
-
integer :user_id
|
6
|
-
string :content
|
7
|
-
end
|
8
|
-
|
9
|
-
optional do
|
10
|
-
string :title, empty: true
|
11
|
-
string :tags, empty: true
|
12
|
-
string :access, empty: true
|
13
|
-
float :latitude
|
14
|
-
float :longitude
|
15
|
-
end
|
16
|
-
|
17
|
-
def init
|
18
|
-
inputs[:data] = raw_inputs[:data] if raw_inputs[:data]
|
19
|
-
|
20
|
-
if latitude.present? || longitude.present?
|
21
|
-
if latitude.present? != longitude.present?
|
22
|
-
service_error "Both Latitude and Longitude are required"
|
23
|
-
end
|
24
|
-
end
|
25
|
-
|
26
|
-
if title == "error"
|
27
|
-
service_error "This is a service error"
|
28
|
-
end
|
29
|
-
|
30
|
-
if title == "custom"
|
31
|
-
field_error :title, "Title should not be 'custom'"
|
32
|
-
end
|
33
|
-
end
|
34
|
-
|
35
|
-
def execute
|
36
|
-
activity = Models::Activity.create(inputs)
|
37
|
-
Serializers::ActivitySerializer.as_json(activity)
|
38
|
-
end
|
39
|
-
end
|
40
|
-
end
|
@@ -1,22 +0,0 @@
|
|
1
|
-
module RestPack::Activity::Service::Commands::Activity
|
2
|
-
class Destroy < RestPack::Service::Command
|
3
|
-
required do
|
4
|
-
integer :id
|
5
|
-
integer :application_id
|
6
|
-
end
|
7
|
-
|
8
|
-
def execute
|
9
|
-
activity = Models::Activity.find_by_id_and_application_id(
|
10
|
-
inputs[:id],
|
11
|
-
inputs[:application_id]
|
12
|
-
)
|
13
|
-
|
14
|
-
if activity
|
15
|
-
activity.destroy
|
16
|
-
nil
|
17
|
-
else
|
18
|
-
status :not_found
|
19
|
-
end
|
20
|
-
end
|
21
|
-
end
|
22
|
-
end
|
@@ -1,21 +0,0 @@
|
|
1
|
-
module RestPack::Activity::Service::Commands::Activity
|
2
|
-
class Get < RestPack::Service::Command
|
3
|
-
required do
|
4
|
-
integer :id
|
5
|
-
integer :application_id
|
6
|
-
end
|
7
|
-
|
8
|
-
def execute
|
9
|
-
activity = Models::Activity.find_by_id_and_application_id(
|
10
|
-
inputs[:id],
|
11
|
-
inputs[:application_id]
|
12
|
-
)
|
13
|
-
|
14
|
-
if activity
|
15
|
-
Serializers::ActivitySerializer.as_json(activity)
|
16
|
-
else
|
17
|
-
status :not_found
|
18
|
-
end
|
19
|
-
end
|
20
|
-
end
|
21
|
-
end
|
@@ -1,28 +0,0 @@
|
|
1
|
-
module RestPack::Activity::Service::Commands::Activity
|
2
|
-
class List < RestPack::Service::Command
|
3
|
-
required do
|
4
|
-
integer :application_id
|
5
|
-
end
|
6
|
-
|
7
|
-
optional do
|
8
|
-
integer :user_id
|
9
|
-
integer :page
|
10
|
-
integer :page_size
|
11
|
-
string :tags
|
12
|
-
string :access
|
13
|
-
string :query
|
14
|
-
end
|
15
|
-
|
16
|
-
def execute
|
17
|
-
scope = Models::Activity.all
|
18
|
-
scope = scope.where(application_id: application_id)
|
19
|
-
|
20
|
-
scope = scope.where(user_id: user_id) if user_id
|
21
|
-
scope = scope.all_tags_csv(tags) if tags
|
22
|
-
scope = scope.any_tags_csv(access, :access) if access
|
23
|
-
scope = scope.search(query) if query
|
24
|
-
|
25
|
-
Serializers::ActivitySerializer.resource(inputs, scope)
|
26
|
-
end
|
27
|
-
end
|
28
|
-
end
|
@@ -1,32 +0,0 @@
|
|
1
|
-
module RestPack::Activity::Service::Commands::Activity
|
2
|
-
class Update < RestPack::Service::Command
|
3
|
-
required do
|
4
|
-
integer :id
|
5
|
-
integer :application_id
|
6
|
-
end
|
7
|
-
|
8
|
-
optional do
|
9
|
-
string :title, empty: true
|
10
|
-
string :content
|
11
|
-
string :tags, empty: true
|
12
|
-
string :access, empty: true
|
13
|
-
float :latitude
|
14
|
-
float :longitude
|
15
|
-
end
|
16
|
-
|
17
|
-
def init
|
18
|
-
inputs[:data] = raw_inputs[:data] if raw_inputs[:data]
|
19
|
-
end
|
20
|
-
|
21
|
-
def execute
|
22
|
-
activity = RestPack::Activity::Service::Models::Activity.find_by_id_and_application_id(inputs[:id], inputs[:application_id])
|
23
|
-
|
24
|
-
if activity
|
25
|
-
activity.update_attributes(inputs)
|
26
|
-
RestPack::Activity::Service::Serializers::ActivitySerializer.as_json(activity)
|
27
|
-
else
|
28
|
-
status :not_found
|
29
|
-
end
|
30
|
-
end
|
31
|
-
end
|
32
|
-
end
|