bluepine 0.1.3 → 0.1.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +2 -0
- data/lib/bluepine.rb +1 -1
- data/lib/bluepine/serializers/serializable.rb +9 -11
- data/lib/bluepine/support.rb +13 -0
- data/lib/bluepine/validators/normalizable.rb +10 -11
- data/lib/bluepine/validators/validatable.rb +1 -1
- data/lib/bluepine/version.rb +1 -1
- metadata +3 -16
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 30e17cc0fa9d9f10980d7a7cb47b356455e40c869b63a58d5f76f32e9b030003
|
4
|
+
data.tar.gz: 3e980cd37141c4450df4e740d5f7e1cb0be1c307c03bb8cc051b677677d2bd3b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 35d96e45f5a7da08bc4702280899fa549e9be4cc392ba40acac9bf2ba85893fd9671b67a4c9a48f5abecbad9bae7df530ce1c9cfd7bbbc5827f8a7c211343c10
|
7
|
+
data.tar.gz: a7a5d27ec69517cd36a385695caca172923765cefa7dd6ea3b53a76429f1e22713710d701216f9b5c2bb442e009487332228a0926f541499e76ddbf4c45d4579
|
data/README.md
CHANGED
@@ -1,5 +1,7 @@
|
|
1
1
|
# Bluepine
|
2
2
|
|
3
|
+
![CircleCI](https://img.shields.io/circleci/project/omise/bluepine.svg?style=flat)
|
4
|
+
|
3
5
|
`Bluepine` is a DSL for defining API [Schema](#schema)/[Endpoint](#endpoint) with the capabilities to generate `Open API (v3)` spec (other specs is coming soon), validate API request and serialize object for API response based on single schema definition.
|
4
6
|
|
5
7
|
## Table of Contents
|
data/lib/bluepine.rb
CHANGED
@@ -1,24 +1,22 @@
|
|
1
1
|
module Bluepine
|
2
2
|
module Serializers
|
3
3
|
module Serializable
|
4
|
-
extend
|
4
|
+
extend Bluepine::Support
|
5
5
|
|
6
6
|
included do
|
7
|
-
|
8
|
-
|
7
|
+
class << self
|
8
|
+
attr_accessor :serializer
|
9
|
+
|
10
|
+
def serializer
|
11
|
+
@serializer || superclass.serializer
|
12
|
+
end
|
13
|
+
end
|
9
14
|
|
10
|
-
# Default serializer
|
11
15
|
self.serializer = ->(v) { v }
|
12
16
|
end
|
13
17
|
|
14
18
|
def serialize(value)
|
15
|
-
self.class.
|
16
|
-
end
|
17
|
-
|
18
|
-
module ClassMethods
|
19
|
-
def serialize(value)
|
20
|
-
serializer.(value)
|
21
|
-
end
|
19
|
+
self.class.serializer.(value)
|
22
20
|
end
|
23
21
|
end
|
24
22
|
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
module Bluepine
|
2
|
+
module Support
|
3
|
+
# Mimic Active Support's .included behaviours
|
4
|
+
def included(base = nil, &block)
|
5
|
+
if base.nil?
|
6
|
+
@_included_block = block
|
7
|
+
else
|
8
|
+
base.extend const_get(:ClassMethods) if const_defined?(:ClassMethods)
|
9
|
+
base.class_eval &@_included_block if instance_variable_defined?(:@_included_block)
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
@@ -1,24 +1,23 @@
|
|
1
1
|
module Bluepine
|
2
2
|
module Validators
|
3
3
|
module Normalizable
|
4
|
-
extend
|
4
|
+
extend Bluepine::Support
|
5
5
|
|
6
6
|
included do
|
7
|
-
|
8
|
-
|
7
|
+
class << self
|
8
|
+
# Normalizes value before passing it to validator
|
9
|
+
attr_accessor :normalizer
|
10
|
+
|
11
|
+
def normalizer
|
12
|
+
@normalizer || superclass.normalizer
|
13
|
+
end
|
14
|
+
end
|
9
15
|
|
10
|
-
# Default normalizer
|
11
16
|
self.normalizer = ->(v) { v }
|
12
17
|
end
|
13
18
|
|
14
19
|
def normalize(value)
|
15
|
-
self.class.
|
16
|
-
end
|
17
|
-
|
18
|
-
module ClassMethods
|
19
|
-
def normalize(value)
|
20
|
-
normalizer.(value)
|
21
|
-
end
|
20
|
+
self.class.normalizer.(value)
|
22
21
|
end
|
23
22
|
end
|
24
23
|
end
|
data/lib/bluepine/version.rb
CHANGED
metadata
CHANGED
@@ -1,29 +1,15 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: bluepine
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Marut K
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-07-
|
11
|
+
date: 2019-07-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
|
-
- !ruby/object:Gem::Dependency
|
14
|
-
name: activesupport
|
15
|
-
requirement: !ruby/object:Gem::Requirement
|
16
|
-
requirements:
|
17
|
-
- - "~>"
|
18
|
-
- !ruby/object:Gem::Version
|
19
|
-
version: '5.0'
|
20
|
-
type: :runtime
|
21
|
-
prerelease: false
|
22
|
-
version_requirements: !ruby/object:Gem::Requirement
|
23
|
-
requirements:
|
24
|
-
- - "~>"
|
25
|
-
- !ruby/object:Gem::Version
|
26
|
-
version: '5.0'
|
27
13
|
- !ruby/object:Gem::Dependency
|
28
14
|
name: activemodel
|
29
15
|
requirement: !ruby/object:Gem::Requirement
|
@@ -179,6 +165,7 @@ files:
|
|
179
165
|
- lib/bluepine/resolver.rb
|
180
166
|
- lib/bluepine/serializer.rb
|
181
167
|
- lib/bluepine/serializers/serializable.rb
|
168
|
+
- lib/bluepine/support.rb
|
182
169
|
- lib/bluepine/validator.rb
|
183
170
|
- lib/bluepine/validators/normalizable.rb
|
184
171
|
- lib/bluepine/validators/proxy.rb
|