restpack_activity 0.0.5 → 0.0.7

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 53efba83edf005114417206ae4bde20850c474bf
4
- data.tar.gz: 6ad29dd7144c7c7af1052ff443ff481900466d5a
3
+ metadata.gz: 78a83e44dd48091b097197d6364e09e283512ca9
4
+ data.tar.gz: 77b177e9fc4b919e3d32b5075198d08e6551919b
5
5
  SHA512:
6
- metadata.gz: 103112562ad21324f7f5b5a280df1f596007ff159b80412125fda1ee9432d16b33afdbc947b44a809ab9c12b1b805317e51bdff3da40dd2a00a4790f441885c2
7
- data.tar.gz: a74ccd4c3ab6a6e59dc11a565abee3e2582097c724b6730a149c12c5fdf57a3f1d8fca1bf3720f5d64059163451df4f60ac7ec51d4ee2fea6e194f01108c1eff
6
+ metadata.gz: cb4c30d671916dfc61279c1d3693e9a78982d3f1351bfe6aa1e090f4ade023685668112ac6e056a6c62f97fc6e5d813a15a6d67854fbdc21ae8668a86829d702
7
+ data.tar.gz: dcb4a6c27cd0564fd3be7f967f5b0d575cc3a0d6dcdfd18e67b75ded6c56c490800412106e2736dca3d66b5fb101669d304705a1c644c63f87e68f45dd537b6f
data/README.md CHANGED
@@ -1,4 +1,4 @@
1
- # restpack_activity [![Build Status](https://api.travis-ci.org/RestPack/restpack_activity.png?branch=master)](https://travis-ci.org/RestPack/restpack_activity) [![Code Climate](https://codeclimate.com/github/RestPack/restpack_activity.png)](https://codeclimate.com/github/RestPack/restpack_activity) [![Dependency Status](https://gemnasium.com/RestPack/restpack_activity.png)](https://gemnasium.com/RestPack/restpack_activity)
1
+ # restpack_activity [![Build Status](https://api.travis-ci.org/RestPack/restpack_activity.png?branch=master)](https://travis-ci.org/RestPack/restpack_activity) [![Code Climate](https://codeclimate.com/github/RestPack/restpack_activity.png)](https://codeclimate.com/github/RestPack/restpack_activity) [![Dependency Status](https://gemnasium.com/RestPack/restpack_activity.png)](https://gemnasium.com/RestPack/restpack_activity) [![Gem Version](https://badge.fury.io/rb/restpack_activity.png)](http://badge.fury.io/rb/restpack_activity)
2
2
 
3
3
  A client gem to the RestPack Activity service
4
4
 
@@ -13,7 +13,7 @@ class Activity
13
13
 
14
14
  def self.get(id)
15
15
  response = service.get(id)
16
- Activity.new(response.result)
16
+ Activity.new(response.result[:activities].first)
17
17
  end
18
18
 
19
19
  def self.destroy(id)
@@ -75,6 +75,7 @@ class Activity
75
75
  end
76
76
 
77
77
  def update_attributes(params)
78
+ #TODO: GJ: extract into base class
78
79
  #TODO: whitelist updateble params
79
80
  @title = params[:title] if params[:title]
80
81
  @content = params[:content] if params[:content]
@@ -97,6 +98,7 @@ class Activity
97
98
  private
98
99
 
99
100
  def attributes
101
+ #TODO: GJ: extract into base class
100
102
  #TODO: GJ: only those that have changed
101
103
  hash = {
102
104
  id: @id,
@@ -104,13 +106,13 @@ class Activity
104
106
  user_id: @user_id,
105
107
  title: @title,
106
108
  content: @content,
107
- data: @data,
108
109
  tags: @tags.join(','),
109
110
  access: @access.join(',')
110
111
  }
111
112
 
112
113
  hash[:latitude] = @latitude unless @latitude.blank?
113
114
  hash[:longitude] = @longitude unless @longitude.blank?
115
+ hash[:data] = @data unless @data.blank?
114
116
  hash
115
117
  end
116
118
  end
@@ -3,23 +3,23 @@ require 'rest_client'
3
3
  module RestPack::Activity::Proxies
4
4
  class Api < RestPack::BaseProxy
5
5
  def self.get(id)
6
- http(:get, "/api/v1/activities/#{id}.json")
6
+ http(:get, "/api/v1/activities/#{id}")
7
7
  end
8
8
 
9
9
  def self.list(params = {})
10
- http(:get, "/api/v1/activities.json", params)
10
+ http(:get, "/api/v1/activities", params)
11
11
  end
12
12
 
13
13
  def self.create(params)
14
- http(:post, "/api/v1/activities.json", params)
14
+ http(:post, "/api/v1/activities", params)
15
15
  end
16
16
 
17
17
  def self.update(params)
18
- http(:put, "/api/v1/activities/#{params[:id]}.json", params)
18
+ http(:put, "/api/v1/activities/#{params[:id]}", params)
19
19
  end
20
20
 
21
21
  def self.destroy(id)
22
- http(:delete, "/api/v1/activities/#{id}.json")
22
+ http(:delete, "/api/v1/activities/#{id}")
23
23
  end
24
24
 
25
25
  private
@@ -27,7 +27,10 @@ module RestPack::Activity::Proxies
27
27
  def self.http(method, path, params = {})
28
28
  params = { params: params } if method == :get
29
29
 
30
- RestClient.send(method, "#{RestPack::Activity.config.api_domain}#{path}", params) do |rest_response|
30
+ credentials = "#{RestPack::Activity.config.application_id}:#{RestPack::Activity.config.api_token}"
31
+
32
+ url = "http://#{credentials}@#{RestPack::Activity.config.api_domain}#{path}"
33
+ RestClient.send(method, url, params) do |rest_response|
31
34
  response = RestPack::Service::Response.from_rest(rest_response)
32
35
  raise_exceptions_if_required(response)
33
36
  response
@@ -1,7 +1,7 @@
1
1
  module RestPack::Activity::Proxies
2
2
  class Local < RestPack::BaseProxy
3
3
  def self.get(id)
4
- response = RestPack::Services::Activity::Get.run({
4
+ response = Commands::Activities::Activity::Get.run({
5
5
  id: id,
6
6
  application_id: RestPack::Activity.config.application_id
7
7
  })
@@ -11,7 +11,7 @@ module RestPack::Activity::Proxies
11
11
  end
12
12
 
13
13
  def self.list(params = {})
14
- response = RestPack::Services::Activity::List.run(params, {
14
+ response = Commands::Activities::Activity::List.run(params, {
15
15
  application_id: RestPack::Activity.config.application_id
16
16
  })
17
17
 
@@ -20,7 +20,7 @@ module RestPack::Activity::Proxies
20
20
  end
21
21
 
22
22
  def self.create(params)
23
- response = RestPack::Services::Activity::Create.run(params, {
23
+ response = Commands::Activities::Activity::Create.run(params, {
24
24
  application_id: RestPack::Activity.config.application_id
25
25
  })
26
26
 
@@ -29,7 +29,7 @@ module RestPack::Activity::Proxies
29
29
  end
30
30
 
31
31
  def self.update(params)
32
- response = RestPack::Services::Activity::Update.run(params, {
32
+ response = Commands::Activities::Activity::Update.run(params, {
33
33
  application_id: RestPack::Activity.config.application_id
34
34
  })
35
35
 
@@ -38,7 +38,7 @@ module RestPack::Activity::Proxies
38
38
  end
39
39
 
40
40
  def self.destroy(id)
41
- response = RestPack::Services::Activity::Destry.run({
41
+ response = Commands::Activities::Activity::Destry.run({
42
42
  id: id,
43
43
  application_id: RestPack::Activity.config.application_id
44
44
  })
@@ -7,6 +7,8 @@ module RestPack
7
7
  case(response.status)
8
8
  when :not_found
9
9
  raise ActiveRecord::RecordNotFound
10
+ when :unauthorized
11
+ raise "Unauthorized RestPack request"
10
12
  end
11
13
  end
12
14
  end
@@ -1,5 +1,5 @@
1
1
  module RestPack
2
2
  module Activity
3
- VERSION = "0.0.5"
3
+ VERSION = "0.0.7"
4
4
  end
5
5
  end
@@ -18,7 +18,7 @@ Gem::Specification.new do |spec|
18
18
  spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
19
  spec.require_paths = ["lib"]
20
20
 
21
- spec.add_dependency "restpack_activity_service", "~> 0.0.8"
21
+ spec.add_dependency "restpack_activity_service"
22
22
  spec.add_dependency "activemodel", "~> 4.0.0"
23
23
  spec.add_dependency "activesupport", "~> 4.0"
24
24
  spec.add_dependency "rest-client", "~> 1.6.7"
metadata CHANGED
@@ -1,29 +1,29 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: restpack_activity
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.5
4
+ version: 0.0.7
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-08-22 00:00:00.000000000 Z
11
+ date: 2013-11-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: restpack_activity_service
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - ~>
17
+ - - '>='
18
18
  - !ruby/object:Gem::Version
19
- version: 0.0.8
19
+ version: '0'
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - ~>
24
+ - - '>='
25
25
  - !ruby/object:Gem::Version
26
- version: 0.0.8
26
+ version: '0'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: activemodel
29
29
  requirement: !ruby/object:Gem::Requirement
@@ -182,7 +182,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
182
182
  version: '0'
183
183
  requirements: []
184
184
  rubyforge_project:
185
- rubygems_version: 2.0.3
185
+ rubygems_version: 2.0.7
186
186
  signing_key:
187
187
  specification_version: 4
188
188
  summary: A client gem to the activity service