core-define 0.0.0 → 0.1.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: 79a4c5dcb3e446014cb23304ff6cebc09bbcdb0cf087648afa24c2c749fe4c92
4
- data.tar.gz: '089ba248453a5c005498648e40452677c2c79beb16b20bc71ab2d9296533629c'
3
+ metadata.gz: 546a6331dced26f191383e62daebae9b91ffb1c352c6b757e5268833df7fdf8c
4
+ data.tar.gz: 55477f27d167b4bbf87c084ca65fc1606df6abd371dbcad1cb3c5894764a5439
5
5
  SHA512:
6
- metadata.gz: 269e89b74547ea21d7cf6c39b24b513c1fdc776ce06f8789b868b5a9e3cbcc60d751c53aeffb593a90d22ab6bf5b258bf7f9587e8d6b4f9a97e384c8a2f449ad
7
- data.tar.gz: 06fa65f3e3f0503390e269d231d2c66d7fe2a02f94aa12cdf28d1681ca4f55b1b8f92777bc22d2c5ca69ccde3c64f97905eae03c926fbd57d173743965c4a9a0
6
+ metadata.gz: 9a43f7447d1b71371770b95e5b249a259eacf14ebda5bae619c45c7c004321450a5074d5f06047e28bacf7fa390365b042174abdd2f57198c9b50b13b7da9a0e
7
+ data.tar.gz: ee3980f0268d8b2009c1c5c01a0e8323f369f68858e3e29346a3d8eff807e6334851a24e27ca4616541fed9551a468fe90f61dfe77ac3b6d9f60b3f6c32c46f2
data/CHANGELOG.md CHANGED
@@ -1,3 +1,9 @@
1
+ ## [v0.1.0](https://github.com/metabahn/corerb/releases/tag/2021-11-02)
2
+
3
+ *released on 2021-11-02*
4
+
5
+ * `add` [#93](https://github.com/metabahn/corerb/pull/93) Allow locations to be passed to defined objects ([bryanp](https://github.com/bryanp))
6
+
1
7
  ## [v0.0.0](https://github.com/metabahn/corerb/releases/tag/2021-10-25)
2
8
 
3
9
  *released on 2021-10-25*
@@ -2,7 +2,7 @@
2
2
 
3
3
  module Core
4
4
  module Define
5
- VERSION = "0.0.0"
5
+ VERSION = "0.1.0"
6
6
 
7
7
  # [public]
8
8
  #
data/lib/is/definable.rb CHANGED
@@ -22,9 +22,15 @@ module Is
22
22
  end
23
23
 
24
24
  extends :definition, dependencies: [Is::Eventable] do
25
- # [public]
25
+ # [public] Defines an object by `name`, within `namespace`.
26
+ #
27
+ # Options passed as keyword arguments are defined as state on the new object.
26
28
  #
27
- def define(*namespace, name, **kwargs, &block)
29
+ # The `__location__` keyword argument is considered part of the public api and must be an instance of
30
+ # `Core::Define::Location`. It's passed using an internal naming convention to avoid possible collisions with
31
+ # other passed state. If not given, the object's location is based on `caller`.
32
+ #
33
+ def define(*namespace, name, __location__: nil, **kwargs, &block)
28
34
  scope = if namespace.any?
29
35
  define_namespace(*namespace)
30
36
  else
@@ -36,8 +42,16 @@ module Is
36
42
  if scope.const_defined?(constant)
37
43
  defined = scope.const_get(constant)
38
44
  else
39
- path, line = caller(1..1).first.split(":", 3)
40
- location = Core::Define::Location.new(path: path, line: line)
45
+ location = if __location__
46
+ unless __location__.respond_to?(:path) && __location__.respond_to?(:line)
47
+ raise ArgumentError, "expected location to respond to `path` and `line`"
48
+ end
49
+
50
+ __location__
51
+ else
52
+ path, line = caller(1..1).first.split(":", 3)
53
+ Core::Define::Location.new(path: path, line: line)
54
+ end
41
55
 
42
56
  performing "core.define" do
43
57
  # Create the right kind of object for `self`.
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: core-define
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.0
4
+ version: 0.1.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: 2021-10-26 00:00:00.000000000 Z
11
+ date: 2021-11-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: core-copy