expand 1.0.4 → 1.0.5
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/LICENSE.txt +1 -1
- data/Rakefile +2 -2
- data/lib/expand/version.rb +1 -1
- data/lib/expand.rb +26 -17
- metadata +4 -11
- data/.github/dependabot.yml +0 -8
- data/.github/workflows/test.yml +0 -37
- data/.gitignore +0 -9
- data/Gemfile +0 -8
- data/bin/console +0 -14
- data/bin/setup +0 -8
- data/expand.gemspec +0 -21
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1c749a422399f6bef2c67bd4ab1503cfd5d3ab99a912b2164c6930931d2861ad
|
4
|
+
data.tar.gz: e5639cd2f02dae004d3e7d60eac7a2a3eeace870eb2022ca778d785d451b5d20
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3fd15dae2380332348db1806ae0ec289ac57a936404df715d2cb0418cbafd009f213df5d958699510b0d4eed668355ffcba681feb8927adb5fa5e24f87dc0700
|
7
|
+
data.tar.gz: e4197b51d7e9c5c352492c418bae31e385efb17aac68ef0db5d5fe2fbcebe5b9e6397e227d3d0911a81f1fc9044b77412eaf2e3964c1785473bae8f35a00905b
|
data/CHANGELOG.md
CHANGED
data/LICENSE.txt
CHANGED
data/Rakefile
CHANGED
data/lib/expand/version.rb
CHANGED
data/lib/expand.rb
CHANGED
@@ -2,7 +2,6 @@ require "expand/version"
|
|
2
2
|
|
3
3
|
# Extend your classes or modules to use the Expand methods
|
4
4
|
module Expand
|
5
|
-
|
6
5
|
# The primary way to access Manager objects is to use the Expand namespace method.
|
7
6
|
# @see Expand#namespace
|
8
7
|
#
|
@@ -48,6 +47,20 @@ module Expand
|
|
48
47
|
@managed.const_set(name, klass)
|
49
48
|
klass
|
50
49
|
end
|
50
|
+
|
51
|
+
def apply(&block)
|
52
|
+
instance_eval(&block)
|
53
|
+
@managed
|
54
|
+
end
|
55
|
+
|
56
|
+
def self.for(context)
|
57
|
+
unless context.is_a?(Module)
|
58
|
+
context = context.to_s.split("::").inject(Object) do |base, mod|
|
59
|
+
base.const_get(mod)
|
60
|
+
end
|
61
|
+
end
|
62
|
+
new(context)
|
63
|
+
end
|
51
64
|
end
|
52
65
|
|
53
66
|
# Allows you to open a module namespace to add constants
|
@@ -82,29 +95,25 @@ module Expand
|
|
82
95
|
# @see Expand::Manager#create_module
|
83
96
|
#
|
84
97
|
def namespace(context, **class_or_module, &block)
|
85
|
-
|
86
|
-
context = context.to_s.split('::').inject(Object) do |base, mod|
|
87
|
-
base.const_get(mod)
|
88
|
-
end
|
89
|
-
end
|
90
|
-
manager = Manager.new(context)
|
91
|
-
|
92
|
-
creating_class, creating_module = class_or_module[:class], class_or_module[:module]
|
93
|
-
raise ArgumentError, "You must choose either class: or module: but not both." if creating_class && creating_module
|
98
|
+
manager = Manager.for(context)
|
94
99
|
|
95
|
-
case
|
96
|
-
|
100
|
+
case class_or_module
|
101
|
+
in { module: Symbol => _creating_module, class: Symbol => _creating_class }
|
102
|
+
raise ArgumentError, "You must choose either class: or module: but not both."
|
103
|
+
in { class: Symbol => creating_class, ** }
|
97
104
|
parent = class_or_module[:parent] || Object
|
105
|
+
|
98
106
|
manager.create_class(creating_class, parent: parent, &block)
|
99
|
-
|
100
|
-
if class_or_module[:parent]
|
101
|
-
warn "An option for :parent was provided as `#{
|
107
|
+
in { module: Symbol => creating_module, ** }
|
108
|
+
if parent = class_or_module[:parent]
|
109
|
+
warn "An option for :parent was provided as `#{parent}' but was ignored when creating the module: #{creating_module}"
|
102
110
|
end
|
111
|
+
|
103
112
|
manager.create_module(creating_module, &block)
|
104
113
|
else
|
105
|
-
manager.
|
114
|
+
manager.apply(&block)
|
106
115
|
end
|
107
116
|
end
|
108
|
-
|
117
|
+
alias_method :expand, :namespace
|
109
118
|
module_function :expand, :namespace
|
110
119
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: expand
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
|
-
-
|
7
|
+
- Jim Gay
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2023-01-01 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: Create classes and modules under an existing namespace
|
14
14
|
email:
|
@@ -17,18 +17,11 @@ executables: []
|
|
17
17
|
extensions: []
|
18
18
|
extra_rdoc_files: []
|
19
19
|
files:
|
20
|
-
- ".github/dependabot.yml"
|
21
|
-
- ".github/workflows/test.yml"
|
22
|
-
- ".gitignore"
|
23
20
|
- CHANGELOG.md
|
24
21
|
- CODE_OF_CONDUCT.md
|
25
|
-
- Gemfile
|
26
22
|
- LICENSE.txt
|
27
23
|
- README.md
|
28
24
|
- Rakefile
|
29
|
-
- bin/console
|
30
|
-
- bin/setup
|
31
|
-
- expand.gemspec
|
32
25
|
- lib/expand.rb
|
33
26
|
- lib/expand/version.rb
|
34
27
|
homepage: https://github.com/saturnflyer/expand
|
@@ -50,7 +43,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
50
43
|
- !ruby/object:Gem::Version
|
51
44
|
version: '0'
|
52
45
|
requirements: []
|
53
|
-
rubygems_version: 3.
|
46
|
+
rubygems_version: 3.4.1
|
54
47
|
signing_key:
|
55
48
|
specification_version: 4
|
56
49
|
summary: Create classes and modules under an existing namespace
|
data/.github/dependabot.yml
DELETED
data/.github/workflows/test.yml
DELETED
@@ -1,37 +0,0 @@
|
|
1
|
-
# This workflow uses actions that are not certified by GitHub.
|
2
|
-
# They are provided by a third-party and are governed by
|
3
|
-
# separate terms of service, privacy policy, and support
|
4
|
-
# documentation.
|
5
|
-
# This workflow will download a prebuilt Ruby version, install dependencies and run tests with Rake
|
6
|
-
# For more information see: https://github.com/marketplace/actions/setup-ruby-jruby-and-truffleruby
|
7
|
-
|
8
|
-
name: Ruby
|
9
|
-
|
10
|
-
on:
|
11
|
-
push:
|
12
|
-
branches: [ "master" ]
|
13
|
-
pull_request:
|
14
|
-
branches: [ "master" ]
|
15
|
-
|
16
|
-
permissions:
|
17
|
-
contents: read
|
18
|
-
|
19
|
-
jobs:
|
20
|
-
test:
|
21
|
-
|
22
|
-
runs-on: ubuntu-latest
|
23
|
-
strategy:
|
24
|
-
matrix:
|
25
|
-
ruby-version: ['2.6', '2.7', '3.0', '3.1']
|
26
|
-
|
27
|
-
steps:
|
28
|
-
- uses: actions/checkout@v3
|
29
|
-
- name: Set up Ruby
|
30
|
-
# To automatically get bug fixes and new Ruby versions for ruby/setup-ruby,
|
31
|
-
# change this to (see https://github.com/ruby/setup-ruby#versioning):
|
32
|
-
uses: ruby/setup-ruby@v1
|
33
|
-
with:
|
34
|
-
ruby-version: ${{ matrix.ruby-version }}
|
35
|
-
bundler-cache: true # runs 'bundle install' and caches installed gems automatically
|
36
|
-
- name: Run tests
|
37
|
-
run: bundle exec rake
|
data/.gitignore
DELETED
data/Gemfile
DELETED
data/bin/console
DELETED
@@ -1,14 +0,0 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
|
3
|
-
require "bundler/setup"
|
4
|
-
require "expand"
|
5
|
-
|
6
|
-
# You can add fixtures and/or initialization code here to make experimenting
|
7
|
-
# with your gem easier. You can also use a different console, if you like.
|
8
|
-
|
9
|
-
# (If you use this, don't forget to add pry to your Gemfile!)
|
10
|
-
# require "pry"
|
11
|
-
# Pry.start
|
12
|
-
|
13
|
-
require "irb"
|
14
|
-
IRB.start
|
data/bin/setup
DELETED
data/expand.gemspec
DELETED
@@ -1,21 +0,0 @@
|
|
1
|
-
# coding: utf-8
|
2
|
-
lib = File.expand_path('../lib', __FILE__)
|
3
|
-
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
-
require 'expand/version'
|
5
|
-
|
6
|
-
Gem::Specification.new do |spec|
|
7
|
-
spec.name = "expand"
|
8
|
-
spec.version = Expand::VERSION
|
9
|
-
spec.authors = ["'Jim Gay'"]
|
10
|
-
spec.email = ["jim@saturnflyer.com"]
|
11
|
-
|
12
|
-
spec.summary = %q{Create classes and modules under an existing namespace}
|
13
|
-
spec.description = %q{Create classes and modules under an existing namespace}
|
14
|
-
spec.homepage = "https://github.com/saturnflyer/expand"
|
15
|
-
spec.license = "MIT"
|
16
|
-
|
17
|
-
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
18
|
-
spec.bindir = "exe"
|
19
|
-
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
20
|
-
spec.require_paths = ["lib"]
|
21
|
-
end
|