dsl_organizer 1.0.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 +7 -0
- data/.gitignore +13 -0
- data/.rspec +3 -0
- data/.rubocop.yml +7 -0
- data/.simplecov +3 -0
- data/.travis.yml +14 -0
- data/Gemfile +4 -0
- data/Gemfile.lock +65 -0
- data/LICENSE.txt +21 -0
- data/README.md +90 -0
- data/Rakefile +11 -0
- data/dsl_organizer.gemspec +45 -0
- data/examples/example1/colors_configuration.rb +61 -0
- data/examples/example2/hooks.rb +78 -0
- data/lib/dsl_organizer.rb +21 -0
- data/lib/dsl_organizer/command_container.rb +8 -0
- data/lib/dsl_organizer/container.rb +20 -0
- data/lib/dsl_organizer/core.rb +88 -0
- data/lib/dsl_organizer/errors.rb +7 -0
- data/lib/dsl_organizer/export_command.rb +27 -0
- data/lib/dsl_organizer/export_container.rb +6 -0
- data/lib/dsl_organizer/version.rb +3 -0
- metadata +156 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: c0464926e6b26e1355e699856ba42e8f89782a0a58b55e546597e374d91def83
|
4
|
+
data.tar.gz: 007313d81abe50444de1f19d8eb2359e40c5ee4edf4644db64da033221f66693
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: f30beec2fb5b11b817b828f3705c3425aad580692ca75acd23ee11f741c30a07092c1b3d29bda5691c15c3e5980a7a472dabaf7d8c0169fd422d530c57962acd
|
7
|
+
data.tar.gz: b86ec90887722601706474e10b9e16cb18bd635b9bba9653051133398d8099d4773085984db51cd518031f36a8898c6fd92360340604de8f396ae345cf3f240e
|
data/.gitignore
ADDED
data/.rspec
ADDED
data/.rubocop.yml
ADDED
data/.simplecov
ADDED
data/.travis.yml
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
language: ruby
|
2
|
+
dist: trusty
|
3
|
+
sudo: required
|
4
|
+
cache: bundler
|
5
|
+
bundler_args: --without console
|
6
|
+
script:
|
7
|
+
- bundle exec rake spec
|
8
|
+
after_success:
|
9
|
+
- '[ -d coverage ] && bundle exec codeclimate-test-reporter'
|
10
|
+
rvm:
|
11
|
+
- 2.3.8
|
12
|
+
- 2.4.5
|
13
|
+
- 2.5.3
|
14
|
+
- 2.6.1
|
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,65 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
dsl_organizer (1.0.0)
|
5
|
+
|
6
|
+
GEM
|
7
|
+
remote: https://rubygems.org/
|
8
|
+
specs:
|
9
|
+
ast (2.4.0)
|
10
|
+
byebug (11.0.0)
|
11
|
+
diff-lcs (1.3)
|
12
|
+
docile (1.3.1)
|
13
|
+
jaro_winkler (1.5.2)
|
14
|
+
json (2.2.0)
|
15
|
+
parallel (1.13.0)
|
16
|
+
parser (2.6.0.0)
|
17
|
+
ast (~> 2.4.0)
|
18
|
+
powerpack (0.1.2)
|
19
|
+
psych (3.1.0)
|
20
|
+
rainbow (3.0.0)
|
21
|
+
rake (10.5.0)
|
22
|
+
rspec (3.8.0)
|
23
|
+
rspec-core (~> 3.8.0)
|
24
|
+
rspec-expectations (~> 3.8.0)
|
25
|
+
rspec-mocks (~> 3.8.0)
|
26
|
+
rspec-core (3.8.0)
|
27
|
+
rspec-support (~> 3.8.0)
|
28
|
+
rspec-expectations (3.8.2)
|
29
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
30
|
+
rspec-support (~> 3.8.0)
|
31
|
+
rspec-mocks (3.8.0)
|
32
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
33
|
+
rspec-support (~> 3.8.0)
|
34
|
+
rspec-support (3.8.0)
|
35
|
+
rubocop (0.65.0)
|
36
|
+
jaro_winkler (~> 1.5.1)
|
37
|
+
parallel (~> 1.10)
|
38
|
+
parser (>= 2.5, != 2.5.1.1)
|
39
|
+
powerpack (~> 0.1)
|
40
|
+
psych (>= 3.1.0)
|
41
|
+
rainbow (>= 2.2.2, < 4.0)
|
42
|
+
ruby-progressbar (~> 1.7)
|
43
|
+
unicode-display_width (~> 1.4.0)
|
44
|
+
ruby-progressbar (1.10.0)
|
45
|
+
simplecov (0.16.1)
|
46
|
+
docile (~> 1.1)
|
47
|
+
json (>= 1.8, < 3)
|
48
|
+
simplecov-html (~> 0.10.0)
|
49
|
+
simplecov-html (0.10.2)
|
50
|
+
unicode-display_width (1.4.1)
|
51
|
+
|
52
|
+
PLATFORMS
|
53
|
+
ruby
|
54
|
+
|
55
|
+
DEPENDENCIES
|
56
|
+
bundler (~> 1.17.2, >= 1.17.2)
|
57
|
+
byebug (~> 11.0.0)
|
58
|
+
dsl_organizer!
|
59
|
+
rake (~> 10.0)
|
60
|
+
rspec (~> 3.0)
|
61
|
+
rubocop (~> 0.65)
|
62
|
+
simplecov (~> 0.16.1)
|
63
|
+
|
64
|
+
BUNDLED WITH
|
65
|
+
1.17.2
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2019 Artem Rumiantcev
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,90 @@
|
|
1
|
+
# DslOrganizer [](https://travis-ci.com/TemaMix/dsl_organizer) [](https://codeclimate.com/github/TemaMix/dsl_organizer)
|
2
|
+
|
3
|
+
DslOrganizer provides a simple way to create self dsl and allows to integrate dsl to logic easy.
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Installation is pretty standard:
|
8
|
+
|
9
|
+
```
|
10
|
+
$ gem install dsl_organizer
|
11
|
+
```
|
12
|
+
|
13
|
+
If you use bundler to add it to your Gemfile:
|
14
|
+
```
|
15
|
+
gem 'dsl_organizer', '~> 1.0'
|
16
|
+
```
|
17
|
+
|
18
|
+
And then execute:
|
19
|
+
|
20
|
+
$ bundle
|
21
|
+
|
22
|
+
|
23
|
+
## Usage
|
24
|
+
### Brief Example
|
25
|
+
1. Firstly, you should think up commands for your dsl.
|
26
|
+
```ruby
|
27
|
+
module Configuration
|
28
|
+
include DslOrganizer.dictionary(
|
29
|
+
commands: [:font_colors, :backgrounds]
|
30
|
+
)
|
31
|
+
end
|
32
|
+
```
|
33
|
+
2. Secondly, you should define executors for your commands and export them.
|
34
|
+
```ruby
|
35
|
+
class FontColorExecutor
|
36
|
+
include DslOrganizer::ExportCommand[:font_colors]
|
37
|
+
|
38
|
+
def call(font_color)
|
39
|
+
colors << font_color
|
40
|
+
end
|
41
|
+
|
42
|
+
def colors
|
43
|
+
@colors ||= []
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
class BackroundExecutor
|
48
|
+
include DslOrganizer::ExportCommand[:backgrounds]
|
49
|
+
|
50
|
+
def call(backround_color)
|
51
|
+
colors << backround_color
|
52
|
+
end
|
53
|
+
|
54
|
+
def colors
|
55
|
+
@colors ||= []
|
56
|
+
end
|
57
|
+
end
|
58
|
+
```
|
59
|
+
3. Thirdly, described logic with using dsl commands can look something like that:
|
60
|
+
```ruby
|
61
|
+
Configuration.run do
|
62
|
+
font_colors'#AAA'
|
63
|
+
font_colors '#BBB'
|
64
|
+
backgrounds '#CCC'
|
65
|
+
end
|
66
|
+
```
|
67
|
+
The dsl commands `color` and `background` will executed immediately.
|
68
|
+
|
69
|
+
4. Finally, you can integrate commands to basic logic to use for it the Dependency Injection pattern:
|
70
|
+
```ruby
|
71
|
+
module Configuration
|
72
|
+
def self.print_all_colors
|
73
|
+
dsl_container[:font_colors].colors.map do |color|
|
74
|
+
puts color
|
75
|
+
end
|
76
|
+
|
77
|
+
dsl_container[:backgrounds].colors.map do |color|
|
78
|
+
puts color
|
79
|
+
end
|
80
|
+
end
|
81
|
+
end
|
82
|
+
```
|
83
|
+
|
84
|
+
## Contributing
|
85
|
+
|
86
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/temamix/dsl_organizer. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
|
87
|
+
|
88
|
+
## License
|
89
|
+
|
90
|
+
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
data/Rakefile
ADDED
@@ -0,0 +1,45 @@
|
|
1
|
+
lib = File.expand_path('lib', __dir__)
|
2
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
3
|
+
require 'dsl_organizer/version'
|
4
|
+
|
5
|
+
Gem::Specification.new do |spec|
|
6
|
+
spec.name = 'dsl_organizer'
|
7
|
+
spec.version = DslOrganizer::VERSION
|
8
|
+
spec.authors = ['Artem Rumiantcev']
|
9
|
+
spec.email = ['tema.place@gmail.com']
|
10
|
+
|
11
|
+
spec.summary = 'DSL organizer allows to add flexible' \
|
12
|
+
' and readable dsl handlers to your project.'
|
13
|
+
spec.homepage = 'http://github.com/TemaMix/dsl_organizer'
|
14
|
+
spec.license = 'MIT'
|
15
|
+
|
16
|
+
# Prevent pushing this gem to RubyGems.org.
|
17
|
+
# To allow pushes either set the 'allowed_push_host'
|
18
|
+
# to allow pushing to a single host
|
19
|
+
# or delete this section to allow pushing to any host.
|
20
|
+
if spec.respond_to?(:metadata)
|
21
|
+
spec.metadata['homepage_uri'] = spec.homepage
|
22
|
+
spec.metadata['source_code_uri'] = spec.homepage
|
23
|
+
else
|
24
|
+
raise 'RubyGems 2.0 or newer is required to protect against ' \
|
25
|
+
'public gem pushes.'
|
26
|
+
end
|
27
|
+
|
28
|
+
# Specify which files should be added to the gem when it is released.
|
29
|
+
# The `git ls-files -z` loads the files
|
30
|
+
# in the RubyGem that have been added into git.
|
31
|
+
spec.files = Dir.chdir(File.expand_path(__dir__)) do
|
32
|
+
`git ls-files -z`.split("\x0")
|
33
|
+
.reject { |f| f.match(%r{^(test|spec|features)/}) }
|
34
|
+
end
|
35
|
+
spec.bindir = 'exe'
|
36
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
37
|
+
spec.require_paths = ['lib']
|
38
|
+
|
39
|
+
spec.add_development_dependency 'bundler', '~> 1.17.2', '>= 1.17.2'
|
40
|
+
spec.add_development_dependency 'byebug', '~> 11.0.0'
|
41
|
+
spec.add_development_dependency 'rake', '~> 10.0'
|
42
|
+
spec.add_development_dependency 'rspec', '~> 3.0'
|
43
|
+
spec.add_development_dependency 'rubocop', '~> 0.65'
|
44
|
+
spec.add_development_dependency 'simplecov', '~> 0.16.1'
|
45
|
+
end
|
@@ -0,0 +1,61 @@
|
|
1
|
+
# Example 1
|
2
|
+
#
|
3
|
+
# Current structure shows as the DslOrganizer can use to create a basic dsl
|
4
|
+
# in your program.
|
5
|
+
#
|
6
|
+
# After execution it in the terminal is printed follow:
|
7
|
+
# `execute before something happen`
|
8
|
+
# `execute some process`
|
9
|
+
# `execute after something happen`
|
10
|
+
|
11
|
+
require 'dsl_organizer'
|
12
|
+
|
13
|
+
class FontColorExecutor
|
14
|
+
include DslOrganizer::ExportCommand[:font_colors]
|
15
|
+
|
16
|
+
def call(font_color)
|
17
|
+
colors << font_color
|
18
|
+
end
|
19
|
+
|
20
|
+
def colors
|
21
|
+
@colors ||= []
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
class BackroundExecutor
|
26
|
+
include DslOrganizer::ExportCommand[:backgrounds]
|
27
|
+
|
28
|
+
def call(backround_color)
|
29
|
+
colors << backround_color
|
30
|
+
end
|
31
|
+
|
32
|
+
def colors
|
33
|
+
@colors ||= []
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
module Configuration
|
38
|
+
include DslOrganizer.dictionary(
|
39
|
+
commands: %i[font_colors backgrounds]
|
40
|
+
)
|
41
|
+
end
|
42
|
+
|
43
|
+
Configuration.run do
|
44
|
+
font_colors '#AAA'
|
45
|
+
font_colors '#BBB'
|
46
|
+
backgrounds '#CCC'
|
47
|
+
end
|
48
|
+
|
49
|
+
module Configuration
|
50
|
+
def self.print_all_colors
|
51
|
+
dsl_container[:font_colors].colors.map do |color|
|
52
|
+
puts color
|
53
|
+
end
|
54
|
+
|
55
|
+
dsl_container[:backgrounds].colors.map do |color|
|
56
|
+
puts color
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
61
|
+
Configuration.print_all_colors
|
@@ -0,0 +1,78 @@
|
|
1
|
+
# Example 2
|
2
|
+
#
|
3
|
+
# Current structure shows as the DslOrganizer can use to create hooks in your
|
4
|
+
# program.
|
5
|
+
#
|
6
|
+
# After execution it in the terminal is printed follow:
|
7
|
+
# `execute before something happen`
|
8
|
+
# `execute some process`
|
9
|
+
# `execute after something happen`
|
10
|
+
|
11
|
+
require 'dsl_organizer'
|
12
|
+
|
13
|
+
class AfterHook
|
14
|
+
include DslOrganizer::ExportCommand[:after]
|
15
|
+
|
16
|
+
def call(&block)
|
17
|
+
hooks.unshift(block)
|
18
|
+
end
|
19
|
+
|
20
|
+
def hooks
|
21
|
+
@hooks ||= []
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
class BeforeHook
|
26
|
+
include DslOrganizer::ExportCommand[:before]
|
27
|
+
|
28
|
+
def call(&block)
|
29
|
+
hooks.push(block)
|
30
|
+
end
|
31
|
+
|
32
|
+
def hooks
|
33
|
+
@hooks ||= []
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
module HooksOperator
|
38
|
+
def self.included(base)
|
39
|
+
base.class_eval do
|
40
|
+
extend ClassMethods
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
module ClassMethods
|
45
|
+
def with_hooks
|
46
|
+
run_hooks(dsl_container[:before].hooks)
|
47
|
+
yield
|
48
|
+
run_hooks(dsl_container[:after].hooks)
|
49
|
+
end
|
50
|
+
|
51
|
+
private
|
52
|
+
|
53
|
+
def run_hooks(hooks)
|
54
|
+
hooks.each { |hook| instance_exec(&hook) }
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
59
|
+
module Process
|
60
|
+
include DslOrganizer.dictionary(
|
61
|
+
commands: %i[before after]
|
62
|
+
)
|
63
|
+
|
64
|
+
include HooksOperator
|
65
|
+
|
66
|
+
def self.start
|
67
|
+
with_hooks do
|
68
|
+
puts 'execute some process'
|
69
|
+
end
|
70
|
+
end
|
71
|
+
end
|
72
|
+
|
73
|
+
Process.run do
|
74
|
+
before { puts 'execute before something happen' }
|
75
|
+
after { puts 'execute after something happen' }
|
76
|
+
end
|
77
|
+
|
78
|
+
Process.start
|
@@ -0,0 +1,21 @@
|
|
1
|
+
require_relative 'dsl_organizer/errors'
|
2
|
+
require_relative 'dsl_organizer/container'
|
3
|
+
require_relative 'dsl_organizer/command_container'
|
4
|
+
require_relative 'dsl_organizer/export_container'
|
5
|
+
require_relative 'dsl_organizer/export_command'
|
6
|
+
require_relative 'dsl_organizer/version'
|
7
|
+
require_relative 'dsl_organizer/core'
|
8
|
+
|
9
|
+
# DslOrganizer allows to build flexible notations very quickly
|
10
|
+
# and same time they will understandable.
|
11
|
+
# @example:
|
12
|
+
# include DslOrganizer.dictionary(commands: {
|
13
|
+
# before: BeforeHook,
|
14
|
+
# after: AfterHook
|
15
|
+
# })
|
16
|
+
# @note:
|
17
|
+
# The idea was found here
|
18
|
+
# https://www.toptal.com/ruby/ruby-dsl-metaprogramming-guide
|
19
|
+
module DslOrganizer
|
20
|
+
extend DslOrganizer::Core
|
21
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
module DslOrganizer
|
2
|
+
# It defines methods to operate with executors.
|
3
|
+
module Container
|
4
|
+
def []=(command, executor)
|
5
|
+
real_container[command] = executor
|
6
|
+
end
|
7
|
+
|
8
|
+
def [](command = nil)
|
9
|
+
real_container[command]
|
10
|
+
end
|
11
|
+
|
12
|
+
def real_container
|
13
|
+
@real_container ||= {}
|
14
|
+
end
|
15
|
+
|
16
|
+
def reset
|
17
|
+
@real_container = {}
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,88 @@
|
|
1
|
+
module DslOrganizer
|
2
|
+
# Load methods for control dsl commands.
|
3
|
+
module Core
|
4
|
+
# @syntax
|
5
|
+
# commands: { <command>:<class executor> }
|
6
|
+
# @example
|
7
|
+
# commands: { after: AfterHook, before: BeforeHook }
|
8
|
+
# @return [Module]
|
9
|
+
def dictionary(commands: [])
|
10
|
+
CommandContainer.reset
|
11
|
+
|
12
|
+
@dsl_commands = commands
|
13
|
+
validate_commands
|
14
|
+
|
15
|
+
dsl_module = new_dsl_module(dsl_operator: new_dsl_operator)
|
16
|
+
Module.new do
|
17
|
+
singleton_class.send :define_method, :included do |host_class|
|
18
|
+
host_class.extend dsl_module
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
private
|
24
|
+
|
25
|
+
attr_reader :dsl_commands
|
26
|
+
|
27
|
+
def validate_commands
|
28
|
+
if dsl_commands.nil? || dsl_commands.empty?
|
29
|
+
raise Errors::DslCommandsNotFound, 'Add DSL commands for work'
|
30
|
+
end
|
31
|
+
|
32
|
+
dsl_commands.each do |command|
|
33
|
+
unless ExportContainer.real_container.key?(command)
|
34
|
+
raise(Errors::DslCommandsNotFound,
|
35
|
+
"Add an executor for the `#{command}` command for work")
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
def new_dsl_module(dsl_operator:)
|
41
|
+
commands = dsl_commands
|
42
|
+
Module.new do
|
43
|
+
define_method :used_dsl do
|
44
|
+
@used_dsl ||= dsl_operator.new
|
45
|
+
end
|
46
|
+
|
47
|
+
define_method :dsl_commands do
|
48
|
+
@dsl_commands ||= commands
|
49
|
+
end
|
50
|
+
|
51
|
+
define_method :dsl_container do
|
52
|
+
CommandContainer
|
53
|
+
end
|
54
|
+
|
55
|
+
def run(&block)
|
56
|
+
used_dsl.instance_eval(&block)
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
61
|
+
def new_dsl_operator
|
62
|
+
commands = dsl_commands
|
63
|
+
Class.new do
|
64
|
+
commands.each do |command|
|
65
|
+
define_method command do |values = [], &block|
|
66
|
+
unless ExportContainer[command].method_defined? :call
|
67
|
+
raise(
|
68
|
+
Errors::MethodCallNotFound,
|
69
|
+
'Not found `call` method for the' \
|
70
|
+
" `#{ExportContainer[command].name}` class and" \
|
71
|
+
" the `#{command}` command"
|
72
|
+
)
|
73
|
+
end
|
74
|
+
|
75
|
+
command_instance = CommandContainer[command] ||
|
76
|
+
ExportContainer[command].new
|
77
|
+
|
78
|
+
unless CommandContainer[command]
|
79
|
+
CommandContainer[command] = command_instance
|
80
|
+
end
|
81
|
+
|
82
|
+
command_instance.call(*values, &block)
|
83
|
+
end
|
84
|
+
end
|
85
|
+
end
|
86
|
+
end
|
87
|
+
end
|
88
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
module DslOrganizer
|
2
|
+
# It allows to define what a class is a executor (hook).
|
3
|
+
# @note Just include this to the target class and think up a command name.
|
4
|
+
# @example
|
5
|
+
# include DslOrganizer::ExportCommand[:after]
|
6
|
+
# rubocop:disable Metrics/MethodLength
|
7
|
+
module ExportCommand
|
8
|
+
def self.[](command_name)
|
9
|
+
Module.new do
|
10
|
+
@command_name = command_name
|
11
|
+
|
12
|
+
def self.included(base)
|
13
|
+
if ExportContainer[@command_name].nil?
|
14
|
+
ExportContainer[@command_name] = base
|
15
|
+
else
|
16
|
+
raise(
|
17
|
+
Errors::ExecutorDidMountEarly,
|
18
|
+
"The component for command name: `#{@command_name}`" \
|
19
|
+
' was mounted early. Avoid duplication naming within commands.'
|
20
|
+
)
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
# rubocop:enable Metrics/MethodLength
|
26
|
+
end
|
27
|
+
end
|
metadata
ADDED
@@ -0,0 +1,156 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: dsl_organizer
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.0.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Artem Rumiantcev
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2019-03-04 00:00:00.000000000 Z
|
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.17.2
|
20
|
+
- - "~>"
|
21
|
+
- !ruby/object:Gem::Version
|
22
|
+
version: 1.17.2
|
23
|
+
type: :development
|
24
|
+
prerelease: false
|
25
|
+
version_requirements: !ruby/object:Gem::Requirement
|
26
|
+
requirements:
|
27
|
+
- - ">="
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: 1.17.2
|
30
|
+
- - "~>"
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: 1.17.2
|
33
|
+
- !ruby/object:Gem::Dependency
|
34
|
+
name: byebug
|
35
|
+
requirement: !ruby/object:Gem::Requirement
|
36
|
+
requirements:
|
37
|
+
- - "~>"
|
38
|
+
- !ruby/object:Gem::Version
|
39
|
+
version: 11.0.0
|
40
|
+
type: :development
|
41
|
+
prerelease: false
|
42
|
+
version_requirements: !ruby/object:Gem::Requirement
|
43
|
+
requirements:
|
44
|
+
- - "~>"
|
45
|
+
- !ruby/object:Gem::Version
|
46
|
+
version: 11.0.0
|
47
|
+
- !ruby/object:Gem::Dependency
|
48
|
+
name: rake
|
49
|
+
requirement: !ruby/object:Gem::Requirement
|
50
|
+
requirements:
|
51
|
+
- - "~>"
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
version: '10.0'
|
54
|
+
type: :development
|
55
|
+
prerelease: false
|
56
|
+
version_requirements: !ruby/object:Gem::Requirement
|
57
|
+
requirements:
|
58
|
+
- - "~>"
|
59
|
+
- !ruby/object:Gem::Version
|
60
|
+
version: '10.0'
|
61
|
+
- !ruby/object:Gem::Dependency
|
62
|
+
name: rspec
|
63
|
+
requirement: !ruby/object:Gem::Requirement
|
64
|
+
requirements:
|
65
|
+
- - "~>"
|
66
|
+
- !ruby/object:Gem::Version
|
67
|
+
version: '3.0'
|
68
|
+
type: :development
|
69
|
+
prerelease: false
|
70
|
+
version_requirements: !ruby/object:Gem::Requirement
|
71
|
+
requirements:
|
72
|
+
- - "~>"
|
73
|
+
- !ruby/object:Gem::Version
|
74
|
+
version: '3.0'
|
75
|
+
- !ruby/object:Gem::Dependency
|
76
|
+
name: rubocop
|
77
|
+
requirement: !ruby/object:Gem::Requirement
|
78
|
+
requirements:
|
79
|
+
- - "~>"
|
80
|
+
- !ruby/object:Gem::Version
|
81
|
+
version: '0.65'
|
82
|
+
type: :development
|
83
|
+
prerelease: false
|
84
|
+
version_requirements: !ruby/object:Gem::Requirement
|
85
|
+
requirements:
|
86
|
+
- - "~>"
|
87
|
+
- !ruby/object:Gem::Version
|
88
|
+
version: '0.65'
|
89
|
+
- !ruby/object:Gem::Dependency
|
90
|
+
name: simplecov
|
91
|
+
requirement: !ruby/object:Gem::Requirement
|
92
|
+
requirements:
|
93
|
+
- - "~>"
|
94
|
+
- !ruby/object:Gem::Version
|
95
|
+
version: 0.16.1
|
96
|
+
type: :development
|
97
|
+
prerelease: false
|
98
|
+
version_requirements: !ruby/object:Gem::Requirement
|
99
|
+
requirements:
|
100
|
+
- - "~>"
|
101
|
+
- !ruby/object:Gem::Version
|
102
|
+
version: 0.16.1
|
103
|
+
description:
|
104
|
+
email:
|
105
|
+
- tema.place@gmail.com
|
106
|
+
executables: []
|
107
|
+
extensions: []
|
108
|
+
extra_rdoc_files: []
|
109
|
+
files:
|
110
|
+
- ".gitignore"
|
111
|
+
- ".rspec"
|
112
|
+
- ".rubocop.yml"
|
113
|
+
- ".simplecov"
|
114
|
+
- ".travis.yml"
|
115
|
+
- Gemfile
|
116
|
+
- Gemfile.lock
|
117
|
+
- LICENSE.txt
|
118
|
+
- README.md
|
119
|
+
- Rakefile
|
120
|
+
- dsl_organizer.gemspec
|
121
|
+
- examples/example1/colors_configuration.rb
|
122
|
+
- examples/example2/hooks.rb
|
123
|
+
- lib/dsl_organizer.rb
|
124
|
+
- lib/dsl_organizer/command_container.rb
|
125
|
+
- lib/dsl_organizer/container.rb
|
126
|
+
- lib/dsl_organizer/core.rb
|
127
|
+
- lib/dsl_organizer/errors.rb
|
128
|
+
- lib/dsl_organizer/export_command.rb
|
129
|
+
- lib/dsl_organizer/export_container.rb
|
130
|
+
- lib/dsl_organizer/version.rb
|
131
|
+
homepage: http://github.com/TemaMix/dsl_organizer
|
132
|
+
licenses:
|
133
|
+
- MIT
|
134
|
+
metadata:
|
135
|
+
homepage_uri: http://github.com/TemaMix/dsl_organizer
|
136
|
+
source_code_uri: http://github.com/TemaMix/dsl_organizer
|
137
|
+
post_install_message:
|
138
|
+
rdoc_options: []
|
139
|
+
require_paths:
|
140
|
+
- lib
|
141
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
142
|
+
requirements:
|
143
|
+
- - ">="
|
144
|
+
- !ruby/object:Gem::Version
|
145
|
+
version: '0'
|
146
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
147
|
+
requirements:
|
148
|
+
- - ">="
|
149
|
+
- !ruby/object:Gem::Version
|
150
|
+
version: '0'
|
151
|
+
requirements: []
|
152
|
+
rubygems_version: 3.0.1
|
153
|
+
signing_key:
|
154
|
+
specification_version: 4
|
155
|
+
summary: DSL organizer allows to add flexible and readable dsl handlers to your project.
|
156
|
+
test_files: []
|