rails_url_shortener 0.1.0 → 0.1.1

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
  SHA256:
3
- metadata.gz: '0847fa49aa14c40889c11cdf80fd32a846208112f7b1e121455f6c6258225cf8'
4
- data.tar.gz: 2479208e471351f49be2f9876f33ce22cc6cf6461c62113b0d5e5c66d8bd884a
3
+ metadata.gz: 964c9390d946bb5229d91c8760689cd5e001b7af1e3182b15e14087488c71a04
4
+ data.tar.gz: ee0971582ed1631913c0aa5ba8e43bbe4ecd5159931b9caa7723075363554102
5
5
  SHA512:
6
- metadata.gz: 94658a6b36105a31e1abc8ce7ac9b67913e2fecec29a834f9898224b1969ac0f593ee72c157bbe149e75a439fe5d68efaa167aebc83758fdd85eb578aef3b047
7
- data.tar.gz: f40c5f6dc58ab19cd03bd714db4d68431889733579dce5e61c8990964fdc82211cc8d95e20d36d54bdc6909b7f93e871ae3648bd21ab5977123c7c93f2a71fed
6
+ metadata.gz: 216e49e0c1f9caba3b04fb5cebdcbf524a7525bc5a249031f3d29556fdfd7cff471652500c6b80166085b305087bfb050005140c52dc02f3f4d499d9421d1ec4
7
+ data.tar.gz: 194d5777d67c70bd659c227dc03e9b347e21396cf00c732453a74b552b2e8cc2b289e80489528d70376b6f3e5a7b113f40fbd84e458d27e64f2feeeb3311680d
data/README.md CHANGED
@@ -1,37 +1,74 @@
1
1
  # RailsUrlShortener
2
2
 
3
- A small rails engine for short urls.
4
- It could be used like a url shortener or a ip logger, it is your choice.
5
- The app generate a short url for you and then (if you want) receive the requests and redirect to the original url.
3
+ RailsUrlShortener is a small rails engine that provide your app with short URLs functionalities. Like a Bitly on your app. By default, RailsUrlShortener save the visits to your link for future interesting things that you may want to do.
6
4
 
7
5
  Why give your data to a third party app if you can do it by yourself?
8
6
 
7
+ ## Key features
8
+
9
+ A few of the things you can do with RailsUrlShortener:
10
+
11
+ * Generate unique keys for links.
12
+ * Provide a method controller that find, save request information and does a 301 redirect to the original url.
13
+ * The short links can be associated with a model in your app.
14
+ * Save interesting things like browser, system and ip data of the 'un-shortened' request.
15
+ * Temporal short links using the expires_at option.
16
+
9
17
  ## Usage
10
18
 
11
- Mount the controller on your app adding the next code on your config/routes.rb:
19
+ ### 1. Mount the engine
20
+
21
+ Mount the engine on your app adding the next code on your config/routes.rb:
22
+
23
+ **If you want to mount this on the root of your app, this should be on the bottom of your routes file.**
12
24
 
13
25
  ```ruby
14
26
  mount RailsUrlShortener::Engine, at: "/"
15
27
 
16
28
  ```
29
+ ### 2. Generate the short link
17
30
 
18
- And generate the short links wherever you want using the helper method:
31
+ And generate the short links like you want:
32
+
33
+ - Using the helper method, this return the ready short link.
19
34
 
20
35
  ```ruby
21
36
  short_url("https://www.github.com/a-chacon/rails_url_shortener")
22
37
  ```
23
38
 
24
- or model method:
39
+ - Or model method, this return the object built. So you can save this on a variable, extract the key and build the short link by your own:
25
40
 
26
41
  ```ruby
27
42
  RailsUrlShortener::Url.generate("https://www.github.com/a-chacon/rails_url_shortener")
28
43
  ```
44
+ ### 3. Share the short link
45
+
46
+ **Then share the short link to your users or wherever you want.**
47
+
48
+ ## Deeper
49
+
50
+ Full params for the short_url helper:
51
+ ```ruby
52
+ short_url(url, owner: nil, key: nil, expires_at: nil, category: nil, url_options: {})
53
+ ```
54
+ Where:
55
+ * **url**: Long url for short.
56
+ * **owner**: Is a model of your app. You can relate an url whatever you want in your app.
57
+ * **key**: Is a custom key that you want to set up.
58
+ * **expires_at**: Is a datetime for expiration, after this the redirection doesn't work.
59
+ * **category**: Tag that you want for that link.
60
+ * **url_options**: Options for the url_for generator. Ex: subdomain or protocol.
61
+
29
62
 
30
- **Then share the short link.**
63
+ And the same for the generate model method except for url_options:
64
+ ```ruby
65
+ RailsUrlShortener::Url.generate(url, owner: nil, key: nil, expires_at: nil, category: nil)
66
+ ```
31
67
 
32
- ### Deeper
68
+ ### Data saved
69
+
70
+ By default, this engine save all request made on your short url, you can use that data for some analytics or simple IP logger. So for get the data in a controller or do wherever you want, you can use the Visit model related to an Url:
33
71
 
34
- By default this engine save all request made on your short url, you can use that data for some analitics or simple ip logger. So for get the data in a controller or do wherever you want you can use the Visit model related to a Url:
35
72
  ```ruby
36
73
  RailsUrlShortener::Url.find_by_key("key").visits # all visits
37
74
 
@@ -41,11 +78,6 @@ Or using the model class:
41
78
  RailsUrlShortener::Visit.all # all in database
42
79
  ```
43
80
 
44
- Also the Url model has a polymorphic relation with an owner that is optional. So you can relate an url whatever you want in your app adding the next relation in a model:
45
- ```ruby
46
- has_many :urls, as: :owner
47
- ```
48
-
49
81
  ## Installation
50
82
 
51
83
  Add this line to your application's Gemfile:
@@ -4,8 +4,8 @@ CHARSETS = {
4
4
  alphanumcase: ('A'..'Z').to_a + ('a'..'z').to_a + (0..9).to_a
5
5
  }
6
6
 
7
- RailsUrlShortener.default_redirect = "/"
8
- RailsUrlShortener.charset = CHARSETS[:alphanumcase]
9
- RailsUrlShortener.key_length = 6
10
- RailsUrlShortener.minimum_key_length = 3
11
- RailsUrlShortener.save_bots_visits = false
7
+ RailsUrlShortener.default_redirect = "/" # where the users are redirect if the link doesn't exists or is expired.
8
+ RailsUrlShortener.charset = CHARSETS[:alphanumcase] # used for generate the keys, better long.
9
+ RailsUrlShortener.key_length = 6 # Key length for random generator
10
+ RailsUrlShortener.minimum_key_length = 3 # minimun permited for a key
11
+ RailsUrlShortener.save_bots_visits = false # if save bots visits
@@ -1,3 +1,3 @@
1
1
  module RailsUrlShortener
2
- VERSION = "0.1.0"
2
+ VERSION = "0.1.1"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rails_url_shortener
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - a-chacon
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-04-12 00:00:00.000000000 Z
11
+ date: 2022-04-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -38,7 +38,23 @@ dependencies:
38
38
  - - ">="
39
39
  - !ruby/object:Gem::Version
40
40
  version: 5.3.0
41
- description: A little engine for rails application that provide url shortener functions.
41
+ - !ruby/object:Gem::Dependency
42
+ name: bundler
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: 1.15.0
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: 1.15.0
55
+ description: RailsUrlShortener is a simple engine that provide to your rail's app
56
+ the functionalities for short URLs. Like bitly.com, but working on your project
57
+ only.
42
58
  email:
43
59
  - andres.ch@protonmail.com
44
60
  executables: []
@@ -67,9 +83,11 @@ homepage: https://www.github.com/a-chacon/rails_url_shortener
67
83
  licenses:
68
84
  - MIT
69
85
  metadata:
70
- homepage_uri: https://www.github.com/a-chacon/rails_url_shortener
71
- source_code_uri: https://www.github.com/a-chacon/rails_url_shortener
72
- changelog_uri: https://www.github.com/a-chacon/rails_url_shortener
86
+ bug_tracker_uri: https://www.github.com/a-chacon/rails_url_shortener/issues
87
+ changelog_uri: https://www.github.com/a-chacon/rails_url_shortener/releases/tag/v0.1.1
88
+ documentation_uri: https://github.com/a-chacon/rails_url_shortener/blob/main/README.md
89
+ source_code_uri: https://github.com/a-chacon/rails_url_shortener/tree/v0.1.1
90
+ rubygems_mfa_required: 'true'
73
91
  post_install_message:
74
92
  rdoc_options: []
75
93
  require_paths:
@@ -78,12 +96,12 @@ required_ruby_version: !ruby/object:Gem::Requirement
78
96
  requirements:
79
97
  - - ">="
80
98
  - !ruby/object:Gem::Version
81
- version: '0'
99
+ version: 2.7.0
82
100
  required_rubygems_version: !ruby/object:Gem::Requirement
83
101
  requirements:
84
102
  - - ">="
85
103
  - !ruby/object:Gem::Version
86
- version: '0'
104
+ version: 1.8.11
87
105
  requirements: []
88
106
  rubygems_version: 3.2.22
89
107
  signing_key: