dropkiq 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +8 -0
- data/.travis.yml +7 -0
- data/CODE_OF_CONDUCT.md +74 -0
- data/Gemfile +4 -0
- data/Gemfile.lock +51 -0
- data/LICENSE.txt +21 -0
- data/README.md +63 -0
- data/Rakefile +10 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/dropkiq.gemspec +47 -0
- data/lib/dropkiq.rb +14 -0
- data/lib/dropkiq/constants.rb +16 -0
- data/lib/dropkiq/drop_class_analyzer.rb +46 -0
- data/lib/dropkiq/drop_method_analyzer.rb +95 -0
- data/lib/dropkiq/railtie.rb +14 -0
- data/lib/dropkiq/tasks/dropkiq/schema.rake +25 -0
- data/lib/dropkiq/version.rb +3 -0
- metadata +162 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 67f91deee2e77eadf3639d16853d4c5c4e3fbff7
|
4
|
+
data.tar.gz: b506e1be0dcaeeecbc0bef0b01bd228a9658116a
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: c0b21a001f69663a377d163df25d0fa3ba26c868675348127b6e1f7228263137dedb95cbd48c0819b59647d489fa31e688855a12143c1cde734fcd5ba11c6c36
|
7
|
+
data.tar.gz: ce674e523319eaaa6c1f2ea8e435e693f9edb2ebbf359943e816be9b66c9e959e375ad4702c22dd01fb558dad868a68838cb0c29a95bfb0936699111a4194511
|
data/.gitignore
ADDED
data/.travis.yml
ADDED
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 piremies@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/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,51 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
dropkiq (0.1.0)
|
5
|
+
activerecord (>= 4.2)
|
6
|
+
liquid (~> 4.0)
|
7
|
+
|
8
|
+
GEM
|
9
|
+
remote: https://rubygems.org/
|
10
|
+
specs:
|
11
|
+
activemodel (5.2.3)
|
12
|
+
activesupport (= 5.2.3)
|
13
|
+
activerecord (5.2.3)
|
14
|
+
activemodel (= 5.2.3)
|
15
|
+
activesupport (= 5.2.3)
|
16
|
+
arel (>= 9.0)
|
17
|
+
activesupport (5.2.3)
|
18
|
+
concurrent-ruby (~> 1.0, >= 1.0.2)
|
19
|
+
i18n (>= 0.7, < 2)
|
20
|
+
minitest (~> 5.1)
|
21
|
+
tzinfo (~> 1.1)
|
22
|
+
arel (9.0.0)
|
23
|
+
coderay (1.1.2)
|
24
|
+
concurrent-ruby (1.1.5)
|
25
|
+
i18n (1.7.0)
|
26
|
+
concurrent-ruby (~> 1.0)
|
27
|
+
liquid (4.0.3)
|
28
|
+
method_source (0.9.2)
|
29
|
+
minitest (5.13.0)
|
30
|
+
pry (0.12.2)
|
31
|
+
coderay (~> 1.1.0)
|
32
|
+
method_source (~> 0.9.0)
|
33
|
+
rake (10.5.0)
|
34
|
+
sqlite3 (1.3.13)
|
35
|
+
thread_safe (0.3.6)
|
36
|
+
tzinfo (1.2.5)
|
37
|
+
thread_safe (~> 0.1)
|
38
|
+
|
39
|
+
PLATFORMS
|
40
|
+
ruby
|
41
|
+
|
42
|
+
DEPENDENCIES
|
43
|
+
bundler (~> 2.0)
|
44
|
+
dropkiq!
|
45
|
+
minitest (~> 5.0)
|
46
|
+
pry (~> 0.12.2)
|
47
|
+
rake (~> 10.0)
|
48
|
+
sqlite3 (~> 1.3.13)
|
49
|
+
|
50
|
+
BUNDLED WITH
|
51
|
+
2.0.1
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2019 Adam Darrah
|
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,63 @@
|
|
1
|
+
![Dropkiq_logo-dk](https://user-images.githubusercontent.com/69064/68704782-dd868e80-055a-11ea-952c-78bd9e9344d6.png)
|
2
|
+
|
3
|
+
# Dropkiq
|
4
|
+
|
5
|
+
**[Dropkiq](https://www.dropkiq.com/) simplifies the creation of Liquid expressions.** Quickly build your dynamic content with the simplest Liquid template editor.
|
6
|
+
|
7
|
+
* *Immediate Feedback:* No more guesswork. Know exactly how your expressions will evaluate in real time.
|
8
|
+
* *No More Typos:* To err is human. Identify mistakes as they happen and take corrective measures.
|
9
|
+
* *Visibility of Options:* Data at your fingertips. See what data is available without asking your development team.
|
10
|
+
|
11
|
+
Check it out at [https://www.dropkiq.com](https://www.dropkiq.com/)!
|
12
|
+
|
13
|
+
## Installation
|
14
|
+
|
15
|
+
Add this line to your application's Gemfile:
|
16
|
+
|
17
|
+
```ruby
|
18
|
+
gem 'dropkiq'
|
19
|
+
```
|
20
|
+
|
21
|
+
And then execute:
|
22
|
+
|
23
|
+
$ bundle
|
24
|
+
|
25
|
+
Or install it yourself as:
|
26
|
+
|
27
|
+
$ gem install dropkiq
|
28
|
+
|
29
|
+
## Usage
|
30
|
+
|
31
|
+
This Gem makes several assumptions about your Ruby on Rails application:
|
32
|
+
|
33
|
+
* Drop classes are expected to have the same name as the corresponding Rails model. For example, if you have an ActiveRecord model with name of `Person`, the drop class is expected to be called `PersonDrop`
|
34
|
+
* Drop class methods are expected to return the same data type as the corresponding Rails-model getter methods for relationships and columns.
|
35
|
+
* This Gem has not been tested with Rails models that have non-default primary key (other than `id`).
|
36
|
+
|
37
|
+
This Gem provides a rake command to generate a schema file that can be used to manage Fixtures on Dropkiq. Create the `db/dropkiq_schema.yaml` file by running the following command:
|
38
|
+
|
39
|
+
```
|
40
|
+
bundle exec rake dropkiq:schema
|
41
|
+
```
|
42
|
+
|
43
|
+
You should now have a `db/dropkiq_schema.yaml` file. This file describes all tables associated to Drop classes in your application, along with all methods avaialble to the Drop class. It is important that you **DO** allow this file to be checked in to version control so that you can maintain your Dropkiq schema over time as you add/remove/modify your Drop classes.
|
44
|
+
|
45
|
+
Notice that `type` has NOT been set on all methods. The Dropkiq Gem is only able to infer the method type for methods that correspond to a column or relationship on the ActiveRecord model. Please take a moment to manually add `type` values for all methods that were not able to be inferred. Notice that if you run `bundle exec rake dropkiq:schema` again, your changes are saved!
|
46
|
+
|
47
|
+
## Development
|
48
|
+
|
49
|
+
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake test` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
50
|
+
|
51
|
+
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
52
|
+
|
53
|
+
## Contributing
|
54
|
+
|
55
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/dropkiq. 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.
|
56
|
+
|
57
|
+
## License
|
58
|
+
|
59
|
+
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
60
|
+
|
61
|
+
## Code of Conduct
|
62
|
+
|
63
|
+
Everyone interacting in the Dropkiq project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/[USERNAME]/dropkiq/blob/master/CODE_OF_CONDUCT.md).
|
data/Rakefile
ADDED
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "dropkiq"
|
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/dropkiq.gemspec
ADDED
@@ -0,0 +1,47 @@
|
|
1
|
+
|
2
|
+
lib = File.expand_path("../lib", __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require "dropkiq/version"
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "dropkiq"
|
8
|
+
spec.version = Dropkiq::VERSION
|
9
|
+
spec.authors = ["Adam Darrah"]
|
10
|
+
spec.email = ["adam@dropkiq.com"]
|
11
|
+
|
12
|
+
spec.summary = %q{Integrate your Ruby on Rails application with Dropkiq for easy Liquid editing}
|
13
|
+
spec.description = %q{Dropkiq simplifies the creation of Liquid (from Shopify) expressions. The Dropkiq Ruby Gem automates the maintenance of fixtures within Dropkiq to allow for testing Liquid expressions.}
|
14
|
+
spec.homepage = "https://github.com/akdarrah/dropkiq-gem"
|
15
|
+
spec.license = "MIT"
|
16
|
+
|
17
|
+
# Prevent pushing this gem to RubyGems.org. To allow pushes either set the 'allowed_push_host'
|
18
|
+
# to allow pushing to a single host or delete this section to allow pushing to any host.
|
19
|
+
# if spec.respond_to?(:metadata)
|
20
|
+
# spec.metadata["allowed_push_host"] = "TODO: Set to 'http://mygemserver.com'"
|
21
|
+
#
|
22
|
+
# spec.metadata["homepage_uri"] = spec.homepage
|
23
|
+
# spec.metadata["source_code_uri"] = "https://github.com/akdarrah/dropkiq-gem"
|
24
|
+
# spec.metadata["changelog_uri"] = "https://github.com/akdarrah/dropkiq-gem"
|
25
|
+
# else
|
26
|
+
# raise "RubyGems 2.0 or newer is required to protect against " \
|
27
|
+
# "public gem pushes."
|
28
|
+
# end
|
29
|
+
|
30
|
+
# Specify which files should be added to the gem when it is released.
|
31
|
+
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
|
32
|
+
spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
|
33
|
+
`git ls-files -z`.split("\x0").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 "pry", "~> 0.12.2"
|
40
|
+
spec.add_development_dependency "bundler", "~> 2.0"
|
41
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
42
|
+
spec.add_development_dependency "minitest", "~> 5.0"
|
43
|
+
spec.add_development_dependency "sqlite3", "~> 1.3.13"
|
44
|
+
|
45
|
+
spec.add_dependency "activerecord", ">= 4.2"
|
46
|
+
spec.add_dependency "liquid", "~> 4.0"
|
47
|
+
end
|
data/lib/dropkiq.rb
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
require "pry"
|
2
|
+
require "liquid"
|
3
|
+
require 'active_record'
|
4
|
+
|
5
|
+
require "dropkiq/version"
|
6
|
+
require "dropkiq/constants"
|
7
|
+
|
8
|
+
require "dropkiq/drop_class_analyzer"
|
9
|
+
require "dropkiq/drop_method_analyzer"
|
10
|
+
require 'dropkiq/railtie' if defined?(Rails)
|
11
|
+
|
12
|
+
module Dropkiq
|
13
|
+
class Error < StandardError; end
|
14
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
module Dropkiq
|
2
|
+
DEFAULT_DROP_PATH = "/app/drops"
|
3
|
+
DEFAULT_LIQUID_DROP_CLASSES = [
|
4
|
+
Liquid::ForloopDrop,
|
5
|
+
Liquid::TablerowloopDrop
|
6
|
+
]
|
7
|
+
|
8
|
+
BOOLEAN_TYPE = "ColumnTypes::Boolean"
|
9
|
+
DATE_TIME_TYPE = "ColumnTypes::DateTime"
|
10
|
+
HAS_MANY_TYPE = "ColumnTypes::HasMany"
|
11
|
+
HAS_ONE_TYPE = "ColumnTypes::HasOne"
|
12
|
+
NUMERIC_TYPE = "ColumnTypes::Numeric"
|
13
|
+
STRING_TYPE = "ColumnTypes::String"
|
14
|
+
TEXT_TYPE = "ColumnTypes::Text"
|
15
|
+
YAML_TYPE = "ColumnTypes::YAML"
|
16
|
+
end
|
@@ -0,0 +1,46 @@
|
|
1
|
+
module Dropkiq
|
2
|
+
class DropClassAnalyzer
|
3
|
+
attr_accessor :liquid_drop_class, :table_name,
|
4
|
+
:active_record_class, :drop_method_params
|
5
|
+
|
6
|
+
def initialize(liquid_drop_class)
|
7
|
+
self.liquid_drop_class = liquid_drop_class
|
8
|
+
end
|
9
|
+
|
10
|
+
def analyze
|
11
|
+
self.active_record_class = find_active_record_class
|
12
|
+
self.table_name = active_record_class.table_name
|
13
|
+
self.drop_method_params = find_drop_method_params
|
14
|
+
end
|
15
|
+
|
16
|
+
def to_param
|
17
|
+
{
|
18
|
+
"#{table_name}" => {
|
19
|
+
"methods" => drop_method_params
|
20
|
+
}
|
21
|
+
}
|
22
|
+
end
|
23
|
+
|
24
|
+
private
|
25
|
+
|
26
|
+
def find_active_record_class
|
27
|
+
namespaces = liquid_drop_class.name.split("::")
|
28
|
+
class_name = namespaces.pop
|
29
|
+
non_drop = class_name.gsub('Drop', '')
|
30
|
+
|
31
|
+
namespaces.push(non_drop).join("::").constantize
|
32
|
+
rescue NameError
|
33
|
+
end
|
34
|
+
|
35
|
+
def find_drop_method_params
|
36
|
+
default_methods = (Liquid::Drop.instance_methods + Object.instance_methods)
|
37
|
+
instance_methods = (liquid_drop_class.instance_methods - default_methods)
|
38
|
+
|
39
|
+
instance_methods.inject({}) do |hash, method|
|
40
|
+
analyzer = Dropkiq::DropMethodAnalyzer.new(self, method)
|
41
|
+
analyzer.analyze
|
42
|
+
hash.merge!(analyzer.to_param)
|
43
|
+
end.sort_by { |key| key }.to_h
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
@@ -0,0 +1,95 @@
|
|
1
|
+
module Dropkiq
|
2
|
+
class DropMethodAnalyzer
|
3
|
+
attr_accessor :drop_class_analyzer, :drop_method,
|
4
|
+
:dropkiq_type, :foreign_table_name
|
5
|
+
|
6
|
+
delegate :active_record_class, to: :drop_class_analyzer
|
7
|
+
|
8
|
+
def initialize(drop_class_analyzer, drop_method)
|
9
|
+
self.drop_class_analyzer = drop_class_analyzer
|
10
|
+
self.drop_method = drop_method
|
11
|
+
end
|
12
|
+
|
13
|
+
def analyze
|
14
|
+
self.dropkiq_type = if is_relationship?
|
15
|
+
relationship_to_dropkiq_type_classifier
|
16
|
+
elsif is_column?
|
17
|
+
column_to_dropkiq_type_classifier
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
def to_param
|
22
|
+
{
|
23
|
+
"#{drop_method}" => {
|
24
|
+
"type" => dropkiq_type,
|
25
|
+
"foreign_table_name" => foreign_table_name
|
26
|
+
}
|
27
|
+
}
|
28
|
+
end
|
29
|
+
|
30
|
+
private
|
31
|
+
|
32
|
+
def reflect_on_association_value
|
33
|
+
active_record_class.reflect_on_association(drop_method)
|
34
|
+
end
|
35
|
+
|
36
|
+
def is_relationship?
|
37
|
+
reflect_on_association_value.present?
|
38
|
+
end
|
39
|
+
|
40
|
+
def relationship_to_dropkiq_type_classifier
|
41
|
+
reflection = reflect_on_association_value
|
42
|
+
self.foreign_table_name = reflection.class_name.constantize.table_name
|
43
|
+
|
44
|
+
case reflection
|
45
|
+
when ActiveRecord::Reflection::BelongsToReflection
|
46
|
+
Dropkiq::HAS_ONE_TYPE
|
47
|
+
when ActiveRecord::Reflection::HasOneReflection
|
48
|
+
Dropkiq::HAS_ONE_TYPE
|
49
|
+
when ActiveRecord::Reflection::HasManyReflection
|
50
|
+
Dropkiq::HAS_MANY_TYPE
|
51
|
+
when ActiveRecord::Reflection::ThroughReflection
|
52
|
+
if reflection.send(:delegate_reflection).is_a?(ActiveRecord::Reflection::HasOneReflection)
|
53
|
+
Dropkiq::HAS_ONE_TYPE
|
54
|
+
else
|
55
|
+
Dropkiq::HAS_MANY_TYPE
|
56
|
+
end
|
57
|
+
when ActiveRecord::Reflection::HasAndBelongsToManyReflection
|
58
|
+
Dropkiq::HAS_MANY_TYPE
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
62
|
+
def columns_hash_value
|
63
|
+
active_record_class.columns_hash[drop_method.to_s]
|
64
|
+
end
|
65
|
+
|
66
|
+
def is_column?
|
67
|
+
columns_hash_value.present?
|
68
|
+
end
|
69
|
+
|
70
|
+
def column_to_dropkiq_type_classifier
|
71
|
+
case columns_hash_value.type
|
72
|
+
when :string
|
73
|
+
Dropkiq::STRING_TYPE
|
74
|
+
when :integer
|
75
|
+
Dropkiq::NUMERIC_TYPE
|
76
|
+
when :boolean
|
77
|
+
Dropkiq::BOOLEAN_TYPE
|
78
|
+
when :datetime
|
79
|
+
Dropkiq::DATE_TIME_TYPE
|
80
|
+
when :date
|
81
|
+
Dropkiq::DATE_TIME_TYPE
|
82
|
+
when :decimal
|
83
|
+
Dropkiq::NUMERIC_TYPE
|
84
|
+
when :float
|
85
|
+
Dropkiq::NUMERIC_TYPE
|
86
|
+
when :text
|
87
|
+
Dropkiq::TEXT_TYPE
|
88
|
+
when :time
|
89
|
+
Dropkiq::DATE_TIME_TYPE
|
90
|
+
when :binary
|
91
|
+
Dropkiq::NUMERIC_TYPE
|
92
|
+
end
|
93
|
+
end
|
94
|
+
end
|
95
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
# lib/railtie.rb
|
2
|
+
require 'dropkiq'
|
3
|
+
require 'rails'
|
4
|
+
|
5
|
+
module Dropkiq
|
6
|
+
class Railtie < Rails::Railtie
|
7
|
+
railtie_name :dropkiq
|
8
|
+
|
9
|
+
rake_tasks do
|
10
|
+
path = File.expand_path(__dir__)
|
11
|
+
Dir.glob("#{path}/tasks/**/*.rake").each { |f| load f }
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
namespace :dropkiq do
|
2
|
+
desc "Generate the fixture schema based on Liquid::Drop classes"
|
3
|
+
task :schema do
|
4
|
+
require "#{Rails.root}/config/environment.rb"
|
5
|
+
Dir.glob("#{Rails.root}#{Dropkiq::DEFAULT_DROP_PATH}/**/*.rb").each { |f| load f }
|
6
|
+
|
7
|
+
existing_schema_yaml = begin
|
8
|
+
File.read("#{Rails.root}/db/dropkiq_schema.yaml")
|
9
|
+
rescue Errno::ENOENT
|
10
|
+
end
|
11
|
+
existing_schema = (existing_schema_yaml.present? ? YAML.load(existing_schema_yaml) : {})
|
12
|
+
|
13
|
+
klasses = Liquid::Drop.descendants - Dropkiq::DEFAULT_LIQUID_DROP_CLASSES
|
14
|
+
fresh_schema = klasses.inject({}) do |schema, klass|
|
15
|
+
analyzer = Dropkiq::DropClassAnalyzer.new(klass)
|
16
|
+
analyzer.analyze
|
17
|
+
schema.merge!(analyzer.to_param)
|
18
|
+
end.sort_by { |key| key }.to_h
|
19
|
+
|
20
|
+
final_schema = fresh_schema.deep_merge(existing_schema)
|
21
|
+
open("#{Rails.root}/db/dropkiq_schema.yaml", 'w') { |f|
|
22
|
+
f.puts final_schema.to_yaml
|
23
|
+
}
|
24
|
+
end
|
25
|
+
end
|
metadata
ADDED
@@ -0,0 +1,162 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: dropkiq
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Adam Darrah
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2019-11-12 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: pry
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: 0.12.2
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: 0.12.2
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: bundler
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '2.0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '2.0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rake
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '10.0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '10.0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: minitest
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '5.0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '5.0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: sqlite3
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - "~>"
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: 1.3.13
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - "~>"
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: 1.3.13
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: activerecord
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - ">="
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '4.2'
|
90
|
+
type: :runtime
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - ">="
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '4.2'
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: liquid
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - "~>"
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: '4.0'
|
104
|
+
type: :runtime
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - "~>"
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: '4.0'
|
111
|
+
description: Dropkiq simplifies the creation of Liquid (from Shopify) expressions.
|
112
|
+
The Dropkiq Ruby Gem automates the maintenance of fixtures within Dropkiq to allow
|
113
|
+
for testing Liquid expressions.
|
114
|
+
email:
|
115
|
+
- adam@dropkiq.com
|
116
|
+
executables: []
|
117
|
+
extensions: []
|
118
|
+
extra_rdoc_files: []
|
119
|
+
files:
|
120
|
+
- ".gitignore"
|
121
|
+
- ".travis.yml"
|
122
|
+
- CODE_OF_CONDUCT.md
|
123
|
+
- Gemfile
|
124
|
+
- Gemfile.lock
|
125
|
+
- LICENSE.txt
|
126
|
+
- README.md
|
127
|
+
- Rakefile
|
128
|
+
- bin/console
|
129
|
+
- bin/setup
|
130
|
+
- dropkiq.gemspec
|
131
|
+
- lib/dropkiq.rb
|
132
|
+
- lib/dropkiq/constants.rb
|
133
|
+
- lib/dropkiq/drop_class_analyzer.rb
|
134
|
+
- lib/dropkiq/drop_method_analyzer.rb
|
135
|
+
- lib/dropkiq/railtie.rb
|
136
|
+
- lib/dropkiq/tasks/dropkiq/schema.rake
|
137
|
+
- lib/dropkiq/version.rb
|
138
|
+
homepage: https://github.com/akdarrah/dropkiq-gem
|
139
|
+
licenses:
|
140
|
+
- MIT
|
141
|
+
metadata: {}
|
142
|
+
post_install_message:
|
143
|
+
rdoc_options: []
|
144
|
+
require_paths:
|
145
|
+
- lib
|
146
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
147
|
+
requirements:
|
148
|
+
- - ">="
|
149
|
+
- !ruby/object:Gem::Version
|
150
|
+
version: '0'
|
151
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
152
|
+
requirements:
|
153
|
+
- - ">="
|
154
|
+
- !ruby/object:Gem::Version
|
155
|
+
version: '0'
|
156
|
+
requirements: []
|
157
|
+
rubyforge_project:
|
158
|
+
rubygems_version: 2.6.14.1
|
159
|
+
signing_key:
|
160
|
+
specification_version: 4
|
161
|
+
summary: Integrate your Ruby on Rails application with Dropkiq for easy Liquid editing
|
162
|
+
test_files: []
|