Skip to content

Commit 8e19b2c

Browse files
purinklearnaudbesnier
authored andcommitted
[+] Configurations - Users can specify the directory for Forest Smart Implementation (#327)
1 parent 8e90ba4 commit 8e19b2c

File tree

4 files changed

+32
-2
lines changed

4 files changed

+32
-2
lines changed

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
# Change Log
22

33
## [Unreleased]
4+
### Added
5+
- Configuration - Add initialisation of configuration directories
6+
47
### Changed
58
- Readme - Add a community section.
69
- Readme - Remove the Licence section as it is already accessible in the Github page header.

lib/forest_liana.rb

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,19 @@ module UserSpace
3737
self.names_overriden = {}
3838
self.meta = {}
3939

40+
@config_dir = 'lib/forest_liana/**/*.rb'
41+
4042
# TODO: Remove once lianas prior to 2.0.0 are not supported anymore.
4143
self.names_old_overriden = {}
4244

45+
def self.config_dir=(config_dir)
46+
@config_dir = config_dir
47+
end
48+
49+
def self.config_dir
50+
Rails.root.join(@config_dir)
51+
end
52+
4353
def self.schema_for_resource resource
4454
self.apimap.find do |collection|
4555
SchemaUtils.find_model_from_collection_name(collection.name)

lib/forest_liana/bootstraper.rb

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -211,8 +211,7 @@ def create_apimap
211211
end
212212

213213
def require_lib_forest_liana
214-
path = Rails.root.join('lib', 'forest_liana', '**', '*.rb')
215-
Dir.glob(File.expand_path(path, __FILE__)).each do |file|
214+
Dir.glob(ForestLiana.config_dir).each do |file|
216215
load file
217216
end
218217
end

test/forest_liana_test.rb

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,22 @@ class ForestLianaTest < ActiveSupport::TestCase
44
test "truth" do
55
assert_kind_of Module, ForestLiana
66
end
7+
8+
test 'config_dirs with no value set' do
9+
assert_equal(
10+
Rails.root.join('lib/forest_liana/**/*.rb'),
11+
ForestLiana.config_dir
12+
)
13+
end
14+
15+
test 'config_dirs with a value set' do
16+
ForestLiana.config_dir = 'lib/custom/**/*.rb'
17+
18+
assert_equal(
19+
Rails.root.join('lib/custom/**/*.rb'),
20+
ForestLiana.config_dir
21+
)
22+
23+
ForestLiana.config_dir = nil
24+
end
725
end

0 commit comments

Comments
 (0)