modulation 1.0 → 1.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +5 -0
- data/README.md +11 -2
- data/lib/modulation/exports.rb +20 -2
- data/lib/modulation/version.rb +1 -1
- metadata +31 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 79d44ad3050dcd57ba2c0ca917d16179197fa4ffe12e12aa7de42a050e8872c3
|
4
|
+
data.tar.gz: 643f1853f37b82fe0e49f62d99db0120696d5e0fa11b4d93faa5d0b9eed60070
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3df78b0f925e7d2f6ddd5547c46755d51a89a76f6aba84bdd02871e456de7bdbbd1c458e46f92d7cbbd3c782b8051abfac3ace1b60853e97e7fc3694e90b3c7b
|
7
|
+
data.tar.gz: f7ae45414fca8d849e521efc4980e6a30b9dd1678b9f21a2b8ce438626369e77845bef4cd4be676bd67cdeb39e2b05153d9a9e5b7f9134818d7beba93280bd17
|
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
@@ -1,5 +1,9 @@
|
|
1
1
|
# Modulation - Explicit Dependency Management for Ruby
|
2
2
|
|
3
|
+
[![Gem Version](https://badge.fury.io/rb/modulation.svg)](http://rubygems.org/gems/modulation)
|
4
|
+
[![Modulation Test](https://github.com/digital-fabric/modulation/workflows/Tests/badge.svg)](https://github.com/digital-fabric/modulation/actions?query=workflow%3ATests)
|
5
|
+
[![MIT licensed](https://img.shields.io/badge/license-MIT-blue.svg)](https://github.com/digital-fabric/modulation/blob/master/LICENSE)
|
6
|
+
|
3
7
|
> Modulation | mɒdjʊˈleɪʃ(ə)n | *Music* - a change from one key to another in a
|
4
8
|
> piece of music.
|
5
9
|
|
@@ -9,6 +13,7 @@
|
|
9
13
|
[EXAMPLES](examples) |
|
10
14
|
[RDOC](https://www.rubydoc.info/gems/modulation/)
|
11
15
|
|
16
|
+
|
12
17
|
Modulation provides an alternative way of organizing your Ruby code. Modulation
|
13
18
|
lets you explicitly import and export declarations in order to better control
|
14
19
|
dependencies in your codebase. Modulation helps you refrain from littering
|
@@ -109,8 +114,9 @@ Each source file is evaluated in the context of a newly-created `Module`
|
|
109
114
|
instance, with some additional methods for introspection and miscellaneous
|
110
115
|
operations such as [hot reloading](#reloading-modules).
|
111
116
|
|
112
|
-
Modulation provides
|
113
|
-
`require` and `require_relative`,
|
117
|
+
Modulation provides alternative APIs for loading modules. Instead of using
|
118
|
+
`require` and `require_relative`, we use `import`, `import_map` etc, discussed
|
119
|
+
in detail in the [API reference](#api-reference).
|
114
120
|
|
115
121
|
## Basic Usage
|
116
122
|
|
@@ -818,6 +824,9 @@ directory path. Modules are loaded automatically upon accessing hash keys.
|
|
818
824
|
|
819
825
|
#### `Kernel#import(path)`
|
820
826
|
|
827
|
+
Returns a loaded module identified by the given path. The path can contain
|
828
|
+
[tags](#using-tags-to-designate-common-subdirectories)
|
829
|
+
|
821
830
|
#### `Kernel#import_all(path)`
|
822
831
|
|
823
832
|
#### `Kernel#import_map(path, options = {})`
|
data/lib/modulation/exports.rb
CHANGED
@@ -127,14 +127,32 @@ module Modulation
|
|
127
127
|
def process_module_constants(mod, singleton, symbols, defined_constants)
|
128
128
|
private_constants = mod.__module_info[:private_constants] = []
|
129
129
|
defined_constants.each do |sym|
|
130
|
+
next if sym == :MODULE
|
131
|
+
|
132
|
+
value = singleton.const_get(sym)
|
133
|
+
define_const_inspect_methods(mod, sym, value) if value.is_a?(Module)
|
134
|
+
|
130
135
|
if symbols.include?(sym)
|
131
|
-
mod.const_set(sym,
|
136
|
+
mod.const_set(sym, value)
|
132
137
|
else
|
133
|
-
private_constants << sym
|
138
|
+
private_constants << sym
|
134
139
|
end
|
135
140
|
end
|
136
141
|
end
|
137
142
|
|
143
|
+
CONST_INSPECT_CODE = <<~EOF
|
144
|
+
def inspect
|
145
|
+
"(%s)::%s"
|
146
|
+
end
|
147
|
+
EOF
|
148
|
+
|
149
|
+
def define_const_inspect_methods(mod, sym, value)
|
150
|
+
if value.method(:inspect).source_location.nil?
|
151
|
+
code = format(CONST_INSPECT_CODE, mod.inspect, sym)
|
152
|
+
value.singleton_class.module_eval(code)
|
153
|
+
end
|
154
|
+
end
|
155
|
+
|
138
156
|
NOT_FOUND_MSG = '%s %s not found in module'
|
139
157
|
|
140
158
|
def raise_exported_symbol_not_found_error(sym, kind)
|
data/lib/modulation/version.rb
CHANGED
metadata
CHANGED
@@ -1,15 +1,43 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: modulation
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 1.0.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Sharon Rosner
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2021-04-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
13
41
|
- !ruby/object:Gem::Dependency
|
14
42
|
name: minitest
|
15
43
|
requirement: !ruby/object:Gem::Requirement
|
@@ -92,7 +120,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
92
120
|
- !ruby/object:Gem::Version
|
93
121
|
version: '0'
|
94
122
|
requirements: []
|
95
|
-
rubygems_version: 3.0.
|
123
|
+
rubygems_version: 3.0.8
|
96
124
|
signing_key:
|
97
125
|
specification_version: 4
|
98
126
|
summary: 'Modulation: explicit dependency management for Ruby'
|