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 +4 -4
- data/.github/workflows/ruby.yml +20 -0
- data/.rubocop.yml +3 -0
- data/Gemfile.lock +1 -16
- data/conifer.gemspec +0 -2
- data/lib/conifer.rb +7 -7
- data/lib/conifer/file.rb +23 -13
- data/lib/conifer/version.rb +1 -1
- metadata +2 -15
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 242c45c7c55f650e17a190ab1451c4c44600d737881d8a2e37c10291c46f9e48
|
4
|
+
data.tar.gz: 160ef67508c13a2e05e3efc9aa4dce2dd07bfd41c16979da8c77dc6b96bac2a4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
data/Gemfile.lock
CHANGED
@@ -1,23 +1,12 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
conifer (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
|
-
|
7
|
+
def self.included(base)
|
8
|
+
base.extend ClassMethods
|
9
|
+
end
|
10
10
|
|
11
|
-
|
12
|
-
def conifer(
|
13
|
-
|
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(
|
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
|
-
|
20
|
+
parsed.dig(*args)
|
21
21
|
end
|
22
22
|
|
23
|
-
def
|
24
|
-
|
23
|
+
def parsed
|
24
|
+
@parsed ||= YAML.safe_load(ERB.new(::File.read(path)).result)
|
25
25
|
end
|
26
26
|
|
27
|
-
|
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
|
30
|
-
|
37
|
+
def filename
|
38
|
+
"#{::File.basename(name.to_s, '.yml')}.yml"
|
31
39
|
end
|
32
40
|
|
33
|
-
def
|
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
|
-
|
53
|
+
return if directory == '/'
|
40
54
|
|
41
|
-
|
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
|
data/lib/conifer/version.rb
CHANGED
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.
|
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"
|