pliny 0.12.0 → 0.13.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 16aea0ec781e78a0b364f7f35e0a941a0e34d250
4
- data.tar.gz: 99cdc6dd5bbb6aed6511befeb0cf1a17ca31694b
3
+ metadata.gz: 37b966bf5f40236d28804fba3d57ad356343f1b5
4
+ data.tar.gz: 67053ff9193b72b45e476da6ede34581811aba4b
5
5
  SHA512:
6
- metadata.gz: 52c1318c1d3dd7f46ce259b0aa4bce3666a2c01cdc98de92733b958df66b273562c4d39bcde0496654655fbe2af53cbf1e56c9e10d6967693db97476fc9f46c9
7
- data.tar.gz: 66f0df7d564027d442f46f7bb5e249d4d99d75d8c38233a0b2ba18c161e5bc0972a3b16b198959dbf0875a3fa8252bcb9784b27003f6434a691dbce306880066
6
+ metadata.gz: a6a9fc47cd36460cd66965491f52f6a66a6d6fa1495d043f50fa90f831f91d4a38a121136b40a1c21a1777f0f2460e9e6caa1e1137695ada1e5d73181a00cfb3
7
+ data.tar.gz: b449a031bb3b3f940f3ab791b9c3ac2ec665b0c20bbed23c9e15f0d596f274072d28c29a22074d4c544777ff90446572eea916bb28718ea114d3702908910990
@@ -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
@@ -1,3 +1,3 @@
1
1
  module Pliny
2
- VERSION = "0.12.0"
2
+ VERSION = "0.13.0"
3
3
  end
@@ -4,7 +4,7 @@ ruby "2.2.3"
4
4
  gem "multi_json"
5
5
  gem "oj"
6
6
  gem "pg"
7
- gem "pliny", "~> 0.12"
7
+ gem "pliny", "~> 0.13"
8
8
  gem "pry"
9
9
  gem "puma", "~> 2.10"
10
10
  gem "rack-ssl"
@@ -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
@@ -15,6 +15,7 @@ Routes = Rack::Builder.new do
15
15
 
16
16
  use Pliny::Router do
17
17
  # mount all endpoints here
18
+ mount Endpoints::Schema
18
19
  end
19
20
 
20
21
  # root app; but will also handle some defaults like 404
@@ -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.12.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-09 00:00:00.000000000 Z
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