conifer 1.1.0 → 1.2.0

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: 0a170b07790bedd693faf1f86de8cea5bc2b6a8b1adcaa10360816a05a00de72
4
- data.tar.gz: 6d3913dae889d4543fcda4c3686d88614c5bb95bfb8704fa41e55b4bb14731e6
3
+ metadata.gz: 520bd98270d714e155b05def5414531da4568094fae4266bcea73327f29d8a2e
4
+ data.tar.gz: ffdb5f410b458f83d22dc6fbf450c46b056cd09532bf42059ab8391db4e0340c
5
5
  SHA512:
6
- metadata.gz: bfef2f2a00f2a7bbebd5c805876ee51276216c37169fc5e782f78ee218013de0f76afcc68abdea9b0844989dea9d9c7c7405e22ff75749c915068f734ef9880d
7
- data.tar.gz: c13bc23806654f72898a68044485f294d4116fd127abd4cddbe0c45b11c6d46c59dd6c59eb9d1d5c89575b524b262325b3e5723a05c0c20fa7c6c175f1d78459
6
+ metadata.gz: 9d9b2b3f1c21db80010ea8ca424b44e859da81fefddf26be66a30aa91c96fe1f1ddcc65be465160dced4978e93932978545dafc3b4efd0a8313b9ee654e53eb0
7
+ data.tar.gz: fc9c43b0a7f6d89881e50a5e9e10c79f3864c2c5ceee1ddc19ca6153f72be811416d695782914b0f1c5564a581f7d8893c58dc82e91386f6189bc94cb0998430
@@ -7,12 +7,18 @@ jobs:
7
7
 
8
8
  runs-on: ubuntu-latest
9
9
 
10
+ strategy:
11
+ matrix:
12
+ ruby:
13
+ - 2.6.x
14
+ - 2.7.x
15
+
10
16
  steps:
11
17
  - uses: actions/checkout@v2
12
- - name: Set up Ruby 2.6
18
+ - name: Set up Ruby
13
19
  uses: actions/setup-ruby@v1
14
20
  with:
15
- ruby-version: 2.6.x
21
+ ruby-version: ${{ matrix.ruby }}
16
22
  - name: Configure Bundler
17
23
  run: |
18
24
  gem install bundler -v 1.17.3 --no-document
@@ -20,7 +26,7 @@ jobs:
20
26
  - name: Run tests with RSpec
21
27
  uses: paambaati/codeclimate-action@v2.5.3
22
28
  env:
23
- CC_TEST_REPORTER_ID: 0e4e712966b3d2fdf63128dc4d0c863fd4c61888b557ffb1673111b4c8b3bdc9
29
+ CC_TEST_REPORTER_ID: ${{ secrets.CC_TEST_REPORTER_ID }}
24
30
  with:
25
31
  coverageCommand: bundle exec rspec
26
32
  debug: false
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- conifer (1.1.0)
4
+ conifer (1.2.0)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
@@ -16,7 +16,7 @@ GEM
16
16
  parser (2.7.0.3)
17
17
  ast (~> 2.4.0)
18
18
  rainbow (3.0.0)
19
- rake (10.5.0)
19
+ rake (13.0.1)
20
20
  rexml (3.2.4)
21
21
  rspec (3.8.0)
22
22
  rspec-core (~> 3.8.0)
@@ -56,7 +56,7 @@ DEPENDENCIES
56
56
  bundler (~> 1.17)
57
57
  climate_control (~> 0.2)
58
58
  conifer!
59
- rake (~> 10.0)
59
+ rake (~> 13.0)
60
60
  rspec (~> 3.0)
61
61
  rubocop (~> 0.80)
62
62
  rubocop-rspec (~> 1.38)
@@ -26,7 +26,7 @@ Gem::Specification.new do |spec|
26
26
 
27
27
  spec.add_development_dependency 'bundler', '~> 1.17'
28
28
  spec.add_development_dependency 'climate_control', '~> 0.2'
29
- spec.add_development_dependency 'rake', '~> 10.0'
29
+ spec.add_development_dependency 'rake', '~> 13.0'
30
30
  spec.add_development_dependency 'rspec', '~> 3.0'
31
31
  spec.add_development_dependency 'rubocop', '~> 0.80'
32
32
  spec.add_development_dependency 'rubocop-rspec', '~> 1.38'
@@ -10,8 +10,8 @@ module Conifer
10
10
 
11
11
  # rubocop:disable Metrics/ParameterLists
12
12
  module ClassMethods
13
- def conifer(name, prefix: nil, dir: nil, method: ::File.basename(name.to_s, '.yml'), singleton: false,
14
- allowed_classes: [])
13
+ def conifer(name, prefix: nil, dir: nil, format: :yml, method: ::File.basename(name.to_s, ".#{format}"),
14
+ singleton: false, allowed_classes: [])
15
15
  dir ||= ::File.expand_path(::File.dirname(caller_locations.first.path))
16
16
 
17
17
  body = proc do
@@ -6,13 +6,15 @@ require 'erb'
6
6
  module Conifer
7
7
  class File
8
8
  NotFoundError = Class.new(StandardError)
9
+ UnsupportedFormatError = Class.new(StandardError)
9
10
 
10
- attr_reader :name, :prefix, :dir, :allowed_classes
11
+ attr_reader :name, :dir, :prefix, :format, :allowed_classes
11
12
 
12
- def initialize(name, dir:, prefix: nil, allowed_classes: [])
13
+ def initialize(name, dir:, prefix: nil, format: :yml, allowed_classes: [])
13
14
  @name = name
14
- @prefix = prefix
15
15
  @dir = dir
16
+ @prefix = prefix
17
+ @format = format
16
18
  @allowed_classes = allowed_classes
17
19
  end
18
20
 
@@ -22,7 +24,14 @@ module Conifer
22
24
  end
23
25
 
24
26
  def parsed
25
- @parsed ||= YAML.safe_load(ERB.new(::File.read(path)).result, allowed_classes)
27
+ @parsed ||= case format
28
+ when :yml, :yaml
29
+ YAML.safe_load(ERB.new(::File.read(path)).result, allowed_classes)
30
+ when :json
31
+ JSON.parse(ERB.new(::File.read(path)).result)
32
+ else
33
+ raise UnsupportedFormatError, "Format '#{format}' is not supported"
34
+ end
26
35
  end
27
36
 
28
37
  def path
@@ -36,7 +45,7 @@ module Conifer
36
45
  end
37
46
 
38
47
  def filename
39
- "#{::File.basename(name.to_s, '.yml')}.yml"
48
+ "#{::File.basename(name.to_s, ".#{format}")}.#{format}"
40
49
  end
41
50
 
42
51
  def validate!
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Conifer
4
- VERSION = '1.1.0'
4
+ VERSION = '1.2.0'
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: conifer
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.0
4
+ version: 1.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Hamed Asghari
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2020-02-27 00:00:00.000000000 Z
11
+ date: 2020-03-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -44,14 +44,14 @@ dependencies:
44
44
  requirements:
45
45
  - - "~>"
46
46
  - !ruby/object:Gem::Version
47
- version: '10.0'
47
+ version: '13.0'
48
48
  type: :development
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
52
  - - "~>"
53
53
  - !ruby/object:Gem::Version
54
- version: '10.0'
54
+ version: '13.0'
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: rspec
57
57
  requirement: !ruby/object:Gem::Requirement