link_shortener 0.1.5 → 0.1.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +4 -26
- data/lib/link_shortener/rebrandly.rb +2 -18
- data/lib/link_shortener/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3d9e998d6d7262f7ca9c05b89242d19d97e32b16
|
4
|
+
data.tar.gz: 7627358b675fea49bc150d83cc9d944d92e570aa
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8564c370f73c2458cf9d9d0e7dfed8074cad13c45b3c7e601993ed41cf9782fdd561a999bcf876d1c1d1c1d4066f54caa8d3e6bbb3cc9ebe72fe3622f5ba89c3
|
7
|
+
data.tar.gz: 1975cf48b3e04178230ec203ee238147648b58de6a6f47e92f83da24ac53579cd7e6b4869e99d2b1bb06ddf730cc05f95920d072f71f17c780e353afdcccf9bb
|
data/README.md
CHANGED
@@ -1,34 +1,12 @@
|
|
1
1
|
# LinkShortener
|
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/link_shortener`. 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
|
6
|
-
|
7
|
-
## Installation
|
8
|
-
|
9
|
-
Add this line to your application's Gemfile:
|
10
|
-
|
11
|
-
```ruby
|
12
|
-
gem 'link_shortener'
|
13
|
-
```
|
14
|
-
|
15
|
-
And then execute:
|
16
|
-
|
17
|
-
$ bundle
|
18
|
-
|
19
|
-
Or install it yourself as:
|
20
|
-
|
21
|
-
$ gem install link_shortener
|
22
|
-
|
23
3
|
## Usage
|
24
4
|
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
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.
|
5
|
+
```
|
6
|
+
LinkShortener::Main.new('http://google.com').call
|
7
|
+
```
|
30
8
|
|
31
|
-
|
9
|
+
set ENV['DEBUG_LINKS'] for debug
|
32
10
|
|
33
11
|
## Contributing
|
34
12
|
|
@@ -17,10 +17,8 @@ module LinkShortener
|
|
17
17
|
url = parse_field(response, 'shortUrl')
|
18
18
|
return nil if url.blank?
|
19
19
|
"#{protocol}://#{url}"
|
20
|
-
rescue
|
21
|
-
|
22
|
-
rescue => e
|
23
|
-
Rollbar.warning(e)
|
20
|
+
rescue StandardError => e
|
21
|
+
raise(e) if ENV['DEBUG_LINKS'].present?
|
24
22
|
nil
|
25
23
|
end
|
26
24
|
|
@@ -48,19 +46,5 @@ module LinkShortener
|
|
48
46
|
def protocol_for(response)
|
49
47
|
parse_field(response, 'https') ? 'https' : 'http'
|
50
48
|
end
|
51
|
-
|
52
|
-
def process_api_error(e)
|
53
|
-
key = "link_error_raised_#{e.message[0..10]}"
|
54
|
-
|
55
|
-
return if redis.get(key) # prevent reaching rollbar limits
|
56
|
-
redis.set(key, true)
|
57
|
-
redis.expire(key, 2.hours.to_i)
|
58
|
-
Rollbar.warning(e)
|
59
|
-
nil
|
60
|
-
end
|
61
|
-
|
62
|
-
def redis
|
63
|
-
Redis.current
|
64
|
-
end
|
65
49
|
end
|
66
50
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: link_shortener
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ruslan Korolev
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-
|
11
|
+
date: 2018-10-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|