conifer 0.1.0 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/lib/conifer.rb +13 -11
- data/lib/conifer/file.rb +6 -1
- data/lib/conifer/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9fad9f0c8078a29011a491e89bc57962e1924bbe41b3014fe46059ba6cc2a4f7
|
4
|
+
data.tar.gz: a945b31b79184f2850d7cd80a75c638da5ab62a6acd24392fe62294dea618520
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 687ae1f37561670156c2fb44e95b4b817af4785fa427b3526d68b884169c8586076cdce1abfaabddbe617881434a4ff586dcd20161ba915c4a61f07a33b6d62b
|
7
|
+
data.tar.gz: e40c1b9a9f8c5c3070b7593033abba374f70a9147c1b562b84af6cea5c0572de3e89302f716785a99424ac1e67a1f3127ed8e15371f6554f42452a078502ac30
|
data/Gemfile.lock
CHANGED
data/lib/conifer.rb
CHANGED
@@ -3,23 +3,25 @@
|
|
3
3
|
require 'conifer/version'
|
4
4
|
require 'conifer/file'
|
5
5
|
|
6
|
-
require 'active_support/
|
6
|
+
require 'active_support/concern'
|
7
7
|
|
8
8
|
module Conifer
|
9
9
|
extend ActiveSupport::Concern
|
10
10
|
|
11
|
-
included do
|
12
|
-
def conifer
|
13
|
-
self.class.__conifer
|
14
|
-
end
|
15
|
-
end
|
16
|
-
|
17
11
|
class_methods do
|
18
|
-
|
12
|
+
def conifer(file, prefix: nil, dir: nil, method: 'conifer', singleton: false)
|
13
|
+
body = proc do
|
14
|
+
return instance_variable_get("@conifer_#{method}") if instance_variable_defined?("@conifer_#{method}")
|
15
|
+
|
16
|
+
directory = dir || ::File.expand_path(::File.dirname(caller_locations.first.path))
|
17
|
+
instance_variable_set "@conifer_#{method}", Conifer::File.new(file, prefix: prefix, dir: directory)
|
18
|
+
end
|
19
19
|
|
20
|
-
|
21
|
-
|
22
|
-
|
20
|
+
if singleton
|
21
|
+
define_singleton_method method, &body
|
22
|
+
else
|
23
|
+
define_method method, &body
|
24
|
+
end
|
23
25
|
end
|
24
26
|
end
|
25
27
|
end
|
data/lib/conifer/file.rb
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
require 'yaml'
|
4
|
+
require 'erb'
|
4
5
|
|
5
6
|
module Conifer
|
6
7
|
class File
|
@@ -15,10 +16,14 @@ module Conifer
|
|
15
16
|
end
|
16
17
|
|
17
18
|
def [](key)
|
18
|
-
args = key.split('.').tap { |v| v.prepend(prefix) if prefix
|
19
|
+
args = key.split('.').tap { |v| v.prepend(prefix) if prefix }
|
19
20
|
config.dig(*args)
|
20
21
|
end
|
21
22
|
|
23
|
+
def as_hash
|
24
|
+
config
|
25
|
+
end
|
26
|
+
|
22
27
|
private
|
23
28
|
|
24
29
|
def config
|
data/lib/conifer/version.rb
CHANGED