pliny 0.12.0 → 0.13.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.
- checksums.yaml +4 -4
- data/lib/pliny/tasks/db.rake +4 -0
- data/lib/pliny/version.rb +1 -1
- data/lib/template/Gemfile +1 -1
- data/lib/template/lib/endpoints/schema.rb +19 -0
- data/lib/template/lib/routes.rb +1 -0
- data/lib/template/spec/endpoints/schema_spec.rb +37 -0
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 37b966bf5f40236d28804fba3d57ad356343f1b5
|
4
|
+
data.tar.gz: 67053ff9193b72b45e476da6ede34581811aba4b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a6a9fc47cd36460cd66965491f52f6a66a6d6fa1495d043f50fa90f831f91d4a38a121136b40a1c21a1777f0f2460e9e6caa1e1137695ada1e5d73181a00cfb3
|
7
|
+
data.tar.gz: b449a031bb3b3f940f3ab791b9c3ac2ec665b0c20bbed23c9e15f0d596f274072d28c29a22074d4c544777ff90446572eea916bb28718ea114d3702908910990
|
data/lib/pliny/tasks/db.rake
CHANGED
@@ -101,6 +101,10 @@ begin
|
|
101
101
|
# add migrations used to compose this schema
|
102
102
|
db = Sequel.connect(database_urls.first)
|
103
103
|
if db.table_exists?(:schema_migrations)
|
104
|
+
# set the search_path so migrations are added in the right schema
|
105
|
+
search_path = db.dataset.with_sql("SHOW search_path").single_value
|
106
|
+
schema << "SET search_path = #{search_path};\n\n"
|
107
|
+
|
104
108
|
db[:schema_migrations].each do |migration|
|
105
109
|
schema << db[:schema_migrations].insert_sql(migration) + ";\n"
|
106
110
|
end
|
data/lib/pliny/version.rb
CHANGED
data/lib/template/Gemfile
CHANGED
@@ -0,0 +1,19 @@
|
|
1
|
+
module Endpoints
|
2
|
+
class Schema < Base
|
3
|
+
get "/schema.json" do
|
4
|
+
content_type "application/schema+json"
|
5
|
+
headers["Cache-Control"] = "public, max-age=3600"
|
6
|
+
unless File.exists?(schema_filename)
|
7
|
+
message = "This application does not have a schema file."
|
8
|
+
raise Pliny::Errors::NotFound.new(message)
|
9
|
+
end
|
10
|
+
File.read(schema_filename)
|
11
|
+
end
|
12
|
+
|
13
|
+
private
|
14
|
+
|
15
|
+
def schema_filename
|
16
|
+
"#{Config.root}/schema/schema.json"
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
data/lib/template/lib/routes.rb
CHANGED
@@ -0,0 +1,37 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
describe Endpoints::Schema do
|
4
|
+
include Rack::Test::Methods
|
5
|
+
|
6
|
+
let(:schema_filename) { "#{Config.root}/schema/schema.json" }
|
7
|
+
|
8
|
+
subject(:get_schema) { get "/schema.json" }
|
9
|
+
|
10
|
+
context "without a schema.json" do
|
11
|
+
before do
|
12
|
+
allow(File).to receive(:exists?).and_return(false)
|
13
|
+
end
|
14
|
+
|
15
|
+
it "raises a 404 on missing schema" do
|
16
|
+
assert_raises(Pliny::Errors::NotFound) do
|
17
|
+
get_schema
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
context "with a schema.json" do
|
23
|
+
let(:contents) { "contents" }
|
24
|
+
|
25
|
+
before do
|
26
|
+
allow(File).to receive(:exists?).and_return(true)
|
27
|
+
allow(File).to receive(:read).and_return(contents)
|
28
|
+
end
|
29
|
+
|
30
|
+
it "returns the schema is present" do
|
31
|
+
get_schema
|
32
|
+
assert_equal 200, last_response.status
|
33
|
+
assert_equal "application/schema+json", last_response.headers["Content-Type"]
|
34
|
+
assert_equal contents, last_response.body
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: pliny
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.13.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Brandur Leach
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2015-10-
|
12
|
+
date: 2015-10-23 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: activesupport
|
@@ -423,6 +423,7 @@ files:
|
|
423
423
|
- lib/template/lib/application.rb
|
424
424
|
- lib/template/lib/endpoints/base.rb
|
425
425
|
- lib/template/lib/endpoints/root.rb
|
426
|
+
- lib/template/lib/endpoints/schema.rb
|
426
427
|
- lib/template/lib/initializer.rb
|
427
428
|
- lib/template/lib/mediators/base.rb
|
428
429
|
- lib/template/lib/routes.rb
|
@@ -430,6 +431,7 @@ files:
|
|
430
431
|
- lib/template/lib/tasks/spec.rake
|
431
432
|
- lib/template/schema/meta.json
|
432
433
|
- lib/template/schema/schemata/.gitkeep
|
434
|
+
- lib/template/spec/endpoints/schema_spec.rb
|
433
435
|
- lib/template/spec/spec_helper.rb
|
434
436
|
- lib/template/spec/spec_support/auto_define_rack_app.rb
|
435
437
|
- lib/template/spec/spec_support/coverage.rb
|