phony_rails 0.14.1 → 0.14.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/CHANGELOG.md +10 -0
- data/Gemfile.lock +22 -20
- data/README.md +20 -3
- data/lib/phony_rails.rb +2 -0
- data/lib/phony_rails/version.rb +1 -1
- data/spec/lib/phony_rails_spec.rb +6 -0
- data/spec/spec_helper.rb +12 -0
- metadata +3 -3
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 8ffe8daa0413f53e2a912a97f25d8a61f11b7329
|
|
4
|
+
data.tar.gz: 31e0cde2c7bfe592716778b86a4bebb8a7a5baba
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 4009ec39fa9c5f4c9282e9164194cbc20cfc6cb0813a3e541d373b9f79ca5cbea5f76e58e500ee817af1fab59c82712bcd6c4eb42f8fd965f965443daab71ce6
|
|
7
|
+
data.tar.gz: 4e993ded99b2f4ad466b4f0dbacd4c90be7c1980137368f7c4db543b5d04346ff6b955f323cb4b2aa7bc7c5a1292d1746984ebc16a09dad638f2378add76ec67
|
data/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,15 @@
|
|
|
1
1
|
# Change Log
|
|
2
2
|
|
|
3
|
+
## [Unreleased](https://github.com/joost/phony_rails/tree/HEAD)
|
|
4
|
+
|
|
5
|
+
[Full Changelog](https://github.com/joost/phony_rails/compare/v0.14.1...HEAD)
|
|
6
|
+
|
|
7
|
+
**Merged pull requests:**
|
|
8
|
+
|
|
9
|
+
- Do not use insecure multiline regex in examples [\#146](https://github.com/joost/phony_rails/pull/146) ([bdewater](https://github.com/bdewater))
|
|
10
|
+
|
|
11
|
+
- support for ActiveModel::Model alternative to database-backed models only [\#144](https://github.com/joost/phony_rails/pull/144) ([brandondees](https://github.com/brandondees))
|
|
12
|
+
|
|
3
13
|
## [v0.14.1](https://github.com/joost/phony_rails/tree/v0.14.1) (2016-05-08)
|
|
4
14
|
|
|
5
15
|
[Full Changelog](https://github.com/joost/phony_rails/compare/v0.14.0...v0.14.1)
|
data/Gemfile.lock
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
PATH
|
|
2
2
|
remote: .
|
|
3
3
|
specs:
|
|
4
|
-
phony_rails (0.14.
|
|
4
|
+
phony_rails (0.14.2)
|
|
5
5
|
activesupport (>= 3.0)
|
|
6
6
|
phony (~> 2.12)
|
|
7
7
|
|
|
@@ -22,8 +22,8 @@ GEM
|
|
|
22
22
|
thread_safe (~> 0.3, >= 0.3.4)
|
|
23
23
|
tzinfo (~> 1.1)
|
|
24
24
|
arel (6.0.3)
|
|
25
|
-
ast (2.
|
|
26
|
-
bson (4.1.
|
|
25
|
+
ast (2.3.0)
|
|
26
|
+
bson (4.1.1)
|
|
27
27
|
builder (3.2.2)
|
|
28
28
|
coderay (1.1.1)
|
|
29
29
|
coveralls (0.8.13)
|
|
@@ -36,9 +36,9 @@ GEM
|
|
|
36
36
|
docile (1.1.5)
|
|
37
37
|
ffi (1.9.10)
|
|
38
38
|
formatador (0.2.5)
|
|
39
|
-
guard (2.
|
|
39
|
+
guard (2.14.0)
|
|
40
40
|
formatador (>= 0.2.4)
|
|
41
|
-
listen (>= 2.7,
|
|
41
|
+
listen (>= 2.7, < 4.0)
|
|
42
42
|
lumberjack (~> 1.0)
|
|
43
43
|
nenv (~> 0.1)
|
|
44
44
|
notiffany (~> 0.0)
|
|
@@ -50,19 +50,20 @@ GEM
|
|
|
50
50
|
guard (~> 2.2)
|
|
51
51
|
guard-compat (~> 1.1)
|
|
52
52
|
guard-compat (1.2.1)
|
|
53
|
-
guard-rspec (4.
|
|
53
|
+
guard-rspec (4.7.2)
|
|
54
54
|
guard (~> 2.1)
|
|
55
55
|
guard-compat (~> 1.1)
|
|
56
56
|
rspec (>= 2.99.0, < 4.0)
|
|
57
57
|
i18n (0.7.0)
|
|
58
58
|
json (1.8.3)
|
|
59
|
-
listen (3.
|
|
60
|
-
rb-fsevent (>= 0.9.
|
|
61
|
-
rb-inotify (>= 0.9.7)
|
|
59
|
+
listen (3.1.5)
|
|
60
|
+
rb-fsevent (~> 0.9, >= 0.9.4)
|
|
61
|
+
rb-inotify (~> 0.9, >= 0.9.7)
|
|
62
|
+
ruby_dep (~> 1.2)
|
|
62
63
|
lumberjack (1.0.10)
|
|
63
64
|
method_source (0.8.2)
|
|
64
|
-
minitest (5.
|
|
65
|
-
mongo (2.2.
|
|
65
|
+
minitest (5.9.0)
|
|
66
|
+
mongo (2.2.5)
|
|
66
67
|
bson (~> 4.0)
|
|
67
68
|
mongoid (5.1.3)
|
|
68
69
|
activemodel (~> 4.0)
|
|
@@ -70,20 +71,20 @@ GEM
|
|
|
70
71
|
origin (~> 2.2)
|
|
71
72
|
tzinfo (>= 0.3.37)
|
|
72
73
|
nenv (0.3.0)
|
|
73
|
-
notiffany (0.0
|
|
74
|
+
notiffany (0.1.0)
|
|
74
75
|
nenv (~> 0.1)
|
|
75
76
|
shellany (~> 0.0)
|
|
76
77
|
origin (2.2.0)
|
|
77
|
-
parser (2.3.
|
|
78
|
+
parser (2.3.1.2)
|
|
78
79
|
ast (~> 2.2)
|
|
79
|
-
phony (2.15.
|
|
80
|
+
phony (2.15.25)
|
|
80
81
|
powerpack (0.1.1)
|
|
81
82
|
pry (0.10.3)
|
|
82
83
|
coderay (~> 1.1.0)
|
|
83
84
|
method_source (~> 0.8.1)
|
|
84
85
|
slop (~> 3.4)
|
|
85
86
|
rainbow (2.1.0)
|
|
86
|
-
rake (11.
|
|
87
|
+
rake (11.2.2)
|
|
87
88
|
rb-fsevent (0.9.7)
|
|
88
89
|
rb-inotify (0.9.7)
|
|
89
90
|
ffi (>= 0.5.0)
|
|
@@ -100,13 +101,14 @@ GEM
|
|
|
100
101
|
diff-lcs (>= 1.2.0, < 2.0)
|
|
101
102
|
rspec-support (~> 3.4.0)
|
|
102
103
|
rspec-support (3.4.1)
|
|
103
|
-
rubocop (0.
|
|
104
|
-
parser (>= 2.3.0
|
|
104
|
+
rubocop (0.40.0)
|
|
105
|
+
parser (>= 2.3.1.0, < 3.0)
|
|
105
106
|
powerpack (~> 0.1)
|
|
106
107
|
rainbow (>= 1.99.1, < 3.0)
|
|
107
108
|
ruby-progressbar (~> 1.7)
|
|
108
109
|
unicode-display_width (~> 1.0, >= 1.0.1)
|
|
109
|
-
ruby-progressbar (1.
|
|
110
|
+
ruby-progressbar (1.8.1)
|
|
111
|
+
ruby_dep (1.3.1)
|
|
110
112
|
shellany (0.0.1)
|
|
111
113
|
simplecov (0.11.2)
|
|
112
114
|
docile (~> 1.1.0)
|
|
@@ -122,7 +124,7 @@ GEM
|
|
|
122
124
|
tins (1.6.0)
|
|
123
125
|
tzinfo (1.2.2)
|
|
124
126
|
thread_safe (~> 0.1)
|
|
125
|
-
unicode-display_width (1.0.
|
|
127
|
+
unicode-display_width (1.0.5)
|
|
126
128
|
|
|
127
129
|
PLATFORMS
|
|
128
130
|
ruby
|
|
@@ -141,4 +143,4 @@ DEPENDENCIES
|
|
|
141
143
|
sqlite3
|
|
142
144
|
|
|
143
145
|
BUNDLED WITH
|
|
144
|
-
1.
|
|
146
|
+
1.12.5
|
data/README.md
CHANGED
|
@@ -46,6 +46,23 @@ class SomeModel < ActiveRecord::Base
|
|
|
46
46
|
end
|
|
47
47
|
```
|
|
48
48
|
|
|
49
|
+
#### ActiveModel (models without database)
|
|
50
|
+
|
|
51
|
+
For Rails-like models without a database, add:
|
|
52
|
+
|
|
53
|
+
```ruby
|
|
54
|
+
class SomeModel
|
|
55
|
+
include ActiveModel::Model # we get AR-like attributes and validations
|
|
56
|
+
include ActiveModel::Validations::Callbacks # a dependency for normalization
|
|
57
|
+
|
|
58
|
+
# your attributes must be defined, they are not inherited from a DB table
|
|
59
|
+
attr_accessor :phone_number, :phone_number_as_normalized
|
|
60
|
+
|
|
61
|
+
# Once the model is set up, we have the same things as with ActiveRecord
|
|
62
|
+
phony_normalize :phone_number, default_country_code: 'US'
|
|
63
|
+
end
|
|
64
|
+
```
|
|
65
|
+
|
|
49
66
|
#### Mongoid
|
|
50
67
|
|
|
51
68
|
For **Mongoid**, in keeping with Mongoid plug-in conventions you must include the `Mongoid::Phony` module:
|
|
@@ -108,9 +125,9 @@ so we can use:
|
|
|
108
125
|
|
|
109
126
|
```ruby
|
|
110
127
|
validates_plausible_phone :phone_number, presence: true
|
|
111
|
-
validates_plausible_phone :phone_number, with:
|
|
112
|
-
validates_plausible_phone :phone_number, without:
|
|
113
|
-
validates_plausible_phone :phone_number, presence: true, with:
|
|
128
|
+
validates_plausible_phone :phone_number, with: /\A\+\d+/
|
|
129
|
+
validates_plausible_phone :phone_number, without: /\A\+\d+/
|
|
130
|
+
validates_plausible_phone :phone_number, presence: true, with: /\A\+\d+/
|
|
114
131
|
```
|
|
115
132
|
|
|
116
133
|
the i18n key is `:improbable_phone`. Languages supported by default: de, en, fr, it, ja, kh, nl, tr, ua and ru.
|
data/lib/phony_rails.rb
CHANGED
|
@@ -201,6 +201,8 @@ end
|
|
|
201
201
|
# check whether it is ActiveRecord or Mongoid being used
|
|
202
202
|
ActiveRecord::Base.send :include, PhonyRails::Extension if defined?(ActiveRecord)
|
|
203
203
|
|
|
204
|
+
ActiveModel::Model.send :include, PhonyRails::Extension if defined?(ActiveModel)
|
|
205
|
+
|
|
204
206
|
if defined?(Mongoid)
|
|
205
207
|
module Mongoid::Phony
|
|
206
208
|
extend ActiveSupport::Concern
|
data/lib/phony_rails/version.rb
CHANGED
|
@@ -687,6 +687,12 @@ describe PhonyRails do
|
|
|
687
687
|
end
|
|
688
688
|
end
|
|
689
689
|
|
|
690
|
+
describe 'ActiveModel + ActiveModel::Validations::Callbacks' do
|
|
691
|
+
let(:model_klass) { ActiveModelModel }
|
|
692
|
+
let(:dummy_klass) { ActiveModelDummy }
|
|
693
|
+
it_behaves_like 'model with PhonyRails'
|
|
694
|
+
end
|
|
695
|
+
|
|
690
696
|
describe 'ActiveRecord' do
|
|
691
697
|
let(:model_klass) { ActiveRecordModel }
|
|
692
698
|
let(:dummy_klass) { ActiveRecordDummy }
|
data/spec/spec_helper.rb
CHANGED
|
@@ -54,6 +54,18 @@ end
|
|
|
54
54
|
class ActiveRecordDummy < ActiveRecordModel
|
|
55
55
|
end
|
|
56
56
|
|
|
57
|
+
class ActiveModelModel # in case you don't want a database for your model
|
|
58
|
+
include ActiveModel::Model # this provides most of the interface of AR
|
|
59
|
+
include ActiveModel::Validations::Callbacks # we use callbacks for normalization
|
|
60
|
+
include SharedModelMethods
|
|
61
|
+
|
|
62
|
+
# database columns don't give us free attributes, we have to define them
|
|
63
|
+
attr_accessor :phone_number, :phone_attribute, :phone_number_as_normalized, :country_code_attribute, :fax_number, :symboled_phone
|
|
64
|
+
end
|
|
65
|
+
|
|
66
|
+
class ActiveModelDummy < ActiveModelModel
|
|
67
|
+
end
|
|
68
|
+
|
|
57
69
|
class MongoidModel
|
|
58
70
|
include Mongoid::Document
|
|
59
71
|
include Mongoid::Phony
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: phony_rails
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.14.
|
|
4
|
+
version: 0.14.2
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Joost Hietbrink
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2016-
|
|
11
|
+
date: 2016-06-16 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: phony
|
|
@@ -127,7 +127,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
127
127
|
version: '0'
|
|
128
128
|
requirements: []
|
|
129
129
|
rubyforge_project:
|
|
130
|
-
rubygems_version: 2.
|
|
130
|
+
rubygems_version: 2.5.1
|
|
131
131
|
signing_key:
|
|
132
132
|
specification_version: 4
|
|
133
133
|
summary: This Gem adds useful methods to your Rails app to validate, display and save
|