able 0.1.2 → 0.1.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +13 -10
- data/able.gemspec +4 -4
- data/lib/able.rb +4 -1
- data/lib/able/emailable.rb +8 -11
- data/lib/able/fullnameable.rb +12 -0
- data/lib/able/tokenizer.rb +32 -0
- data/lib/able/version.rb +1 -1
- metadata +6 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 85e8bf6fced362435c4074897de80c04b06ffbc8
|
4
|
+
data.tar.gz: eeb1d7634b86c54001baad051d7a5c18c3788b71
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e05c8bfc91052b724abd71d3e965c0f7810f11b1a60cc6cb3846dda6eb7599fd9402c54490922967640bb5169f275547c6000f617d2b01faa69b131f4ce7660d
|
7
|
+
data.tar.gz: 04ba880e9155f7c3fca41d5565c2df90f7a117f5ada2865e4427feb5ac73a6792369fef33cb0638be58890f285f1b25e055e880af0e81ac5f9632db9dc68a527
|
data/README.md
CHANGED
@@ -1,8 +1,6 @@
|
|
1
1
|
# Able
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
TODO: Delete this and the text above, and describe your gem
|
3
|
+
This gem helps you to start develop new app simple. See usage instructions
|
6
4
|
|
7
5
|
## Installation
|
8
6
|
|
@@ -22,17 +20,22 @@ Or install it yourself as:
|
|
22
20
|
|
23
21
|
## Usage
|
24
22
|
|
25
|
-
|
26
|
-
|
27
|
-
|
23
|
+
1. [Emailable](https://github.com/entity1991/able/tree/master/lib/able/emailable.rb)
|
24
|
+
2. [Fullnameable](https://github.com/entity1991/able/tree/master/lib/able/fullnameable.rb)
|
25
|
+
`full_name` method
|
28
26
|
|
29
|
-
|
30
|
-
|
31
|
-
|
27
|
+
3. [Tokenizer](https://github.com/entity1991/able/tree/master/lib/able/tokenizer.rb)
|
28
|
+
Type inside your model
|
29
|
+
```ruby
|
30
|
+
before_create do
|
31
|
+
generate_token :api_token
|
32
|
+
generate_uuid!
|
33
|
+
end
|
34
|
+
```
|
32
35
|
|
33
36
|
## Contributing
|
34
37
|
|
35
|
-
Bug reports and pull requests are welcome on GitHub at https://github.com/
|
38
|
+
Bug reports and pull requests are welcome on GitHub at [https://github.com/entity1991/able](https://github.com/entity1991/able).
|
36
39
|
|
37
40
|
|
38
41
|
## License
|
data/able.gemspec
CHANGED
@@ -9,10 +9,10 @@ Gem::Specification.new do |spec|
|
|
9
9
|
spec.authors = ["entity"]
|
10
10
|
spec.email = ["ruslankuzma@gmail.com"]
|
11
11
|
|
12
|
-
spec.summary = %q{
|
13
|
-
spec.description = %q{
|
14
|
-
|
15
|
-
spec.license =
|
12
|
+
spec.summary = %q{Simple helpers for active record models}
|
13
|
+
spec.description = %q{Here you can find some concern methods you use almost in each one project. }
|
14
|
+
spec.homepage = 'https://github.com/entity1991/able'
|
15
|
+
spec.license = 'MIT'
|
16
16
|
|
17
17
|
# Prevent pushing this gem to RubyGems.org. To allow pushes either set the 'allowed_push_host'
|
18
18
|
# to allow pushing to a single host or delete this section to allow pushing to any host.
|
data/lib/able.rb
CHANGED
data/lib/able/emailable.rb
CHANGED
@@ -1,16 +1,13 @@
|
|
1
|
-
module Able
|
1
|
+
module Able::Emailable
|
2
|
+
extend ActiveSupport::Concern
|
2
3
|
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
def email=(value)
|
7
|
-
write_attribute :email, value.try(:downcase) # ignore nil value
|
8
|
-
end
|
4
|
+
def email=(value)
|
5
|
+
write_attribute :email, value.try(:downcase) # ignore nil value
|
6
|
+
end
|
9
7
|
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
end
|
8
|
+
included do
|
9
|
+
def self.find_by_email(email)
|
10
|
+
self.where(email: email.downcase).first
|
14
11
|
end
|
15
12
|
end
|
16
13
|
|
@@ -0,0 +1,32 @@
|
|
1
|
+
module Able::Tokenizer
|
2
|
+
extend ActiveSupport::Concern
|
3
|
+
|
4
|
+
# Todo DRY
|
5
|
+
|
6
|
+
def generate_token(column = :token)
|
7
|
+
if self.respond_to? column
|
8
|
+
begin
|
9
|
+
self[column] = SecureRandom.urlsafe_base64
|
10
|
+
end while self.class.exists?(column => self[column])
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
def generate_token!(column = :token)
|
15
|
+
generate_token(column)
|
16
|
+
save!
|
17
|
+
end
|
18
|
+
|
19
|
+
def generate_uuid(column = :uuid)
|
20
|
+
if self.respond_to? column
|
21
|
+
begin
|
22
|
+
self[column] = SecureRandom.uuid
|
23
|
+
end while self.class.exists?(column => self[column])
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
def generate_uuid!(column = :uuid)
|
28
|
+
generate_uuid(column)
|
29
|
+
save!
|
30
|
+
end
|
31
|
+
|
32
|
+
end
|
data/lib/able/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: able
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- entity
|
@@ -52,7 +52,7 @@ dependencies:
|
|
52
52
|
- - "~>"
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: '3.0'
|
55
|
-
description:
|
55
|
+
description: 'Here you can find some concern methods you use almost in each one project. '
|
56
56
|
email:
|
57
57
|
- ruslankuzma@gmail.com
|
58
58
|
executables: []
|
@@ -72,8 +72,10 @@ files:
|
|
72
72
|
- bin/setup
|
73
73
|
- lib/able.rb
|
74
74
|
- lib/able/emailable.rb
|
75
|
+
- lib/able/fullnameable.rb
|
76
|
+
- lib/able/tokenizer.rb
|
75
77
|
- lib/able/version.rb
|
76
|
-
homepage:
|
78
|
+
homepage: https://github.com/entity1991/able
|
77
79
|
licenses:
|
78
80
|
- MIT
|
79
81
|
metadata:
|
@@ -97,5 +99,5 @@ rubyforge_project:
|
|
97
99
|
rubygems_version: 2.4.8
|
98
100
|
signing_key:
|
99
101
|
specification_version: 4
|
100
|
-
summary:
|
102
|
+
summary: Simple helpers for active record models
|
101
103
|
test_files: []
|