shaf 0.4.0 → 0.4.1
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 +5 -5
- checksums.yaml.gz.sig +0 -0
- data.tar.gz.sig +0 -0
- data/lib/shaf/command.rb +1 -0
- data/lib/shaf/command/new.rb +0 -1
- data/lib/shaf/command/version.rb +25 -0
- data/lib/shaf/errors.rb +3 -1
- data/lib/shaf/generator/scaffold.rb +1 -0
- data/lib/shaf/helpers/payload.rb +19 -4
- data/lib/shaf/upgrade/package.rb +4 -4
- data/lib/shaf/utils.rb +15 -10
- data/lib/shaf/version.rb +1 -1
- data/templates/api/controllers/root_controller.rb +3 -1
- data/templates/config/settings.yml +1 -0
- data/upgrades/0.4.0.tar.gz +0 -0
- metadata +5 -3
- metadata.gz.sig +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 33b4f2f8ba33dcc7d3f8abe950745897fca2439e
|
4
|
+
data.tar.gz: d677b6e4db2843c764027e91b00ee384a24baa60
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 24eaf2fb8f70443206460d48853ea44d304c1616a65be60defb33147ee09e53923ee13b3563efc0ad00ce41976d7acd6048047d3b1f6d0323341fc9946900546
|
7
|
+
data.tar.gz: 7714930986d85adea752deb9bd7c200a3a7f06cb10826f4e39c9b066dd96b4fd58bae7e327c8fe8bc5e276ab781a9112e8d123e2787a4676fec09a06d10954fd
|
checksums.yaml.gz.sig
CHANGED
Binary file
|
data.tar.gz.sig
CHANGED
Binary file
|
data/lib/shaf/command.rb
CHANGED
data/lib/shaf/command/new.rb
CHANGED
@@ -0,0 +1,25 @@
|
|
1
|
+
module Shaf
|
2
|
+
module Command
|
3
|
+
class Version < Base
|
4
|
+
|
5
|
+
identifier %r(\Av(ersion)?\Z)
|
6
|
+
usage 'version'
|
7
|
+
|
8
|
+
def call
|
9
|
+
print_shaf_version
|
10
|
+
print_project_version
|
11
|
+
end
|
12
|
+
|
13
|
+
def print_shaf_version
|
14
|
+
puts "Installed Shaf version: #{Shaf::VERSION}"
|
15
|
+
end
|
16
|
+
|
17
|
+
def print_project_version
|
18
|
+
path = project_root
|
19
|
+
return if path.nil?
|
20
|
+
project = path.split('/').last
|
21
|
+
puts "Project '#{project}' created with Shaf version: #{read_shaf_version}"
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
data/lib/shaf/errors.rb
CHANGED
@@ -10,6 +10,7 @@ module Shaf
|
|
10
10
|
raise "Please provide a resource name when using the scaffold generator!"
|
11
11
|
end
|
12
12
|
|
13
|
+
options[:specs] = true if options[:specs].nil?
|
13
14
|
Generator::Factory.create('model', *args).call(options)
|
14
15
|
Generator::Factory.create('controller', *controller_args).call(options)
|
15
16
|
end
|
data/lib/shaf/helpers/payload.rb
CHANGED
@@ -72,16 +72,25 @@ module Shaf
|
|
72
72
|
return name == '_method'
|
73
73
|
end
|
74
74
|
|
75
|
-
def respond_with_collection(resource, status: 200, serializer: nil)
|
76
|
-
respond_with(
|
75
|
+
def respond_with_collection(resource, status: 200, serializer: nil, **kwargs)
|
76
|
+
respond_with(
|
77
|
+
resource,
|
78
|
+
status: status,
|
79
|
+
serializer: serializer,
|
80
|
+
collection: true,
|
81
|
+
**kwargs
|
82
|
+
)
|
77
83
|
end
|
78
84
|
|
79
|
-
def respond_with(resource, status: 200, serializer: nil, collection: false)
|
85
|
+
def respond_with(resource, status: 200, serializer: nil, collection: false, **kwargs)
|
80
86
|
status(status)
|
81
87
|
|
82
88
|
preferred_response = preferred_response_type(resource)
|
83
89
|
serialized = serialize(resource, serializer, collection)
|
84
90
|
|
91
|
+
http_cache = kwargs.fetch(:http_cache, Settings.http_cache)
|
92
|
+
add_cache_headers(serialized) if http_cache
|
93
|
+
|
85
94
|
if preferred_response == mime_type(:html)
|
86
95
|
respond_with_html(resource, serialized)
|
87
96
|
else
|
@@ -108,12 +117,18 @@ module Shaf
|
|
108
117
|
log.debug "Responding with html. Output payload (#{resource.class}): #{serialized}"
|
109
118
|
content_type :html
|
110
119
|
case resource
|
111
|
-
when
|
120
|
+
when Formable::Form
|
112
121
|
body erb(:form, locals: {form: resource, serialized: serialized})
|
113
122
|
else
|
114
123
|
body erb(:payload, locals: {serialized: serialized})
|
115
124
|
end
|
116
125
|
end
|
117
126
|
|
127
|
+
def add_cache_headers(payload)
|
128
|
+
return if payload.nil? || payload.empty?
|
129
|
+
|
130
|
+
sha1 = Digest::SHA1.hexdigest payload
|
131
|
+
etag sha1, :weak # Weak or Strong??
|
132
|
+
end
|
118
133
|
end
|
119
134
|
end
|
data/lib/shaf/upgrade/package.rb
CHANGED
@@ -36,13 +36,13 @@ module Shaf
|
|
36
36
|
private
|
37
37
|
|
38
38
|
def target_versions
|
39
|
-
return @target_versions if @target_versions
|
39
|
+
return @target_versions if defined? @target_versions
|
40
40
|
|
41
41
|
files = Dir[File.join(UPGRADE_FILES_PATH, '*.tar.gz')]
|
42
|
-
@target_versions = files.
|
42
|
+
@target_versions = files.map do |file|
|
43
43
|
str = File.basename(file, '.tar.gz')
|
44
|
-
|
45
|
-
end
|
44
|
+
Version.new(str)
|
45
|
+
end.sort
|
46
46
|
end
|
47
47
|
|
48
48
|
def strip_suffix(file)
|
data/lib/shaf/utils.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
require 'shaf/version'
|
2
|
+
|
1
3
|
module Shaf
|
2
4
|
module Utils
|
3
5
|
class ProjectRootNotFound < StandardError; end
|
@@ -24,18 +26,19 @@ module Shaf
|
|
24
26
|
noun[0..-2]
|
25
27
|
end
|
26
28
|
|
29
|
+
def pluralize(noun)
|
30
|
+
Utils::pluralize(noun)
|
31
|
+
end
|
32
|
+
|
27
33
|
def gem_root
|
28
34
|
self.class.gem_root
|
29
35
|
end
|
30
36
|
|
31
37
|
def project_root
|
38
|
+
return @project_root if defined? @project_root
|
32
39
|
dir = Dir.pwd
|
33
|
-
|
34
|
-
if is_project_root?(dir)
|
35
|
-
return dir
|
36
|
-
elsif dir == '/'
|
37
|
-
break
|
38
|
-
end
|
40
|
+
while dir != '/' do
|
41
|
+
return @project_root = dir if is_project_root?(dir)
|
39
42
|
dir = File.expand_path("..", dir)
|
40
43
|
end
|
41
44
|
end
|
@@ -68,16 +71,18 @@ module Shaf
|
|
68
71
|
end
|
69
72
|
end
|
70
73
|
|
71
|
-
def pluralize(noun)
|
72
|
-
Utils::pluralize(noun)
|
73
|
-
end
|
74
|
-
|
75
74
|
def read_shaf_file
|
76
75
|
return {} unless File.exist? SHAF_VERSION_FILE
|
77
76
|
str = File.read(SHAF_VERSION_FILE)
|
78
77
|
YAML.load(str) || {}
|
79
78
|
end
|
80
79
|
|
80
|
+
def read_shaf_file!
|
81
|
+
in_project_root do
|
82
|
+
read_shaf_file
|
83
|
+
end
|
84
|
+
end
|
85
|
+
|
81
86
|
def write_shaf_file(data = {})
|
82
87
|
data = read_shaf_file.merge(data)
|
83
88
|
File.write SHAF_VERSION_FILE,
|
data/lib/shaf/version.rb
CHANGED
@@ -1,8 +1,10 @@
|
|
1
1
|
class RootController < BaseController
|
2
2
|
|
3
|
-
|
3
|
+
HTTP_CACHE_MAX_AGE = 86400 # 60 * 60 * 24 = 1 day
|
4
|
+
register_uri :root, '/'
|
4
5
|
|
5
6
|
get root_uri do
|
7
|
+
cache_control(:private, max_age: HTTP_CACHE_MAX_AGE) if Shaf::Settings.http_cache
|
6
8
|
respond_with nil, serializer: RootSerializer
|
7
9
|
end
|
8
10
|
end
|
Binary file
|
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.4.
|
4
|
+
version: 0.4.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Sammy Henningsson
|
@@ -30,7 +30,7 @@ cert_chain:
|
|
30
30
|
ZMhjYR7sRczGJx+GxGU2EaR0bjRsPVlC4ywtFxoOfRG3WaJcpWGEoAoMJX6Z0bRv
|
31
31
|
M40=
|
32
32
|
-----END CERTIFICATE-----
|
33
|
-
date: 2018-07-
|
33
|
+
date: 2018-07-22 00:00:00.000000000 Z
|
34
34
|
dependencies:
|
35
35
|
- !ruby/object:Gem::Dependency
|
36
36
|
name: rake
|
@@ -71,6 +71,7 @@ files:
|
|
71
71
|
- lib/shaf/command/server.rb
|
72
72
|
- lib/shaf/command/templates/Gemfile.erb
|
73
73
|
- lib/shaf/command/upgrade.rb
|
74
|
+
- lib/shaf/command/version.rb
|
74
75
|
- lib/shaf/doc_model.rb
|
75
76
|
- lib/shaf/errors.rb
|
76
77
|
- lib/shaf/extensions.rb
|
@@ -157,6 +158,7 @@ files:
|
|
157
158
|
- templates/spec/integration/root_spec.rb
|
158
159
|
- templates/spec/serializers/root_serializer_spec.rb
|
159
160
|
- templates/spec/spec_helper.rb
|
161
|
+
- upgrades/0.4.0.tar.gz
|
160
162
|
homepage: https://github.com/sammyhenningsson/shaf
|
161
163
|
licenses:
|
162
164
|
- MIT
|
@@ -178,7 +180,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
178
180
|
version: '0'
|
179
181
|
requirements: []
|
180
182
|
rubyforge_project:
|
181
|
-
rubygems_version: 2.
|
183
|
+
rubygems_version: 2.6.14
|
182
184
|
signing_key:
|
183
185
|
specification_version: 4
|
184
186
|
summary: Sinatra Hypermedia Api Framework
|
metadata.gz.sig
CHANGED
Binary file
|