activerecord-except 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 040e5cdb7c16b43d480090c15a88766f3590dabd3b69dbec36e5e13be40707f2
4
+ data.tar.gz: 53aa5d6555aca4d447b3015d746de3789832f3cb92b0eb3d555171ec35f660d9
5
+ SHA512:
6
+ metadata.gz: ebf822a0f929243658263d2462c86f5a2c504ce2a8161967323ee19b7fda1af9d8da6fbe4386b0e4f1803175b849ba519368b5e55a9b182d0fabf8fa6ddcffbd
7
+ data.tar.gz: 6a4a4899a4381c2addf2f466810ea072680d219cf3249b00877d8b65575858b05e74806d4b71cdc14b944ff3ffc98f768a99f01b0255fd9c7c842d08bdd61eda
@@ -0,0 +1,10 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /_yardoc/
4
+ /coverage/
5
+ /doc/
6
+ /pkg/
7
+ /spec/reports/
8
+ /tmp/
9
+ tags
10
+ Gemfile.lock
@@ -0,0 +1,6 @@
1
+ ---
2
+ language: ruby
3
+ cache: bundler
4
+ rvm:
5
+ - 2.6.6
6
+ before_install: gem install bundler -v 2.1.4
data/Gemfile ADDED
@@ -0,0 +1,8 @@
1
+ # frozen_string_literal: true
2
+
3
+ source 'https://rubygems.org'
4
+
5
+ gemspec
6
+
7
+ gem 'minitest', '~> 5.0'
8
+ gem 'rake', '~> 12.0'
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2020 Mauro Morales
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.
@@ -0,0 +1,41 @@
1
+ # Activerecord::Except
2
+
3
+ Provides `ActiveRecord::Relation#except`, a convenience method that let's you
4
+ select all the fields from a table with the exception of the given ones.
5
+
6
+ ## Installation
7
+
8
+ Add this line to your Rails' application Gemfile:
9
+
10
+ ```ruby
11
+ gem 'activerecord-except'
12
+ ```
13
+
14
+ And then execute:
15
+
16
+ $ bundle install
17
+
18
+ ## Usage
19
+
20
+ ```ruby
21
+ User.all.except(:unwanted_field_name)
22
+ ```
23
+
24
+ ## Development
25
+
26
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run
27
+ `rake test` to run the tests. You can also run `bin/console` for an interactive
28
+ prompt that will allow you to experiment.
29
+
30
+ To install this gem onto your local machine, run `bundle exec rake install`. To
31
+ release a new version, update the version number in `version.rb`, and then run
32
+ `bundle exec rake release`, which will create a git tag for the version, push
33
+ git commits and tags, and push the `.gem` file to
34
+ [rubygems.org](https://rubygems.org).
35
+
36
+
37
+
38
+ ## License
39
+
40
+ The gem is available as open source under the terms of the [MIT
41
+ License](https://opensource.org/licenses/MIT).
@@ -0,0 +1,12 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'bundler/gem_tasks'
4
+ require 'rake/testtask'
5
+
6
+ Rake::TestTask.new(:test) do |t|
7
+ t.libs << 'test'
8
+ t.libs << 'lib'
9
+ t.test_files = FileList['test/**/*_test.rb']
10
+ end
11
+
12
+ task default: :test
@@ -0,0 +1,38 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative 'lib/activerecord/except/version'
4
+
5
+ Gem::Specification.new do |spec|
6
+ spec.name = 'activerecord-except'
7
+ spec.version = Activerecord::Except::VERSION
8
+ spec.authors = ['Mauro Morales']
9
+ spec.email = ['contact@mauromorales.com']
10
+
11
+ spec.summary = 'Select all fields from a table with the exception of the given ones'
12
+ spec.description = <<~TEXT
13
+ Provides `ActiveRecord::Relation#except`, a convenience method that let's
14
+ you select all the fields from a table with the exception of the given
15
+ ones.
16
+ TEXT
17
+ spec.homepage = 'https://git.sr.ht/~mrls/activerecord-except'
18
+ spec.license = 'MIT'
19
+ spec.required_ruby_version = Gem::Requirement.new('>= 2.3.0')
20
+
21
+ spec.metadata['homepage_uri'] = spec.homepage
22
+ spec.metadata['source_code_uri'] = 'https://git.sr.ht/~mrls/activerecord-except'
23
+
24
+ # Specify which files should be added to the gem when it is released.
25
+ # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
26
+ spec.files = Dir.chdir(File.expand_path(__dir__)) do
27
+ `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
28
+ end
29
+ spec.bindir = 'exe'
30
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
31
+ spec.require_paths = ['lib']
32
+
33
+ spec.add_dependency 'activerecord', '>= 4'
34
+
35
+ spec.add_development_dependency 'minitest'
36
+ spec.add_development_dependency 'rake'
37
+ spec.add_development_dependency 'sqlite3'
38
+ end
@@ -0,0 +1,15 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
4
+ require 'bundler/setup'
5
+ require 'activerecord/except'
6
+
7
+ # You can add fixtures and/or initialization code here to make experimenting
8
+ # with your gem easier. You can also use a different console, if you like.
9
+
10
+ # (If you use this, don't forget to add pry to your Gemfile!)
11
+ # require "pry"
12
+ # Pry.start
13
+
14
+ require 'irb'
15
+ IRB.start(__FILE__)
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,10 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'activerecord/except/relation'
4
+ require 'activerecord/except/version'
5
+
6
+ module Activerecord
7
+ module Except
8
+ class Error < StandardError; end
9
+ end
10
+ end
@@ -0,0 +1,10 @@
1
+ # frozen_string_literal: true
2
+
3
+ module ActiveRecord
4
+ class Relation
5
+ def except(*fields)
6
+ inverted_fields = klass._default_attributes.keys.map(&:to_sym).reject { |attr| fields.include?(attr) }
7
+ _select!(inverted_fields)
8
+ end
9
+ end
10
+ end
@@ -0,0 +1,7 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Activerecord
4
+ module Except
5
+ VERSION = '0.1.0'
6
+ end
7
+ end
metadata ADDED
@@ -0,0 +1,116 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: activerecord-except
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Mauro Morales
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2020-08-27 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'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '4'
27
+ - !ruby/object:Gem::Dependency
28
+ name: minitest
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '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: '0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: sqlite3
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ description: |
70
+ Provides `ActiveRecord::Relation#except`, a convenience method that let's
71
+ you select all the fields from a table with the exception of the given
72
+ ones.
73
+ email:
74
+ - contact@mauromorales.com
75
+ executables: []
76
+ extensions: []
77
+ extra_rdoc_files: []
78
+ files:
79
+ - ".gitignore"
80
+ - ".travis.yml"
81
+ - Gemfile
82
+ - LICENSE.txt
83
+ - README.md
84
+ - Rakefile
85
+ - activerecord-except.gemspec
86
+ - bin/console
87
+ - bin/setup
88
+ - lib/activerecord/except.rb
89
+ - lib/activerecord/except/relation.rb
90
+ - lib/activerecord/except/version.rb
91
+ homepage: https://git.sr.ht/~mrls/activerecord-except
92
+ licenses:
93
+ - MIT
94
+ metadata:
95
+ homepage_uri: https://git.sr.ht/~mrls/activerecord-except
96
+ source_code_uri: https://git.sr.ht/~mrls/activerecord-except
97
+ post_install_message:
98
+ rdoc_options: []
99
+ require_paths:
100
+ - lib
101
+ required_ruby_version: !ruby/object:Gem::Requirement
102
+ requirements:
103
+ - - ">="
104
+ - !ruby/object:Gem::Version
105
+ version: 2.3.0
106
+ required_rubygems_version: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - ">="
109
+ - !ruby/object:Gem::Version
110
+ version: '0'
111
+ requirements: []
112
+ rubygems_version: 3.0.3
113
+ signing_key:
114
+ specification_version: 4
115
+ summary: Select all fields from a table with the exception of the given ones
116
+ test_files: []