backframe 0.0.24 → 0.0.25
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile +1 -0
- data/backframe.gemspec +1 -0
- data/lib/backframe/activerecord/acts_as_enum.rb +2 -2
- data/lib/backframe/activerecord/acts_as_phone.rb +53 -0
- data/lib/backframe/railtie.rb +1 -0
- data/lib/backframe/version.rb +1 -1
- data/lib/backframe.rb +2 -1
- metadata +17 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: cc3320f6d64afafe3208ac49dc236168f0aa2a94
|
4
|
+
data.tar.gz: 68b6f22bd6111cab616b14a2df5e79586d635710
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 261fd39a46c53abf6ee19a4b8d059ec5f45d85f75a86945c4df773e676de9031b51bf0f010a1bc30388c57d7fca34c4762ada986d50192b20dad6354911f7037
|
7
|
+
data.tar.gz: 5b1d411b3fe134d163bf86942aff506ba49c58757a4cc3927c0635f0a8497eb0d17df4db4836340b7f8838e867058f439b256326ca2b86a9c9b78d046a7b6fdc
|
data/Gemfile
CHANGED
data/backframe.gemspec
CHANGED
@@ -17,6 +17,7 @@ Gem::Specification.new do |gem|
|
|
17
17
|
gem.require_paths = ["lib"]
|
18
18
|
|
19
19
|
gem.add_runtime_dependency 'write_xlsx', '~> 0.83.0'
|
20
|
+
gem.add_runtime_dependency 'phony', '~> 2.15.21'
|
20
21
|
gem.add_runtime_dependency 'activerecord', '~> 4.0'
|
21
22
|
gem.add_runtime_dependency 'activesupport', '~> 4.0'
|
22
23
|
gem.add_runtime_dependency 'active_model_serializers', '>= 0.10.0.rc4'
|
@@ -38,7 +38,7 @@ module Backframe
|
|
38
38
|
validates_inclusion_of field, :in => arguments[:in]
|
39
39
|
|
40
40
|
class_eval <<-EOV
|
41
|
-
scope :#{field}_is, -> (*options) { where('#{field} IN (?)', (options.is_a?(Array) ? options : [options])) }
|
41
|
+
scope :#{field}_is, -> (*options) { where('"#{self.table_name}"."#{field}" IN (?)', (options.is_a?(Array) ? options : [options])) }
|
42
42
|
|
43
43
|
def #{field}_is?(*options)
|
44
44
|
(options.is_a?(Array) ? options : [options]).map(&:to_s).include?(self.#{field})
|
@@ -46,7 +46,7 @@ module Backframe
|
|
46
46
|
EOV
|
47
47
|
|
48
48
|
class_eval <<-EOV
|
49
|
-
scope :#{field}_not, -> (*options) { where('#{field} NOT IN (?)', (options.is_a?(Array) ? options : [options])) }
|
49
|
+
scope :#{field}_not, -> (*options) { where('"#{self.table_name}"."#{field}" NOT IN (?)', (options.is_a?(Array) ? options : [options])) }
|
50
50
|
|
51
51
|
def #{field}_not?(*options)
|
52
52
|
!(options.is_a?(Array) ? options : [options]).map(&:to_s).include?(self.#{field})
|
@@ -0,0 +1,53 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
require 'phony'
|
4
|
+
|
5
|
+
module Backframe
|
6
|
+
module ActsAsPhone
|
7
|
+
|
8
|
+
extend ActiveSupport::Concern
|
9
|
+
|
10
|
+
def self.included(base)
|
11
|
+
base.send :extend, ClassMethods
|
12
|
+
end
|
13
|
+
|
14
|
+
module ClassMethods
|
15
|
+
|
16
|
+
def acts_as_phone(entity)
|
17
|
+
|
18
|
+
class_eval <<-EOV
|
19
|
+
|
20
|
+
after_initialize :extract_#{entity}, :if => Proc.new { |c| c.#{entity}.present? }
|
21
|
+
before_save :compress_#{entity}, :if => Proc.new { |c| c.#{entity}.present? }
|
22
|
+
|
23
|
+
validate :validates_#{entity}, :if => Proc.new { |c| c.#{entity}.present? }
|
24
|
+
private
|
25
|
+
|
26
|
+
def extract_#{entity}
|
27
|
+
self.#{entity} = Phony.format(self.#{entity}, :format => '%{ndc}-%{local}')
|
28
|
+
end
|
29
|
+
|
30
|
+
def compress_#{entity}
|
31
|
+
self.#{entity} = Phony.normalize(self.#{entity})
|
32
|
+
self.#{entity} = '1'+self.#{entity} if (self.#{entity}.length == 10)
|
33
|
+
end
|
34
|
+
|
35
|
+
def validates_#{entity}
|
36
|
+
testvalue = Phony.normalize(self.#{entity})
|
37
|
+
testvalue = '1'+test if (testvalue.length == 10)
|
38
|
+
if Phony.plausible?(testvalue)
|
39
|
+
self.#{entity}.add(:#{entity}, 'invalid #{entity} number')
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
EOV
|
44
|
+
|
45
|
+
end
|
46
|
+
|
47
|
+
end
|
48
|
+
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
|
53
|
+
|
data/lib/backframe/railtie.rb
CHANGED
@@ -12,6 +12,7 @@ module Backframe
|
|
12
12
|
ActiveRecord::Base.send(:include, Backframe::ActsAsDistinct)
|
13
13
|
ActiveRecord::Base.send(:include, Backframe::ActsAsEnum)
|
14
14
|
ActiveRecord::Base.send(:include, Backframe::ActsAsOrderable)
|
15
|
+
ActiveRecord::Base.send(:include, Backframe::ActsAsPhone)
|
15
16
|
ActiveRecord::Base.send(:include, Backframe::ActsAsUser)
|
16
17
|
ActiveRecord::Base.send(:include, Backframe::DefaultValues)
|
17
18
|
ActiveRecord::Base.send(:include, Backframe::FilterSort)
|
data/lib/backframe/version.rb
CHANGED
data/lib/backframe.rb
CHANGED
@@ -12,8 +12,9 @@ require 'backframe/actioncontroller/acts_as_resource'
|
|
12
12
|
require 'backframe/actioncontroller/acts_as_session'
|
13
13
|
require 'backframe/activerecord/acts_as_activable'
|
14
14
|
require 'backframe/activerecord/acts_as_distinct'
|
15
|
-
require 'backframe/activerecord/acts_as_orderable'
|
16
15
|
require 'backframe/activerecord/acts_as_enum'
|
16
|
+
require 'backframe/activerecord/acts_as_orderable'
|
17
|
+
require 'backframe/activerecord/acts_as_phone'
|
17
18
|
require 'backframe/activerecord/acts_as_user'
|
18
19
|
require 'backframe/activerecord/default_values'
|
19
20
|
require 'backframe/activerecord/filter_sort'
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: backframe
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.25
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Greg Kops
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2016-05-
|
12
|
+
date: 2016-05-17 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: write_xlsx
|
@@ -25,6 +25,20 @@ dependencies:
|
|
25
25
|
- - "~>"
|
26
26
|
- !ruby/object:Gem::Version
|
27
27
|
version: 0.83.0
|
28
|
+
- !ruby/object:Gem::Dependency
|
29
|
+
name: phony
|
30
|
+
requirement: !ruby/object:Gem::Requirement
|
31
|
+
requirements:
|
32
|
+
- - "~>"
|
33
|
+
- !ruby/object:Gem::Version
|
34
|
+
version: 2.15.21
|
35
|
+
type: :runtime
|
36
|
+
prerelease: false
|
37
|
+
version_requirements: !ruby/object:Gem::Requirement
|
38
|
+
requirements:
|
39
|
+
- - "~>"
|
40
|
+
- !ruby/object:Gem::Version
|
41
|
+
version: 2.15.21
|
28
42
|
- !ruby/object:Gem::Dependency
|
29
43
|
name: activerecord
|
30
44
|
requirement: !ruby/object:Gem::Requirement
|
@@ -109,6 +123,7 @@ files:
|
|
109
123
|
- lib/backframe/activerecord/acts_as_distinct.rb
|
110
124
|
- lib/backframe/activerecord/acts_as_enum.rb
|
111
125
|
- lib/backframe/activerecord/acts_as_orderable.rb
|
126
|
+
- lib/backframe/activerecord/acts_as_phone.rb
|
112
127
|
- lib/backframe/activerecord/acts_as_user.rb
|
113
128
|
- lib/backframe/activerecord/default_values.rb
|
114
129
|
- lib/backframe/activerecord/filter_sort.rb
|