pliny 0.32.0 → 1.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/pliny/commands/creator.rb +1 -1
- data/lib/pliny/commands/generator/base.rb +1 -1
- data/lib/pliny/errors.rb +1 -1
- data/lib/pliny/metrics.rb +4 -2
- data/lib/pliny/middleware/cors.rb +6 -6
- data/lib/pliny/middleware/versioning.rb +1 -1
- data/lib/pliny/version.rb +1 -1
- data/lib/template/Gemfile +6 -6
- data/spec/helpers/zulu_time_spec.rb +0 -1
- data/spec/integration_spec.rb +0 -1
- data/spec/metrics_spec.rb +16 -0
- data/spec/spec_helper.rb +1 -0
- metadata +20 -20
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0737c4e1c61ecef9881625ff6bb0d2afeacc63977f239b7e2562d4aec3c3609a
|
4
|
+
data.tar.gz: f8db4293037c673ff3e33e025c75e86664f19cd207f3e36a2934e47eb981e942
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: bad71b767121811048ca67857644d74d6b7e565461e96cc6f52fa3b8207a41cb6f5fa8b4d32d14fc49894709a7959c55ddd7a6c8972f1555f6d5b6108c160978
|
7
|
+
data.tar.gz: d0e2adac5319670b3c12344f6b4d40a989e74770f4ffdbffdbf7082941ed7f2590802babf478966a63c475638f4736961855a449cf9629779baf696f98f2eb28
|
@@ -35,7 +35,7 @@ module Pliny::Commands
|
|
35
35
|
Dir.glob("#{app_dir}/{*,.*}.erb").each do |file|
|
36
36
|
static_file = file.gsub(/\.erb$/, '')
|
37
37
|
|
38
|
-
template = ERB.new(File.read(file)
|
38
|
+
template = ERB.new(File.read(file))
|
39
39
|
context = OpenStruct.new(app_name: name)
|
40
40
|
content = template.result(context.instance_eval { binding })
|
41
41
|
|
@@ -41,7 +41,7 @@ module Pliny::Commands
|
|
41
41
|
|
42
42
|
def render_template(template_file, vars = {})
|
43
43
|
template_path = File.dirname(__FILE__) + "/../../templates/#{template_file}"
|
44
|
-
template = ERB.new(File.read(template_path),
|
44
|
+
template = ERB.new(File.read(template_path), trim_mode: '>')
|
45
45
|
context = OpenStruct.new(vars)
|
46
46
|
template.result(context.instance_eval { binding })
|
47
47
|
end
|
data/lib/pliny/errors.rb
CHANGED
@@ -4,7 +4,7 @@ module Pliny
|
|
4
4
|
attr_accessor :id
|
5
5
|
|
6
6
|
def self.render(error)
|
7
|
-
headers = { "
|
7
|
+
headers = { "content-type" => "application/json; charset=utf-8" }
|
8
8
|
data = { id: error.id, message: error.message }
|
9
9
|
[error.status, headers, [MultiJson.encode(data)]]
|
10
10
|
end
|
data/lib/pliny/metrics.rb
CHANGED
@@ -16,11 +16,13 @@ module Pliny
|
|
16
16
|
counts
|
17
17
|
end
|
18
18
|
|
19
|
-
def measure(*
|
19
|
+
def measure(*inputs, &block)
|
20
20
|
if block
|
21
21
|
elapsed, return_value = time_elapsed(&block)
|
22
22
|
end
|
23
23
|
|
24
|
+
opts = inputs.last.is_a?(Hash) ? inputs.pop : {}
|
25
|
+
|
24
26
|
measurement =
|
25
27
|
if opts.has_key?(:value)
|
26
28
|
opts[:value]
|
@@ -30,7 +32,7 @@ module Pliny
|
|
30
32
|
0
|
31
33
|
end
|
32
34
|
|
33
|
-
measures = Hash[
|
35
|
+
measures = Hash[inputs.map { |n| ["#{Config.app_name}.#{n}", measurement] }]
|
34
36
|
|
35
37
|
backends.each do |backend|
|
36
38
|
report_and_catch { backend.report_measures(measures) }
|
@@ -44,12 +44,12 @@ module Pliny::Middleware
|
|
44
44
|
|
45
45
|
def cors_headers(env)
|
46
46
|
{
|
47
|
-
'
|
48
|
-
'
|
49
|
-
'
|
50
|
-
'
|
51
|
-
'
|
52
|
-
'
|
47
|
+
'access-control-allow-origin' => env["HTTP_ORIGIN"],
|
48
|
+
'access-control-allow-methods' => ALLOW_METHODS.join(', '),
|
49
|
+
'access-control-allow-headers' => allow_headers.join(', '),
|
50
|
+
'access-control-allow-credentials' => "true",
|
51
|
+
'access-control-max-age' => "1728000",
|
52
|
+
'access-control-expose-headers' => EXPOSE_HEADERS.join(', ')
|
53
53
|
}
|
54
54
|
end
|
55
55
|
end
|
@@ -26,7 +26,7 @@ module Pliny::Middleware
|
|
26
26
|
error = { id: :bad_version, message: <<-eos }
|
27
27
|
Please specify a version along with the MIME type. For example, `Accept: application/vnd.#{@app_name}+json; version=1`.
|
28
28
|
eos
|
29
|
-
return [400, { "
|
29
|
+
return [400, { "content-type" => "application/json; charset=utf-8" },
|
30
30
|
[MultiJson.encode(error)]]
|
31
31
|
end
|
32
32
|
|
data/lib/pliny/version.rb
CHANGED
data/lib/template/Gemfile
CHANGED
@@ -6,22 +6,22 @@ gem "oj"
|
|
6
6
|
gem "pg"
|
7
7
|
gem "pliny", "~> 0.32"
|
8
8
|
gem "pry"
|
9
|
-
gem "puma", "~>
|
9
|
+
gem "puma", "~> 6"
|
10
10
|
gem "rack-ssl"
|
11
|
-
gem "rack-timeout", "~> 0.
|
11
|
+
gem "rack-timeout", "~> 0.6"
|
12
12
|
gem "rake"
|
13
13
|
gem "rollbar"
|
14
|
-
gem "sequel", "~>
|
14
|
+
gem "sequel", "~> 5.73"
|
15
15
|
gem "sequel-paranoid"
|
16
|
-
gem "sequel_pg", "~> 1.
|
17
|
-
gem "sinatra", [">=
|
16
|
+
gem "sequel_pg", "~> 1.17", require: "sequel"
|
17
|
+
gem "sinatra", [">= 2.0", "< 3.0"], require: "sinatra/base"
|
18
18
|
gem "sinatra-contrib", require: ["sinatra/namespace", "sinatra/reloader"]
|
19
19
|
gem "sinatra-router"
|
20
20
|
gem "sucker_punch"
|
21
21
|
|
22
22
|
group :development, :test do
|
23
23
|
gem "pry-byebug"
|
24
|
-
gem "rubocop", "~>
|
24
|
+
gem "rubocop", "~> 1.56", require: false
|
25
25
|
gem "rubocop-rspec", require: false
|
26
26
|
end
|
27
27
|
|
data/spec/integration_spec.rb
CHANGED
data/spec/metrics_spec.rb
CHANGED
@@ -102,5 +102,21 @@ describe Pliny::Metrics do
|
|
102
102
|
"pliny.waldo" => 0
|
103
103
|
)
|
104
104
|
end
|
105
|
+
|
106
|
+
it "measures value in implicit hash with multiple metrics names" do
|
107
|
+
metrics.measure("metric.name", "another.name", value: 3.14, foo: :bar)
|
108
|
+
expect(test_backend).to have_received(:report_measures).once.with(
|
109
|
+
"pliny.metric.name" => 3.14,
|
110
|
+
"pliny.another.name" => 3.14
|
111
|
+
)
|
112
|
+
end
|
113
|
+
|
114
|
+
it "measures value in explicit hash with multiple metrics names" do
|
115
|
+
metrics.measure("metric.name", "another.name", { value: 3.14, foo: :bar })
|
116
|
+
expect(test_backend).to have_received(:report_measures).once.with(
|
117
|
+
"pliny.metric.name" => 3.14,
|
118
|
+
"pliny.another.name" => 3.14
|
119
|
+
)
|
120
|
+
end
|
105
121
|
end
|
106
122
|
end
|
data/spec/spec_helper.rb
CHANGED
metadata
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: pliny
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 1.1.0
|
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: 2024-02-13 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: activesupport
|
@@ -17,20 +17,20 @@ dependencies:
|
|
17
17
|
requirements:
|
18
18
|
- - ">="
|
19
19
|
- !ruby/object:Gem::Version
|
20
|
-
version:
|
20
|
+
version: '6.0'
|
21
21
|
- - "<"
|
22
22
|
- !ruby/object:Gem::Version
|
23
|
-
version: '
|
23
|
+
version: '8.0'
|
24
24
|
type: :runtime
|
25
25
|
prerelease: false
|
26
26
|
version_requirements: !ruby/object:Gem::Requirement
|
27
27
|
requirements:
|
28
28
|
- - ">="
|
29
29
|
- !ruby/object:Gem::Version
|
30
|
-
version:
|
30
|
+
version: '6.0'
|
31
31
|
- - "<"
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: '
|
33
|
+
version: '8.0'
|
34
34
|
- !ruby/object:Gem::Dependency
|
35
35
|
name: multi_json
|
36
36
|
requirement: !ruby/object:Gem::Requirement
|
@@ -77,20 +77,20 @@ dependencies:
|
|
77
77
|
requirements:
|
78
78
|
- - ">="
|
79
79
|
- !ruby/object:Gem::Version
|
80
|
-
version: '
|
80
|
+
version: '2.0'
|
81
81
|
- - "<"
|
82
82
|
- !ruby/object:Gem::Version
|
83
|
-
version: '
|
83
|
+
version: '5.0'
|
84
84
|
type: :runtime
|
85
85
|
prerelease: false
|
86
86
|
version_requirements: !ruby/object:Gem::Requirement
|
87
87
|
requirements:
|
88
88
|
- - ">="
|
89
89
|
- !ruby/object:Gem::Version
|
90
|
-
version: '
|
90
|
+
version: '2.0'
|
91
91
|
- - "<"
|
92
92
|
- !ruby/object:Gem::Version
|
93
|
-
version: '
|
93
|
+
version: '5.0'
|
94
94
|
- !ruby/object:Gem::Dependency
|
95
95
|
name: http_accept
|
96
96
|
requirement: !ruby/object:Gem::Requirement
|
@@ -171,14 +171,14 @@ dependencies:
|
|
171
171
|
requirements:
|
172
172
|
- - "~>"
|
173
173
|
- !ruby/object:Gem::Version
|
174
|
-
version:
|
174
|
+
version: '2'
|
175
175
|
type: :development
|
176
176
|
prerelease: false
|
177
177
|
version_requirements: !ruby/object:Gem::Requirement
|
178
178
|
requirements:
|
179
179
|
- - "~>"
|
180
180
|
- !ruby/object:Gem::Version
|
181
|
-
version:
|
181
|
+
version: '2'
|
182
182
|
- !ruby/object:Gem::Dependency
|
183
183
|
name: rspec
|
184
184
|
requirement: !ruby/object:Gem::Requirement
|
@@ -205,20 +205,20 @@ dependencies:
|
|
205
205
|
requirements:
|
206
206
|
- - ">="
|
207
207
|
- !ruby/object:Gem::Version
|
208
|
-
version: '
|
208
|
+
version: '2.0'
|
209
209
|
- - "<"
|
210
210
|
- !ruby/object:Gem::Version
|
211
|
-
version: '
|
211
|
+
version: '5.0'
|
212
212
|
type: :development
|
213
213
|
prerelease: false
|
214
214
|
version_requirements: !ruby/object:Gem::Requirement
|
215
215
|
requirements:
|
216
216
|
- - ">="
|
217
217
|
- !ruby/object:Gem::Version
|
218
|
-
version: '
|
218
|
+
version: '2.0'
|
219
219
|
- - "<"
|
220
220
|
- !ruby/object:Gem::Version
|
221
|
-
version: '
|
221
|
+
version: '5.0'
|
222
222
|
- !ruby/object:Gem::Dependency
|
223
223
|
name: timecop
|
224
224
|
requirement: !ruby/object:Gem::Requirement
|
@@ -497,7 +497,7 @@ homepage: https://github.com/interagent/pliny
|
|
497
497
|
licenses:
|
498
498
|
- MIT
|
499
499
|
metadata: {}
|
500
|
-
post_install_message:
|
500
|
+
post_install_message:
|
501
501
|
rdoc_options: []
|
502
502
|
require_paths:
|
503
503
|
- lib
|
@@ -512,8 +512,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
512
512
|
- !ruby/object:Gem::Version
|
513
513
|
version: '0'
|
514
514
|
requirements: []
|
515
|
-
rubygems_version: 3.
|
516
|
-
signing_key:
|
515
|
+
rubygems_version: 3.5.3
|
516
|
+
signing_key:
|
517
517
|
specification_version: 4
|
518
518
|
summary: Basic tooling to support API apps in Sinatra
|
519
519
|
test_files: []
|