shaf 0.3.1 → 0.4.0

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.
Files changed (45) hide show
  1. checksums.yaml +4 -4
  2. checksums.yaml.gz.sig +0 -0
  3. data.tar.gz.sig +0 -0
  4. data/bin/shaf +3 -0
  5. data/lib/shaf.rb +1 -0
  6. data/lib/shaf/api_doc/document.rb +0 -1
  7. data/lib/shaf/app.rb +1 -1
  8. data/lib/shaf/command.rb +19 -2
  9. data/lib/shaf/command/generate.rb +11 -1
  10. data/lib/shaf/command/new.rb +1 -6
  11. data/lib/shaf/command/server.rb +7 -0
  12. data/lib/shaf/command/upgrade.rb +38 -0
  13. data/lib/shaf/extensions/authorize.rb +8 -6
  14. data/lib/shaf/extensions/resource_uris.rb +129 -71
  15. data/lib/shaf/generator.rb +4 -0
  16. data/lib/shaf/generator/controller.rb +2 -2
  17. data/lib/shaf/generator/migration.rb +33 -14
  18. data/lib/shaf/generator/migration/add_column.rb +1 -3
  19. data/lib/shaf/generator/migration/add_index.rb +42 -0
  20. data/lib/shaf/generator/model.rb +4 -4
  21. data/lib/shaf/generator/policy.rb +1 -1
  22. data/lib/shaf/generator/scaffold.rb +3 -3
  23. data/lib/shaf/generator/serializer.rb +5 -5
  24. data/lib/shaf/rake.rb +5 -0
  25. data/lib/shaf/rake/db.rb +79 -0
  26. data/lib/shaf/rake/test.rb +32 -0
  27. data/lib/shaf/registrable_factory.rb +8 -3
  28. data/lib/shaf/settings.rb +20 -4
  29. data/lib/shaf/tasks.rb +6 -3
  30. data/lib/shaf/{api_doc/task.rb → tasks/api_doc_task.rb} +6 -5
  31. data/lib/shaf/tasks/db_task.rb +42 -0
  32. data/lib/shaf/tasks/test_task.rb +16 -0
  33. data/lib/shaf/upgrade.rb +3 -0
  34. data/lib/shaf/upgrade/manifest.rb +31 -0
  35. data/lib/shaf/upgrade/package.rb +158 -0
  36. data/lib/shaf/upgrade/version.rb +52 -0
  37. data/lib/shaf/utils.rb +30 -0
  38. data/lib/shaf/version.rb +1 -1
  39. data/templates/Rakefile +2 -3
  40. data/templates/config/database.rb +3 -3
  41. metadata +33 -202
  42. metadata.gz.sig +0 -0
  43. data/lib/shaf/api_doc.rb +0 -3
  44. data/lib/shaf/tasks/db.rb +0 -81
  45. data/lib/shaf/tasks/test.rb +0 -48
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: shaf
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.1
4
+ version: 0.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sammy Henningsson
@@ -10,28 +10,27 @@ bindir: bin
10
10
  cert_chain:
11
11
  - |
12
12
  -----BEGIN CERTIFICATE-----
13
- MIIDljCCAn6gAwIBAgIBATANBgkqhkiG9w0BAQUFADBIMRowGAYDVQQDDBFzYW1t
14
- eS5oZW5uaW5nc3NvbjEVMBMGCgmSJomT8ixkARkWBWdtYWlsMRMwEQYKCZImiZPy
15
- LGQBGRYDY29tMB4XDTE3MDcwODE0MDUxOVoXDTE4MDcwODE0MDUxOVowSDEaMBgG
16
- A1UEAwwRc2FtbXkuaGVubmluZ3Nzb24xFTATBgoJkiaJk/IsZAEZFgVnbWFpbDET
17
- MBEGCgmSJomT8ixkARkWA2NvbTCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoC
18
- ggEBAK+SDC1mfyhucJ6Va21rIHUGscEtQrdvyBqxFG1s2TgPMAv4RbqwdJVPa7kj
19
- tbCzslADlUE1oru2C+rcJsMtVGX02ukMIPHT1OjTyy0/EMqLqSy3WeRI8APyDSxC
20
- Vbe+h5BMf3zZnYfddR6AeG7ln09T1P/tX+9lTMc+I+DW1fUlQgY48CNUayvtJR61
21
- svXvXMrhLhi29SQig1qmH6Zoe22/JgH+m2JksPndY5Ep3gqfDc6Imwu2vGvmGErJ
22
- D63FB0XQ/wb4WVH4l7sHQSTfKDp8SImCt1xqNgIyjw578ZG2geGLoncuxgD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XUegHhu5Z9PU9T/7V/vZUzHPiPg1tX1JUIGOPAjVGsr7SUetbL171zK4S4Y
20
+ tvUkIoNaph+maHttvyYB/ptiZLD53WORKd4Knw3OiJsLtrxr5hhKyQ+txQdF0P8G
21
+ +FlR+Je7B0Ek3yg6fEiJgrdcajYCMo8Oe/GRtoHhi6J3LsYA620P1BSCddZQ2XeL
22
+ y3rzIZyMU0iaT69nAgMBAAGjgYowgYcwCQYDVR0TBAIwADALBgNVHQ8EBAMCBLAw
23
+ HQYDVR0OBBYEFLpI49QndnmuiDhwy2XtMps7No1pMCYGA1UdEQQfMB2BG3NhbW15
24
+ Lmhlbm5pbmdzc29uQGdtYWlsLmNvbTAmBgNVHRIEHzAdgRtzYW1teS5oZW5uaW5n
25
+ c3NvbkBnbWFpbC5jb20wDQYJKoZIhvcNAQELBQADggEBAFJZqH6sgeiTLvMLpxaK
26
+ K1GaYSCyZbMutf5C3tIAgkmU5UD6B8R0bw6gTM1deM5NJ60LjzqY7rlK3YKDIbTn
27
+ iXMCe9vd4yE/jb5Zi8Wk//9n8CMG68dQpBvmcQ58/M4gTtgsx+lIgXuI5dPQMmRi
28
+ bhWQqqWqxT9X6njjfXFk4xn3z6mfFQNPAYqRVeTHUpXBQZPt+bYXRwHPFZGWkx4l
29
+ BnuuhYKt3CR7YIgvnsQWlTAcU1Ipdayj6UfYqUtlc6cF3CL96NOx7mgZXV8URFiX
30
+ ZMhjYR7sRczGJx+GxGU2EaR0bjRsPVlC4ywtFxoOfRG3WaJcpWGEoAoMJX6Z0bRv
31
+ M40=
33
32
  -----END CERTIFICATE-----
34
- date: 2018-04-08 00:00:00.000000000 Z
33
+ date: 2018-07-16 00:00:00.000000000 Z
35
34
  dependencies:
36
35
  - !ruby/object:Gem::Dependency
37
36
  name: rake
@@ -53,182 +52,6 @@ dependencies:
53
52
  - - ">="
54
53
  - !ruby/object:Gem::Version
55
54
  version: '10.0'
56
- - !ruby/object:Gem::Dependency
57
- name: minitest
58
- requirement: !ruby/object:Gem::Requirement
59
- requirements:
60
- - - "~>"
61
- - !ruby/object:Gem::Version
62
- version: '5.10'
63
- - - ">="
64
- - !ruby/object:Gem::Version
65
- version: '5.0'
66
- type: :development
67
- prerelease: false
68
- version_requirements: !ruby/object:Gem::Requirement
69
- requirements:
70
- - - "~>"
71
- - !ruby/object:Gem::Version
72
- version: '5.10'
73
- - - ">="
74
- - !ruby/object:Gem::Version
75
- version: '5.0'
76
- - !ruby/object:Gem::Dependency
77
- name: hal_presenter
78
- requirement: !ruby/object:Gem::Requirement
79
- requirements:
80
- - - "~>"
81
- - !ruby/object:Gem::Version
82
- version: 0.4.3
83
- - - ">="
84
- - !ruby/object:Gem::Version
85
- version: 0.4.0
86
- type: :development
87
- prerelease: false
88
- version_requirements: !ruby/object:Gem::Requirement
89
- requirements:
90
- - - "~>"
91
- - !ruby/object:Gem::Version
92
- version: 0.4.3
93
- - - ">="
94
- - !ruby/object:Gem::Version
95
- version: 0.4.0
96
- - !ruby/object:Gem::Dependency
97
- name: sinatra
98
- requirement: !ruby/object:Gem::Requirement
99
- requirements:
100
- - - "~>"
101
- - !ruby/object:Gem::Version
102
- version: 2.0.1
103
- - - ">="
104
- - !ruby/object:Gem::Version
105
- version: 2.0.0
106
- type: :development
107
- prerelease: false
108
- version_requirements: !ruby/object:Gem::Requirement
109
- requirements:
110
- - - "~>"
111
- - !ruby/object:Gem::Version
112
- version: 2.0.1
113
- - - ">="
114
- - !ruby/object:Gem::Version
115
- version: 2.0.0
116
- - !ruby/object:Gem::Dependency
117
- name: sequel
118
- requirement: !ruby/object:Gem::Requirement
119
- requirements:
120
- - - "~>"
121
- - !ruby/object:Gem::Version
122
- version: '5.6'
123
- type: :development
124
- prerelease: false
125
- version_requirements: !ruby/object:Gem::Requirement
126
- requirements:
127
- - - "~>"
128
- - !ruby/object:Gem::Version
129
- version: '5.6'
130
- - !ruby/object:Gem::Dependency
131
- name: sinatra-sequel
132
- requirement: !ruby/object:Gem::Requirement
133
- requirements:
134
- - - "~>"
135
- - !ruby/object:Gem::Version
136
- version: 0.9.0
137
- type: :development
138
- prerelease: false
139
- version_requirements: !ruby/object:Gem::Requirement
140
- requirements:
141
- - - "~>"
142
- - !ruby/object:Gem::Version
143
- version: 0.9.0
144
- - !ruby/object:Gem::Dependency
145
- name: thin
146
- requirement: !ruby/object:Gem::Requirement
147
- requirements:
148
- - - "~>"
149
- - !ruby/object:Gem::Version
150
- version: '1.7'
151
- - - ">="
152
- - !ruby/object:Gem::Version
153
- version: 1.7.2
154
- type: :development
155
- prerelease: false
156
- version_requirements: !ruby/object:Gem::Requirement
157
- requirements:
158
- - - "~>"
159
- - !ruby/object:Gem::Version
160
- version: '1.7'
161
- - - ">="
162
- - !ruby/object:Gem::Version
163
- version: 1.7.2
164
- - !ruby/object:Gem::Dependency
165
- name: bcrypt
166
- requirement: !ruby/object:Gem::Requirement
167
- requirements:
168
- - - "~>"
169
- - !ruby/object:Gem::Version
170
- version: '3.1'
171
- - - ">="
172
- - !ruby/object:Gem::Version
173
- version: 3.1.11
174
- type: :development
175
- prerelease: false
176
- version_requirements: !ruby/object:Gem::Requirement
177
- requirements:
178
- - - "~>"
179
- - !ruby/object:Gem::Version
180
- version: '3.1'
181
- - - ">="
182
- - !ruby/object:Gem::Version
183
- version: 3.1.11
184
- - !ruby/object:Gem::Dependency
185
- name: redcarpet
186
- requirement: !ruby/object:Gem::Requirement
187
- requirements:
188
- - - "~>"
189
- - !ruby/object:Gem::Version
190
- version: '3.4'
191
- type: :development
192
- prerelease: false
193
- version_requirements: !ruby/object:Gem::Requirement
194
- requirements:
195
- - - "~>"
196
- - !ruby/object:Gem::Version
197
- version: '3.4'
198
- - !ruby/object:Gem::Dependency
199
- name: minitest-hooks
200
- requirement: !ruby/object:Gem::Requirement
201
- requirements:
202
- - - "~>"
203
- - !ruby/object:Gem::Version
204
- version: '1.4'
205
- - - ">="
206
- - !ruby/object:Gem::Version
207
- version: 1.4.2
208
- type: :development
209
- prerelease: false
210
- version_requirements: !ruby/object:Gem::Requirement
211
- requirements:
212
- - - "~>"
213
- - !ruby/object:Gem::Version
214
- version: '1.4'
215
- - - ">="
216
- - !ruby/object:Gem::Version
217
- version: 1.4.2
218
- - !ruby/object:Gem::Dependency
219
- name: rack-test
220
- requirement: !ruby/object:Gem::Requirement
221
- requirements:
222
- - - "~>"
223
- - !ruby/object:Gem::Version
224
- version: 0.8.3
225
- type: :development
226
- prerelease: false
227
- version_requirements: !ruby/object:Gem::Requirement
228
- requirements:
229
- - - "~>"
230
- - !ruby/object:Gem::Version
231
- version: 0.8.3
232
55
  description: A framework for building hypermedia driven APIs with sinatra and sequel.
233
56
  email: sammy.henningsson@gmail.com
234
57
  executables:
@@ -238,10 +61,8 @@ extra_rdoc_files: []
238
61
  files:
239
62
  - bin/shaf
240
63
  - lib/shaf.rb
241
- - lib/shaf/api_doc.rb
242
64
  - lib/shaf/api_doc/comment.rb
243
65
  - lib/shaf/api_doc/document.rb
244
- - lib/shaf/api_doc/task.rb
245
66
  - lib/shaf/app.rb
246
67
  - lib/shaf/command.rb
247
68
  - lib/shaf/command/console.rb
@@ -249,6 +70,7 @@ files:
249
70
  - lib/shaf/command/new.rb
250
71
  - lib/shaf/command/server.rb
251
72
  - lib/shaf/command/templates/Gemfile.erb
73
+ - lib/shaf/command/upgrade.rb
252
74
  - lib/shaf/doc_model.rb
253
75
  - lib/shaf/errors.rb
254
76
  - lib/shaf/extensions.rb
@@ -261,6 +83,7 @@ files:
261
83
  - lib/shaf/generator/controller.rb
262
84
  - lib/shaf/generator/migration.rb
263
85
  - lib/shaf/generator/migration/add_column.rb
86
+ - lib/shaf/generator/migration/add_index.rb
264
87
  - lib/shaf/generator/migration/create_table.rb
265
88
  - lib/shaf/generator/migration/drop_column.rb
266
89
  - lib/shaf/generator/migration/empty.rb
@@ -282,6 +105,9 @@ files:
282
105
  - lib/shaf/helpers/payload.rb
283
106
  - lib/shaf/middleware.rb
284
107
  - lib/shaf/middleware/request_id.rb
108
+ - lib/shaf/rake.rb
109
+ - lib/shaf/rake/db.rb
110
+ - lib/shaf/rake/test.rb
285
111
  - lib/shaf/registrable_factory.rb
286
112
  - lib/shaf/settings.rb
287
113
  - lib/shaf/spec.rb
@@ -295,8 +121,13 @@ files:
295
121
  - lib/shaf/spec/payload_utils.rb
296
122
  - lib/shaf/spec/serializer_spec.rb
297
123
  - lib/shaf/tasks.rb
298
- - lib/shaf/tasks/db.rb
299
- - lib/shaf/tasks/test.rb
124
+ - lib/shaf/tasks/api_doc_task.rb
125
+ - lib/shaf/tasks/db_task.rb
126
+ - lib/shaf/tasks/test_task.rb
127
+ - lib/shaf/upgrade.rb
128
+ - lib/shaf/upgrade/manifest.rb
129
+ - lib/shaf/upgrade/package.rb
130
+ - lib/shaf/upgrade/version.rb
300
131
  - lib/shaf/utils.rb
301
132
  - lib/shaf/version.rb
302
133
  - templates/Rakefile
metadata.gz.sig CHANGED
Binary file
data/lib/shaf/api_doc.rb DELETED
@@ -1,3 +0,0 @@
1
- require 'shaf/api_doc/document'
2
- require 'shaf/api_doc/comment'
3
- require 'shaf/api_doc/task'
data/lib/shaf/tasks/db.rb DELETED
@@ -1,81 +0,0 @@
1
- namespace :db do
2
- desc "Prints current schema version"
3
- task :version do
4
- require 'config/database'
5
- if DB.tables.include?(:schema_migrations)
6
- migration = DB[:schema_migrations].order(:filename).last
7
- filename = migration && migration[:filename]
8
- if match = /(\d*)_(.*).rb/.match(filename)
9
- puts "Schema version: #{match[1]} (#{match[2]})"
10
- else
11
- puts "No migration found"
12
- end
13
- else
14
- puts "No schema_info table"
15
- end
16
- end
17
-
18
- desc "Prints all schema versions"
19
- task :versions do
20
- require 'config/database'
21
- if DB.tables.include?(:schema_migrations)
22
- DB[:schema_migrations].each do |migration|
23
- filename = migration && migration[:filename]
24
- if match = /(\d*)_(.*).rb/.match(filename)
25
- puts "#{match[1]}: #{match[2]}"
26
- end
27
- end
28
- else
29
- puts "No schema_info table"
30
- end
31
- end
32
-
33
- desc "Run migrations"
34
- task :migrate, [:version] do |t, args|
35
- require 'config/database'
36
- Sequel.extension :migration
37
- if args[:version]
38
- puts "Migrating to version #{args[:version]}"
39
- Sequel::Migrator.run(DB, MIGRATIONS_DIR, target: args[:version].to_i)
40
- else
41
- puts "Migrating to latest"
42
- Sequel::Migrator.run(DB, MIGRATIONS_DIR)
43
- end
44
- end
45
-
46
- desc "Perform rollback to specified number of steps back or to the previous version"
47
- task :rollback, :target do |t, args|
48
- args.with_defaults(target: 1)
49
- require 'config/database'
50
- Sequel.extension :migration
51
- all_migrations = DB[:schema_migrations].all
52
- target = -(args[:target].to_i + 1)
53
- target = 0 if -target > all_migrations.size
54
- filename = all_migrations.dig(target, :filename)
55
- version = filename[/(\d*)_.*.rb/, 1].to_i
56
-
57
- warn_if_rolling_back_more_than = 5
58
- if target == 0 || -target > warn_if_rolling_back_more_than
59
- puts "This would migrate the Database to version: #{version}. Continue [N/y]?"
60
- next unless /\Ay/i =~ STDIN.gets.chomp&.downcase
61
- end
62
- Sequel::Migrator.run(DB, MIGRATIONS_DIR, target: version)
63
- end
64
-
65
- desc "Reset the database by deleting all rows in all columns"
66
- task :reset do
67
- require 'config/database'
68
- Sequel.extension :migration
69
- version = 0
70
- Sequel::Migrator.run(DB, MIGRATIONS_DIR, target: version)
71
- Sequel::Migrator.run(DB, MIGRATIONS_DIR)
72
- end
73
-
74
- Rake::Task["db:migrate"].enhance do
75
- Rake::Task["db:version"].invoke
76
- end
77
-
78
- Rake::Task["db:rollback"].enhance do
79
- Rake::Task["db:version"].invoke
80
- end
81
- end
@@ -1,48 +0,0 @@
1
- require 'rake/testtask'
2
-
3
- namespace :test do |ns|
4
- Rake::TestTask.new(:integration) do |t|
5
- t.libs = %w(. api spec)
6
- t.pattern = "spec/integration/**/*_spec.rb"
7
- t.verbose = true
8
- t.warning = false
9
- end
10
-
11
- Rake::TestTask.new(:models) do |t|
12
- t.libs = %w(. api spec)
13
- t.pattern = "spec/models/**/*_spec.rb"
14
- t.verbose = true
15
- t.warning = false
16
- end
17
-
18
- Rake::TestTask.new(:serializers) do |t|
19
- t.libs = %w(. api spec)
20
- t.pattern = "spec/serializers/**/*_spec.rb"
21
- t.verbose = true
22
- t.warning = false
23
- end
24
-
25
- Rake::TestTask.new(:lib) do |t|
26
- t.libs = %w(. api spec)
27
- t.pattern = "spec/lib/**/*_spec.rb"
28
- t.verbose = true
29
- t.warning = false
30
- end
31
-
32
- Rake::TestTask.new(:all) do |t|
33
- t.libs = %w(. api spec)
34
- t.pattern = [
35
- "spec/lib/**/*_spec.rb",
36
- "spec/models/**/*_spec.rb",
37
- "spec/serializers/**/*_spec.rb",
38
- "spec/integration/**/*_spec.rb"
39
- ]
40
- t.verbose = true
41
- t.warning = false
42
- end
43
-
44
- end
45
-
46
- desc "Run all tests"
47
- task test: 'test:all'
48
-