polr 1.0.0 → 1.0.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
- SHA1:
3
- metadata.gz: 9449ab738884b68f2cce11ac253cfb6aa5528829
4
- data.tar.gz: 7af22ccab0f10040335df01b747e5a68f765fc9f
2
+ SHA256:
3
+ metadata.gz: 67c16ae753e255a2bc68fac6d20e442977be1fb440d35e07b5363957d5338425
4
+ data.tar.gz: 4badac999202579468694af07a16a9cdf899996a1cac171763c009a63b95b3b6
5
5
  SHA512:
6
- metadata.gz: af1f45eccf8b6c145b4b76a2e9775ec2e3c5ef951ac403da4cb280030ff7902920588571c509c5790b4b1a290b646b0621f4c8ecc5c8a7b0ab49ba9bbe985def
7
- data.tar.gz: adaa6eabf3975920f6b83ae1d40e4f04555958e36d7216f7e6ba5c1e47c9b620ed7eebc4f95ee1e18778afe07246b087102ded79dd1a2e4188b5d56691c98b76
6
+ metadata.gz: b1d16a0fcf3a7c5e0b6380283ce3fa4ed620edc04c8d6d28e5b60147f15f5def391c45cba4326ef660e1d8a4dbcc2ba9ac83a1d3d71aabaf6d0b9c4decf77aa2
7
+ data.tar.gz: 7dbec61407b464ee3a052a8719abac3491bdd33686f6494869fad8cf8dcfbc3e786998f1ea41ecaed503d2be827f785254be8e0b0f18945083846d93aff02865
data/Gemfile CHANGED
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  source 'https://rubygems.org'
2
4
 
3
5
  # Specify your gem's dependencies in polr.gemspec
data/Rakefile CHANGED
@@ -1,10 +1,12 @@
1
- require "bundler/gem_tasks"
2
- require "rake/testtask"
1
+ # frozen_string_literal: true
2
+
3
+ require 'bundler/gem_tasks'
4
+ require 'rake/testtask'
3
5
 
4
6
  Rake::TestTask.new(:test) do |t|
5
- t.libs << "test"
6
- t.libs << "lib"
7
+ t.libs << 'test'
8
+ t.libs << 'lib'
7
9
  t.test_files = FileList['test/**/*_test.rb']
8
10
  end
9
11
 
10
- task :default => :spec
12
+ task default: :spec
@@ -1,7 +1,8 @@
1
1
  #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
2
3
 
3
- require "bundler/setup"
4
- require "polr"
4
+ require 'bundler/setup'
5
+ require 'polr'
5
6
 
6
7
  # You can add fixtures and/or initialization code here to make experimenting
7
8
  # with your gem easier. You can also use a different console, if you like.
@@ -10,5 +11,5 @@ require "polr"
10
11
  # require "pry"
11
12
  # Pry.start
12
13
 
13
- require "irb"
14
+ require 'irb'
14
15
  IRB.start
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'polr/version'
2
4
  require 'polr/api'
3
5
 
@@ -1,14 +1,16 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'rest-client'
2
4
  require 'json'
3
5
 
4
6
  module Polr
5
- API_VERSION = 'v2'
7
+ API_VERSION = 'v2'.freeze
6
8
 
7
9
  Error = Class.new StandardError
8
10
 
9
11
  module Api
10
- def self.api_url path = nil
11
- %Q(#{Polr.configuration.api_url}/api/#{API_VERSION}/action/#{path})
12
+ def self.api_url(path = nil)
13
+ %(#{Polr.configuration.api_url}/api/#{API_VERSION}/action/#{path})
12
14
  end
13
15
 
14
16
  def self.api_key
@@ -18,26 +20,30 @@ module Polr
18
20
  def self.process
19
21
  JSON.parse(yield).with_indifferent_access
20
22
  rescue Errno::ECONNREFUSED, Errno::EHOSTUNREACH => e # API unreachable
21
- raise Polr::Error.new 'Polr API is unreachable'
23
+ raise Polr::Error, 'Polr API is unreachable'
22
24
  rescue RestClient::Exception => e # HTTP status error
23
- result = (JSON.parse(e.response) rescue {})
24
- raise Polr::Error.new(result['error'] || 'undefined error')
25
+ result = (begin
26
+ JSON.parse(e.response)
27
+ rescue StandardError
28
+ {}
29
+ end)
30
+ raise Polr::Error, result['error'] || 'undefined error'
25
31
  rescue JSON::ParserError => e # JSON error
26
- raise Polr::Error.new e.message
32
+ raise Polr::Error, e.message
27
33
  end
28
34
 
29
- def self.request path, params
30
- RestClient.get( Api::api_url(path.to_s), { params: params.merge(key: Api::api_key, response_type: :json), content_type: :json, accept: :json, timeout: 10 } )
35
+ def self.request(path, params)
36
+ RestClient.get(Api.api_url(path.to_s), params: params.merge(key: Api.api_key, response_type: :json), content_type: :json, accept: :json, timeout: 10)
31
37
  end
32
38
  end
33
39
 
34
40
  # Actions to use
35
41
 
36
- def self.shorten url, **options
37
- Api::process { Api::request(:shorten, { url: url }.merge(options)) }
42
+ def self.shorten(url, **options)
43
+ Api.process { Api.request(:shorten, { url: url }.merge(options)) }
38
44
  end
39
45
 
40
- def self.lookup url_ending, **options
41
- Api::process { Api::request(:lookup, { url_ending: url_ending }.merge(options)) }
46
+ def self.lookup(url_ending, **options)
47
+ Api.process { Api.request(:lookup, { url_ending: url_ending }.merge(options)) }
42
48
  end
43
49
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Polr
2
- VERSION = "1.0.0"
4
+ VERSION = '1.0.1'
3
5
  end
@@ -1,26 +1,27 @@
1
- # coding: utf-8
2
- lib = File.expand_path('../lib', __FILE__)
1
+ # frozen_string_literal: true
2
+
3
+ lib = File.expand_path('lib', __dir__)
3
4
  $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
5
  require 'polr/version'
5
6
 
6
7
  Gem::Specification.new do |spec|
7
- spec.name = "polr"
8
+ spec.name = 'polr'
8
9
  spec.version = Polr::VERSION
9
- spec.authors = ["Fabien Dobat"]
10
- spec.email = ["fabien.dobat@seniormedia.fr"]
10
+ spec.authors = ['Fabien Dobat']
11
+ spec.email = ['fabien.dobat@seniormedia.fr']
11
12
 
12
- spec.summary = %q{Ruby wrapper for Polr API}
13
- spec.description = %q{A simple ruby wrapper to use your self hosted Polr API}
14
- spec.homepage = "https://github.com/SeniorMedia/polr-ruby"
15
- spec.license = "MIT"
13
+ spec.summary = 'Ruby wrapper for Polr API'
14
+ spec.description = 'A simple ruby wrapper to use your self hosted Polr API'
15
+ spec.homepage = 'https://github.com/SeniorMedia/polr-ruby'
16
+ spec.license = 'MIT'
16
17
 
17
18
  spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
18
19
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
19
- spec.require_paths = ["lib"]
20
+ spec.require_paths = ['lib']
20
21
 
21
- spec.add_dependency 'rest-client'
22
+ spec.add_dependency 'rest-client', '~> 2'
22
23
 
23
- spec.add_development_dependency 'bundler', '~> 1.11'
24
- spec.add_development_dependency 'rake', '~> 10.0'
24
+ spec.add_development_dependency 'bundler', '~> 2'
25
25
  spec.add_development_dependency 'minitest'
26
+ spec.add_development_dependency 'rake', '~> 10.0'
26
27
  end
metadata CHANGED
@@ -1,71 +1,71 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: polr
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Fabien Dobat
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-04-27 00:00:00.000000000 Z
11
+ date: 2019-08-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rest-client
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - ">="
17
+ - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: '0'
19
+ version: '2'
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - ">="
24
+ - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: '0'
26
+ version: '2'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: bundler
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
31
  - - "~>"
32
32
  - !ruby/object:Gem::Version
33
- version: '1.11'
33
+ version: '2'
34
34
  type: :development
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
38
  - - "~>"
39
39
  - !ruby/object:Gem::Version
40
- version: '1.11'
40
+ version: '2'
41
41
  - !ruby/object:Gem::Dependency
42
- name: rake
42
+ name: minitest
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
- - - "~>"
45
+ - - ">="
46
46
  - !ruby/object:Gem::Version
47
- version: '10.0'
47
+ version: '0'
48
48
  type: :development
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
- - - "~>"
52
+ - - ">="
53
53
  - !ruby/object:Gem::Version
54
- version: '10.0'
54
+ version: '0'
55
55
  - !ruby/object:Gem::Dependency
56
- name: minitest
56
+ name: rake
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
- - - ">="
59
+ - - "~>"
60
60
  - !ruby/object:Gem::Version
61
- version: '0'
61
+ version: '10.0'
62
62
  type: :development
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
- - - ">="
66
+ - - "~>"
67
67
  - !ruby/object:Gem::Version
68
- version: '0'
68
+ version: '10.0'
69
69
  description: A simple ruby wrapper to use your self hosted Polr API
70
70
  email:
71
71
  - fabien.dobat@seniormedia.fr
@@ -105,8 +105,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
105
105
  - !ruby/object:Gem::Version
106
106
  version: '0'
107
107
  requirements: []
108
- rubyforge_project:
109
- rubygems_version: 2.5.1
108
+ rubygems_version: 3.0.3
110
109
  signing_key:
111
110
  specification_version: 4
112
111
  summary: Ruby wrapper for Polr API