pg_serializable 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 +11 -0
- data/.rspec +3 -0
- data/.travis.yml +7 -0
- data/CODE_OF_CONDUCT.md +74 -0
- data/Gemfile +6 -0
- data/LICENSE.txt +21 -0
- data/README.md +43 -0
- data/Rakefile +6 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/lib/pg_serializable/aliaser.rb +15 -0
- data/lib/pg_serializable/errors.rb +6 -0
- data/lib/pg_serializable/nodes/as.rb +14 -0
- data/lib/pg_serializable/nodes/association.rb +71 -0
- data/lib/pg_serializable/nodes/attribute.rb +14 -0
- data/lib/pg_serializable/nodes/base.rb +9 -0
- data/lib/pg_serializable/nodes/coalesce.rb +13 -0
- data/lib/pg_serializable/nodes/json_agg.rb +13 -0
- data/lib/pg_serializable/nodes/json_array.rb +13 -0
- data/lib/pg_serializable/nodes/json_build_object.rb +13 -0
- data/lib/pg_serializable/nodes.rb +8 -0
- data/lib/pg_serializable/serializer.rb +102 -0
- data/lib/pg_serializable/version.rb +3 -0
- data/lib/pg_serializable.rb +47 -0
- data/pg_serializable.gemspec +41 -0
- metadata +139 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 9ef02b6457601f2d201dc81241644ceeda7914df
|
4
|
+
data.tar.gz: a19b84c078527d28c20e387665efac2830f41c5c
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: e0093725bd655c8f1e9f96f4e3576d639925e52af60402c11d549147b0bfe999a9d2453fb30ecab65300669e3fdaf6b0b60ad20f8f57626cbb8e506b2e951d6a
|
7
|
+
data.tar.gz: 952b1b05a28ce3a1706d8ec7f2f201d6e2d24d025913d75687824279f3c58867e55a7d70c6ca6b402a8d1d50f26d39da01101f1180549ed7827cb854664c3564
|
data/.gitignore
ADDED
data/.rspec
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 matthewjf@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/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2018 matthewjf
|
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,43 @@
|
|
1
|
+
# PgSerializable
|
2
|
+
|
3
|
+
Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/pg_serializable`. To experiment with that code, run `bin/console` for an interactive prompt.
|
4
|
+
|
5
|
+
TODO: Delete this and the text above, and describe your gem
|
6
|
+
|
7
|
+
## Installation
|
8
|
+
|
9
|
+
Add this line to your application's Gemfile:
|
10
|
+
|
11
|
+
```ruby
|
12
|
+
gem 'pg_serializable'
|
13
|
+
```
|
14
|
+
|
15
|
+
And then execute:
|
16
|
+
|
17
|
+
$ bundle
|
18
|
+
|
19
|
+
Or install it yourself as:
|
20
|
+
|
21
|
+
$ gem install pg_serializable
|
22
|
+
|
23
|
+
## Usage
|
24
|
+
|
25
|
+
TODO: Write usage instructions here
|
26
|
+
|
27
|
+
## Development
|
28
|
+
|
29
|
+
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
30
|
+
|
31
|
+
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).
|
32
|
+
|
33
|
+
## Contributing
|
34
|
+
|
35
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/pg_serializable. 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.
|
36
|
+
|
37
|
+
## License
|
38
|
+
|
39
|
+
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
40
|
+
|
41
|
+
## Code of Conduct
|
42
|
+
|
43
|
+
Everyone interacting in the PgSerializable project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/[USERNAME]/pg_serializable/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 "pg_serializable"
|
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
@@ -0,0 +1,14 @@
|
|
1
|
+
module PgSerializable
|
2
|
+
module Nodes
|
3
|
+
class As < Base
|
4
|
+
def initialize(scope, table_alias)
|
5
|
+
@scope = scope
|
6
|
+
@table_alias = table_alias
|
7
|
+
end
|
8
|
+
|
9
|
+
def to_sql
|
10
|
+
"(#{@scope.respond_to?(:to_sql) ? @scope.to_sql : @scope.to_s}) #{@table_alias}"
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
@@ -0,0 +1,71 @@
|
|
1
|
+
module PgSerializable
|
2
|
+
module Nodes
|
3
|
+
class Association < Base
|
4
|
+
attr_reader :klass, :name
|
5
|
+
|
6
|
+
def initialize(klass, name, type, label: nil)
|
7
|
+
@name = name
|
8
|
+
@klass = klass
|
9
|
+
@type = type
|
10
|
+
@label = label || name
|
11
|
+
end
|
12
|
+
|
13
|
+
def to_sql(outer_alias, aliaser)
|
14
|
+
["\'#{@label}\'", "(#{value(outer_alias, aliaser)})"].join(',')
|
15
|
+
end
|
16
|
+
|
17
|
+
def target
|
18
|
+
@target ||= association.klass
|
19
|
+
end
|
20
|
+
|
21
|
+
private
|
22
|
+
|
23
|
+
def value(outer_alias, aliaser)
|
24
|
+
next_alias = aliaser.next!
|
25
|
+
self.send(@type, outer_alias, next_alias, aliaser)
|
26
|
+
end
|
27
|
+
|
28
|
+
def has_many(outer_alias, next_alias, aliaser)
|
29
|
+
return has_many_through(outer_alias, next_alias, aliaser) if association.through_reflection?
|
30
|
+
target.as_json_array(aliaser).where("#{next_alias}.#{primary_key}=#{outer_alias}.#{foreign_key}").to_sql
|
31
|
+
end
|
32
|
+
|
33
|
+
def has_many_through(outer_alias, next_alias, aliaser)
|
34
|
+
through = association.through_reflection
|
35
|
+
source = association.source_reflection
|
36
|
+
# NOTE: this will fail if the source table shares the same foreign key as your join table
|
37
|
+
# i.e. products and categories have a join table but categories has a product_id column
|
38
|
+
association
|
39
|
+
.klass
|
40
|
+
.select("#{source.table_name}.*, #{through.table_name}.#{source.join_foreign_key}, #{through.table_name}.#{through.join_primary_key}")
|
41
|
+
.joins(through.name)
|
42
|
+
.as_json_array(aliaser)
|
43
|
+
.where("#{next_alias}.#{through.join_primary_key}=#{outer_alias}.#{foreign_key}")
|
44
|
+
.to_sql
|
45
|
+
end
|
46
|
+
|
47
|
+
def has_one(outer_alias, next_alias, aliaser)
|
48
|
+
subquery_alias = "#{next_alias[0]}#{next_alias[1]}#{next_alias[0]}" # avoid alias collision
|
49
|
+
target.select("DISTINCT ON (#{primary_key}) #{subquery_alias}.*").from(
|
50
|
+
"#{target.table_name} #{subquery_alias}"
|
51
|
+
).as_json_object(aliaser).where("#{next_alias}.#{primary_key}=#{outer_alias}.#{foreign_key}").to_sql
|
52
|
+
end
|
53
|
+
|
54
|
+
def belongs_to(outer_alias, next_alias, aliaser)
|
55
|
+
target.as_json_object(aliaser).where("#{next_alias}.#{primary_key}=#{outer_alias}.#{foreign_key}").to_sql
|
56
|
+
end
|
57
|
+
|
58
|
+
def association
|
59
|
+
@association ||= @klass.reflect_on_association(@name)
|
60
|
+
end
|
61
|
+
|
62
|
+
def foreign_key
|
63
|
+
@foreign_key ||= association.join_foreign_key
|
64
|
+
end
|
65
|
+
|
66
|
+
def primary_key
|
67
|
+
@primary_key ||= association.join_primary_key
|
68
|
+
end
|
69
|
+
end
|
70
|
+
end
|
71
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
module PgSerializable
|
2
|
+
module Nodes
|
3
|
+
class Attribute < Base
|
4
|
+
def initialize(column_name, label: nil)
|
5
|
+
@column_name = column_name
|
6
|
+
@label = label || column_name
|
7
|
+
end
|
8
|
+
|
9
|
+
def to_sql(table_alias=nil)
|
10
|
+
["\'#{@label}\'", "#{table_alias ? table_alias + '.' : ''}#{@column_name}"].join(',')
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
@@ -0,0 +1,8 @@
|
|
1
|
+
require 'pg_serializable/nodes/base'
|
2
|
+
require 'pg_serializable/nodes/as'
|
3
|
+
require 'pg_serializable/nodes/association'
|
4
|
+
require 'pg_serializable/nodes/attribute'
|
5
|
+
require 'pg_serializable/nodes/coalesce'
|
6
|
+
require 'pg_serializable/nodes/json_agg'
|
7
|
+
require 'pg_serializable/nodes/json_array'
|
8
|
+
require 'pg_serializable/nodes/json_build_object'
|
@@ -0,0 +1,102 @@
|
|
1
|
+
module PgSerializable
|
2
|
+
class Serializer
|
3
|
+
attr_reader :klass
|
4
|
+
|
5
|
+
def initialize(klass)
|
6
|
+
@klass = klass
|
7
|
+
@attributes = []
|
8
|
+
end
|
9
|
+
|
10
|
+
def attributes(*attrs)
|
11
|
+
attrs.each do |attribute|
|
12
|
+
@attributes << Nodes::Attribute.new(attribute) if column_exists?(attribute)
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
def attribute(column_name, label: nil)
|
17
|
+
@attributes << Nodes::Attribute.new(column_name, label: label) if column_exists?(column_name)
|
18
|
+
end
|
19
|
+
|
20
|
+
def has_many(association, label: nil)
|
21
|
+
@attributes << Nodes::Association.new(klass, association, :has_many, label: label) if association_exists?(association)
|
22
|
+
end
|
23
|
+
|
24
|
+
def belongs_to(association, label: nil)
|
25
|
+
@attributes << Nodes::Association.new(klass, association, :belongs_to, label: label) if association_exists?(association)
|
26
|
+
end
|
27
|
+
|
28
|
+
def has_one(association, label: nil)
|
29
|
+
@attributes << Nodes::Association.new(klass, association, :has_one, label: label) if association_exists?(association)
|
30
|
+
end
|
31
|
+
|
32
|
+
def as_json_array(skope, aliaser)
|
33
|
+
@aliaser = aliaser
|
34
|
+
@table_alias = @aliaser.to_s
|
35
|
+
query(json_agg.to_sql, skope)
|
36
|
+
end
|
37
|
+
|
38
|
+
def as_json_object(skope, aliaser)
|
39
|
+
@aliaser = aliaser
|
40
|
+
@table_alias = @aliaser.to_s
|
41
|
+
query(json_build_object.to_sql, skope)
|
42
|
+
end
|
43
|
+
|
44
|
+
def check_for_cycles!(klass=self.klass)
|
45
|
+
@attributes.each do |attribute|
|
46
|
+
next unless attribute.is_a?(Nodes::Association)
|
47
|
+
target_klass = attribute.target
|
48
|
+
raise AssociationError.new("serializers contain a cycle, check class `#{attribute.klass}` for association `:#{attribute.name}`") if target_klass == klass
|
49
|
+
target_klass.serializer.check_for_cycles!(self.klass)
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
private
|
54
|
+
|
55
|
+
def query(select_sql, from_scope)
|
56
|
+
klass
|
57
|
+
.unscoped
|
58
|
+
.select(select_sql)
|
59
|
+
.from(Nodes::As.new(from_scope, @table_alias).to_sql)
|
60
|
+
end
|
61
|
+
|
62
|
+
def build_attributes
|
63
|
+
res = []
|
64
|
+
@attributes.each do |attribute|
|
65
|
+
if attribute.is_a?(Nodes::Attribute)
|
66
|
+
res << attribute.to_sql(@table_alias)
|
67
|
+
elsif attribute.is_a?(Nodes::Association)
|
68
|
+
res << attribute.to_sql(@table_alias, @aliaser)
|
69
|
+
else
|
70
|
+
raise 'unknown attribute type'
|
71
|
+
end
|
72
|
+
end
|
73
|
+
res.join(',')
|
74
|
+
end
|
75
|
+
|
76
|
+
def json_build_object
|
77
|
+
Nodes::JsonBuildObject.new(build_attributes)
|
78
|
+
end
|
79
|
+
|
80
|
+
def json_agg
|
81
|
+
Nodes::Coalesce.new(Nodes::JsonAgg.new(json_build_object), Nodes::JsonArray.new)
|
82
|
+
end
|
83
|
+
|
84
|
+
def table_alias
|
85
|
+
@table_alias
|
86
|
+
end
|
87
|
+
|
88
|
+
def association(name)
|
89
|
+
klass.reflect_on_association(name)
|
90
|
+
end
|
91
|
+
|
92
|
+
def column_exists?(column_name)
|
93
|
+
raise AttributeError.new("`#{column_name.to_s}` column doesn't exist for table #{klass.table_name}") unless klass.column_names.include? column_name.to_s
|
94
|
+
true
|
95
|
+
end
|
96
|
+
|
97
|
+
def association_exists?(name)
|
98
|
+
raise AssociationError.new("`#{name.to_s}` association doesn't exist for table #{klass.table_name}") if klass.reflect_on_association(name).nil?
|
99
|
+
true
|
100
|
+
end
|
101
|
+
end
|
102
|
+
end
|
@@ -0,0 +1,47 @@
|
|
1
|
+
require 'active_support/concern'
|
2
|
+
|
3
|
+
require 'pg_serializable/version'
|
4
|
+
require 'pg_serializable/errors'
|
5
|
+
require 'pg_serializable/aliaser'
|
6
|
+
require 'pg_serializable/nodes'
|
7
|
+
require 'pg_serializable/serializer'
|
8
|
+
|
9
|
+
module PgSerializable
|
10
|
+
extend ActiveSupport::Concern
|
11
|
+
included do
|
12
|
+
def json
|
13
|
+
ActiveRecord::Base.connection.select_one(
|
14
|
+
self.class.where(id: id).limit(1).as_json_object.to_sql
|
15
|
+
)['json_build_object']
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
class_methods do
|
20
|
+
def json
|
21
|
+
ActiveRecord::Base.connection.select_one(
|
22
|
+
serializer.as_json_array(pg_scope, Aliaser.new).to_sql
|
23
|
+
)['coalesce']
|
24
|
+
end
|
25
|
+
|
26
|
+
def as_json_array(table_alias = Aliaser.new)
|
27
|
+
serializer.as_json_array(pg_scope, table_alias)
|
28
|
+
end
|
29
|
+
|
30
|
+
def as_json_object(table_alias = Aliaser.new)
|
31
|
+
serializer.as_json_object(pg_scope, table_alias)
|
32
|
+
end
|
33
|
+
|
34
|
+
def serializable(&blk)
|
35
|
+
serializer.instance_eval &blk
|
36
|
+
serializer.check_for_cycles!
|
37
|
+
end
|
38
|
+
|
39
|
+
def serializer
|
40
|
+
@serializer ||= Serializer.new(self)
|
41
|
+
end
|
42
|
+
|
43
|
+
def pg_scope
|
44
|
+
respond_to?(:to_sql) ? self : all
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
@@ -0,0 +1,41 @@
|
|
1
|
+
|
2
|
+
lib = File.expand_path("../lib", __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require "pg_serializable/version"
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "pg_serializable"
|
8
|
+
spec.version = PgSerializable::VERSION
|
9
|
+
spec.authors = ["matthewjf"]
|
10
|
+
spec.email = ["matthewjf@gmail.com"]
|
11
|
+
|
12
|
+
spec.summary = %q{serializes rails models from postgres (9.5+)}
|
13
|
+
spec.description = %q{serializes rails models from postgres (9.5+)}
|
14
|
+
spec.homepage = "https://github.com/matthewjf/pg_serializable"
|
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
|
+
# else
|
22
|
+
# raise "RubyGems 2.0 or newer is required to protect against " \
|
23
|
+
# "public gem pushes."
|
24
|
+
# end
|
25
|
+
|
26
|
+
# Specify which files should be added to the gem when it is released.
|
27
|
+
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
|
28
|
+
spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
|
29
|
+
`git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
30
|
+
end
|
31
|
+
spec.bindir = "exe"
|
32
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
33
|
+
spec.require_paths = ["lib"]
|
34
|
+
|
35
|
+
spec.add_development_dependency "bundler", "~> 1.16"
|
36
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
37
|
+
spec.add_development_dependency "rspec", "~> 3.0"
|
38
|
+
|
39
|
+
spec.add_runtime_dependency "activesupport", "~> 5.2"
|
40
|
+
spec.add_runtime_dependency "activerecord", "~> 5.2"
|
41
|
+
end
|
metadata
ADDED
@@ -0,0 +1,139 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: pg_serializable
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- matthewjf
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2018-10-03 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.16'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.16'
|
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: rspec
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '3.0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '3.0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: activesupport
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '5.2'
|
62
|
+
type: :runtime
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '5.2'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: activerecord
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - "~>"
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '5.2'
|
76
|
+
type: :runtime
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - "~>"
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '5.2'
|
83
|
+
description: serializes rails models from postgres (9.5+)
|
84
|
+
email:
|
85
|
+
- matthewjf@gmail.com
|
86
|
+
executables: []
|
87
|
+
extensions: []
|
88
|
+
extra_rdoc_files: []
|
89
|
+
files:
|
90
|
+
- ".gitignore"
|
91
|
+
- ".rspec"
|
92
|
+
- ".travis.yml"
|
93
|
+
- CODE_OF_CONDUCT.md
|
94
|
+
- Gemfile
|
95
|
+
- LICENSE.txt
|
96
|
+
- README.md
|
97
|
+
- Rakefile
|
98
|
+
- bin/console
|
99
|
+
- bin/setup
|
100
|
+
- lib/pg_serializable.rb
|
101
|
+
- lib/pg_serializable/aliaser.rb
|
102
|
+
- lib/pg_serializable/errors.rb
|
103
|
+
- lib/pg_serializable/nodes.rb
|
104
|
+
- lib/pg_serializable/nodes/as.rb
|
105
|
+
- lib/pg_serializable/nodes/association.rb
|
106
|
+
- lib/pg_serializable/nodes/attribute.rb
|
107
|
+
- lib/pg_serializable/nodes/base.rb
|
108
|
+
- lib/pg_serializable/nodes/coalesce.rb
|
109
|
+
- lib/pg_serializable/nodes/json_agg.rb
|
110
|
+
- lib/pg_serializable/nodes/json_array.rb
|
111
|
+
- lib/pg_serializable/nodes/json_build_object.rb
|
112
|
+
- lib/pg_serializable/serializer.rb
|
113
|
+
- lib/pg_serializable/version.rb
|
114
|
+
- pg_serializable.gemspec
|
115
|
+
homepage: https://github.com/matthewjf/pg_serializable
|
116
|
+
licenses:
|
117
|
+
- MIT
|
118
|
+
metadata: {}
|
119
|
+
post_install_message:
|
120
|
+
rdoc_options: []
|
121
|
+
require_paths:
|
122
|
+
- lib
|
123
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
124
|
+
requirements:
|
125
|
+
- - ">="
|
126
|
+
- !ruby/object:Gem::Version
|
127
|
+
version: '0'
|
128
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
129
|
+
requirements:
|
130
|
+
- - ">="
|
131
|
+
- !ruby/object:Gem::Version
|
132
|
+
version: '0'
|
133
|
+
requirements: []
|
134
|
+
rubyforge_project:
|
135
|
+
rubygems_version: 2.5.2
|
136
|
+
signing_key:
|
137
|
+
specification_version: 4
|
138
|
+
summary: serializes rails models from postgres (9.5+)
|
139
|
+
test_files: []
|