shortener 0.2.0 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +15 -0
- data/.gitignore +1 -0
- data/.travis.yml +9 -0
- data/README.rdoc +12 -0
- data/app/models/shortener/shortened_url.rb +10 -3
- data/lib/shortener/active_record_extension.rb +1 -1
- data/lib/shortener/version.rb +1 -1
- data/spec/dummy/config/routes.rb +1 -1
- metadata +30 -19
checksums.yaml
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
---
|
2
|
+
!binary "U0hBMQ==":
|
3
|
+
metadata.gz: !binary |-
|
4
|
+
ZDY1OWIyY2I4YjNiZjViNWQ5YTcxMDM4Nzc3MTlkMmRkOTkxMjhhNQ==
|
5
|
+
data.tar.gz: !binary |-
|
6
|
+
MWIwNjJlNTk3MGVkZWViNjBiY2Y2MjhlM2YwM2Q3ZDcxY2I2MWRiZg==
|
7
|
+
SHA512:
|
8
|
+
metadata.gz: !binary |-
|
9
|
+
NTY4YzIwODExNWEyYzQ0YjMxNjc5MmFlMTJmZGE5YjU3YjFiOTkxZjk4YjVh
|
10
|
+
MzkyYmNjZjNlMDZiMzgzNzA2NmVlMmUyZDk2MWVhYTAxMDZmMzZkMjRiYTkz
|
11
|
+
OThiZGJkYTI5MjRiMzczZjg1MGYwYTU2ZTg1YWI1ODc4MmE2ZDQ=
|
12
|
+
data.tar.gz: !binary |-
|
13
|
+
NGY2Mzc4YWM0MGJjNDk0MWZjMDYyMjNhOGM2MGJmYWMxNDg5YjJhMDVlYTgz
|
14
|
+
NDk4ZTY4NjM4YTI1NDdhYTIyZmI3MzY0YjQwNjM2NDk3NjdjOWJjNTA5ZjRl
|
15
|
+
NzhlNGY3YmJlZmEwZjNiY2M4OGI5MDc5Yzk4ZTliNGM4NDZhMDA=
|
data/.gitignore
CHANGED
data/.travis.yml
ADDED
data/README.rdoc
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
{<img src="https://secure.travis-ci.org/jpmcgrath/shortener.png?branch=master" alt="Build Status" />}[http://travis-ci.org/jpmcgrath/shortener]
|
2
|
+
|
1
3
|
= Shortener
|
2
4
|
|
3
5
|
Shortener is a Rails Engine Gem that makes it easy to create and interpret shortened URLs on your own domain from within your Rails application. Once installed Shortener will generate, store URLS and "unshorten" shortened URLs for your applications visitors, all whilst collecting basic usage metrics.
|
@@ -97,6 +99,16 @@ The interceptor supports a few more arguments, see the implementation for detail
|
|
97
99
|
|
98
100
|
Shortener is based on code from Dealush[http://dealush.com], for a bit of backstory to Shortener see this {blog post}[http://jamespmcgrath.com/a-simple-link-shortener-in-rails/].
|
99
101
|
|
102
|
+
== In The Wild
|
103
|
+
|
104
|
+
Shortener is used in a number of production systems:
|
105
|
+
|
106
|
+
{Doorkeeper - An Event Management Tool}[http://www.doorkeeperhq.com/]
|
107
|
+
|
108
|
+
{Dealush - A Local shopping Sales Notification Service}[http://dealush.com]
|
109
|
+
|
110
|
+
If you are using Shortener in your project and would like to be added to this list, please get in touch!
|
111
|
+
|
100
112
|
== Authors
|
101
113
|
|
102
114
|
* {James McGrath}[https://github.com/jpmcgrath]
|
@@ -29,7 +29,7 @@ class Shortener::ShortenedUrl < ActiveRecord::Base
|
|
29
29
|
# so check the datastore
|
30
30
|
cleaned_url = clean_url(orig_url)
|
31
31
|
scope = owner ? owner.shortened_urls : self
|
32
|
-
scope.
|
32
|
+
scope.where(:url => cleaned_url).first_or_create
|
33
33
|
end
|
34
34
|
|
35
35
|
# return shortened url on success, nil on failure
|
@@ -43,13 +43,20 @@ class Shortener::ShortenedUrl < ActiveRecord::Base
|
|
43
43
|
|
44
44
|
private
|
45
45
|
|
46
|
+
# the create method changed in rails 4...
|
47
|
+
if Rails::VERSION::MAJOR >= 4
|
48
|
+
CREATE_METHOD_NAME = "create_record"
|
49
|
+
else
|
50
|
+
CREATE_METHOD_NAME = "create"
|
51
|
+
end
|
52
|
+
|
46
53
|
# we'll rely on the DB to make sure the unique key is really unique.
|
47
54
|
# if it isn't unique, the unique index will catch this and raise an error
|
48
|
-
|
55
|
+
define_method CREATE_METHOD_NAME do
|
49
56
|
count = 0
|
50
57
|
begin
|
51
58
|
self.unique_key = generate_unique_key
|
52
|
-
super
|
59
|
+
super()
|
53
60
|
rescue ActiveRecord::RecordNotUnique, ActiveRecord::StatementInvalid => err
|
54
61
|
if (count +=1) < 5
|
55
62
|
logger.info("retrying with different unique key")
|
data/lib/shortener/version.rb
CHANGED
data/spec/dummy/config/routes.rb
CHANGED
metadata
CHANGED
@@ -1,8 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: shortener
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
5
|
-
prerelease:
|
4
|
+
version: 0.3.0
|
6
5
|
platform: ruby
|
7
6
|
authors:
|
8
7
|
- James P. McGrath
|
@@ -10,52 +9,64 @@ authors:
|
|
10
9
|
autorequire:
|
11
10
|
bindir: bin
|
12
11
|
cert_chain: []
|
13
|
-
date:
|
12
|
+
date: 2014-01-08 00:00:00.000000000 Z
|
14
13
|
dependencies:
|
15
14
|
- !ruby/object:Gem::Dependency
|
16
15
|
name: rails
|
17
|
-
requirement:
|
18
|
-
none: false
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
19
17
|
requirements:
|
20
18
|
- - ! '>='
|
21
19
|
- !ruby/object:Gem::Version
|
22
20
|
version: 3.0.7
|
23
21
|
type: :runtime
|
24
22
|
prerelease: false
|
25
|
-
version_requirements:
|
23
|
+
version_requirements: !ruby/object:Gem::Requirement
|
24
|
+
requirements:
|
25
|
+
- - ! '>='
|
26
|
+
- !ruby/object:Gem::Version
|
27
|
+
version: 3.0.7
|
26
28
|
- !ruby/object:Gem::Dependency
|
27
29
|
name: sqlite3
|
28
|
-
requirement:
|
29
|
-
none: false
|
30
|
+
requirement: !ruby/object:Gem::Requirement
|
30
31
|
requirements:
|
31
32
|
- - ! '>='
|
32
33
|
- !ruby/object:Gem::Version
|
33
34
|
version: '0'
|
34
35
|
type: :development
|
35
36
|
prerelease: false
|
36
|
-
version_requirements:
|
37
|
+
version_requirements: !ruby/object:Gem::Requirement
|
38
|
+
requirements:
|
39
|
+
- - ! '>='
|
40
|
+
- !ruby/object:Gem::Version
|
41
|
+
version: '0'
|
37
42
|
- !ruby/object:Gem::Dependency
|
38
43
|
name: rspec-rails
|
39
|
-
requirement:
|
40
|
-
none: false
|
44
|
+
requirement: !ruby/object:Gem::Requirement
|
41
45
|
requirements:
|
42
46
|
- - ! '>='
|
43
47
|
- !ruby/object:Gem::Version
|
44
48
|
version: '0'
|
45
49
|
type: :development
|
46
50
|
prerelease: false
|
47
|
-
version_requirements:
|
51
|
+
version_requirements: !ruby/object:Gem::Requirement
|
52
|
+
requirements:
|
53
|
+
- - ! '>='
|
54
|
+
- !ruby/object:Gem::Version
|
55
|
+
version: '0'
|
48
56
|
- !ruby/object:Gem::Dependency
|
49
57
|
name: shoulda-matchers
|
50
|
-
requirement:
|
51
|
-
none: false
|
58
|
+
requirement: !ruby/object:Gem::Requirement
|
52
59
|
requirements:
|
53
60
|
- - ! '>='
|
54
61
|
- !ruby/object:Gem::Version
|
55
62
|
version: '0'
|
56
63
|
type: :development
|
57
64
|
prerelease: false
|
58
|
-
version_requirements:
|
65
|
+
version_requirements: !ruby/object:Gem::Requirement
|
66
|
+
requirements:
|
67
|
+
- - ! '>='
|
68
|
+
- !ruby/object:Gem::Version
|
69
|
+
version: '0'
|
59
70
|
description: Shortener is a Rails Engine Gem that makes it easy to create and interpret
|
60
71
|
shortened URLs on your own domain from within your Rails application. Once installed
|
61
72
|
Shortener will generate, store URLS and "unshorten" shortened URLs for your applications
|
@@ -68,6 +79,7 @@ extensions: []
|
|
68
79
|
extra_rdoc_files: []
|
69
80
|
files:
|
70
81
|
- .gitignore
|
82
|
+
- .travis.yml
|
71
83
|
- Gemfile
|
72
84
|
- MIT-LICENSE
|
73
85
|
- README.rdoc
|
@@ -118,27 +130,26 @@ files:
|
|
118
130
|
- spec/spec_helper.rb
|
119
131
|
homepage: http://jamespmcgrath.com/projects/shortener
|
120
132
|
licenses: []
|
133
|
+
metadata: {}
|
121
134
|
post_install_message:
|
122
135
|
rdoc_options: []
|
123
136
|
require_paths:
|
124
137
|
- lib
|
125
138
|
required_ruby_version: !ruby/object:Gem::Requirement
|
126
|
-
none: false
|
127
139
|
requirements:
|
128
140
|
- - ! '>='
|
129
141
|
- !ruby/object:Gem::Version
|
130
142
|
version: '0'
|
131
143
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
132
|
-
none: false
|
133
144
|
requirements:
|
134
145
|
- - ! '>'
|
135
146
|
- !ruby/object:Gem::Version
|
136
147
|
version: 1.3.6
|
137
148
|
requirements: []
|
138
149
|
rubyforge_project: shortener
|
139
|
-
rubygems_version: 1.
|
150
|
+
rubygems_version: 2.1.11
|
140
151
|
signing_key:
|
141
|
-
specification_version:
|
152
|
+
specification_version: 4
|
142
153
|
summary: Shortener is a Rails Engine that makes it easy to create shortened URLs for
|
143
154
|
your rails application.
|
144
155
|
test_files: []
|