pliny 0.27.0 → 0.30.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 +4 -4
- data/lib/pliny/commands/updater.rb +5 -5
- data/lib/pliny/db_support.rb +1 -0
- data/lib/pliny/helpers/params.rb +18 -3
- data/lib/pliny/helpers/serialize.rb +28 -29
- data/lib/pliny/log.rb +13 -8
- data/lib/pliny/middleware/canonical_log_line.rb +2 -2
- data/lib/pliny/tasks/db.rake +10 -13
- data/lib/pliny/version.rb +1 -1
- data/lib/template/Gemfile +1 -1
- data/lib/template/lib/endpoints/base.rb +1 -1
- data/spec/commands/creator_spec.rb +17 -15
- data/spec/commands/updater_spec.rb +11 -9
- data/spec/db_support_spec.rb +13 -10
- data/spec/helpers/params_spec.rb +20 -3
- data/spec/helpers/serialize_spec.rb +2 -2
- data/spec/integration_spec.rb +14 -9
- data/spec/log_spec.rb +68 -1
- metadata +36 -55
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 594ffc14e101ac813df431ff24c41370089114f5d5505b5a0ff72b0f6b2bc3bf
|
4
|
+
data.tar.gz: 1567a181f563ab92e1e7cef94cfcc38f60cd4f742b16a16580a1d2705396712b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: bdae87227f343e45275c2cc40afce4ed16d5610dc2c9cbc824ac96ecbd4a88747d5599abacec72c9fdfa8ee5d217aab426cb5b42dcfe1931b8a9e98bf38f13d8
|
7
|
+
data.tar.gz: 0b4f1418cdfa8adb477063400cbbd16398cf44b2615dee460bb23f0e839820567b1bf6c7bfa590ed37ae32490336b022e1df53e03161b893e331d44b4e23b09c
|
@@ -1,7 +1,7 @@
|
|
1
|
-
require
|
2
|
-
require
|
3
|
-
require
|
4
|
-
require
|
1
|
+
require "fileutils"
|
2
|
+
require "pathname"
|
3
|
+
require "pliny/version"
|
4
|
+
require "uri"
|
5
5
|
|
6
6
|
module Pliny::Commands
|
7
7
|
class Updater
|
@@ -37,7 +37,7 @@ module Pliny::Commands
|
|
37
37
|
|
38
38
|
# we need a local copy of the pliny repo to produce a diff
|
39
39
|
def ensure_repo_available
|
40
|
-
if File.
|
40
|
+
if File.exist?(repo_dir)
|
41
41
|
unless system("cd #{repo_dir} && git fetch --tags")
|
42
42
|
abort("Could not update Pliny repo at #{repo_dir}")
|
43
43
|
end
|
data/lib/pliny/db_support.rb
CHANGED
data/lib/pliny/helpers/params.rb
CHANGED
@@ -8,9 +8,13 @@ module Pliny::Helpers
|
|
8
8
|
|
9
9
|
def parse_body_params
|
10
10
|
if request.media_type == "application/json"
|
11
|
-
|
11
|
+
begin
|
12
|
+
decoded = MultiJson.decode(request.body.read)
|
13
|
+
rescue MultiJson::ParseError => e
|
14
|
+
raise Pliny::Errors::BadRequest, e.message
|
15
|
+
end
|
12
16
|
request.body.rewind
|
13
|
-
|
17
|
+
load_params(decoded)
|
14
18
|
elsif request.form_data?
|
15
19
|
load_params(request.POST)
|
16
20
|
else
|
@@ -21,10 +25,21 @@ module Pliny::Helpers
|
|
21
25
|
def load_params(data)
|
22
26
|
# Sinatra 1.x only supports the method. Sinatra 2.x only supports the class
|
23
27
|
if defined?(Sinatra::IndifferentHash)
|
24
|
-
|
28
|
+
indifferent_params_v2(data)
|
25
29
|
else
|
26
30
|
indifferent_params(data)
|
27
31
|
end
|
28
32
|
end
|
33
|
+
|
34
|
+
def indifferent_params_v2(data)
|
35
|
+
case data
|
36
|
+
when Hash
|
37
|
+
Sinatra::IndifferentHash[data]
|
38
|
+
when Array
|
39
|
+
data.map { |item| indifferent_params_v2(item) }
|
40
|
+
else
|
41
|
+
data
|
42
|
+
end
|
43
|
+
end
|
29
44
|
end
|
30
45
|
end
|
@@ -1,42 +1,41 @@
|
|
1
1
|
module Pliny::Helpers
|
2
2
|
module Serialize
|
3
|
-
def self.
|
4
|
-
base.
|
3
|
+
def self.registered(base)
|
4
|
+
base.helpers Helpers
|
5
|
+
base.set :serializer_class, nil
|
5
6
|
end
|
6
7
|
|
7
|
-
|
8
|
-
|
8
|
+
module Helpers
|
9
|
+
def serialize(data, structure = :default)
|
10
|
+
serializer_class = settings.serializer_class
|
9
11
|
|
10
|
-
|
11
|
-
|
12
|
-
No serializer has been specified for this endpoint. Please specify one with
|
13
|
-
`serializer Serializers::ModelName` in the endpoint.
|
14
|
-
|
15
|
-
|
12
|
+
if serializer_class.nil?
|
13
|
+
raise <<~eos.strip
|
14
|
+
No serializer has been specified for this endpoint. Please specify one with
|
15
|
+
`serializer Serializers::ModelName` in the endpoint.
|
16
|
+
eos
|
17
|
+
end
|
16
18
|
|
17
|
-
|
19
|
+
env['pliny.serializer_arity'] = data.respond_to?(:size) ? data.size : 1
|
18
20
|
|
19
|
-
|
20
|
-
|
21
|
-
|
21
|
+
start = Time.now
|
22
|
+
serializer_class.new(structure).serialize(data).tap do
|
23
|
+
env['pliny.serializer_timing'] = (Time.now - start).to_f
|
24
|
+
end
|
22
25
|
end
|
23
26
|
end
|
24
27
|
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
@serializer_class = serializer_class
|
37
|
-
end
|
38
|
-
|
39
|
-
attr_reader :serializer_class
|
28
|
+
# Provide a way to specify endpoint serializer class.
|
29
|
+
#
|
30
|
+
# class Endpoints::User < Base
|
31
|
+
# serializer Serializers::User
|
32
|
+
#
|
33
|
+
# get do
|
34
|
+
# encode serialize(User.all)
|
35
|
+
# end
|
36
|
+
# end
|
37
|
+
def serializer(serializer_class)
|
38
|
+
set :serializer_class, serializer_class
|
40
39
|
end
|
41
40
|
end
|
42
41
|
end
|
data/lib/pliny/log.rb
CHANGED
@@ -123,14 +123,17 @@ module Pliny
|
|
123
123
|
end
|
124
124
|
end
|
125
125
|
|
126
|
-
def
|
127
|
-
|
126
|
+
def replace_newlines(v)
|
127
|
+
v.gsub("\n", "\\n")
|
128
|
+
end
|
129
|
+
|
130
|
+
def quote_string(v)
|
128
131
|
if !v.include?('"')
|
129
|
-
%{
|
132
|
+
%{"#{v}"}
|
130
133
|
elsif !v.include?("'")
|
131
|
-
%{
|
134
|
+
%{'#{v}'}
|
132
135
|
else
|
133
|
-
%{
|
136
|
+
%{"#{v.gsub(/"/, '\\"')}"}
|
134
137
|
end
|
135
138
|
end
|
136
139
|
|
@@ -140,18 +143,20 @@ module Pliny
|
|
140
143
|
|
141
144
|
def unparse_pair(k, v)
|
142
145
|
v = v.call if v.is_a?(Proc)
|
143
|
-
|
146
|
+
|
144
147
|
if v == nil
|
145
148
|
nil
|
146
149
|
elsif v == true
|
147
150
|
k
|
148
151
|
elsif v.is_a?(Float)
|
149
152
|
"#{k}=#{format("%.3f", v)}"
|
150
|
-
elsif v.is_a?(String) && v =~ /\s/
|
151
|
-
quote_string(k, v)
|
152
153
|
elsif v.is_a?(Time)
|
153
154
|
"#{k}=#{v.iso8601}"
|
154
155
|
else
|
156
|
+
v = "#{v}"
|
157
|
+
v = replace_newlines(v)
|
158
|
+
v = quote_string(v) if v =~ /\s/
|
159
|
+
|
155
160
|
"#{k}=#{v}"
|
156
161
|
end
|
157
162
|
end
|
data/lib/pliny/tasks/db.rake
CHANGED
@@ -32,12 +32,12 @@ begin
|
|
32
32
|
|
33
33
|
desc "Seed the database with data"
|
34
34
|
task :seed do
|
35
|
-
if File.exist?(
|
35
|
+
if File.exist?("./db/seeds.rb")
|
36
36
|
database_urls.each do |database_url|
|
37
37
|
# make a DB instance available to the seeds file
|
38
|
-
self.class.send(:remove_const,
|
39
|
-
self.class.const_set(
|
40
|
-
load
|
38
|
+
self.class.send(:remove_const, "DB") if self.class.const_defined?("DB")
|
39
|
+
self.class.const_set("DB", Sequel.connect(database_url))
|
40
|
+
load "db/seeds.rb"
|
41
41
|
end
|
42
42
|
disconnect
|
43
43
|
end
|
@@ -66,7 +66,7 @@ begin
|
|
66
66
|
admin_url = Pliny::DbSupport.admin_url(database_url)
|
67
67
|
db = Sequel.connect(admin_url)
|
68
68
|
name = name_from_uri(database_url)
|
69
|
-
db.run(%
|
69
|
+
db.run(%(DROP DATABASE IF EXISTS "#{name}"))
|
70
70
|
puts "Dropped `#{name}`"
|
71
71
|
end
|
72
72
|
disconnect
|
@@ -75,7 +75,7 @@ begin
|
|
75
75
|
namespace :schema do
|
76
76
|
desc "Load the database schema"
|
77
77
|
task :load do
|
78
|
-
if File.
|
78
|
+
if File.exist?("./db/schema.sql")
|
79
79
|
schema = File.read("./db/schema.sql")
|
80
80
|
database_urls.each do |database_url|
|
81
81
|
db = Sequel.connect(database_url)
|
@@ -118,14 +118,14 @@ begin
|
|
118
118
|
end
|
119
119
|
|
120
120
|
desc "Merges migrations into schema and removes them"
|
121
|
-
task :
|
121
|
+
task merge: ["db:setup", "db:schema:dump"] do
|
122
122
|
FileUtils.rm Dir["./db/migrate/*.rb"]
|
123
123
|
puts "Removed migrations"
|
124
124
|
end
|
125
125
|
end
|
126
126
|
|
127
127
|
desc "Setup the database"
|
128
|
-
task :
|
128
|
+
task setup: [:drop, :create, "schema:load", :migrate, :seed]
|
129
129
|
|
130
130
|
private
|
131
131
|
|
@@ -138,12 +138,10 @@ begin
|
|
138
138
|
if ENV["DATABASE_URL"]
|
139
139
|
[ENV["DATABASE_URL"]]
|
140
140
|
else
|
141
|
-
%w
|
141
|
+
%w[.env .env.test].map { |env_file|
|
142
142
|
env_path = "./#{env_file}"
|
143
|
-
if File.
|
143
|
+
if File.exist?(env_path)
|
144
144
|
Pliny::Utils.parse_env(env_path)["DATABASE_URL"]
|
145
|
-
else
|
146
|
-
nil
|
147
145
|
end
|
148
146
|
}.compact
|
149
147
|
end
|
@@ -153,7 +151,6 @@ begin
|
|
153
151
|
URI.parse(uri).path[1..-1]
|
154
152
|
end
|
155
153
|
end
|
156
|
-
|
157
154
|
rescue LoadError
|
158
155
|
puts "Couldn't load sequel. Skipping database tasks"
|
159
156
|
end
|
data/lib/pliny/version.rb
CHANGED
data/lib/template/Gemfile
CHANGED
@@ -1,5 +1,5 @@
|
|
1
|
-
require
|
2
|
-
require
|
1
|
+
require "pliny/commands/creator"
|
2
|
+
require "spec_helper"
|
3
3
|
|
4
4
|
describe Pliny::Commands::Creator do
|
5
5
|
before do
|
@@ -7,21 +7,23 @@ describe Pliny::Commands::Creator do
|
|
7
7
|
end
|
8
8
|
|
9
9
|
describe "#run!" do
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
10
|
+
around do |example|
|
11
|
+
Dir.mktmpdir("plinytest-") do |dir|
|
12
|
+
Dir.chdir(dir) do
|
13
|
+
example.run
|
14
|
+
end
|
15
|
+
end
|
14
16
|
end
|
15
17
|
|
16
18
|
it "copies the template app over" do
|
17
19
|
@gen.run!
|
18
|
-
assert File.
|
19
|
-
assert File.
|
20
|
+
assert File.exist?("./foobar")
|
21
|
+
assert File.exist?("./foobar/Gemfile")
|
20
22
|
end
|
21
23
|
|
22
24
|
it "deletes the .git from it" do
|
23
25
|
@gen.run!
|
24
|
-
refute File.
|
26
|
+
refute File.exist?("./foobar/.git")
|
25
27
|
end
|
26
28
|
|
27
29
|
it "deletes the .erb files from it" do
|
@@ -31,25 +33,25 @@ describe Pliny::Commands::Creator do
|
|
31
33
|
|
32
34
|
it "changes DATABASE_URL in .env.sample to use the app name" do
|
33
35
|
@gen.run!
|
34
|
-
db_url = File.read("./foobar/.env.sample").split("\n").detect
|
36
|
+
db_url = File.read("./foobar/.env.sample").split("\n").detect { |line|
|
35
37
|
line.include?("DATABASE_URL=")
|
36
|
-
|
38
|
+
}
|
37
39
|
assert_equal "DATABASE_URL=postgres:///foobar-development", db_url
|
38
40
|
end
|
39
41
|
|
40
42
|
it "changes DATABASE_URL in .env.test to use the app name" do
|
41
43
|
@gen.run!
|
42
|
-
db_url = File.read("./foobar/.env.test").split("\n").detect
|
44
|
+
db_url = File.read("./foobar/.env.test").split("\n").detect { |line|
|
43
45
|
line.include?("DATABASE_URL=")
|
44
|
-
|
46
|
+
}
|
45
47
|
assert_equal "DATABASE_URL=postgres:///foobar-test", db_url
|
46
48
|
end
|
47
49
|
|
48
50
|
it "changes APP_NAME in app.json to use the app name" do
|
49
51
|
@gen.run!
|
50
|
-
db_url = File.read("./foobar/app.json").split("\n").detect
|
52
|
+
db_url = File.read("./foobar/app.json").split("\n").detect { |line|
|
51
53
|
line.include?("\"name\":")
|
52
|
-
|
54
|
+
}
|
53
55
|
assert_equal " \"name\": \"foobar\",", db_url
|
54
56
|
end
|
55
57
|
end
|
@@ -1,5 +1,5 @@
|
|
1
|
-
require
|
2
|
-
require
|
1
|
+
require "pliny/commands/updater"
|
2
|
+
require "spec_helper"
|
3
3
|
|
4
4
|
describe Pliny::Commands::Updater do
|
5
5
|
before do
|
@@ -10,19 +10,21 @@ describe Pliny::Commands::Updater do
|
|
10
10
|
end
|
11
11
|
|
12
12
|
describe "#run!" do
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
13
|
+
around do |example|
|
14
|
+
Dir.mktmpdir("plinytest-") do |dir|
|
15
|
+
Dir.chdir(dir) do
|
16
|
+
File.open("./Gemfile.lock", "w") do |f|
|
17
|
+
f.puts " pliny (0.6.3)"
|
18
|
+
end
|
19
|
+
example.run
|
20
|
+
end
|
19
21
|
end
|
20
22
|
end
|
21
23
|
|
22
24
|
it "creates a patch with Pliny diffs between the two versions" do
|
23
25
|
@cmd.run!
|
24
26
|
patch = File.read(@cmd.patch_file)
|
25
|
-
assert patch.include?(
|
27
|
+
assert patch.include?("--- a/Gemfile")
|
26
28
|
assert patch.include?('-gem "pliny", "~> 0.6"')
|
27
29
|
end
|
28
30
|
end
|
data/spec/db_support_spec.rb
CHANGED
@@ -6,15 +6,18 @@ describe Pliny::DbSupport do
|
|
6
6
|
let(:logger) { Logger.new(StringIO.new) }
|
7
7
|
let(:support) { Pliny::DbSupport.new(url, logger) }
|
8
8
|
|
9
|
-
|
10
|
-
|
9
|
+
around do |example|
|
10
|
+
Dir.mktmpdir("plinytest-") do |dir|
|
11
|
+
Dir.chdir(dir) do
|
12
|
+
FileUtils.mkdir_p("./db/migrate")
|
13
|
+
|
14
|
+
example.run
|
15
|
+
end
|
16
|
+
end
|
11
17
|
end
|
12
18
|
|
13
|
-
before
|
19
|
+
before do
|
14
20
|
DB.tables.each { |t| DB.drop_table(t) }
|
15
|
-
FileUtils.rm_rf(@path)
|
16
|
-
FileUtils.mkdir_p("#{@path}/db/migrate")
|
17
|
-
Dir.chdir(@path)
|
18
21
|
end
|
19
22
|
|
20
23
|
describe ".admin_url" do
|
@@ -33,7 +36,7 @@ describe Pliny::DbSupport do
|
|
33
36
|
|
34
37
|
describe "#migrate" do
|
35
38
|
before do
|
36
|
-
File.open("
|
39
|
+
File.open("./db/migrate/#{Time.now.to_i}_create_foo.rb", "w") do |f|
|
37
40
|
f.puts "
|
38
41
|
Sequel.migration do
|
39
42
|
change do
|
@@ -57,11 +60,11 @@ describe Pliny::DbSupport do
|
|
57
60
|
describe "#rollback" do
|
58
61
|
before do
|
59
62
|
@t = Time.now
|
60
|
-
File.open("
|
63
|
+
File.open("./db/migrate/#{(@t - 2).to_i}_first.rb", "w") do |f|
|
61
64
|
f.puts "Sequel.migration { change { create_table(:first) } }"
|
62
65
|
end
|
63
66
|
|
64
|
-
File.open("
|
67
|
+
File.open("./db/migrate/#{(@t - 1).to_i}_second.rb", "w") do |f|
|
65
68
|
f.puts "Sequel.migration { change { create_table(:second) } }"
|
66
69
|
end
|
67
70
|
end
|
@@ -80,7 +83,7 @@ describe Pliny::DbSupport do
|
|
80
83
|
end
|
81
84
|
|
82
85
|
it "handles databases not migrated (schema_migrations is empty)" do
|
83
|
-
support.migrate
|
86
|
+
support.migrate((@t - 2).to_i)
|
84
87
|
support.rollback # destroy table, leave schema_migrations
|
85
88
|
support.rollback # should noop
|
86
89
|
end
|
data/spec/helpers/params_spec.rb
CHANGED
@@ -1,7 +1,6 @@
|
|
1
1
|
require "spec_helper"
|
2
2
|
|
3
3
|
describe Pliny::Helpers::Params do
|
4
|
-
|
5
4
|
def app
|
6
5
|
Sinatra.new do
|
7
6
|
helpers Pliny::Helpers::Params
|
@@ -12,17 +11,35 @@ describe Pliny::Helpers::Params do
|
|
12
11
|
end
|
13
12
|
|
14
13
|
it "loads json params" do
|
15
|
-
post "/", {hello: "world"}.to_json, {
|
14
|
+
post "/", {hello: "world"}.to_json, {"CONTENT_TYPE" => "application/json"}
|
16
15
|
assert_equal "{\"hello\":\"world\"}", last_response.body
|
17
16
|
end
|
18
17
|
|
18
|
+
it "loads json array of params" do
|
19
|
+
post "/", [{hello: "world"}, {goodbye: "moon"}].to_json, {"CONTENT_TYPE" => "application/json"}
|
20
|
+
assert_equal "[{\"hello\":\"world\"},{\"goodbye\":\"moon\"}]", last_response.body
|
21
|
+
end
|
22
|
+
|
23
|
+
it "loads json array of arrays of params" do
|
24
|
+
post "/", [[{hello: "world"}], [{goodbye: "moon"}]].to_json, {"CONTENT_TYPE" => "application/json"}
|
25
|
+
assert_equal "[[{\"hello\":\"world\"}],[{\"goodbye\":\"moon\"}]]", last_response.body
|
26
|
+
end
|
27
|
+
|
19
28
|
it "loads form data params" do
|
20
29
|
post "/", {hello: "world"}
|
21
30
|
assert_equal "{\"hello\":\"world\"}", last_response.body
|
22
31
|
end
|
23
32
|
|
24
33
|
it "loads from an unknown content type" do
|
25
|
-
post "/", "<hello>world</hello>", {
|
34
|
+
post "/", "<hello>world</hello>", {"CONTENT_TYPE" => "application/xml"}
|
26
35
|
assert_equal "{}", last_response.body
|
27
36
|
end
|
37
|
+
|
38
|
+
it "should throw bad request when receiving invalid json via post" do
|
39
|
+
err = assert_raises(Pliny::Errors::BadRequest) do
|
40
|
+
post "/", "{\"foo\"}", {"CONTENT_TYPE" => "application/json"}
|
41
|
+
end
|
42
|
+
|
43
|
+
assert_match /unexpected token/, err.message
|
44
|
+
end
|
28
45
|
end
|
@@ -4,7 +4,7 @@ describe Pliny::Helpers::Serialize do
|
|
4
4
|
context "without a serializer" do
|
5
5
|
def app
|
6
6
|
Sinatra.new do
|
7
|
-
|
7
|
+
register Pliny::Helpers::Serialize
|
8
8
|
|
9
9
|
get "/" do
|
10
10
|
MultiJson.encode(serialize([]))
|
@@ -29,7 +29,7 @@ describe Pliny::Helpers::Serialize do
|
|
29
29
|
|
30
30
|
def app
|
31
31
|
Sinatra.new do
|
32
|
-
|
32
|
+
register Pliny::Helpers::Serialize
|
33
33
|
|
34
34
|
serializer Serializer
|
35
35
|
|
data/spec/integration_spec.rb
CHANGED
@@ -2,19 +2,24 @@ require "spec_helper"
|
|
2
2
|
|
3
3
|
describe "Pliny integration test" do
|
4
4
|
before(:all) do
|
5
|
-
|
6
|
-
|
7
|
-
Dir.
|
5
|
+
@original_dir = Dir.pwd
|
6
|
+
|
7
|
+
test_dir = Dir.mktmpdir("plinytest-")
|
8
|
+
Dir.chdir(test_dir)
|
8
9
|
|
9
10
|
bash "pliny-new myapp"
|
10
11
|
|
11
|
-
Dir.chdir("
|
12
|
+
Dir.chdir("myapp")
|
12
13
|
bash "bin/setup"
|
13
14
|
end
|
14
15
|
|
16
|
+
after(:all) do
|
17
|
+
Dir.chdir(@original_dir)
|
18
|
+
end
|
19
|
+
|
15
20
|
describe "bin/setup" do
|
16
21
|
it "generates .env" do
|
17
|
-
assert File.
|
22
|
+
assert File.exist?("./.env")
|
18
23
|
end
|
19
24
|
end
|
20
25
|
|
@@ -24,19 +29,19 @@ describe "Pliny integration test" do
|
|
24
29
|
end
|
25
30
|
|
26
31
|
it "creates the model file" do
|
27
|
-
assert File.
|
32
|
+
assert File.exist?("./lib/models/artist.rb")
|
28
33
|
end
|
29
34
|
|
30
35
|
it "creates the endpoint file" do
|
31
|
-
assert File.
|
36
|
+
assert File.exist?("./lib/endpoints/artists.rb")
|
32
37
|
end
|
33
38
|
|
34
39
|
it "creates the serializer file" do
|
35
|
-
assert File.
|
40
|
+
assert File.exist?("./lib/serializers/artist.rb")
|
36
41
|
end
|
37
42
|
|
38
43
|
it "creates the schema file" do
|
39
|
-
assert File.
|
44
|
+
assert File.exist?("./schema/schemata/artist.yaml")
|
40
45
|
end
|
41
46
|
end
|
42
47
|
|
data/spec/log_spec.rb
CHANGED
@@ -5,7 +5,6 @@ describe Pliny::Log do
|
|
5
5
|
@io = StringIO.new
|
6
6
|
Pliny.stdout = @io
|
7
7
|
Pliny.stderr = @io
|
8
|
-
allow(@io).to receive(:print)
|
9
8
|
end
|
10
9
|
|
11
10
|
after do
|
@@ -130,4 +129,72 @@ describe Pliny::Log do
|
|
130
129
|
end
|
131
130
|
end
|
132
131
|
end
|
132
|
+
|
133
|
+
describe "unparsing" do
|
134
|
+
it "removes nils from log" do
|
135
|
+
expect(@io).to receive(:print).with("\n")
|
136
|
+
|
137
|
+
Pliny.log(foo: nil)
|
138
|
+
end
|
139
|
+
|
140
|
+
it "leaves bare keys for true values" do
|
141
|
+
expect(@io).to receive(:print).with("foo\n")
|
142
|
+
|
143
|
+
Pliny.log(foo: true)
|
144
|
+
end
|
145
|
+
|
146
|
+
it "truncates floats" do
|
147
|
+
expect(@io).to receive(:print).with("foo=3.142\n")
|
148
|
+
|
149
|
+
Pliny.log(foo: Math::PI)
|
150
|
+
end
|
151
|
+
|
152
|
+
it "outputs times in ISO8601 format" do
|
153
|
+
expect(@io).to receive(:print).with("foo=2020-01-01T00:00:00Z\n")
|
154
|
+
|
155
|
+
Pliny.log(foo: Time.utc(2020))
|
156
|
+
end
|
157
|
+
|
158
|
+
it "quotes strings that contain spaces" do
|
159
|
+
expect(@io).to receive(:print).with("foo=\"string with spaces\"\n")
|
160
|
+
|
161
|
+
Pliny.log(foo: "string with spaces")
|
162
|
+
end
|
163
|
+
|
164
|
+
it "replaces newlines in strings" do
|
165
|
+
expect(@io).to receive(:print).with("foo=\"string\\nwith newlines\\n\"\n")
|
166
|
+
|
167
|
+
Pliny.log(foo: "string\nwith newlines\n")
|
168
|
+
end
|
169
|
+
|
170
|
+
it "by default interpolates objects into strings" do
|
171
|
+
expect(@io).to receive(:print).with("foo=message\n")
|
172
|
+
expect(@io).to receive(:print).with("foo=42\n")
|
173
|
+
expect(@io).to receive(:print).with("foo=bar\n")
|
174
|
+
|
175
|
+
Pliny.log(foo: StandardError.new("message"))
|
176
|
+
Pliny.log(foo: 42)
|
177
|
+
|
178
|
+
klass = Class.new do
|
179
|
+
def to_s
|
180
|
+
"bar"
|
181
|
+
end
|
182
|
+
end
|
183
|
+
Pliny.log(foo: klass.new)
|
184
|
+
end
|
185
|
+
|
186
|
+
it "quotes strings that are generated from object interpolation" do
|
187
|
+
expect(@io).to receive(:print).with("foo=\"message with space\"\n")
|
188
|
+
expect(@io).to receive(:print).with("foo=\"bar with space\"\n")
|
189
|
+
|
190
|
+
Pliny.log(foo: StandardError.new("message with space"))
|
191
|
+
|
192
|
+
klass = Class.new do
|
193
|
+
def to_s
|
194
|
+
"bar with space"
|
195
|
+
end
|
196
|
+
end
|
197
|
+
Pliny.log(foo: klass.new)
|
198
|
+
end
|
199
|
+
end
|
133
200
|
end
|
metadata
CHANGED
@@ -1,36 +1,36 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: pliny
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.30.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Brandur Leach
|
8
8
|
- Pedro Belo
|
9
|
-
autorequire:
|
9
|
+
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2021-06-17 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: activesupport
|
16
16
|
requirement: !ruby/object:Gem::Requirement
|
17
17
|
requirements:
|
18
|
-
- - "~>"
|
19
|
-
- !ruby/object:Gem::Version
|
20
|
-
version: '5.0'
|
21
18
|
- - ">="
|
22
19
|
- !ruby/object:Gem::Version
|
23
20
|
version: 5.0.1
|
21
|
+
- - "<"
|
22
|
+
- !ruby/object:Gem::Version
|
23
|
+
version: '7.0'
|
24
24
|
type: :runtime
|
25
25
|
prerelease: false
|
26
26
|
version_requirements: !ruby/object:Gem::Requirement
|
27
27
|
requirements:
|
28
|
-
- - "~>"
|
29
|
-
- !ruby/object:Gem::Version
|
30
|
-
version: '5.0'
|
31
28
|
- - ">="
|
32
29
|
- !ruby/object:Gem::Version
|
33
30
|
version: 5.0.1
|
31
|
+
- - "<"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '7.0'
|
34
34
|
- !ruby/object:Gem::Dependency
|
35
35
|
name: multi_json
|
36
36
|
requirement: !ruby/object:Gem::Requirement
|
@@ -135,62 +135,50 @@ dependencies:
|
|
135
135
|
name: thor
|
136
136
|
requirement: !ruby/object:Gem::Requirement
|
137
137
|
requirements:
|
138
|
-
- - "
|
138
|
+
- - ">="
|
139
139
|
- !ruby/object:Gem::Version
|
140
140
|
version: '0.19'
|
141
|
-
- - "
|
141
|
+
- - "<"
|
142
142
|
- !ruby/object:Gem::Version
|
143
|
-
version: 0
|
143
|
+
version: '2.0'
|
144
144
|
type: :runtime
|
145
145
|
prerelease: false
|
146
146
|
version_requirements: !ruby/object:Gem::Requirement
|
147
147
|
requirements:
|
148
|
-
- - "
|
148
|
+
- - ">="
|
149
149
|
- !ruby/object:Gem::Version
|
150
150
|
version: '0.19'
|
151
|
-
- - "
|
151
|
+
- - "<"
|
152
152
|
- !ruby/object:Gem::Version
|
153
|
-
version: 0
|
153
|
+
version: '2.0'
|
154
154
|
- !ruby/object:Gem::Dependency
|
155
155
|
name: rake
|
156
156
|
requirement: !ruby/object:Gem::Requirement
|
157
157
|
requirements:
|
158
158
|
- - "~>"
|
159
159
|
- !ruby/object:Gem::Version
|
160
|
-
version: '0
|
161
|
-
- - ">="
|
162
|
-
- !ruby/object:Gem::Version
|
163
|
-
version: 0.8.7
|
160
|
+
version: '13.0'
|
164
161
|
type: :development
|
165
162
|
prerelease: false
|
166
163
|
version_requirements: !ruby/object:Gem::Requirement
|
167
164
|
requirements:
|
168
165
|
- - "~>"
|
169
166
|
- !ruby/object:Gem::Version
|
170
|
-
version: '0
|
171
|
-
- - ">="
|
172
|
-
- !ruby/object:Gem::Version
|
173
|
-
version: 0.8.7
|
167
|
+
version: '13.0'
|
174
168
|
- !ruby/object:Gem::Dependency
|
175
169
|
name: rack-test
|
176
170
|
requirement: !ruby/object:Gem::Requirement
|
177
171
|
requirements:
|
178
172
|
- - "~>"
|
179
173
|
- !ruby/object:Gem::Version
|
180
|
-
version:
|
181
|
-
- - ">="
|
182
|
-
- !ruby/object:Gem::Version
|
183
|
-
version: 0.6.2
|
174
|
+
version: 1.1.0
|
184
175
|
type: :development
|
185
176
|
prerelease: false
|
186
177
|
version_requirements: !ruby/object:Gem::Requirement
|
187
178
|
requirements:
|
188
179
|
- - "~>"
|
189
180
|
- !ruby/object:Gem::Version
|
190
|
-
version:
|
191
|
-
- - ">="
|
192
|
-
- !ruby/object:Gem::Version
|
193
|
-
version: 0.6.2
|
181
|
+
version: 1.1.0
|
194
182
|
- !ruby/object:Gem::Dependency
|
195
183
|
name: rspec
|
196
184
|
requirement: !ruby/object:Gem::Requirement
|
@@ -285,60 +273,54 @@ dependencies:
|
|
285
273
|
requirements:
|
286
274
|
- - "~>"
|
287
275
|
- !ruby/object:Gem::Version
|
288
|
-
version: '0
|
289
|
-
- - "
|
276
|
+
version: '1.0'
|
277
|
+
- - "<"
|
290
278
|
- !ruby/object:Gem::Version
|
291
|
-
version: 0
|
279
|
+
version: '2.0'
|
292
280
|
type: :development
|
293
281
|
prerelease: false
|
294
282
|
version_requirements: !ruby/object:Gem::Requirement
|
295
283
|
requirements:
|
296
284
|
- - "~>"
|
297
285
|
- !ruby/object:Gem::Version
|
298
|
-
version: '0
|
299
|
-
- - "
|
286
|
+
version: '1.0'
|
287
|
+
- - "<"
|
300
288
|
- !ruby/object:Gem::Version
|
301
|
-
version: 0
|
289
|
+
version: '2.0'
|
302
290
|
- !ruby/object:Gem::Dependency
|
303
291
|
name: rollbar
|
304
292
|
requirement: !ruby/object:Gem::Requirement
|
305
293
|
requirements:
|
306
294
|
- - "~>"
|
307
295
|
- !ruby/object:Gem::Version
|
308
|
-
version: '2
|
309
|
-
- - ">="
|
310
|
-
- !ruby/object:Gem::Version
|
311
|
-
version: 2.11.0
|
296
|
+
version: '3.2'
|
312
297
|
type: :development
|
313
298
|
prerelease: false
|
314
299
|
version_requirements: !ruby/object:Gem::Requirement
|
315
300
|
requirements:
|
316
301
|
- - "~>"
|
317
302
|
- !ruby/object:Gem::Version
|
318
|
-
version: '2
|
319
|
-
- - ">="
|
320
|
-
- !ruby/object:Gem::Version
|
321
|
-
version: 2.11.0
|
303
|
+
version: '3.2'
|
322
304
|
- !ruby/object:Gem::Dependency
|
323
305
|
name: sequel
|
324
306
|
requirement: !ruby/object:Gem::Requirement
|
325
307
|
requirements:
|
326
308
|
- - "~>"
|
327
309
|
- !ruby/object:Gem::Version
|
328
|
-
version: '4
|
329
|
-
- - "
|
310
|
+
version: '5.4'
|
311
|
+
- - "<"
|
330
312
|
- !ruby/object:Gem::Version
|
331
|
-
version:
|
313
|
+
version: '6.0'
|
332
314
|
type: :development
|
333
315
|
prerelease: false
|
334
316
|
version_requirements: !ruby/object:Gem::Requirement
|
335
317
|
requirements:
|
336
318
|
- - "~>"
|
337
319
|
- !ruby/object:Gem::Version
|
338
|
-
version: '4
|
339
|
-
- - "
|
320
|
+
version: '5.4'
|
321
|
+
- - "<"
|
340
322
|
- !ruby/object:Gem::Version
|
341
|
-
version:
|
323
|
+
version: '6.0'
|
342
324
|
- !ruby/object:Gem::Dependency
|
343
325
|
name: rubocop
|
344
326
|
requirement: !ruby/object:Gem::Requirement
|
@@ -515,7 +497,7 @@ homepage: https://github.com/interagent/pliny
|
|
515
497
|
licenses:
|
516
498
|
- MIT
|
517
499
|
metadata: {}
|
518
|
-
post_install_message:
|
500
|
+
post_install_message:
|
519
501
|
rdoc_options: []
|
520
502
|
require_paths:
|
521
503
|
- lib
|
@@ -530,9 +512,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
530
512
|
- !ruby/object:Gem::Version
|
531
513
|
version: '0'
|
532
514
|
requirements: []
|
533
|
-
|
534
|
-
|
535
|
-
signing_key:
|
515
|
+
rubygems_version: 3.1.6
|
516
|
+
signing_key:
|
536
517
|
specification_version: 4
|
537
518
|
summary: Basic tooling to support API apps in Sinatra
|
538
519
|
test_files: []
|