conifer 0.3.0 → 1.0.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: e65067414f6a9fcaf9bde6230138b19174617dd99c94368d0bdacbfbb5b9a49f
4
- data.tar.gz: 3a307793593c2d0d07de4cd8ee9decfb10d72bec471343dec51216a4b38dfa8a
3
+ metadata.gz: 242c45c7c55f650e17a190ab1451c4c44600d737881d8a2e37c10291c46f9e48
4
+ data.tar.gz: 160ef67508c13a2e05e3efc9aa4dce2dd07bfd41c16979da8c77dc6b96bac2a4
5
5
  SHA512:
6
- metadata.gz: 77d67b7c3bc8a97cd4f40b55db432b499c7a496adf7638f7b1dc14f6636c4efefcbfabc73b736347e1dcb591b0579fcb6d5180b8893cc3ab2f6bde9d375ce765
7
- data.tar.gz: 34ac10cf5e9c5c8d3f92ee867f8639ab54fe2e2e8944fe76c0f05a035904db60b1d3b7907dbcee74ac7b313246e4425c2355eaa1f2fa3d0ce9f44dc46ad393cd
6
+ metadata.gz: 4ddc85687be772047571e4c7f56a60e4b2b44f867828de6abc5e38c308467faba238b51c4a6b2d1f880dbb53d9df8938ec1714b96044026b4843d356b0be61b9
7
+ data.tar.gz: 2567e3a020b165acdb8479ffe2b54163c69fe231814fa89a39eddb0df08751b2d305eccd663b44df07d0220d4caa22db78a122cb4c49ef2fef53b2beb780b346
@@ -0,0 +1,20 @@
1
+ name: Ruby
2
+
3
+ on: [push]
4
+
5
+ jobs:
6
+ build:
7
+
8
+ runs-on: ubuntu-latest
9
+
10
+ steps:
11
+ - uses: actions/checkout@v2
12
+ - name: Set up Ruby 2.6
13
+ uses: actions/setup-ruby@v1
14
+ with:
15
+ ruby-version: 2.6.x
16
+ - name: Build and test with RSpec
17
+ run: |
18
+ gem install bundler -v 1.17.3 --no-document
19
+ bundle install --jobs 4 --retry 3
20
+ bundle exec rspec
data/.rubocop.yml CHANGED
@@ -14,3 +14,6 @@ Style/PercentLiteralDelimiters:
14
14
  '%W': '()'
15
15
  '%i': '()'
16
16
  '%I': '()'
17
+
18
+ Style/NumericLiterals:
19
+ Enabled: false
data/Gemfile.lock CHANGED
@@ -1,23 +1,12 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- conifer (0.3.0)
5
- activesupport (>= 5.0.0)
4
+ conifer (1.0.0)
6
5
 
7
6
  GEM
8
7
  remote: https://rubygems.org/
9
8
  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)
16
- concurrent-ruby (1.1.6)
17
9
  diff-lcs (1.3)
18
- i18n (1.8.2)
19
- concurrent-ruby (~> 1.0)
20
- minitest (5.14.0)
21
10
  rake (10.5.0)
22
11
  rspec (3.8.0)
23
12
  rspec-core (~> 3.8.0)
@@ -32,10 +21,6 @@ GEM
32
21
  diff-lcs (>= 1.2.0, < 2.0)
33
22
  rspec-support (~> 3.8.0)
34
23
  rspec-support (3.8.2)
35
- thread_safe (0.3.6)
36
- tzinfo (1.2.6)
37
- thread_safe (~> 0.1)
38
- zeitwerk (2.2.2)
39
24
 
40
25
  PLATFORMS
41
26
  ruby
data/conifer.gemspec CHANGED
@@ -24,8 +24,6 @@ Gem::Specification.new do |spec|
24
24
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
25
25
  spec.require_paths = ['lib']
26
26
 
27
- spec.add_dependency 'activesupport', '>= 5.0.0'
28
-
29
27
  spec.add_development_dependency 'bundler', '~> 1.17'
30
28
  spec.add_development_dependency 'rake', '~> 10.0'
31
29
  spec.add_development_dependency 'rspec', '~> 3.0'
data/lib/conifer.rb CHANGED
@@ -3,19 +3,19 @@
3
3
  require 'conifer/version'
4
4
  require 'conifer/file'
5
5
 
6
- require 'active_support/concern'
7
-
8
6
  module Conifer
9
- extend ActiveSupport::Concern
7
+ def self.included(base)
8
+ base.extend ClassMethods
9
+ end
10
10
 
11
- class_methods do
12
- def conifer(file, prefix: nil, dir: nil, method: ::File.basename(file.to_s, '.yml'), singleton: false)
13
- directory = dir || ::File.expand_path(::File.dirname(caller_locations.first.path))
11
+ module ClassMethods
12
+ def conifer(name, prefix: nil, dir: nil, method: ::File.basename(name.to_s, '.yml'), singleton: false)
13
+ dir ||= ::File.expand_path(::File.dirname(caller_locations.first.path))
14
14
 
15
15
  body = proc do
16
16
  return instance_variable_get("@conifer_#{method}") if instance_variable_defined?("@conifer_#{method}")
17
17
 
18
- instance_variable_set "@conifer_#{method}", Conifer::File.new(file, prefix: prefix, dir: directory)
18
+ instance_variable_set "@conifer_#{method}", Conifer::File.new(name, prefix: prefix, dir: dir).tap(&:validate!)
19
19
  end
20
20
 
21
21
  if singleton
data/lib/conifer/file.rb CHANGED
@@ -17,33 +17,43 @@ module Conifer
17
17
 
18
18
  def [](key)
19
19
  args = key.split('.').tap { |v| v.prepend(prefix) if prefix }
20
- config.dig(*args)
20
+ parsed.dig(*args)
21
21
  end
22
22
 
23
- def as_hash
24
- config
23
+ def parsed
24
+ @parsed ||= YAML.safe_load(ERB.new(::File.read(path)).result)
25
25
  end
26
26
 
27
- private
27
+ def path
28
+ return @path if defined? @path
29
+
30
+ @path = find_path
31
+ end
32
+
33
+ def exists?
34
+ !path.nil?
35
+ end
28
36
 
29
- def config
30
- @config ||= YAML.safe_load(ERB.new(::File.read(path)).result)
37
+ def filename
38
+ "#{::File.basename(name.to_s, '.yml')}.yml"
31
39
  end
32
40
 
33
- def path(directory = dir)
41
+ def validate!
42
+ raise NotFoundError, "Could not find file #{filename}" if path.nil?
43
+ end
44
+
45
+ private
46
+
47
+ def find_path(directory = dir)
34
48
  file = ::File.join(directory, filename).to_s
35
49
 
36
50
  if ::File.exist?(file)
37
51
  file
38
52
  else
39
- raise NotFoundError, "Could not find file #{filename}" if directory == '/'
53
+ return if directory == '/'
40
54
 
41
- path(::File.expand_path('..', directory))
55
+ find_path(::File.expand_path('..', directory))
42
56
  end
43
57
  end
44
-
45
- def filename
46
- "#{::File.basename(name.to_s, '.yml')}.yml"
47
- end
48
58
  end
49
59
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Conifer
4
- VERSION = '0.3.0'
4
+ VERSION = '1.0.0'
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: conifer
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 1.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Hamed Asghari
@@ -10,20 +10,6 @@ bindir: exe
10
10
  cert_chain: []
11
11
  date: 2020-02-26 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.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.0
27
13
  - !ruby/object:Gem::Dependency
28
14
  name: bundler
29
15
  requirement: !ruby/object:Gem::Requirement
@@ -73,6 +59,7 @@ executables: []
73
59
  extensions: []
74
60
  extra_rdoc_files: []
75
61
  files:
62
+ - ".github/workflows/ruby.yml"
76
63
  - ".gitignore"
77
64
  - ".rspec"
78
65
  - ".rubocop.yml"