vehicle_coding_ph 1.2.0 → 1.2.1

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
  SHA256:
3
- metadata.gz: bfabb96edaefb820f72fb034babb4580eceb44c4b385a68d63299bc1beedcdf9
4
- data.tar.gz: d28debcd5713a9cfdbbcb335fb306ccae601ba364fd142003f30424d5539a1d0
3
+ metadata.gz: 211954f2ff90d9f8e74351ce83d651af85a8823959f4bcbd3927f536e2707bfb
4
+ data.tar.gz: 0d8838676c71c8c3d309f5ce1754d4ca6074918b5049607fbe3e3241e39510d9
5
5
  SHA512:
6
- metadata.gz: f3fd45fbb2083812c8fc3c987c7063d39576ef853dce6603c66e1803ceb7c2d65303f29704ac84f881d065d3e2ccad629dd680b54dcc2eb197cde6e68dff5b21
7
- data.tar.gz: 380a4bd8ee6c04567112af7db46164a0eba4d4a1cb988f0986f1044d12c08b51290822a260a8330097fb998a502a7efa9098591eb67af7c73f52f2990b6224af
6
+ metadata.gz: 6afa27989d9586d068ac8e1c1566192c1d64dfd0bac03a27c88384a0ade78fde7ff0ed7a6228e457d9ad8ab7f458f18b2351bf3a19fbee94be6cb4308573a408
7
+ data.tar.gz: 6634af28597d5db30e0112517724c4d0503c8e7a1807372664fa5a016becaf675290b1e03dad4ce7a6a43ab1a107c0a8f92f7e596694174edc464cc7fe9f29fc
data/Gemfile.lock CHANGED
@@ -1,14 +1,25 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- vehicle_coding_ph (1.2.0)
4
+ vehicle_coding_ph (1.2.1)
5
+ activesupport
5
6
 
6
7
  GEM
7
8
  remote: https://rubygems.org/
8
9
  specs:
10
+ activesupport (6.0.2.1)
11
+ concurrent-ruby (~> 1.0, >= 1.0.2)
12
+ i18n (>= 0.7, < 2)
13
+ minitest (~> 5.1)
14
+ tzinfo (~> 1.1)
15
+ zeitwerk (~> 2.2)
9
16
  coderay (1.1.2)
17
+ concurrent-ruby (1.1.5)
10
18
  diff-lcs (1.3)
19
+ i18n (1.7.0)
20
+ concurrent-ruby (~> 1.0)
11
21
  method_source (0.9.2)
22
+ minitest (5.13.0)
12
23
  pry (0.12.2)
13
24
  coderay (~> 1.1.0)
14
25
  method_source (~> 0.9.0)
@@ -26,7 +37,11 @@ GEM
26
37
  diff-lcs (>= 1.2.0, < 2.0)
27
38
  rspec-support (~> 3.9.0)
28
39
  rspec-support (3.9.0)
40
+ thread_safe (0.3.6)
29
41
  timecop (0.9.1)
42
+ tzinfo (1.2.6)
43
+ thread_safe (~> 0.1)
44
+ zeitwerk (2.2.2)
30
45
 
31
46
  PLATFORMS
32
47
  ruby
@@ -0,0 +1,32 @@
1
+ ---
2
+ - day: Monday
3
+ plates:
4
+ - "1"
5
+ - "2"
6
+
7
+ - day: Tuesday
8
+ plates:
9
+ - "3"
10
+ - "4"
11
+
12
+ - day: Wednesday
13
+ plates:
14
+ - "5"
15
+ - "6"
16
+
17
+ - day: Thursday
18
+ plates:
19
+ - "7"
20
+ - "8"
21
+
22
+ - day: Friday
23
+ plates:
24
+ - "9"
25
+ - "0"
26
+
27
+ - day: Saturday
28
+ plates: []
29
+
30
+ - day: Sunday
31
+ plates: []
32
+
@@ -1,4 +1,6 @@
1
1
  require "date"
2
+ require "yaml"
3
+ require "active_support/core_ext/hash/indifferent_access"
2
4
  require "vehicle_coding_ph/version"
3
5
  require "vehicle_coding_ph/checker"
4
6
  require "vehicle_coding_ph/response"
@@ -6,15 +8,10 @@ require "vehicle_coding_ph/response"
6
8
  module VehicleCodingPh
7
9
  class Error < StandardError; end
8
10
 
9
- PLATE_TO_DAY_MAPPING = {
10
- "Monday" => ["1", "2"],
11
- "Tuesday" => ["3", "4"],
12
- "Wednesday" => ["5", "6"],
13
- "Thursday" => ["7", "8"],
14
- "Friday" => ["9", "0"],
15
- "Saturday" => [],
16
- "Sunday" => [],
17
- }
11
+ def self.coding_scheme
12
+ file = File.join(File.dirname(__FILE__), "sources", "coding_scheme.yml")
13
+ YAML.load_file(file).map(&:with_indifferent_access)
14
+ end
18
15
 
19
16
  AREA_TO_HOUR_MAPPING = {
20
17
  "Marikina" => [],
@@ -29,10 +29,10 @@ module VehicleCodingPh
29
29
  last_digit = plate[-1]
30
30
  day_today = Date::DAYNAMES[datetime.wday]
31
31
 
32
- mapping = VehicleCodingPh::PLATE_TO_DAY_MAPPING.
33
- select { |day, digits| day == day_today }
32
+ mapping = VehicleCodingPh.coding_scheme.
33
+ find { |mapping| mapping[:day] == day_today }
34
34
 
35
- mapping[day_today].include?(last_digit)
35
+ mapping[:plates].include?(last_digit)
36
36
  end
37
37
  private_class_method :coding?
38
38
 
@@ -1,3 +1,3 @@
1
1
  module VehicleCodingPh
2
- VERSION = "1.2.0"
2
+ VERSION = "1.2.1"
3
3
  end
@@ -33,4 +33,6 @@ Gem::Specification.new do |spec|
33
33
  spec.add_development_dependency "rspec", "~> 3.0"
34
34
  spec.add_development_dependency "timecop"
35
35
  spec.add_development_dependency "pry"
36
+
37
+ spec.add_dependency "activesupport"
36
38
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: vehicle_coding_ph
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.0
4
+ version: 1.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mark Chavez
@@ -80,6 +80,20 @@ dependencies:
80
80
  - - ">="
81
81
  - !ruby/object:Gem::Version
82
82
  version: '0'
83
+ - !ruby/object:Gem::Dependency
84
+ name: activesupport
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - ">="
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
90
+ type: :runtime
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - ">="
95
+ - !ruby/object:Gem::Version
96
+ version: '0'
83
97
  description: Plate number coding in the Philippines.
84
98
  email:
85
99
  - markchav3z@gmail.com
@@ -98,6 +112,7 @@ files:
98
112
  - Rakefile
99
113
  - bin/console
100
114
  - bin/setup
115
+ - lib/sources/coding_scheme.yml
101
116
  - lib/vehicle_coding_ph.rb
102
117
  - lib/vehicle_coding_ph/checker.rb
103
118
  - lib/vehicle_coding_ph/response.rb