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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: dcff28a7120f80209702153057646101676e1c91
4
- data.tar.gz: 34493a52a3f2f16da48a0d0fdbb16d5351fd3d77
3
+ metadata.gz: 85e8bf6fced362435c4074897de80c04b06ffbc8
4
+ data.tar.gz: eeb1d7634b86c54001baad051d7a5c18c3788b71
5
5
  SHA512:
6
- metadata.gz: 3226959de12d702f71f40d60e61fbeb8b8fd7f1be94458a1aa11277bbe6cc466bf532c92d4ad0440477b51cb3d1ff8f961d37c9f9be7cbd46c0df513b409f1c4
7
- data.tar.gz: e3636ffb3915b8961f232f3174eaff016062c3f49b4976fbd95430d385e0ef85fc9cece6b2d1f900889cf4751982cc647777c97ad492d6debab1ef3179e6e59c
6
+ metadata.gz: e05c8bfc91052b724abd71d3e965c0f7810f11b1a60cc6cb3846dda6eb7599fd9402c54490922967640bb5169f275547c6000f617d2b01faa69b131f4ce7660d
7
+ data.tar.gz: 04ba880e9155f7c3fca41d5565c2df90f7a117f5ada2865e4427feb5ac73a6792369fef33cb0638be58890f285f1b25e055e880af0e81ac5f9632db9dc68a527
data/README.md CHANGED
@@ -1,8 +1,6 @@
1
1
  # Able
2
2
 
3
- Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/able`. To experiment with that code, run `bin/console` for an interactive prompt.
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
- TODO: Write usage instructions here
26
-
27
- ## Development
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
- After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
30
-
31
- To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
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/[USERNAME]/able.
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{Write a short summary, because Rubygems requires one.}
13
- spec.description = %q{Write a longer description or delete this line.}
14
- # spec.homepage = "TODO: Put your gem's website or public repo URL here."
15
- spec.license = "MIT"
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
@@ -1,5 +1,8 @@
1
1
  require "able/version"
2
- require "able/emailable"
2
+
3
+ require 'able/emailable'
4
+ require 'able/fullnameable'
5
+ require 'able/tokenizer'
3
6
 
4
7
  module Able
5
8
  # Your code goes here...
@@ -1,16 +1,13 @@
1
- module Able
1
+ module Able::Emailable
2
+ extend ActiveSupport::Concern
2
3
 
3
- module Emailable
4
- extend ActiveSupport::Concern
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
- included do
11
- def self.find_by_email(email)
12
- self.where(email: email.downcase).first
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,12 @@
1
+ module Able::Fullnameable
2
+ extend ActiveSupport::Concern
3
+
4
+ def full_name
5
+ "#{first_name} #{last_name}".split(' ').map(&:capitalize).join(' ')
6
+ end
7
+
8
+ def to_s
9
+ full_name
10
+ end
11
+
12
+ end
@@ -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
@@ -1,3 +1,3 @@
1
1
  module Able
2
- VERSION = "0.1.2"
2
+ VERSION = '0.1.3'
3
3
  end
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.2
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: Write a longer description or delete this line.
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: Write a short summary, because Rubygems requires one.
102
+ summary: Simple helpers for active record models
101
103
  test_files: []