remotty-rails 0.0.4 → 0.0.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile +3 -0
- data/README.md +25 -2
- data/app/controllers/remotty/base_application_controller.rb +15 -0
- data/lib/generators/remotty/rails/templates/auth_token.rb +4 -4
- data/lib/remotty/rails/version.rb +1 -1
- data/remotty-rails.gemspec +2 -0
- metadata +16 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8055898b932109c2e2528d6ebfb46127f4e35f6e
|
4
|
+
data.tar.gz: 92b9247d2d11c926a69c976329dfe3f3a5740235
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 624f1cca5014dcf1dd55d7c11b5acb04f67503ffa120f2808851366dd83dd42304c4821e15cdce77b413346fa5a91bb77297dcf701ca9139c6177a622029beb9
|
7
|
+
data.tar.gz: 667a741ad9221e32160f14e82757606e2aa10b00c456859a7b6ba5239a86b009bc41764e1b5e6b51393e3e2c75ead139739a5166369afdd66af945c479891286
|
data/Gemfile
CHANGED
data/README.md
CHANGED
@@ -26,6 +26,7 @@ AngularJS + Rails API를 사용할 때 기본적인 셋팅을 도와주어 빠
|
|
26
26
|
* use avatar for profile image
|
27
27
|
* use paperclip for attachment
|
28
28
|
* use serializer for json response
|
29
|
+
* use kaminari for paging
|
29
30
|
* CORS
|
30
31
|
* no cookie/no session
|
31
32
|
|
@@ -67,6 +68,22 @@ def render_error(code = 'ERROR', message = '', status = 400)
|
|
67
68
|
end
|
68
69
|
```
|
69
70
|
|
71
|
+
* render_paging helper
|
72
|
+
|
73
|
+
```ruby
|
74
|
+
def render_paging(items)
|
75
|
+
meta = {
|
76
|
+
total_count: items.total_count,
|
77
|
+
current_page: items.current_page,
|
78
|
+
per_page: items.limit_value
|
79
|
+
}
|
80
|
+
|
81
|
+
render json: items,
|
82
|
+
meta_key: 'page',
|
83
|
+
meta: meta,
|
84
|
+
root: 'items'
|
85
|
+
end
|
86
|
+
```
|
70
87
|
|
71
88
|
## Library
|
72
89
|
|
@@ -95,10 +112,15 @@ $ rails-api new {{project}} --skip-test-unit --skip-sprockets
|
|
95
112
|
|
96
113
|
```ruby
|
97
114
|
gem 'remotty-rails'
|
115
|
+
|
116
|
+
# user
|
98
117
|
gem 'devise'
|
99
118
|
gem 'omniauth-facebook'
|
100
119
|
gem 'omniauth-twitter'
|
120
|
+
|
121
|
+
# attachment
|
101
122
|
gem 'paperclip'
|
123
|
+
gem 'kaminari'
|
102
124
|
```
|
103
125
|
|
104
126
|
* And then execute:
|
@@ -141,8 +163,8 @@ devise_for :users,
|
|
141
163
|
omniauth_callbacks: 'remotty/users/omniauth_callbacks'}
|
142
164
|
|
143
165
|
devise_scope :user do
|
144
|
-
post 'api/v1/session/avatar' => 'users/registrations#avatar'
|
145
|
-
delete 'api/v1/session/avatar' => 'users/registrations#remove_avatar'
|
166
|
+
post 'api/v1/session/avatar' => 'remotty/users/registrations#avatar'
|
167
|
+
delete 'api/v1/session/avatar' => 'remotty/users/registrations#remove_avatar'
|
146
168
|
end
|
147
169
|
```
|
148
170
|
|
@@ -159,6 +181,7 @@ group :development do
|
|
159
181
|
gem 'better_errors'
|
160
182
|
gem 'binding_of_caller'
|
161
183
|
gem 'letter_opener'
|
184
|
+
gem 'rails-erd'
|
162
185
|
end
|
163
186
|
```
|
164
187
|
|
@@ -19,6 +19,21 @@ module Remotty::BaseApplicationController
|
|
19
19
|
|
20
20
|
protected
|
21
21
|
|
22
|
+
# paging - kaminari dependency
|
23
|
+
def render_paging(items)
|
24
|
+
meta = {
|
25
|
+
total_count: items.total_count,
|
26
|
+
current_page: items.current_page,
|
27
|
+
per_page: items.limit_value
|
28
|
+
}
|
29
|
+
|
30
|
+
render json: items,
|
31
|
+
meta_key: 'page',
|
32
|
+
meta: meta,
|
33
|
+
root: 'items'
|
34
|
+
end
|
35
|
+
|
36
|
+
# error
|
22
37
|
def render_error(code = 'ERROR', message = '', status = 400)
|
23
38
|
render json: {
|
24
39
|
error: {
|
@@ -12,11 +12,11 @@ class AuthToken < ActiveRecord::Base
|
|
12
12
|
|
13
13
|
# source 정보 업데이트
|
14
14
|
# 보통 ip가 변경될 경우가 많을듯 하고 변하지 않더라도 최종 갱신시간을 변경함
|
15
|
-
def update_source(
|
16
|
-
if
|
17
|
-
|
15
|
+
def update_source(new_source, new_source_info)
|
16
|
+
if source != new_source || source_info != new_source_info
|
17
|
+
update(source: new_source, source_info: new_source_info)
|
18
18
|
else
|
19
|
-
|
19
|
+
touch
|
20
20
|
end
|
21
21
|
end
|
22
22
|
end
|
data/remotty-rails.gemspec
CHANGED
@@ -31,6 +31,8 @@ Gem::Specification.new do |spec|
|
|
31
31
|
spec.add_dependency 'fog', '>= 1.22.0'
|
32
32
|
spec.add_dependency 'open_uri_redirections', '>= 0.1.4'
|
33
33
|
|
34
|
+
spec.add_dependency 'kaminari', '>= 0.15.1'
|
35
|
+
|
34
36
|
spec.add_development_dependency "bundler", "~> 1.6"
|
35
37
|
spec.add_development_dependency "rake"
|
36
38
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: remotty-rails
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Chungsub Kim
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2014-05-
|
12
|
+
date: 2014-05-28 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rack-cors
|
@@ -151,6 +151,20 @@ dependencies:
|
|
151
151
|
- - ">="
|
152
152
|
- !ruby/object:Gem::Version
|
153
153
|
version: 0.1.4
|
154
|
+
- !ruby/object:Gem::Dependency
|
155
|
+
name: kaminari
|
156
|
+
requirement: !ruby/object:Gem::Requirement
|
157
|
+
requirements:
|
158
|
+
- - ">="
|
159
|
+
- !ruby/object:Gem::Version
|
160
|
+
version: 0.15.1
|
161
|
+
type: :runtime
|
162
|
+
prerelease: false
|
163
|
+
version_requirements: !ruby/object:Gem::Requirement
|
164
|
+
requirements:
|
165
|
+
- - ">="
|
166
|
+
- !ruby/object:Gem::Version
|
167
|
+
version: 0.15.1
|
154
168
|
- !ruby/object:Gem::Dependency
|
155
169
|
name: bundler
|
156
170
|
requirement: !ruby/object:Gem::Requirement
|