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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: a81a52fa3760bfbda94193a1e1de70bd498dd8112455ec774fc9b5735bf8fbfa
4
- data.tar.gz: 37e1ca88843461ccc8e3d137e4c686d3969641a381210ec7cb40a0215ec184c4
3
+ metadata.gz: 79d44ad3050dcd57ba2c0ca917d16179197fa4ffe12e12aa7de42a050e8872c3
4
+ data.tar.gz: 643f1853f37b82fe0e49f62d99db0120696d5e0fa11b4d93faa5d0b9eed60070
5
5
  SHA512:
6
- metadata.gz: 2f57985001fea20c87d1b8a7a1e06244fd21a52a5e1830177ee3d379e9cb81913a03dde161fdcc78fe4d7f14d8a486def00058cca2b01b8f8e233cb70b413107
7
- data.tar.gz: 0cbc73dc2b7684a7b63fe50c6d505175f78b894fa0b043991ae4591cfc38e1a3849c3ac6c4b7f50e1cdb190f8570e6e00cd4405cb3f95d9494aff7485cf64437
6
+ metadata.gz: 3df78b0f925e7d2f6ddd5547c46755d51a89a76f6aba84bdd02871e456de7bdbbd1c458e46f92d7cbbd3c782b8051abfac3ace1b60853e97e7fc3694e90b3c7b
7
+ data.tar.gz: f7ae45414fca8d849e521efc4980e6a30b9dd1678b9f21a2b8ce438626369e77845bef4cd4be676bd67cdeb39e2b05153d9a9e5b7f9134818d7beba93280bd17
data/CHANGELOG.md CHANGED
@@ -1,3 +1,8 @@
1
+ 1.0.1 2021-04-21
2
+ ----------------
3
+
4
+ * Override inspect method for classes defined in modules (#7)
5
+
1
6
  1.0 2019-10-18
2
7
  --------------
3
8
 
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 an alternative APIs for loading modules. Instead of using
113
- `require` and `require_relative`, you use `import`, `import_map` and other APIs.
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 = {})`
@@ -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, singleton.const_get(sym))
136
+ mod.const_set(sym, value)
132
137
  else
133
- private_constants << sym unless sym == :MODULE
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)
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Modulation
4
- VERSION = '1.0'
4
+ VERSION = '1.0.1'
5
5
  end
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: '1.0'
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: 2019-10-18 00:00:00.000000000 Z
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.6
123
+ rubygems_version: 3.0.8
96
124
  signing_key:
97
125
  specification_version: 4
98
126
  summary: 'Modulation: explicit dependency management for Ruby'