core-loader 0.1.1 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 9650cdc4cda182f6e2603097b50e055c24d46701d899293b67408fd86cd61f04
4
- data.tar.gz: 121fab36735f4e8b8ddd5b1709b0a1b34f7a6fc314a356dbe49a448b44f331a9
3
+ metadata.gz: 1484ad0d5e2736ca252c0ec67308556dd0b45bffdfb8cd51756f1a4007d87bc6
4
+ data.tar.gz: beb2f418301e05f53bed4dec557126cd37fd4633b6769987718e1243e06296a2
5
5
  SHA512:
6
- metadata.gz: 2350e78fa80a8002d3a514a459520d2aeaad1fc16cd51bc34e2554cb4a01916df64c157553065448307f51196fe9386a42ecf81eb7681e5e0caefd5106fe336b
7
- data.tar.gz: 1152ea9b2baf7d991dd1bdbb9380ee6b22d408b64268f15318de0d62336553bcda683114b2f255c9f895f8e86f90a5c96ba890fb257de7952b55e84db45fab11
6
+ metadata.gz: 9f5746e5b02cd234aa4a3b741505fb284d1c21cc8f803e59fe23e5294da1530d6d1e0679550e07cabda01a6047e348d65c6dc2f62959792a73f71cf239bdc3d3
7
+ data.tar.gz: 629be77c6e72453a2ecd2c811324fcc162e387883d582f27ff3c61fa6d2dccbe9956b985bc5a1b1ef9ac77d7edbaea6c37e6f94f664a1e27e21f3e5866d6e564
data/CHANGELOG.md CHANGED
@@ -1,26 +1,33 @@
1
- ## [v0.1.1](https://github.com/metabahn/corerb/releases/tag/2022-01-08)
1
+ ## [v0.2.0](https://github.com/bryanp/corerb/releases/tag/2023-12-24)
2
+
3
+ *released on 2023-12-24*
4
+
5
+ * `dep` [#143](https://github.com/bryanp/corerb/pull/143) Deprecate `Is::*` and `Refine::*` namespaces ([bryanp](https://github.com/bryanp))
6
+ * `dep` [#135](https://github.com/bryanp/corerb/pull/135) Remove Ruby 2 support ([bryanp](https://github.com/bryanp))
7
+
8
+ ## [v0.1.1](https://github.com/bryanp/corerb/releases/tag/2022-01-08)
2
9
 
3
10
  *released on 2022-01-08*
4
11
 
5
- * `fix` [#117](https://github.com/metabahn/corerb/pull/117) Explicitly define makeables in loader, resolving some context issues ([bryanp](https://github.com/bryanp))
12
+ * `fix` [#117](https://github.com/bryanp/corerb/pull/117) Explicitly define makeables in loader, resolving some context issues ([bryanp](https://github.com/bryanp))
6
13
 
7
- ## [v0.1.0](https://github.com/metabahn/corerb/releases/tag/2022-01-07)
14
+ ## [v0.1.0](https://github.com/bryanp/corerb/releases/tag/2022-01-07)
8
15
 
9
16
  *released on 2022-01-07*
10
17
 
11
- * `chg` [#115](https://github.com/metabahn/corerb/pull/115) Make the loader context configurable ([bryanp](https://github.com/bryanp))
12
- * `chg` [#114](https://github.com/metabahn/corerb/pull/114) Add an explicit strict option to loader ([bryanp](https://github.com/bryanp))
18
+ * `chg` [#115](https://github.com/bryanp/corerb/pull/115) Make the loader context configurable ([bryanp](https://github.com/bryanp))
19
+ * `chg` [#114](https://github.com/bryanp/corerb/pull/114) Add an explicit strict option to loader ([bryanp](https://github.com/bryanp))
13
20
 
14
- ## [v0.0.1](https://github.com/metabahn/corerb/releases/tag/2021-11-23.1)
21
+ ## [v0.0.1](https://github.com/bryanp/corerb/releases/tag/2021-11-23.1)
15
22
 
16
23
  *released on 2021-11-23*
17
24
 
18
- * `chg` [#109](https://github.com/metabahn/corerb/pull/109) Prefer `__send__` to `send` ([bryanp](https://github.com/bryanp))
25
+ * `chg` [#109](https://github.com/bryanp/corerb/pull/109) Prefer `__send__` to `send` ([bryanp](https://github.com/bryanp))
19
26
 
20
- ## [v0.0.0](https://github.com/metabahn/corerb/releases/tag/2021-11-02)
27
+ ## [v0.0.0](https://github.com/bryanp/corerb/releases/tag/2021-11-02)
21
28
 
22
29
  *released on 2021-11-02*
23
30
 
24
- * `add` [#94](https://github.com/metabahn/corerb/pull/94) Initial implementation of the core-loader gem ([bryanp](https://github.com/bryanp))
31
+ * `add` [#94](https://github.com/bryanp/corerb/pull/94) Initial implementation of the core-loader gem ([bryanp](https://github.com/bryanp))
25
32
 
26
33
 
@@ -2,7 +2,7 @@
2
2
 
3
3
  module Core
4
4
  module Loader
5
- VERSION = "0.1.1"
5
+ VERSION = "0.2.0"
6
6
 
7
7
  # [public]
8
8
  #
data/lib/core/loader.rb CHANGED
@@ -1,7 +1,90 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require "core/extension"
4
+ require "core/state"
5
+
3
6
  module Core
7
+ # [public]
8
+ #
4
9
  module Loader
10
+ require_relative "loader/context"
5
11
  require_relative "loader/version"
12
+
13
+ extend Core::Extension
14
+
15
+ extends dependencies: [Core::State]
16
+
17
+ extends :definition do
18
+ # [public]
19
+ #
20
+ def loads(definable, path, pattern: "*.rb", strict: true, context: Core::Loader::Context)
21
+ unless ancestors.include?(Core::Factory) && makes?(definable)
22
+ raise "cannot load unknown object `#{definable}`"
23
+ end
24
+
25
+ __loads__[definable.to_sym] = {
26
+ type: definable,
27
+ path: Pathname(path),
28
+ pattern: pattern,
29
+ strict: strict,
30
+ context: context
31
+ }
32
+ end
33
+
34
+ # [public]
35
+ #
36
+ def load(reload: false)
37
+ loadable = []
38
+
39
+ __loads__.each_pair do |definable, options|
40
+ find_loadable_paths(options[:path], options, loadable)
41
+ end
42
+
43
+ while (loadable_path, loadable_options = loadable.shift)
44
+ if reload || !loaded?(loadable_path)
45
+ loadable_options[:context].load(
46
+ path: loadable_path,
47
+ root: loadable_options[:path],
48
+ type: loadable_options[:type],
49
+ strict: loadable_options[:strict],
50
+ target: self
51
+ )
52
+
53
+ __loaded_paths__ << loadable_path
54
+ end
55
+ end
56
+ end
57
+
58
+ # [public]
59
+ #
60
+ def reload
61
+ load(reload: true)
62
+ end
63
+
64
+ # [public]
65
+ #
66
+ def reset
67
+ __loaded_paths__.clear
68
+ end
69
+
70
+ private def loaded?(path)
71
+ __loaded_paths__.include?(Pathname(path))
72
+ end
73
+
74
+ private def find_loadable_paths(path, options, loadable)
75
+ path.glob(options[:pattern]).sort.each do |each_path|
76
+ loadable << [each_path, options]
77
+ end
78
+
79
+ path.glob("*").select(&:directory?).sort.each do |each_path|
80
+ find_loadable_paths(each_path, options, loadable)
81
+ end
82
+ end
83
+ end
84
+
85
+ applies do
86
+ state :__loads__, :class, default: {}
87
+ state :__loaded_paths__, :class, default: []
88
+ end
6
89
  end
7
90
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: core-loader
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Bryan Powell
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-01-09 00:00:00.000000000 Z
11
+ date: 2023-12-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: core-extension
@@ -16,44 +16,44 @@ dependencies:
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: '0.3'
19
+ version: '0.5'
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: '0.3'
26
+ version: '0.5'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: core-factory
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
31
  - - "~>"
32
32
  - !ruby/object:Gem::Version
33
- version: '0.0'
33
+ version: '0.2'
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
38
  - - "~>"
39
39
  - !ruby/object:Gem::Version
40
- version: '0.0'
40
+ version: '0.2'
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: core-state
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
45
  - - "~>"
46
46
  - !ruby/object:Gem::Version
47
- version: '0.1'
47
+ version: '0.2'
48
48
  type: :runtime
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: '0.1'
54
+ version: '0.2'
55
55
  description: Load Ruby objects from the filesystem.
56
- email: bryan@metabahn.com
56
+ email: bryan@bryanp.org
57
57
  executables: []
58
58
  extensions: []
59
59
  extra_rdoc_files: []
@@ -63,8 +63,7 @@ files:
63
63
  - lib/core/loader.rb
64
64
  - lib/core/loader/context.rb
65
65
  - lib/core/loader/version.rb
66
- - lib/is/loadable.rb
67
- homepage: https://github.com/metabahn/corerb/
66
+ homepage: https://github.com/bryanp/corerb/
68
67
  licenses:
69
68
  - MPL-2.0
70
69
  metadata: {}
@@ -76,14 +75,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
76
75
  requirements:
77
76
  - - ">="
78
77
  - !ruby/object:Gem::Version
79
- version: '2.7'
78
+ version: '3.0'
80
79
  required_rubygems_version: !ruby/object:Gem::Requirement
81
80
  requirements:
82
81
  - - ">="
83
82
  - !ruby/object:Gem::Version
84
83
  version: '0'
85
84
  requirements: []
86
- rubygems_version: 3.2.22
85
+ rubygems_version: 3.5.1
87
86
  signing_key:
88
87
  specification_version: 4
89
88
  summary: Load Ruby objects from the filesystem.
data/lib/is/loadable.rb DELETED
@@ -1,89 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require "is/extension"
4
- require "is/stateful"
5
-
6
- require_relative "../core/loader/context"
7
-
8
- module Is
9
- # [public]
10
- #
11
- module Loadable
12
- extend Is::Extension
13
-
14
- extends dependencies: [Is::Stateful]
15
-
16
- extends :definition do
17
- # [public]
18
- #
19
- def loads(definable, path, pattern: "*.rb", strict: true, context: Core::Loader::Context)
20
- unless ancestors.include?(Is::Factory) && makes?(definable)
21
- raise "cannot load unknown object `#{definable}`"
22
- end
23
-
24
- __loads__[definable.to_sym] = {
25
- type: definable,
26
- path: Pathname(path),
27
- pattern: pattern,
28
- strict: strict,
29
- context: context
30
- }
31
- end
32
-
33
- # [public]
34
- #
35
- def load(reload: false)
36
- loadable = []
37
-
38
- __loads__.each_pair do |definable, options|
39
- find_loadable_paths(options[:path], options, loadable)
40
- end
41
-
42
- while (loadable_path, loadable_options = loadable.shift)
43
- if reload || !loaded?(loadable_path)
44
- loadable_options[:context].load(
45
- path: loadable_path,
46
- root: loadable_options[:path],
47
- type: loadable_options[:type],
48
- strict: loadable_options[:strict],
49
- target: self
50
- )
51
-
52
- __loaded_paths__ << loadable_path
53
- end
54
- end
55
- end
56
-
57
- # [public]
58
- #
59
- def reload
60
- load(reload: true)
61
- end
62
-
63
- # [public]
64
- #
65
- def reset
66
- __loaded_paths__.clear
67
- end
68
-
69
- private def loaded?(path)
70
- __loaded_paths__.include?(Pathname(path))
71
- end
72
-
73
- private def find_loadable_paths(path, options, loadable)
74
- path.glob(options[:pattern]).sort.each do |each_path|
75
- loadable << [each_path, options]
76
- end
77
-
78
- path.glob("*").select(&:directory?).sort.each do |each_path|
79
- find_loadable_paths(each_path, options, loadable)
80
- end
81
- end
82
- end
83
-
84
- applies do
85
- state :__loads__, :class, default: {}
86
- state :__loaded_paths__, :class, default: []
87
- end
88
- end
89
- end