landable 1.13.1 → 1.13.2
Sign up to get free protection for your applications and to get access to all the features.
- data/.rubocop.yml +281 -0
- data/.travis.yml +0 -1
- data/CHANGELOG.md +5 -1
- data/Gemfile +3 -4
- data/README.md +2 -0
- data/Rakefile +6 -3
- data/app/controllers/concerns/landable/variables_concern.rb +9 -9
- data/app/controllers/landable/api/access_tokens_controller.rb +7 -8
- data/app/controllers/landable/api/assets_controller.rb +29 -26
- data/app/controllers/landable/api/audits_controller.rb +6 -5
- data/app/controllers/landable/api/configurations_controller.rb +1 -1
- data/app/controllers/landable/api/directories_controller.rb +2 -2
- data/app/controllers/landable/api/page_revisions_controller.rb +2 -4
- data/app/controllers/landable/api/pages_controller.rb +39 -40
- data/app/controllers/landable/api/template_revisions_controller.rb +1 -2
- data/app/controllers/landable/api/templates_controller.rb +15 -14
- data/app/controllers/landable/api/themes_controller.rb +15 -14
- data/app/controllers/landable/api_controller.rb +10 -11
- data/app/controllers/landable/public/pages_controller.rb +2 -2
- data/app/controllers/landable/public/preview/page_revisions_controller.rb +2 -2
- data/app/controllers/landable/public/preview/pages_controller.rb +1 -1
- data/app/controllers/landable/public/sitemap_controller.rb +2 -2
- data/app/decorators/landable/page_decorator.rb +3 -3
- data/app/helpers/landable/pages_helper.rb +2 -2
- data/app/helpers/landable/traffic_helper.rb +2 -4
- data/app/models/concerns/landable/has_assets.rb +6 -9
- data/app/models/concerns/landable/has_templates.rb +6 -7
- data/app/models/concerns/landable/librarian.rb +5 -5
- data/app/models/concerns/landable/table_name.rb +2 -2
- data/app/models/landable/access_token.rb +1 -1
- data/app/models/landable/asset.rb +8 -8
- data/app/models/landable/asset_search_engine.rb +7 -8
- data/app/models/landable/author.rb +2 -1
- data/app/models/landable/category.rb +1 -3
- data/app/models/landable/directory.rb +2 -2
- data/app/models/landable/page.rb +44 -50
- data/app/models/landable/page_revision.rb +27 -41
- data/app/models/landable/page_search_engine.rb +5 -6
- data/app/models/landable/search_engine.rb +2 -2
- data/app/models/landable/template.rb +9 -11
- data/app/models/landable/template_revision.rb +4 -14
- data/app/models/landable/theme.rb +1 -1
- data/app/models/landable/traffic/attribution.rb +3 -1
- data/app/models/landable/traffic/page_view.rb +1 -1
- data/app/models/landable/traffic/user_agent.rb +1 -1
- data/app/models/landable/traffic/visit.rb +1 -1
- data/app/responders/landable/api_responder.rb +5 -3
- data/app/responders/landable/page_render_responder.rb +1 -1
- data/app/serializers/landable/asset_serializer.rb +1 -1
- data/app/serializers/landable/audit_serializer.rb +2 -3
- data/app/serializers/landable/directory_serializer.rb +2 -2
- data/app/serializers/landable/page_revision_serializer.rb +0 -1
- data/app/serializers/landable/page_serializer.rb +5 -5
- data/app/serializers/landable/template_serializer.rb +2 -2
- data/app/services/landable/authentication_service.rb +1 -1
- data/app/services/landable/registration_service.rb +3 -2
- data/app/services/landable/render_service.rb +16 -18
- data/app/services/landable/screenshot_service.rb +3 -4
- data/app/services/landable/tidy_service.rb +32 -37
- data/app/validators/path_validator.rb +1 -3
- data/app/validators/url_validator.rb +4 -7
- data/config/routes.rb +3 -6
- data/db/migrate/20130510221424_create_landable_schema.rb +45 -56
- data/db/migrate/20130909182713_landable_pages__add_updated_by.rb +2 -2
- data/db/migrate/20130909182715_landable_page_revisions__break_out_snapshot.rb +9 -12
- data/db/migrate/20131002220041_file_based_themes.rb +3 -3
- data/db/migrate/20131008164204_create_head_tag_on_page.rb +4 -4
- data/db/migrate/20131008193544_drop_status_codes_model.rb +1 -2
- data/db/migrate/20131028145652_add_traffic_schema.rb +5 -5
- data/db/migrate/20131101213623_add_dnt_column_to_visits.rb +1 -1
- data/db/migrate/20131106185946_add_index_on_page_revisions_path.rb +1 -1
- data/db/migrate/20131106193021_page_revisisons__path_status_code_index.rb +1 -1
- data/db/migrate/20131121150902_add_attribution_id_to_unique_index.rb +2 -2
- data/db/migrate/20131216214027_drop_browser_screenshot_tables.rb +3 -3
- data/db/migrate/20140128170659_file_backed_templates.rb +1 -1
- data/db/migrate/20140205193757_fix_status_codes.rb +3 -3
- data/db/migrate/20140220170324_add_slug_to_categories.rb +1 -1
- data/db/migrate/20140224205516_rename_traffic_schema.rb +7 -9
- data/db/migrate/20140509190128_create_template_revisions.rb +13 -15
- data/db/migrate/20140509192856_create_audits.rb +3 -3
- data/db/migrate/20140602213937_path_response_time_view.rb +20 -19
- data/features/step_definitions/asset_steps.rb +10 -12
- data/features/step_definitions/core_api_steps.rb +29 -27
- data/features/step_definitions/factory_steps.rb +16 -16
- data/features/step_definitions/html_steps.rb +1 -1
- data/features/step_definitions/liquid_steps.rb +8 -8
- data/features/step_definitions/theme_steps.rb +4 -4
- data/features/support/env.rb +5 -5
- data/landable.gemspec +2 -2
- data/lib/generators/landable/landable_generator.rb +2 -2
- data/lib/generators/templates/landable.rb +1 -1
- data/lib/landable.rb +7 -7
- data/lib/landable/configuration.rb +10 -19
- data/lib/landable/engine.rb +19 -19
- data/lib/landable/error.rb +1 -3
- data/lib/landable/layout.rb +6 -6
- data/lib/landable/liquid/asset_tags.rb +3 -5
- data/lib/landable/liquid/drops.rb +3 -8
- data/lib/landable/liquid/filters.rb +1 -3
- data/lib/landable/liquid/tags.rb +10 -10
- data/lib/landable/migration.rb +30 -30
- data/lib/landable/mime_types.rb +1 -1
- data/lib/landable/partial.rb +2 -2
- data/lib/landable/seeds.rb +3 -4
- data/lib/landable/traffic.rb +4 -8
- data/lib/landable/traffic/tracker.rb +48 -43
- data/lib/landable/traffic/user_tracker.rb +15 -10
- data/lib/landable/version.rb +1 -1
- data/lib/schema_moves.rb +15 -16
- data/lib/tasks/landable/cucumber.rake +46 -47
- data/lib/tasks/landable/data.rake +13 -14
- data/lib/tasks/landable/pgtap.rake +12 -18
- data/lib/tasks/landable/seed.rake +4 -4
- data/spec/concerns/landable/has_assets_spec.rb +15 -19
- data/spec/concerns/landable/has_templates_spec.rb +10 -13
- data/spec/concerns/landable/librarian.rb +4 -4
- data/spec/concerns/landable/table_name_spec.rb +3 -5
- data/spec/concerns/landable/traffic/table_name_spec.rb +2 -4
- data/spec/controllers/concerns/landable/variables_concern_spec.rb +11 -10
- data/spec/controllers/landable/api/assets_controller_spec.rb +15 -14
- data/spec/controllers/landable/api/audits_controller_spec.rb +104 -102
- data/spec/controllers/landable/api/categories_controller_spec.rb +36 -34
- data/spec/controllers/landable/api/configuration_controller_spec.rb +14 -12
- data/spec/controllers/landable/api/directories_controller_spec.rb +52 -50
- data/spec/controllers/landable/api/page_revisions_controller_spec.rb +20 -18
- data/spec/controllers/landable/api/pages_controller_spec.rb +204 -203
- data/spec/controllers/landable/api/template_revisions_controller_spec.rb +20 -18
- data/spec/controllers/landable/api/templates_controller_spec.rb +39 -37
- data/spec/controllers/landable/api_controller_spec.rb +24 -26
- data/spec/controllers/public/preview/page_revisions_controller_spec.rb +36 -34
- data/spec/controllers/public/preview/pages_controller_spec.rb +32 -30
- data/spec/controllers/public/sitemap_controller_spec.rb +19 -17
- data/spec/decorators/page_decorator_spec.rb +9 -9
- data/spec/dummy/app/helpers/application_helper.rb +1 -1
- data/spec/dummy/config/application.rb +5 -6
- data/spec/dummy/config/boot.rb +1 -1
- data/spec/dummy/config/environments/test.rb +1 -1
- data/spec/dummy/config/initializers/landable.rb +7 -6
- data/spec/factories/asset.rb +1 -1
- data/spec/factories/audit.rb +1 -1
- data/spec/factories/authors.rb +1 -1
- data/spec/factories/category.rb +1 -1
- data/spec/factories/pages.rb +4 -4
- data/spec/factories/template.rb +3 -3
- data/spec/factories/theme.rb +2 -2
- data/spec/helpers/pages_helper_spec.rb +5 -5
- data/spec/lib/landable/configuration_spec.rb +2 -4
- data/spec/lib/landable/event_publisher_spec.rb +1 -3
- data/spec/lib/landable/layout_spec.rb +4 -4
- data/spec/lib/landable/liquid_spec.rb +12 -14
- data/spec/lib/landable/migration_spec.rb +4 -4
- data/spec/lib/landable/partial_spec.rb +18 -18
- data/spec/lib/landable/tracking_spec.rb +27 -29
- data/spec/lib/landable/traffic_spec.rb +29 -33
- data/spec/models/landable/access_token_spec.rb +1 -1
- data/spec/models/landable/asset_spec.rb +9 -11
- data/spec/models/landable/directory_spec.rb +7 -7
- data/spec/models/landable/page/errors_spec.rb +1 -3
- data/spec/models/landable/page_revision_spec.rb +23 -24
- data/spec/models/landable/page_spec.rb +41 -42
- data/spec/models/landable/template_revision_spec.rb +3 -3
- data/spec/models/landable/template_spec.rb +11 -11
- data/spec/models/landable/theme_spec.rb +2 -2
- data/spec/models/landable/traffic/referer_spec.rb +3 -3
- data/spec/responders/page_render_responder_spec.rb +0 -2
- data/spec/routing/public_page_route_spec.rb +4 -5
- data/spec/services/landable/authentication_service_spec.rb +7 -7
- data/spec/services/landable/render_service_spec.rb +8 -8
- data/spec/services/landable/screenshot_service_spec.rb +3 -3
- data/spec/services/landable/tidy_service_spec.rb +20 -20
- data/spec/spec_helper.rb +3 -3
- data/spec/support/behaviors.rb +4 -4
- data/spec/support/helpers.rb +1 -1
- metadata +86 -35
- checksums.yaml +0 -7
data/.rubocop.yml
ADDED
@@ -0,0 +1,281 @@
|
|
1
|
+
Lint/AmbiguousOperator:
|
2
|
+
Enabled: true
|
3
|
+
|
4
|
+
Lint/AmbiguousRegexpLiteral:
|
5
|
+
Enabled: true
|
6
|
+
|
7
|
+
Lint/AssignmentInCondition:
|
8
|
+
Enabled: true
|
9
|
+
|
10
|
+
Lint/BlockAlignment:
|
11
|
+
Enabled: true
|
12
|
+
|
13
|
+
Lint/Debugger:
|
14
|
+
Enabled: true
|
15
|
+
Exclude:
|
16
|
+
- features/step_definitions/debug_steps.rb
|
17
|
+
|
18
|
+
Lint/DeprecatedClassMethods:
|
19
|
+
Enabled: true
|
20
|
+
|
21
|
+
Lint/Eval:
|
22
|
+
Enabled: true
|
23
|
+
|
24
|
+
Lint/LiteralInInterpolation:
|
25
|
+
Enabled: true
|
26
|
+
|
27
|
+
Lint/ShadowingOuterLocalVariable:
|
28
|
+
Enabled: true
|
29
|
+
|
30
|
+
Lint/StringConversionInInterpolation:
|
31
|
+
Enabled: true
|
32
|
+
|
33
|
+
Lint/UnusedBlockArgument:
|
34
|
+
Enabled: true
|
35
|
+
|
36
|
+
Lint/UnusedMethodArgument:
|
37
|
+
Enabled: true
|
38
|
+
|
39
|
+
Lint/UselessAssignment:
|
40
|
+
Enabled: true
|
41
|
+
|
42
|
+
Lint/Void:
|
43
|
+
Enabled: true
|
44
|
+
|
45
|
+
Metrics/AbcSize:
|
46
|
+
Max: 391
|
47
|
+
|
48
|
+
Metrics/ClassLength:
|
49
|
+
Max: 240
|
50
|
+
|
51
|
+
Metrics/CyclomaticComplexity:
|
52
|
+
Max: 12
|
53
|
+
|
54
|
+
Metrics/LineLength:
|
55
|
+
Max: 298
|
56
|
+
|
57
|
+
Metrics/MethodLength:
|
58
|
+
Max: 224
|
59
|
+
|
60
|
+
Metrics/ModuleLength:
|
61
|
+
Max: 160
|
62
|
+
Exclude:
|
63
|
+
- spec/**/*
|
64
|
+
|
65
|
+
Metrics/PerceivedComplexity:
|
66
|
+
Max: 13
|
67
|
+
|
68
|
+
Performance/Detect:
|
69
|
+
Enabled: true
|
70
|
+
|
71
|
+
Style/AccessModifierIndentation:
|
72
|
+
Enabled: true
|
73
|
+
|
74
|
+
Style/AccessorMethodName:
|
75
|
+
Enabled: true
|
76
|
+
|
77
|
+
Style/Alias:
|
78
|
+
Enabled: true
|
79
|
+
|
80
|
+
Style/AlignHash:
|
81
|
+
Enabled: true
|
82
|
+
|
83
|
+
Style/AlignParameters:
|
84
|
+
Enabled: true
|
85
|
+
|
86
|
+
Style/AndOr:
|
87
|
+
Enabled: true
|
88
|
+
|
89
|
+
Style/BarePercentLiterals:
|
90
|
+
Enabled: true
|
91
|
+
|
92
|
+
Style/BlockDelimiters:
|
93
|
+
Enabled: true
|
94
|
+
|
95
|
+
Style/BlockEndNewline:
|
96
|
+
Enabled: true
|
97
|
+
|
98
|
+
Style/BracesAroundHashParameters:
|
99
|
+
Enabled: true
|
100
|
+
|
101
|
+
Style/CaseEquality:
|
102
|
+
Enabled: true
|
103
|
+
|
104
|
+
Style/ClassAndModuleChildren:
|
105
|
+
Enabled: true
|
106
|
+
Exclude:
|
107
|
+
- db/migrate/*
|
108
|
+
|
109
|
+
Style/ClassCheck:
|
110
|
+
Enabled: true
|
111
|
+
|
112
|
+
Style/ClassVars:
|
113
|
+
Enabled: true
|
114
|
+
|
115
|
+
Style/ColonMethodCall:
|
116
|
+
Enabled: true
|
117
|
+
|
118
|
+
Style/CommentAnnotation:
|
119
|
+
Enabled: true
|
120
|
+
|
121
|
+
Style/Documentation:
|
122
|
+
Enabled: false
|
123
|
+
|
124
|
+
Style/DotPosition:
|
125
|
+
Enabled: true
|
126
|
+
|
127
|
+
Style/DoubleNegation:
|
128
|
+
Enabled: true
|
129
|
+
|
130
|
+
Style/EmptyLines:
|
131
|
+
Enabled: true
|
132
|
+
|
133
|
+
Style/EmptyLinesAroundAccessModifier:
|
134
|
+
Enabled: true
|
135
|
+
|
136
|
+
Style/EmptyLinesAroundBlockBody:
|
137
|
+
Enabled: true
|
138
|
+
|
139
|
+
Style/EmptyLinesAroundClassBody:
|
140
|
+
Enabled: true
|
141
|
+
|
142
|
+
Style/EmptyLinesAroundMethodBody:
|
143
|
+
Enabled: true
|
144
|
+
|
145
|
+
Style/EmptyLinesAroundModuleBody:
|
146
|
+
Enabled: true
|
147
|
+
|
148
|
+
Style/FormatString:
|
149
|
+
Enabled: true
|
150
|
+
|
151
|
+
Style/GuardClause:
|
152
|
+
Enabled: true
|
153
|
+
|
154
|
+
Style/HashSyntax:
|
155
|
+
Enabled: true
|
156
|
+
|
157
|
+
Style/IfUnlessModifier:
|
158
|
+
Enabled: true
|
159
|
+
|
160
|
+
Style/IndentHash:
|
161
|
+
Enabled: true
|
162
|
+
|
163
|
+
Style/IndentationConsistency:
|
164
|
+
Enabled: true
|
165
|
+
|
166
|
+
Style/IndentationWidth:
|
167
|
+
Enabled: true
|
168
|
+
|
169
|
+
Style/Lambda:
|
170
|
+
Enabled: true
|
171
|
+
|
172
|
+
Style/MethodCallParentheses:
|
173
|
+
Enabled: true
|
174
|
+
|
175
|
+
Style/MethodDefParentheses:
|
176
|
+
Enabled: true
|
177
|
+
|
178
|
+
Style/MultilineBlockLayout:
|
179
|
+
Enabled: true
|
180
|
+
|
181
|
+
Style/MultilineOperationIndentation:
|
182
|
+
Enabled: true
|
183
|
+
|
184
|
+
Style/NegatedIf:
|
185
|
+
Enabled: true
|
186
|
+
|
187
|
+
Style/NilComparison:
|
188
|
+
Enabled: true
|
189
|
+
|
190
|
+
Style/Not:
|
191
|
+
Enabled: true
|
192
|
+
|
193
|
+
Style/PercentLiteralDelimiters:
|
194
|
+
Enabled: true
|
195
|
+
|
196
|
+
Style/PerlBackrefs:
|
197
|
+
Enabled: true
|
198
|
+
|
199
|
+
Style/PredicateName:
|
200
|
+
Enabled: true
|
201
|
+
|
202
|
+
Style/RaiseArgs:
|
203
|
+
Enabled: true
|
204
|
+
|
205
|
+
Style/RedundantBegin:
|
206
|
+
Enabled: true
|
207
|
+
|
208
|
+
Style/RedundantSelf:
|
209
|
+
Enabled: true
|
210
|
+
|
211
|
+
Style/RegexpLiteral:
|
212
|
+
Enabled: true
|
213
|
+
|
214
|
+
Style/RescueModifier:
|
215
|
+
Enabled: true
|
216
|
+
|
217
|
+
Style/SignalException:
|
218
|
+
Enabled: true
|
219
|
+
|
220
|
+
Style/SingleSpaceBeforeFirstArg:
|
221
|
+
Enabled: true
|
222
|
+
|
223
|
+
Style/SpaceAfterColon:
|
224
|
+
Enabled: true
|
225
|
+
|
226
|
+
Style/SpaceAfterComma:
|
227
|
+
Enabled: true
|
228
|
+
|
229
|
+
Style/SpaceAroundEqualsInParameterDefault:
|
230
|
+
Enabled: true
|
231
|
+
|
232
|
+
Style/SpaceAroundOperators:
|
233
|
+
Enabled: true
|
234
|
+
|
235
|
+
Style/SpaceBeforeBlockBraces:
|
236
|
+
Enabled: true
|
237
|
+
|
238
|
+
Style/SpaceBeforeModifierKeyword:
|
239
|
+
Enabled: true
|
240
|
+
|
241
|
+
Style/SpaceInsideBlockBraces:
|
242
|
+
Enabled: true
|
243
|
+
|
244
|
+
Style/SpaceInsideBrackets:
|
245
|
+
Enabled: true
|
246
|
+
|
247
|
+
Style/SpaceInsideHashLiteralBraces:
|
248
|
+
Enabled: true
|
249
|
+
|
250
|
+
Style/SpaceInsideParens:
|
251
|
+
Enabled: true
|
252
|
+
|
253
|
+
Style/SpecialGlobalVars:
|
254
|
+
Enabled: true
|
255
|
+
|
256
|
+
Style/StringLiterals:
|
257
|
+
Enabled: true
|
258
|
+
|
259
|
+
Style/StringLiteralsInInterpolation:
|
260
|
+
Enabled: true
|
261
|
+
|
262
|
+
Style/Tab:
|
263
|
+
Enabled: true
|
264
|
+
|
265
|
+
Style/TrailingBlankLines:
|
266
|
+
Enabled: true
|
267
|
+
|
268
|
+
Style/TrailingComma:
|
269
|
+
Enabled: true
|
270
|
+
|
271
|
+
Style/TrailingWhitespace:
|
272
|
+
Enabled: true
|
273
|
+
|
274
|
+
Style/TrivialAccessors:
|
275
|
+
Enabled: true
|
276
|
+
|
277
|
+
Style/VariableInterpolation:
|
278
|
+
Enabled: true
|
279
|
+
|
280
|
+
Style/WordArray:
|
281
|
+
MinSize: 11
|
data/.travis.yml
CHANGED
data/CHANGELOG.md
CHANGED
@@ -2,7 +2,11 @@
|
|
2
2
|
|
3
3
|
See README.md before updating this file.
|
4
4
|
|
5
|
-
## Unreleased [#](https://github.com/enova/landable/compare/v1.13.
|
5
|
+
## Unreleased [#](https://github.com/enova/landable/compare/v1.13.2...master)
|
6
|
+
|
7
|
+
## 1.13.2 [#](https://github.com/enova/landable/compare/v1.13.1...v1.13.2)
|
8
|
+
* Bugfix: Fix landable traffic errors
|
9
|
+
* Remove support for Ruby < 2.0.0
|
6
10
|
|
7
11
|
## 1.13.1 [#](https://github.com/enova/landable/compare/v1.12.3...v1.13.1)
|
8
12
|
* BugFix: Default referer.path to '' [#60]
|
data/Gemfile
CHANGED
@@ -1,17 +1,16 @@
|
|
1
|
-
source
|
1
|
+
source 'https://rubygems.org'
|
2
2
|
|
3
3
|
# load dependencies from landable.gemspec
|
4
4
|
gemspec
|
5
5
|
|
6
6
|
# allow us to load up a specific version of rails, since the gemspec is
|
7
7
|
# concerned only with compatibility (see bin/test)
|
8
|
-
if ENV.key? 'RAILS_VERSION'
|
9
|
-
gem 'rails', ENV['RAILS_VERSION']
|
10
|
-
end
|
8
|
+
gem 'rails', ENV['RAILS_VERSION'] if ENV.key? 'RAILS_VERSION'
|
11
9
|
|
12
10
|
# development/test dependencies, and anything else that doesn't belong or fit
|
13
11
|
# in the gemspec
|
14
12
|
group :test do
|
13
|
+
gem 'rubocop'
|
15
14
|
gem 'minitest'
|
16
15
|
gem 'shoulda-matchers'
|
17
16
|
gem 'cucumber-rails', require: false
|
data/README.md
CHANGED
@@ -49,6 +49,8 @@ Run `./script/redb` to refresh the dummy app's database.
|
|
49
49
|
|
50
50
|
Run the test suite with `rake landable`.
|
51
51
|
|
52
|
+
We use [Rubocop](https://github.com/bbatsov/rubocop), so your test must all pass Rubocops Tests in order for your PR to be accepted!
|
53
|
+
|
52
54
|
## Contributing
|
53
55
|
Contributions are welcome - submit a pull request.
|
54
56
|
|
data/Rakefile
CHANGED
@@ -1,10 +1,11 @@
|
|
1
1
|
begin
|
2
2
|
require 'bundler/setup'
|
3
|
+
require 'rubocop/rake_task'
|
3
4
|
rescue LoadError
|
4
5
|
puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
|
5
6
|
end
|
6
7
|
|
7
|
-
APP_RAKEFILE = File.expand_path(
|
8
|
+
APP_RAKEFILE = File.expand_path('../spec/dummy/Rakefile', __FILE__)
|
8
9
|
load 'rails/tasks/engine.rake'
|
9
10
|
|
10
11
|
Bundler::GemHelper.install_tasks
|
@@ -12,10 +13,12 @@ Bundler::GemHelper.install_tasks
|
|
12
13
|
Dir.glob(File.expand_path('../lib/tasks/landable/*.rake', __FILE__)).each { |f| load f }
|
13
14
|
|
14
15
|
desc 'Landable test suite'
|
15
|
-
task :
|
16
|
+
task landable: [
|
17
|
+
'rubocop',
|
16
18
|
'app:db:test:prepare',
|
17
19
|
'landable:seed',
|
18
20
|
'landable:spec',
|
19
21
|
'landable:cucumber',
|
20
22
|
'landable:pgtap'
|
21
|
-
]
|
23
|
+
]
|
24
|
+
RuboCop::RakeTask.new
|
@@ -4,35 +4,35 @@ module Landable
|
|
4
4
|
module VariablesConcern
|
5
5
|
# includes
|
6
6
|
extend ActiveSupport::Concern
|
7
|
-
|
7
|
+
|
8
8
|
included do
|
9
9
|
# attribute definitions
|
10
10
|
cattr_accessor :imported_variables do
|
11
11
|
{}
|
12
12
|
end
|
13
13
|
end
|
14
|
-
|
14
|
+
|
15
15
|
# standard methods
|
16
|
-
|
16
|
+
|
17
17
|
# custom methods
|
18
18
|
module ClassMethods
|
19
19
|
def register_landable_variable(variable_name, method_name = nil)
|
20
20
|
method_name ||= variable_name
|
21
|
-
|
21
|
+
|
22
22
|
imported_variables[variable_name] = method_name
|
23
23
|
end
|
24
24
|
end
|
25
|
-
|
25
|
+
|
26
26
|
def fetch_landable_variables
|
27
27
|
variables = {}
|
28
|
-
|
29
|
-
imported_variables.each do |variable_name, method_name|
|
28
|
+
|
29
|
+
imported_variables.each do |variable_name, method_name|
|
30
30
|
variables[variable_name] = send(method_name)
|
31
31
|
end
|
32
32
|
|
33
33
|
variables.with_indifferent_access
|
34
34
|
end
|
35
|
-
|
35
|
+
|
36
36
|
# end
|
37
37
|
end
|
38
|
-
end
|
38
|
+
end
|
@@ -1,4 +1,4 @@
|
|
1
|
-
require_dependency
|
1
|
+
require_dependency 'landable/api_controller'
|
2
2
|
|
3
3
|
module Landable
|
4
4
|
module Api
|
@@ -33,16 +33,15 @@ module Landable
|
|
33
33
|
head :unauthorized
|
34
34
|
end
|
35
35
|
|
36
|
-
|
37
36
|
private
|
38
37
|
|
39
|
-
|
40
|
-
|
41
|
-
|
38
|
+
def find_own_access_token(id = params[:id])
|
39
|
+
current_author.access_tokens.fresh.find(id)
|
40
|
+
end
|
42
41
|
|
43
|
-
|
44
|
-
|
45
|
-
|
42
|
+
def asset_token_params
|
43
|
+
params.require(:access_token).permit(:username, :password)
|
44
|
+
end
|
46
45
|
end
|
47
46
|
end
|
48
47
|
end
|
@@ -6,30 +6,31 @@ module Landable
|
|
6
6
|
class AssetsController < ApiController
|
7
7
|
# filters
|
8
8
|
before_filter :load_asset, except: [:create, :index]
|
9
|
-
|
9
|
+
|
10
10
|
# RESTful methods
|
11
11
|
def create
|
12
12
|
asset = Asset.new(asset_params)
|
13
|
+
original = asset.duplicate_of
|
13
14
|
|
14
|
-
if original
|
15
|
+
if original
|
15
16
|
head :moved_permanently, location: asset_url(original)
|
16
17
|
return
|
17
18
|
end
|
18
|
-
|
19
|
+
|
19
20
|
Asset.transaction do
|
20
21
|
asset.author = current_author
|
21
22
|
asset.save!
|
22
23
|
end
|
23
|
-
|
24
|
+
|
24
25
|
respond_with asset, status: :created, location: asset_url(asset)
|
25
26
|
end
|
26
|
-
|
27
|
+
|
27
28
|
def destroy
|
28
29
|
@asset.try(:deactivate)
|
29
|
-
|
30
|
+
|
30
31
|
respond_with @asset
|
31
32
|
end
|
32
|
-
|
33
|
+
|
33
34
|
def index
|
34
35
|
search = Landable::AssetSearchEngine.new(search_params.merge(ids: params[:ids]))
|
35
36
|
respond_with search.results, meta: search.meta
|
@@ -37,37 +38,39 @@ module Landable
|
|
37
38
|
|
38
39
|
def reactivate
|
39
40
|
@asset.try(:reactivate)
|
40
|
-
|
41
|
+
|
41
42
|
respond_with @asset
|
42
43
|
end
|
43
|
-
|
44
|
+
|
44
45
|
def show
|
45
46
|
respond_with @asset
|
46
47
|
end
|
47
|
-
|
48
|
+
|
48
49
|
def update
|
49
50
|
@asset.update_attributes!(asset_params)
|
50
51
|
|
51
52
|
respond_with @asset
|
52
53
|
end
|
53
|
-
|
54
|
+
|
54
55
|
# custom methods
|
56
|
+
|
55
57
|
private
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
58
|
+
|
59
|
+
def asset_params
|
60
|
+
params.require(:asset).permit(:id, :name, :description, :data, :file)
|
61
|
+
end
|
62
|
+
|
63
|
+
def load_asset
|
64
|
+
@asset = Asset.find(params[:id])
|
65
|
+
end
|
66
|
+
|
67
|
+
def search_params
|
68
|
+
@search_params ||=
|
69
|
+
begin
|
70
|
+
hash = params.permit(search: [:name])
|
71
|
+
hash[:search] || {}
|
72
|
+
end
|
73
|
+
end
|
71
74
|
end
|
72
75
|
end
|
73
76
|
end
|