expand 1.0.2 → 1.0.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/.github/dependabot.yml +8 -0
- data/.github/workflows/test.yml +37 -0
- data/CHANGELOG.md +13 -5
- data/Gemfile +4 -0
- data/README.md +15 -0
- data/expand.gemspec +0 -4
- data/lib/expand/version.rb +1 -1
- data/lib/expand.rb +19 -3
- metadata +9 -52
- data/.travis.yml +0 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 2ea9a1efdd9f3eb0013dcf094347e32d3c48aeb6d819d95d76a368c14de20862
|
4
|
+
data.tar.gz: d21f446e4e5a1d793da4cc23c9017d6e15ba80066905cd302e9be33e25cfff2f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0660ff8939459c77f34920c14d5b678ed5a8703bc3dfab0b2a523afd75a07b516e9d25596b0ca333ad3c3f52ae1fd623047bb4033961a68e306fef25970f8401
|
7
|
+
data.tar.gz: 3e51316a7a7a0b7c5ca31de138b6c09ebba2446f450166ce1a43ec4a1912b86f1cce7baf3c3e063bd05bd55c34513b67304a8ac99ddeb068b830102afde4d0ad
|
@@ -0,0 +1,37 @@
|
|
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/CHANGELOG.md
CHANGED
@@ -1,6 +1,14 @@
|
|
1
|
-
|
2
|
-
- allow specified namespace to be a module instead of a string
|
1
|
+
## 1.0.3
|
3
2
|
|
4
|
-
|
5
|
-
|
6
|
-
|
3
|
+
- allow the creation of a module or class in the namespace/expand method itself.
|
4
|
+
|
5
|
+
## 1.0.2
|
6
|
+
|
7
|
+
- Add documentation
|
8
|
+
|
9
|
+
## 1.0.1
|
10
|
+
- allow specified namespace to be a module instead of a string
|
11
|
+
|
12
|
+
## 1.0.0 (2016-01-14)
|
13
|
+
Initial release.
|
14
|
+
- allow creation of classes and modules under a namespace
|
data/Gemfile
CHANGED
data/README.md
CHANGED
@@ -34,6 +34,21 @@ end
|
|
34
34
|
SomeGem::Thing::NewThing #=> SomeGem::Thing::NewThing
|
35
35
|
```
|
36
36
|
|
37
|
+
And even simpler, you can do it all in one line:
|
38
|
+
|
39
|
+
```ruby
|
40
|
+
require 'expand'
|
41
|
+
extend Expand
|
42
|
+
|
43
|
+
namespace SomeGem::Thing, class: :NewThing, parent: SomeExistingOtherClass do
|
44
|
+
# define methods here
|
45
|
+
end
|
46
|
+
|
47
|
+
namespace SomeGem::Thing, class: :NewModule do
|
48
|
+
# define methods here
|
49
|
+
end
|
50
|
+
```
|
51
|
+
|
37
52
|
## Installation
|
38
53
|
|
39
54
|
Add this line to your application's Gemfile:
|
data/expand.gemspec
CHANGED
@@ -18,8 +18,4 @@ Gem::Specification.new do |spec|
|
|
18
18
|
spec.bindir = "exe"
|
19
19
|
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
20
20
|
spec.require_paths = ["lib"]
|
21
|
-
|
22
|
-
spec.add_development_dependency "bundler", "~> 1.11"
|
23
|
-
spec.add_development_dependency "rake", "~> 10.0"
|
24
|
-
spec.add_development_dependency "minitest", "~> 5.0"
|
25
21
|
end
|
data/lib/expand/version.rb
CHANGED
data/lib/expand.rb
CHANGED
@@ -8,7 +8,7 @@ module Expand
|
|
8
8
|
#
|
9
9
|
class Manager
|
10
10
|
# @see Expand#namespace
|
11
|
-
def initialize(namespace)
|
11
|
+
def initialize(namespace, **class_or_module, &block)
|
12
12
|
@managed = namespace
|
13
13
|
end
|
14
14
|
|
@@ -71,13 +71,29 @@ module Expand
|
|
71
71
|
# @see Expand::Manager#create_class
|
72
72
|
# @see Expand::Manager#create_module
|
73
73
|
#
|
74
|
-
def namespace(context, &block)
|
74
|
+
def namespace(context, **class_or_module, &block)
|
75
75
|
unless context.is_a?(Module)
|
76
76
|
context = context.to_s.split('::').inject(Object) do |base, mod|
|
77
77
|
base.const_get(mod)
|
78
78
|
end
|
79
79
|
end
|
80
|
-
Manager.new(context)
|
80
|
+
manager = Manager.new(context)
|
81
|
+
|
82
|
+
creating_class, creating_module = class_or_module[:class], class_or_module[:module]
|
83
|
+
raise ArgumentError, "You must choose either class: or module: but not both." if creating_class && creating_module
|
84
|
+
|
85
|
+
case
|
86
|
+
when creating_class
|
87
|
+
parent = class_or_module[:parent] || Object
|
88
|
+
manager.create_class(creating_class, parent: parent, &block)
|
89
|
+
when creating_module
|
90
|
+
if class_or_module[:parent]
|
91
|
+
warn "An option for :parent was provided as `#{class_or_module[:parent]}' but was ignored when creating the module: #{class_or_module[:module]}"
|
92
|
+
end
|
93
|
+
manager.create_module(creating_module, &block)
|
94
|
+
else
|
95
|
+
manager.instance_eval(&block)
|
96
|
+
end
|
81
97
|
end
|
82
98
|
alias expand namespace
|
83
99
|
end
|
metadata
CHANGED
@@ -1,57 +1,15 @@
|
|
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.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- "'Jim Gay'"
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
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: '1.11'
|
20
|
-
type: :development
|
21
|
-
prerelease: false
|
22
|
-
version_requirements: !ruby/object:Gem::Requirement
|
23
|
-
requirements:
|
24
|
-
- - "~>"
|
25
|
-
- !ruby/object:Gem::Version
|
26
|
-
version: '1.11'
|
27
|
-
- !ruby/object:Gem::Dependency
|
28
|
-
name: rake
|
29
|
-
requirement: !ruby/object:Gem::Requirement
|
30
|
-
requirements:
|
31
|
-
- - "~>"
|
32
|
-
- !ruby/object:Gem::Version
|
33
|
-
version: '10.0'
|
34
|
-
type: :development
|
35
|
-
prerelease: false
|
36
|
-
version_requirements: !ruby/object:Gem::Requirement
|
37
|
-
requirements:
|
38
|
-
- - "~>"
|
39
|
-
- !ruby/object:Gem::Version
|
40
|
-
version: '10.0'
|
41
|
-
- !ruby/object:Gem::Dependency
|
42
|
-
name: minitest
|
43
|
-
requirement: !ruby/object:Gem::Requirement
|
44
|
-
requirements:
|
45
|
-
- - "~>"
|
46
|
-
- !ruby/object:Gem::Version
|
47
|
-
version: '5.0'
|
48
|
-
type: :development
|
49
|
-
prerelease: false
|
50
|
-
version_requirements: !ruby/object:Gem::Requirement
|
51
|
-
requirements:
|
52
|
-
- - "~>"
|
53
|
-
- !ruby/object:Gem::Version
|
54
|
-
version: '5.0'
|
11
|
+
date: 2022-07-20 00:00:00.000000000 Z
|
12
|
+
dependencies: []
|
55
13
|
description: Create classes and modules under an existing namespace
|
56
14
|
email:
|
57
15
|
- jim@saturnflyer.com
|
@@ -59,8 +17,9 @@ executables: []
|
|
59
17
|
extensions: []
|
60
18
|
extra_rdoc_files: []
|
61
19
|
files:
|
20
|
+
- ".github/dependabot.yml"
|
21
|
+
- ".github/workflows/test.yml"
|
62
22
|
- ".gitignore"
|
63
|
-
- ".travis.yml"
|
64
23
|
- CHANGELOG.md
|
65
24
|
- CODE_OF_CONDUCT.md
|
66
25
|
- Gemfile
|
@@ -76,7 +35,7 @@ homepage: https://github.com/saturnflyer/expand
|
|
76
35
|
licenses:
|
77
36
|
- MIT
|
78
37
|
metadata: {}
|
79
|
-
post_install_message:
|
38
|
+
post_install_message:
|
80
39
|
rdoc_options: []
|
81
40
|
require_paths:
|
82
41
|
- lib
|
@@ -91,10 +50,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
91
50
|
- !ruby/object:Gem::Version
|
92
51
|
version: '0'
|
93
52
|
requirements: []
|
94
|
-
|
95
|
-
|
96
|
-
signing_key:
|
53
|
+
rubygems_version: 3.3.17
|
54
|
+
signing_key:
|
97
55
|
specification_version: 4
|
98
56
|
summary: Create classes and modules under an existing namespace
|
99
57
|
test_files: []
|
100
|
-
has_rdoc:
|
data/.travis.yml
DELETED