brace_comb 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/CODE_OF_CONDUCT.md +74 -0
- data/README.md +96 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/lib/brace_comb.rb +34 -0
- data/lib/brace_comb/config.rb +18 -0
- data/lib/brace_comb/dependency_helper.rb +77 -0
- data/lib/brace_comb/dependency_model.rb +66 -0
- data/lib/brace_comb/exceptions/callback_failure.rb +9 -0
- data/lib/brace_comb/version.rb +3 -0
- data/lib/generators/brace_comb/generator.rb +14 -0
- data/lib/generators/brace_comb/initializer_generator.rb +16 -0
- data/lib/generators/brace_comb/migration_generator.rb +47 -0
- data/lib/generators/brace_comb/model_generator.rb +47 -0
- metadata +205 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: aaeb1d4b8c9364abcf4faa7f520def42a3181a69
|
4
|
+
data.tar.gz: 05e4fd1cee33718bdf03e001263d447a23ac2b58
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 414d1aa676d6b862f2391be9a822515bae2d3627d6c2c6e8e71724da5534526729009929d0979d8ca66190f1563743b6e1dfc864f879e2a51794e756d3a1342f
|
7
|
+
data.tar.gz: e48fd0c6d8320910b9ea27efcf09603258b46d2eaadd421ed786bcc5dd1d090618e561140002d7dc39a3195695a962b93505945f2324402787afa5bb3f3370a9
|
data/CODE_OF_CONDUCT.md
ADDED
@@ -0,0 +1,74 @@
|
|
1
|
+
# Contributor Covenant Code of Conduct
|
2
|
+
|
3
|
+
## Our Pledge
|
4
|
+
|
5
|
+
In the interest of fostering an open and welcoming environment, we as
|
6
|
+
contributors and maintainers pledge to making participation in our project and
|
7
|
+
our community a harassment-free experience for everyone, regardless of age, body
|
8
|
+
size, disability, ethnicity, gender identity and expression, level of experience,
|
9
|
+
nationality, personal appearance, race, religion, or sexual identity and
|
10
|
+
orientation.
|
11
|
+
|
12
|
+
## Our Standards
|
13
|
+
|
14
|
+
Examples of behavior that contributes to creating a positive environment
|
15
|
+
include:
|
16
|
+
|
17
|
+
* Using welcoming and inclusive language
|
18
|
+
* Being respectful of differing viewpoints and experiences
|
19
|
+
* Gracefully accepting constructive criticism
|
20
|
+
* Focusing on what is best for the community
|
21
|
+
* Showing empathy towards other community members
|
22
|
+
|
23
|
+
Examples of unacceptable behavior by participants include:
|
24
|
+
|
25
|
+
* The use of sexualized language or imagery and unwelcome sexual attention or
|
26
|
+
advances
|
27
|
+
* Trolling, insulting/derogatory comments, and personal or political attacks
|
28
|
+
* Public or private harassment
|
29
|
+
* Publishing others' private information, such as a physical or electronic
|
30
|
+
address, without explicit permission
|
31
|
+
* Other conduct which could reasonably be considered inappropriate in a
|
32
|
+
professional setting
|
33
|
+
|
34
|
+
## Our Responsibilities
|
35
|
+
|
36
|
+
Project maintainers are responsible for clarifying the standards of acceptable
|
37
|
+
behavior and are expected to take appropriate and fair corrective action in
|
38
|
+
response to any instances of unacceptable behavior.
|
39
|
+
|
40
|
+
Project maintainers have the right and responsibility to remove, edit, or
|
41
|
+
reject comments, commits, code, wiki edits, issues, and other contributions
|
42
|
+
that are not aligned to this Code of Conduct, or to ban temporarily or
|
43
|
+
permanently any contributor for other behaviors that they deem inappropriate,
|
44
|
+
threatening, offensive, or harmful.
|
45
|
+
|
46
|
+
## Scope
|
47
|
+
|
48
|
+
This Code of Conduct applies both within project spaces and in public spaces
|
49
|
+
when an individual is representing the project or its community. Examples of
|
50
|
+
representing a project or community include using an official project e-mail
|
51
|
+
address, posting via an official social media account, or acting as an appointed
|
52
|
+
representative at an online or offline event. Representation of a project may be
|
53
|
+
further defined and clarified by project maintainers.
|
54
|
+
|
55
|
+
## Enforcement
|
56
|
+
|
57
|
+
Instances of abusive, harassing, or otherwise unacceptable behavior may be
|
58
|
+
reported by contacting the project team at ankitagupta12391@gmail.com. All
|
59
|
+
complaints will be reviewed and investigated and will result in a response that
|
60
|
+
is deemed necessary and appropriate to the circumstances. The project team is
|
61
|
+
obligated to maintain confidentiality with regard to the reporter of an incident.
|
62
|
+
Further details of specific enforcement policies may be posted separately.
|
63
|
+
|
64
|
+
Project maintainers who do not follow or enforce the Code of Conduct in good
|
65
|
+
faith may face temporary or permanent repercussions as determined by other
|
66
|
+
members of the project's leadership.
|
67
|
+
|
68
|
+
## Attribution
|
69
|
+
|
70
|
+
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
|
71
|
+
available at [http://contributor-covenant.org/version/1/4][version]
|
72
|
+
|
73
|
+
[homepage]: http://contributor-covenant.org
|
74
|
+
[version]: http://contributor-covenant.org/version/1/4/
|
data/README.md
ADDED
@@ -0,0 +1,96 @@
|
|
1
|
+
# BraceComb
|
2
|
+
|
3
|
+
Brace Comb is a small bit of wax built between two combs or frames to fasten them together. Brace comb is also built between a comb and adjacent wood, or between two wooden parts such as top bars.
|
4
|
+
|
5
|
+
Allows setting dependency logic between entities, and declaring resolution methods and callbacks to resolve dependencies.
|
6
|
+
|
7
|
+
## Background
|
8
|
+
|
9
|
+
In workflow management systems, there is often a need to define that certain tasks should only begin when another task(s) is complete.
|
10
|
+
|
11
|
+
Instead of having each workflow system define database entities to denote dependency relationships between tasks/dependents, this gem provides features that can create both the dependency and dependent model. These entity names are configurable based on the project needs.
|
12
|
+
|
13
|
+
In addition, it accepts methods/procs to define the logic for dependency resolution via resolution callbacks. In the same vein as active record callbacks, dependency resolution callbacks can define actions that should be executed before a dependency is resolved and after a dependency is resolved. If any before callbacks fail, then dependency resolution will also fail.
|
14
|
+
|
15
|
+
## Installation
|
16
|
+
|
17
|
+
1. Add JobDependencies to your `Gemfile`.
|
18
|
+
|
19
|
+
`gem 'brace_comb'`
|
20
|
+
|
21
|
+
2. Create an initializer for `brace_comb`
|
22
|
+
|
23
|
+
a. `bundle exec rails generate brace_comb:initializer`
|
24
|
+
|
25
|
+
b. Modify the name of dependency and dependent tables in the initializer `config/initializers/brace_comb.rb`
|
26
|
+
|
27
|
+
c. Run `bundle exec rails generate brace_comb:migration` to create the migration
|
28
|
+
|
29
|
+
d. Create the dependency tables and associations using `bundle exec rake db:migrate`
|
30
|
+
|
31
|
+
e. Generate the basic dependency model by running:
|
32
|
+
```bundle exec rails generate brace_comb:model ''```
|
33
|
+
|
34
|
+
## Usage
|
35
|
+
|
36
|
+
1. Declare a dependency type by adding in the following to the dependency class:
|
37
|
+
```
|
38
|
+
include BraceComb::Helper
|
39
|
+
enum type: { shopping: 0 }
|
40
|
+
```
|
41
|
+
2. Declare a dependency by typing in the following in any ActiveRecord class:
|
42
|
+
|
43
|
+
a. Using a method name in the resolver
|
44
|
+
```
|
45
|
+
declare_dependency type: :shopping,
|
46
|
+
resolver: :shopping_complete
|
47
|
+
before_resolved: [:completed_status?],
|
48
|
+
after_resolved: [:complete_job]
|
49
|
+
```
|
50
|
+
|
51
|
+
or
|
52
|
+
|
53
|
+
b. Using a proc in the resolver
|
54
|
+
|
55
|
+
```
|
56
|
+
declare_dependency type: :shopping,
|
57
|
+
resolver: ->(data) { data.condition },
|
58
|
+
before_resolved: [:completed_status?],
|
59
|
+
after_resolved: [:complete_job]
|
60
|
+
```
|
61
|
+
3. Create dependencies between the dependent class by using the following helper in any instance method of a model class:
|
62
|
+
|
63
|
+
- When an exception needs to be raised:
|
64
|
+
`initialize_dependency! from: job1, to: job2, type: 'shopping'`
|
65
|
+
|
66
|
+
or
|
67
|
+
- When a boolean needs to be returned:
|
68
|
+
`initialize_dependency from: job1, to: job2, type: 'shopping'`
|
69
|
+
|
70
|
+
5. Resolve dependencies from any active record model by using:
|
71
|
+
|
72
|
+
- When an exception needs to be raised:
|
73
|
+
```
|
74
|
+
dependency.resolve!(identifier: 123, status: :resolved)
|
75
|
+
```
|
76
|
+
|
77
|
+
or
|
78
|
+
- When a boolean needs to be returned:
|
79
|
+
|
80
|
+
```
|
81
|
+
dependency.resolve(identifier: 123, status: :resolved)
|
82
|
+
```
|
83
|
+
Any arguments passed to `resolve!` methods will be directly sent to the resolver. So arguments should be sent based on the resolver definition
|
84
|
+
|
85
|
+
## Under consideration
|
86
|
+
- Allowing dependency declaration to accept multiple resolvers, and allowing resolve to accept the name of the resolver. This could possibly by done in `resolve` method itself instead of `declare_dependency`
|
87
|
+
- Automatically including the concern for `resolve` inside the dependency class
|
88
|
+
- Combining the installation steps into 1-2 steps
|
89
|
+
- And more...
|
90
|
+
## Contributing
|
91
|
+
|
92
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/honestbee/brace_comb. 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.
|
93
|
+
|
94
|
+
## License
|
95
|
+
|
96
|
+
The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
|
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require 'bundler/setup'
|
4
|
+
require 'job_dependencies'
|
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(__FILE__)
|
data/bin/setup
ADDED
data/lib/brace_comb.rb
ADDED
@@ -0,0 +1,34 @@
|
|
1
|
+
require 'dry-configurable'
|
2
|
+
|
3
|
+
require 'brace_comb/version'
|
4
|
+
require 'brace_comb/config'
|
5
|
+
require 'brace_comb/dependency_model'
|
6
|
+
require 'brace_comb/dependency_helper'
|
7
|
+
|
8
|
+
module BraceComb
|
9
|
+
class << self
|
10
|
+
# return config
|
11
|
+
def config
|
12
|
+
Config.config
|
13
|
+
end
|
14
|
+
|
15
|
+
# Provides a block to override default config
|
16
|
+
def setup(&block)
|
17
|
+
Config.setup(&block)
|
18
|
+
end
|
19
|
+
|
20
|
+
def dependency_model
|
21
|
+
config.dependency_table_name.singularize.camelize
|
22
|
+
end
|
23
|
+
|
24
|
+
def dependent_model
|
25
|
+
config.dependent_table_name.singularize.camelize
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
ActiveSupport.on_load(:active_record) do
|
31
|
+
include BraceComb::Model
|
32
|
+
end
|
33
|
+
|
34
|
+
|
@@ -0,0 +1,18 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
module BraceComb
|
3
|
+
# configurator for setting up all the configurable settings for job dependency
|
4
|
+
class Config
|
5
|
+
extend Dry::Configurable
|
6
|
+
# defines the table name between which dependencies are created
|
7
|
+
setting :dependent_table_name, 'job'
|
8
|
+
setting :dependency_table_name, 'job_dependency'
|
9
|
+
|
10
|
+
class << self
|
11
|
+
def setup
|
12
|
+
configure do |config|
|
13
|
+
yield(config)
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,77 @@
|
|
1
|
+
module BraceComb
|
2
|
+
module Helper
|
3
|
+
module ClassMethods
|
4
|
+
# declare_dependency
|
5
|
+
# type: :shopping
|
6
|
+
# resolver: :shopping_completed
|
7
|
+
# before_resolved: [:completed_status?]
|
8
|
+
# after_resolved: :complete_job, Proc.new {}
|
9
|
+
# Options:
|
10
|
+
# resolver: Methods or procs that can mark the dependency as resolved
|
11
|
+
# before_resolved: Checks that can be performed before a dependency is resolved.
|
12
|
+
# If any of these return false then the dependency resolution will result in a false
|
13
|
+
# or exception.
|
14
|
+
# after_resolved: if the dependency resolution succeeds, each of these methods will be
|
15
|
+
# executed one by one. All the subsequent after_resolved hooks will not be executed if any
|
16
|
+
# of the predecessor after_resolved hook throws an exception. However, this will not make
|
17
|
+
# a difference to the resolution status of the dependency itself
|
18
|
+
def declare_dependency(options = {})
|
19
|
+
dependency_mapping = dependency_mapping_value
|
20
|
+
dependency_mapping[options[:type]] = options.slice(
|
21
|
+
:resolver,
|
22
|
+
:before_resolved,
|
23
|
+
:after_resolved
|
24
|
+
)
|
25
|
+
set_dependency_mapping(dependency_mapping)
|
26
|
+
end
|
27
|
+
|
28
|
+
def dependency_mapping_value
|
29
|
+
klass = dependency_model
|
30
|
+
dependency_mapping = klass.instance_variable_get(:@dependency_mapping)
|
31
|
+
value = dependency_mapping || {}
|
32
|
+
value.tap do |dependency_mapping_value|
|
33
|
+
klass.instance_variable_set(:@dependency_mapping, dependency_mapping_value)
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
def set_dependency_mapping(value)
|
38
|
+
dependency_model.instance_variable_set(:@dependency_mapping, value)
|
39
|
+
end
|
40
|
+
|
41
|
+
def dependency_model
|
42
|
+
::BraceComb.dependency_model.constantize
|
43
|
+
end
|
44
|
+
|
45
|
+
# private_class_method :dependency_mapping_value, :set_dependency_mapping
|
46
|
+
end
|
47
|
+
|
48
|
+
module InstanceMethods
|
49
|
+
# initialize_dependency from: job1, to: job2, type: 'shopping'
|
50
|
+
def initialize_dependency(from: nil, to: nil, dependency_type: nil)
|
51
|
+
dependency_model.create(
|
52
|
+
source_id: from,
|
53
|
+
destination_id: to,
|
54
|
+
dependency_type: dependency_type
|
55
|
+
)
|
56
|
+
end
|
57
|
+
|
58
|
+
# initialize_dependency from: job1, to: job2, type: 'shopping'
|
59
|
+
def initialize_dependency!(from: nil, to: nil, dependency_type: nil)
|
60
|
+
dependency_model.create!(
|
61
|
+
source_id: from,
|
62
|
+
destination_id: to,
|
63
|
+
dependency_type: dependency_type
|
64
|
+
)
|
65
|
+
end
|
66
|
+
|
67
|
+
def dependency_model
|
68
|
+
::BraceComb.dependency_model.constantize
|
69
|
+
end
|
70
|
+
end
|
71
|
+
|
72
|
+
def self.included(base)
|
73
|
+
base.send :include, InstanceMethods
|
74
|
+
base.send :extend, ClassMethods
|
75
|
+
end
|
76
|
+
end
|
77
|
+
end
|
@@ -0,0 +1,66 @@
|
|
1
|
+
require 'brace_comb/exceptions/callback_failure'
|
2
|
+
|
3
|
+
module BraceComb
|
4
|
+
module Model
|
5
|
+
module InstanceMethods
|
6
|
+
# throws an exception if before callbacks return false
|
7
|
+
# throws an exception if before, after callbacks or resolver raises an exception
|
8
|
+
# rolls back the transaction if before callbacks return false or if any exception is raised
|
9
|
+
def resolve!(args = nil)
|
10
|
+
dependency_mapping = self.class.
|
11
|
+
instance_variable_get(:@dependency_mapping)[self.dependency_type.to_sym]
|
12
|
+
ActiveRecord::Base.transaction do
|
13
|
+
execute_before_callbacks(dependency_mapping[:before_resolved])
|
14
|
+
execute_resolver(dependency_mapping[:resolver], args)
|
15
|
+
execute_after_callbacks(dependency_mapping[:after_resolved])
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
# returns false if before callbacks return false
|
20
|
+
# throws an exception if before, after callbacks or resolver raises an exception
|
21
|
+
# rolls back the transaction if before callbacks return false or if any exception is raised
|
22
|
+
def resolve(args = nil)
|
23
|
+
resolve!(args)
|
24
|
+
true
|
25
|
+
rescue BraceComb::Exceptions::CallbackFailure
|
26
|
+
false
|
27
|
+
end
|
28
|
+
|
29
|
+
def execute_after_callbacks(after_callbacks)
|
30
|
+
after_callbacks.each do |after_callback|
|
31
|
+
execute_callback(after_callback)
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
# Resolver can be a proc or method
|
36
|
+
def execute_resolver(resolver, args)
|
37
|
+
return resolver.call(self) if resolver.respond_to?(:call)
|
38
|
+
if method(resolver).arity.zero?
|
39
|
+
__send__(resolver)
|
40
|
+
else
|
41
|
+
__send__(resolver, args)
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
def execute_before_callbacks(before_callbacks)
|
46
|
+
before_callbacks.each do |before_callback|
|
47
|
+
result = execute_callback(before_callback)
|
48
|
+
raise BraceComb::Exceptions::CallbackFailure.new unless result
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
# Callbacks can be procs or methods
|
53
|
+
def execute_callback(callback)
|
54
|
+
if callback.respond_to?(:call)
|
55
|
+
callback.call(self)
|
56
|
+
else
|
57
|
+
__send__(callback)
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
62
|
+
def self.included(base)
|
63
|
+
base.send :include, InstanceMethods
|
64
|
+
end
|
65
|
+
end
|
66
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
require 'brace_comb'
|
2
|
+
module BraceComb
|
3
|
+
class Generator < Rails::Generators::Base
|
4
|
+
private
|
5
|
+
|
6
|
+
def dependent_table_name
|
7
|
+
::BraceComb.config.dependent_table_name.pluralize.downcase
|
8
|
+
end
|
9
|
+
|
10
|
+
def dependency_table_name
|
11
|
+
::BraceComb.config.dependency_table_name.pluralize.downcase
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
require 'generators/brace_comb/generator'
|
2
|
+
require 'rails/generators'
|
3
|
+
module BraceComb
|
4
|
+
# creates job depedency initializer
|
5
|
+
class InitializerGenerator < Generator
|
6
|
+
def create_initializer
|
7
|
+
create_file(
|
8
|
+
'config/initializers/brace_comb.rb',
|
9
|
+
"BraceComb.setup do |config|\n"\
|
10
|
+
" config.dependent_table_name = '#{dependent_table_name}'\n"\
|
11
|
+
" config.dependency_table_name = '#{dependency_table_name}'\n"\
|
12
|
+
"end"
|
13
|
+
)
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
@@ -0,0 +1,47 @@
|
|
1
|
+
require 'generators/brace_comb/generator'
|
2
|
+
require 'rails/generators'
|
3
|
+
require 'rails/generators/active_record'
|
4
|
+
module BraceComb
|
5
|
+
# Installs job dependencies migrations
|
6
|
+
class MigrationGenerator < Generator
|
7
|
+
include ::Rails::Generators::Migration
|
8
|
+
source_root File.expand_path('../templates', __FILE__)
|
9
|
+
|
10
|
+
def create_migration_file
|
11
|
+
add_migrations(dependent_table_name, 'create_dependent')
|
12
|
+
add_migrations(dependency_table_name, 'create_dependencies')
|
13
|
+
add_migrations(nil, 'add_associations')
|
14
|
+
end
|
15
|
+
|
16
|
+
private
|
17
|
+
|
18
|
+
def add_migrations(table_name, template)
|
19
|
+
migration_dir = File.expand_path("db/migrate")
|
20
|
+
migration_name = table_name || template
|
21
|
+
if migration_exists?(migration_dir, migration_name)
|
22
|
+
::Kernel.warn "Migration already exists: #{migration_name}"
|
23
|
+
else
|
24
|
+
migration_template(
|
25
|
+
"#{template}.rb.erb",
|
26
|
+
"db/migrate/#{migration_name.pluralize}.rb",
|
27
|
+
migration_version: migration_version
|
28
|
+
)
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
def migration_exists?(migration_dir, table_name)
|
33
|
+
[table_name.singularize, table_name.pluralize].any? do |table|
|
34
|
+
self.class.migration_exists?(migration_dir, "create_#{table}")
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
def self.next_migration_number(dirname)
|
39
|
+
::ActiveRecord::Generators::Base.next_migration_number(dirname)
|
40
|
+
end
|
41
|
+
|
42
|
+
def migration_version
|
43
|
+
major = ActiveRecord::VERSION::MAJOR
|
44
|
+
"[#{major}.#{ActiveRecord::VERSION::MINOR}]" if major >= 5
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
@@ -0,0 +1,47 @@
|
|
1
|
+
require 'rails/generators/active_record'
|
2
|
+
require 'brace_comb'
|
3
|
+
module BraceComb
|
4
|
+
# creates job depedency initializer
|
5
|
+
class ModelGenerator < ActiveRecord::Generators::Base
|
6
|
+
def generate_model
|
7
|
+
invoke 'active_record:model',
|
8
|
+
[dependency_model],
|
9
|
+
migration: false unless model_exists? && behavior == :invoke
|
10
|
+
end
|
11
|
+
|
12
|
+
def inject_model_content
|
13
|
+
content = model_contents
|
14
|
+
|
15
|
+
class_path = if namespaced?
|
16
|
+
class_name.to_s.split('::')
|
17
|
+
else
|
18
|
+
[class_name]
|
19
|
+
end
|
20
|
+
|
21
|
+
indent_depth = class_path.size - 1
|
22
|
+
content = content.split('\n').map { |line| ' ' * indent_depth + line } .join('\n') << '\n'
|
23
|
+
|
24
|
+
inject_into_class(model_path, class_path.last, content) if model_exists?
|
25
|
+
end
|
26
|
+
|
27
|
+
private
|
28
|
+
|
29
|
+
def dependency_model
|
30
|
+
::BraceComb.dependency_model.to_s.underscore
|
31
|
+
end
|
32
|
+
|
33
|
+
def model_exists?()
|
34
|
+
File.exist?(File.join(destination_root, model_path))
|
35
|
+
end
|
36
|
+
|
37
|
+
def model_path
|
38
|
+
@model_path ||= File.join('app', 'models', "#{dependency_model}.rb")
|
39
|
+
end
|
40
|
+
|
41
|
+
def model_contents
|
42
|
+
<<-CONTENT
|
43
|
+
enum status: { pending: 0, resolved: 2 }
|
44
|
+
CONTENT
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
metadata
ADDED
@@ -0,0 +1,205 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: brace_comb
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.2
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Ankita Gupta
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2017-08-18 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: activerecord
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '4.0'
|
20
|
+
- - "<"
|
21
|
+
- !ruby/object:Gem::Version
|
22
|
+
version: '5.2'
|
23
|
+
type: :runtime
|
24
|
+
prerelease: false
|
25
|
+
version_requirements: !ruby/object:Gem::Requirement
|
26
|
+
requirements:
|
27
|
+
- - ">="
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: '4.0'
|
30
|
+
- - "<"
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: '5.2'
|
33
|
+
- !ruby/object:Gem::Dependency
|
34
|
+
name: dry-configurable
|
35
|
+
requirement: !ruby/object:Gem::Requirement
|
36
|
+
requirements:
|
37
|
+
- - "~>"
|
38
|
+
- !ruby/object:Gem::Version
|
39
|
+
version: '0.6'
|
40
|
+
type: :runtime
|
41
|
+
prerelease: false
|
42
|
+
version_requirements: !ruby/object:Gem::Requirement
|
43
|
+
requirements:
|
44
|
+
- - "~>"
|
45
|
+
- !ruby/object:Gem::Version
|
46
|
+
version: '0.6'
|
47
|
+
- !ruby/object:Gem::Dependency
|
48
|
+
name: activesupport
|
49
|
+
requirement: !ruby/object:Gem::Requirement
|
50
|
+
requirements:
|
51
|
+
- - ">="
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
version: 4.2.5
|
54
|
+
type: :development
|
55
|
+
prerelease: false
|
56
|
+
version_requirements: !ruby/object:Gem::Requirement
|
57
|
+
requirements:
|
58
|
+
- - ">="
|
59
|
+
- !ruby/object:Gem::Version
|
60
|
+
version: 4.2.5
|
61
|
+
- !ruby/object:Gem::Dependency
|
62
|
+
name: bundler
|
63
|
+
requirement: !ruby/object:Gem::Requirement
|
64
|
+
requirements:
|
65
|
+
- - "~>"
|
66
|
+
- !ruby/object:Gem::Version
|
67
|
+
version: '1.15'
|
68
|
+
type: :development
|
69
|
+
prerelease: false
|
70
|
+
version_requirements: !ruby/object:Gem::Requirement
|
71
|
+
requirements:
|
72
|
+
- - "~>"
|
73
|
+
- !ruby/object:Gem::Version
|
74
|
+
version: '1.15'
|
75
|
+
- !ruby/object:Gem::Dependency
|
76
|
+
name: generator_spec
|
77
|
+
requirement: !ruby/object:Gem::Requirement
|
78
|
+
requirements:
|
79
|
+
- - "~>"
|
80
|
+
- !ruby/object:Gem::Version
|
81
|
+
version: 0.9.3
|
82
|
+
type: :development
|
83
|
+
prerelease: false
|
84
|
+
version_requirements: !ruby/object:Gem::Requirement
|
85
|
+
requirements:
|
86
|
+
- - "~>"
|
87
|
+
- !ruby/object:Gem::Version
|
88
|
+
version: 0.9.3
|
89
|
+
- !ruby/object:Gem::Dependency
|
90
|
+
name: pry
|
91
|
+
requirement: !ruby/object:Gem::Requirement
|
92
|
+
requirements:
|
93
|
+
- - ">="
|
94
|
+
- !ruby/object:Gem::Version
|
95
|
+
version: '0'
|
96
|
+
type: :development
|
97
|
+
prerelease: false
|
98
|
+
version_requirements: !ruby/object:Gem::Requirement
|
99
|
+
requirements:
|
100
|
+
- - ">="
|
101
|
+
- !ruby/object:Gem::Version
|
102
|
+
version: '0'
|
103
|
+
- !ruby/object:Gem::Dependency
|
104
|
+
name: rake
|
105
|
+
requirement: !ruby/object:Gem::Requirement
|
106
|
+
requirements:
|
107
|
+
- - "~>"
|
108
|
+
- !ruby/object:Gem::Version
|
109
|
+
version: '10.0'
|
110
|
+
type: :development
|
111
|
+
prerelease: false
|
112
|
+
version_requirements: !ruby/object:Gem::Requirement
|
113
|
+
requirements:
|
114
|
+
- - "~>"
|
115
|
+
- !ruby/object:Gem::Version
|
116
|
+
version: '10.0'
|
117
|
+
- !ruby/object:Gem::Dependency
|
118
|
+
name: rspec-rails
|
119
|
+
requirement: !ruby/object:Gem::Requirement
|
120
|
+
requirements:
|
121
|
+
- - "~>"
|
122
|
+
- !ruby/object:Gem::Version
|
123
|
+
version: '3.5'
|
124
|
+
type: :development
|
125
|
+
prerelease: false
|
126
|
+
version_requirements: !ruby/object:Gem::Requirement
|
127
|
+
requirements:
|
128
|
+
- - "~>"
|
129
|
+
- !ruby/object:Gem::Version
|
130
|
+
version: '3.5'
|
131
|
+
- !ruby/object:Gem::Dependency
|
132
|
+
name: sqlite3
|
133
|
+
requirement: !ruby/object:Gem::Requirement
|
134
|
+
requirements:
|
135
|
+
- - ">="
|
136
|
+
- !ruby/object:Gem::Version
|
137
|
+
version: '0'
|
138
|
+
type: :development
|
139
|
+
prerelease: false
|
140
|
+
version_requirements: !ruby/object:Gem::Requirement
|
141
|
+
requirements:
|
142
|
+
- - ">="
|
143
|
+
- !ruby/object:Gem::Version
|
144
|
+
version: '0'
|
145
|
+
- !ruby/object:Gem::Dependency
|
146
|
+
name: with_model
|
147
|
+
requirement: !ruby/object:Gem::Requirement
|
148
|
+
requirements:
|
149
|
+
- - "~>"
|
150
|
+
- !ruby/object:Gem::Version
|
151
|
+
version: '1.2'
|
152
|
+
type: :development
|
153
|
+
prerelease: false
|
154
|
+
version_requirements: !ruby/object:Gem::Requirement
|
155
|
+
requirements:
|
156
|
+
- - "~>"
|
157
|
+
- !ruby/object:Gem::Version
|
158
|
+
version: '1.2'
|
159
|
+
description: Allows setting of dependenices between jobs and setting rules for dependency
|
160
|
+
resolution
|
161
|
+
email:
|
162
|
+
- ankita.gupta@honestbee.com
|
163
|
+
executables: []
|
164
|
+
extensions: []
|
165
|
+
extra_rdoc_files: []
|
166
|
+
files:
|
167
|
+
- CODE_OF_CONDUCT.md
|
168
|
+
- README.md
|
169
|
+
- bin/console
|
170
|
+
- bin/setup
|
171
|
+
- lib/brace_comb.rb
|
172
|
+
- lib/brace_comb/config.rb
|
173
|
+
- lib/brace_comb/dependency_helper.rb
|
174
|
+
- lib/brace_comb/dependency_model.rb
|
175
|
+
- lib/brace_comb/exceptions/callback_failure.rb
|
176
|
+
- lib/brace_comb/version.rb
|
177
|
+
- lib/generators/brace_comb/generator.rb
|
178
|
+
- lib/generators/brace_comb/initializer_generator.rb
|
179
|
+
- lib/generators/brace_comb/migration_generator.rb
|
180
|
+
- lib/generators/brace_comb/model_generator.rb
|
181
|
+
homepage: https://github.com/honestbee/brace_comb
|
182
|
+
licenses:
|
183
|
+
- MIT
|
184
|
+
metadata: {}
|
185
|
+
post_install_message:
|
186
|
+
rdoc_options: []
|
187
|
+
require_paths:
|
188
|
+
- lib
|
189
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
190
|
+
requirements:
|
191
|
+
- - ">="
|
192
|
+
- !ruby/object:Gem::Version
|
193
|
+
version: '0'
|
194
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
195
|
+
requirements:
|
196
|
+
- - ">="
|
197
|
+
- !ruby/object:Gem::Version
|
198
|
+
version: '0'
|
199
|
+
requirements: []
|
200
|
+
rubyforge_project:
|
201
|
+
rubygems_version: 2.6.7
|
202
|
+
signing_key:
|
203
|
+
specification_version: 4
|
204
|
+
summary: Allows creation of job dependencies
|
205
|
+
test_files: []
|