ips_validator 0.1.1 → 0.1.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/ips_validator.gemspec +1 -1
- data/lib/ips_validator.rb +6 -2
- data/lib/ips_validator/validator.rb +47 -19
- data/lib/ips_validator/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d00c478e2dd921147cda18b9ab576f51ff1b0c1ca2047f1d51289bd409cb33d1
|
4
|
+
data.tar.gz: 01f40ecedc1e9a4e6a5c5d412d1f81bf2371b60c70771ea03411ffab36a9d074
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3d87e7f9cc904c1194853d0442f14b7511ac8d017292777d1511be8728a19b09edbbd760535e12b5a6bc095eda6ac06890a76dd27673a4a21a6e4e091e0fa0fa
|
7
|
+
data.tar.gz: 167730fd7124f681077d2736efb3bedfca3c8ca64974d778e155790f8e929830ed706b81f997037b2142f81a0627957a5222eda2b740b79162d759ec7a8b8684
|
data/ips_validator.gemspec
CHANGED
@@ -10,7 +10,7 @@ Gem::Specification.new do |spec|
|
|
10
10
|
spec.email = ["@bakaoh"]
|
11
11
|
|
12
12
|
spec.summary = "Small library to check if Improvement Proposals(IPs) have valid front matter"
|
13
|
-
spec.homepage = "https://github.com/thefortube"
|
13
|
+
spec.homepage = "https://github.com/thefortube/ips_validator"
|
14
14
|
spec.license = "MIT"
|
15
15
|
|
16
16
|
# Prevent pushing this gem to RubyGems.org. To allow pushes either set the 'allowed_push_host'
|
data/lib/ips_validator.rb
CHANGED
@@ -5,7 +5,7 @@ require 'ips_validator/validator'
|
|
5
5
|
module IpsValidator
|
6
6
|
class Runner
|
7
7
|
class << self
|
8
|
-
def run(
|
8
|
+
def run(args)
|
9
9
|
num_valid = 0
|
10
10
|
num_invalid = 0
|
11
11
|
num_error = 0
|
@@ -15,11 +15,15 @@ module IpsValidator
|
|
15
15
|
types = []
|
16
16
|
categories = []
|
17
17
|
layers = []
|
18
|
+
xip = args[0].to_sym
|
19
|
+
file_names = args[1..-1]
|
20
|
+
|
18
21
|
file_names.map do |file_name|
|
19
22
|
attributes = Loader.load(file_name)
|
20
23
|
total+=1
|
21
24
|
begin
|
22
|
-
|
25
|
+
validator = ValidatorFactory.make(xip)
|
26
|
+
v = validator.new(attributes)
|
23
27
|
if v.valid?
|
24
28
|
num_valid+=1
|
25
29
|
else
|
@@ -1,28 +1,56 @@
|
|
1
1
|
require 'active_model'
|
2
2
|
|
3
3
|
module IpsValidator
|
4
|
-
class
|
5
|
-
def
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
4
|
+
class ValidatorFactory
|
5
|
+
def self.make(name)
|
6
|
+
Class.new do
|
7
|
+
def initialize(opts = {})
|
8
|
+
# ruby does not allow method with -
|
9
|
+
# replaces - with _
|
10
|
+
opts.keys.each do |key|
|
11
|
+
raise("#{key} incude _ which is not allowed") if key.to_s.match(/_/)
|
12
|
+
if key.to_s.match(/-/)
|
13
|
+
new_key = opts.keys.last.to_s.gsub('-','_')
|
14
|
+
opts[new_key] = opts.delete key
|
15
|
+
end
|
16
|
+
end
|
17
|
+
super(opts)
|
13
18
|
end
|
19
|
+
|
20
|
+
include ActiveModel::Model
|
21
|
+
attr_accessor name, :title, :author, :status, :created, :updated, :implementation
|
22
|
+
attr_accessor :replaces, :requires, :layer, :resolution
|
23
|
+
# replace - with _
|
24
|
+
attr_accessor :discussions_to, :superseded_by, :review_period_end
|
25
|
+
validates_presence_of :title, :author, :status, :created
|
26
|
+
validates name, presence: true
|
27
|
+
validates_inclusion_of :status, in: ['WIP', 'Proposed', 'Approved', 'Implemented', 'Rejected']
|
14
28
|
end
|
15
|
-
super(opts)
|
16
29
|
end
|
17
|
-
|
18
|
-
include ActiveModel::Model
|
19
|
-
attr_accessor :fip, :title, :author, :status, :created, :updated
|
20
|
-
attr_accessor :replaces, :requires, :layer, :resolution
|
21
|
-
# replace - with _
|
22
|
-
attr_accessor :discussions_to, :superseded_by, :review_period_end
|
23
|
-
validates_presence_of :title, :author, :status, :created
|
24
|
-
validates :fip, presence: true
|
25
|
-
validates_inclusion_of :status, in: ['WIP', 'Proposed', 'Approved', 'Implemented', 'Rejected']
|
26
30
|
end
|
31
|
+
|
32
|
+
# class Validator
|
33
|
+
# def initialize(opts = {})
|
34
|
+
# # ruby does not allow method with -
|
35
|
+
# # replaces - with _
|
36
|
+
# opts.keys.each do |key|
|
37
|
+
# raise("#{key} incude _ which is not allowed") if key.to_s.match(/_/)
|
38
|
+
# if key.to_s.match(/-/)
|
39
|
+
# new_key = opts.keys.last.to_s.gsub('-','_')
|
40
|
+
# opts[new_key] = opts.delete key
|
41
|
+
# end
|
42
|
+
# end
|
43
|
+
# super(opts)
|
44
|
+
# end
|
45
|
+
|
46
|
+
# include ActiveModel::Model
|
47
|
+
# attr_accessor :fip, :title, :author, :status, :created, :updated
|
48
|
+
# attr_accessor :replaces, :requires, :layer, :resolution
|
49
|
+
# # replace - with _
|
50
|
+
# attr_accessor :discussions_to, :superseded_by, :review_period_end
|
51
|
+
# validates_presence_of :title, :author, :status, :created
|
52
|
+
# validates :fip, presence: true
|
53
|
+
# validates_inclusion_of :status, in: ['WIP', 'Proposed', 'Approved', 'Implemented', 'Rejected']
|
54
|
+
# end
|
27
55
|
end
|
28
56
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ips_validator
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Bakaoh
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-10-
|
11
|
+
date: 2020-10-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -102,7 +102,7 @@ files:
|
|
102
102
|
- lib/ips_validator/loader.rb
|
103
103
|
- lib/ips_validator/validator.rb
|
104
104
|
- lib/ips_validator/version.rb
|
105
|
-
homepage: https://github.com/thefortube
|
105
|
+
homepage: https://github.com/thefortube/ips_validator
|
106
106
|
licenses:
|
107
107
|
- MIT
|
108
108
|
metadata: {}
|