anonymous_active_record 0.1.1 β 0.1.2
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 +4 -4
- data/Gemfile +2 -1
- data/README.md +37 -7
- data/anonymous_active_record.gemspec +7 -8
- data/lib/anonymous_active_record/generator.rb +1 -1
- data/lib/anonymous_active_record/version.rb +1 -1
- data/lib/anonymous_active_record.rb +3 -3
- metadata +17 -17
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 06cc5b89d0dd74bf695170d403d5e13cf43890ad4dec496d4277ace4a02fa0a6
|
4
|
+
data.tar.gz: 447127ce3f3cdfc5ad4ac3b9112ab0d674847756e90cb7eb7606bb2cab828475
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ea9a4e359af2441fd4a111027a7563d505296051bf027f0380e05b8d1531b9242fa89294809ca8d7a9335d67c1009748d051dedade71ec9c3053ff0e38079ade
|
7
|
+
data.tar.gz: 4f0913bd9ec3382efde4a4a70a6f979332bc6c224b1560ac30c3da50188d61b3c3fac9a51a05a12378e39398d2e8ecfc3d10e9bbffd0b50cf17b2797e7aacea9
|
data/Gemfile
CHANGED
@@ -5,10 +5,11 @@ git_source(:github) { |repo_name| "https://github.com/#{repo_name}" }
|
|
5
5
|
group :test do
|
6
6
|
ruby_version = Gem::Version.new(RUBY_VERSION)
|
7
7
|
if ruby_version >= Gem::Version.new('2.1')
|
8
|
-
gem 'rubocop', '~> 0.
|
8
|
+
gem 'rubocop', '~> 0.59.0'
|
9
9
|
gem 'rubocop-rspec', '~> 1.24.0'
|
10
10
|
end
|
11
11
|
gem 'pry', '~> 0.11' if ruby_version >= Gem::Version.new('2.0')
|
12
|
+
gem 'simplecov', require: false, group: :test
|
12
13
|
end
|
13
14
|
|
14
15
|
# Specify your gem's dependencies in anonymous_active_record.gemspec
|
data/README.md
CHANGED
@@ -1,6 +1,4 @@
|
|
1
1
|
# AnonymousActiveRecord
|
2
|
-
[](https://app.fossa.io/projects/git%2Bgithub.com%2Fpboling%2Fanonymous_active_record?ref=badge_shield)
|
3
|
-
|
4
2
|
|
5
3
|
This library was π© inspired by π©, the [Wolverine project](https://github.com/mcary/wolverine), which [implemented a clever workaround](https://github.com/mcary/wolverine/commit/fa27fa2cc485b2fa83d71b2045ba5a0a069dba75) to the official non-support of [anonymous classes by ActiveRecord](https://github.com/rails/rails/issues/8934).
|
6
4
|
|
@@ -9,16 +7,17 @@ Warning: Use of this gem is a **security risk**, due to the use of Ruby's `eval`
|
|
9
7
|
| Project | AnonymousActiveRecord |
|
10
8
|
|------------------------ | ----------------------- |
|
11
9
|
| gem name | [anonymous_active_record](https://rubygems.org/gems/anonymous_active_record) |
|
12
|
-
| license | [](https://opensource.org/licenses/MIT)
|
10
|
+
| license | [](https://opensource.org/licenses/MIT) |
|
13
11
|
| download rank | [](https://github.com/pboling/anonymous_active_record) |
|
14
12
|
| version | [](https://rubygems.org/gems/anonymous_active_record) |
|
15
|
-
| dependencies | [](https://depfu.com/github/pboling/anonymous_active_record?project_id=5614) |
|
16
14
|
| continuous integration | [](https://travis-ci.org/pboling/anonymous_active_record) |
|
17
15
|
| test coverage | [](https://codeclimate.com/github/pboling/anonymous_active_record/test_coverage) |
|
18
16
|
| maintainability | [](https://codeclimate.com/github/pboling/anonymous_active_record/maintainability) |
|
19
17
|
| code triage | [](https://www.codetriage.com/pboling/anonymous_active_record) |
|
20
|
-
|
|
21
|
-
|
|
18
|
+
| FOSSA Licenses | [](https://app.fossa.io/projects/git%2Bgithub.com%2Fpboling%2Fanonymous_active_record?ref=badge_shield) |
|
19
|
+
| homepage | [on Github.com][homepage], [on Railsbling.com][blogpage] |
|
20
|
+
| documentation | [on RDoc.info][documentation] |
|
22
21
|
| Spread ~β‘βββ₯ββ‘~ | [π π π](https://about.me/peter.boling), [π](https://www.crowdrise.com/helprefugeeswithhopefortomorrowliberia/fundraiser/peterboling), [β](https://plus.google.com/+PeterBoling/posts), [πΌ](https://angel.co/peter-boling), [π](https://www.topcoder.com/members/pboling/), [:shipit:](http://coderwall.com/pboling), [](http://twitter.com/galtzo) |
|
23
22
|
|
24
23
|
## Installation
|
@@ -142,6 +141,37 @@ Bug reports and pull requests are welcome on GitHub at https://github.com/pbolin
|
|
142
141
|
|
143
142
|
Everyone interacting in the AnonymousActiveRecord projectβs codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/pboling/anonymous_active_record/blob/master/CODE_OF_CONDUCT.md).
|
144
143
|
|
144
|
+
## Versioning
|
145
|
+
|
146
|
+
This library aims to adhere to [Semantic Versioning 2.0.0][semver].
|
147
|
+
Violations of this scheme should be reported as bugs. Specifically,
|
148
|
+
if a minor or patch version is released that breaks backward
|
149
|
+
compatibility, a new version should be immediately released that
|
150
|
+
restores compatibility. Breaking changes to the public API will
|
151
|
+
only be introduced with new major versions.
|
152
|
+
|
153
|
+
As a result of this policy, you can (and should) specify a
|
154
|
+
dependency on this gem using the [Pessimistic Version Constraint][pvc] with two digits of precision.
|
155
|
+
|
156
|
+
For example:
|
157
|
+
|
158
|
+
```ruby
|
159
|
+
spec.add_dependency 'anonymous_active_record', '~> 0.0'
|
160
|
+
```
|
145
161
|
|
146
162
|
## License
|
147
|
-
|
163
|
+
|
164
|
+
* Copyright (c) 2018 [Peter H. Boling][peterboling] of [Rails Bling][railsbling]
|
165
|
+
|
166
|
+
[](https://opensource.org/licenses/MIT)
|
167
|
+
|
168
|
+
[](https://app.fossa.io/projects/git%2Bgithub.com%2Fpboling%2Fanonymous_active_record?ref=badge_large)
|
169
|
+
|
170
|
+
[license]: LICENSE.txt
|
171
|
+
[semver]: http://semver.org/
|
172
|
+
[pvc]: http://guides.rubygems.org/patterns/#pessimistic-version-constraint
|
173
|
+
[railsbling]: http://www.railsbling.com
|
174
|
+
[peterboling]: http://www.peterboling.com
|
175
|
+
[documentation]: http://rdoc.info/github/pboling/anonymous_active_record/frames
|
176
|
+
[homepage]: https://github.com/pboling/anonymous_active_record/
|
177
|
+
[blogpage]: http://www.railsbling.com/tags/anonymous_active_record/
|
@@ -1,5 +1,4 @@
|
|
1
|
-
|
2
|
-
lib = File.expand_path('../lib', __FILE__)
|
1
|
+
lib = File.expand_path('lib', __dir__)
|
3
2
|
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
3
|
require 'anonymous_active_record/version'
|
5
4
|
|
@@ -23,10 +22,10 @@ Gem::Specification.new do |spec|
|
|
23
22
|
|
24
23
|
spec.required_ruby_version = '>= 2.4' # Requirement for Ruby String#capitalize
|
25
24
|
|
26
|
-
spec.add_development_dependency 'bundler', '~> 1
|
27
|
-
spec.add_development_dependency '
|
28
|
-
spec.add_development_dependency '
|
29
|
-
spec.add_development_dependency '
|
30
|
-
spec.add_development_dependency 'sqlite3', '~> 1
|
31
|
-
spec.add_dependency 'activerecord', '~> 5
|
25
|
+
spec.add_development_dependency 'bundler', '~> 1'
|
26
|
+
spec.add_development_dependency 'byebug', '~> 10'
|
27
|
+
spec.add_development_dependency 'rake', '~> 12'
|
28
|
+
spec.add_development_dependency 'rspec', '~> 3'
|
29
|
+
spec.add_development_dependency 'sqlite3', '~> 1'
|
30
|
+
spec.add_dependency 'activerecord', '~> 5'
|
32
31
|
end
|
@@ -17,7 +17,7 @@ module AnonymousActiveRecord
|
|
17
17
|
attr_reader :klass_namespaces, :table_name, :klass_name
|
18
18
|
|
19
19
|
def initialize(table_name, klass_namespaces = [], klass_basename = nil)
|
20
|
-
@klass_namespaces = Array(klass_namespaces).map(&:to_s).map {|x| x.gsub(/[^a-z0-9]+/i, '_') }
|
20
|
+
@klass_namespaces = Array(klass_namespaces).map(&:to_s).map { |x| x.gsub(/[^a-z0-9]+/i, '_') }
|
21
21
|
klass_context = [(klass_basename || DEFAULT_NAME).gsub(/[^a-z0-9]+/i, '_').capitalize, SecureRandom.uuid.gsub(/[^a-z0-9]+/i, '_')].join('_')
|
22
22
|
@table_name = (table_name || klass_context).downcase.to_s
|
23
23
|
# String#capitalize is Ruby >= 2.4, https://stackoverflow.com/a/3725154/213191
|
@@ -36,9 +36,9 @@ require 'anonymous_active_record/factory'
|
|
36
36
|
#
|
37
37
|
module AnonymousActiveRecord
|
38
38
|
DEFAULT_CONNECTION_PARAMS = {
|
39
|
-
|
40
|
-
|
41
|
-
|
39
|
+
adapter: 'sqlite3',
|
40
|
+
encoding: 'utf8',
|
41
|
+
database: ':memory:'
|
42
42
|
}.freeze
|
43
43
|
|
44
44
|
# Defines a pseudo anonymous class in a particular namespace of your choosing.
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: anonymous_active_record
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Peter Boling
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-09-
|
11
|
+
date: 2018-09-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -16,84 +16,84 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: '1
|
19
|
+
version: '1'
|
20
20
|
type: :development
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: '1
|
26
|
+
version: '1'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
|
-
name:
|
28
|
+
name: byebug
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
31
|
- - "~>"
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: '
|
33
|
+
version: '10'
|
34
34
|
type: :development
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
38
|
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version: '
|
40
|
+
version: '10'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
|
-
name:
|
42
|
+
name: rake
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
45
|
- - "~>"
|
46
46
|
- !ruby/object:Gem::Version
|
47
|
-
version: '
|
47
|
+
version: '12'
|
48
48
|
type: :development
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
52
|
- - "~>"
|
53
53
|
- !ruby/object:Gem::Version
|
54
|
-
version: '
|
54
|
+
version: '12'
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
|
-
name:
|
56
|
+
name: rspec
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
58
58
|
requirements:
|
59
59
|
- - "~>"
|
60
60
|
- !ruby/object:Gem::Version
|
61
|
-
version: '
|
61
|
+
version: '3'
|
62
62
|
type: :development
|
63
63
|
prerelease: false
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
65
65
|
requirements:
|
66
66
|
- - "~>"
|
67
67
|
- !ruby/object:Gem::Version
|
68
|
-
version: '
|
68
|
+
version: '3'
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
70
|
name: sqlite3
|
71
71
|
requirement: !ruby/object:Gem::Requirement
|
72
72
|
requirements:
|
73
73
|
- - "~>"
|
74
74
|
- !ruby/object:Gem::Version
|
75
|
-
version: '1
|
75
|
+
version: '1'
|
76
76
|
type: :development
|
77
77
|
prerelease: false
|
78
78
|
version_requirements: !ruby/object:Gem::Requirement
|
79
79
|
requirements:
|
80
80
|
- - "~>"
|
81
81
|
- !ruby/object:Gem::Version
|
82
|
-
version: '1
|
82
|
+
version: '1'
|
83
83
|
- !ruby/object:Gem::Dependency
|
84
84
|
name: activerecord
|
85
85
|
requirement: !ruby/object:Gem::Requirement
|
86
86
|
requirements:
|
87
87
|
- - "~>"
|
88
88
|
- !ruby/object:Gem::Version
|
89
|
-
version: '5
|
89
|
+
version: '5'
|
90
90
|
type: :runtime
|
91
91
|
prerelease: false
|
92
92
|
version_requirements: !ruby/object:Gem::Requirement
|
93
93
|
requirements:
|
94
94
|
- - "~>"
|
95
95
|
- !ruby/object:Gem::Version
|
96
|
-
version: '5
|
96
|
+
version: '5'
|
97
97
|
description: Replacement for broken Class.new(ActiveRecord::Base)
|
98
98
|
email:
|
99
99
|
- peter.boling@gmail.com
|