tp_client 0.2.2 → 0.2.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
  SHA256:
3
- metadata.gz: 74db5f53c5017070ac69231e4ba9e4db02e145f00944ac3b9776f0b6189840e0
4
- data.tar.gz: 0f7eed9ead59dbc324238ace99f2292a255bbf8b11377e26c63dc329c8541e67
3
+ metadata.gz: 1d299ffb9c92c622e0e0a530a0d2f541b422ab4e12983014a69b3e6602a0b60f
4
+ data.tar.gz: c6c0bd4bae393698a2153b2302706ae179f016d07d5339918cb131263ca51fe9
5
5
  SHA512:
6
- metadata.gz: 5c295b28692f105778b54dcb4f3fa75470b5bf2594eca84032645f3b73fd05131d75be044c864ab471cdc0e594268b603974c70eec0c38b96706df082524df02
7
- data.tar.gz: e36ac6716ca438dd51db4272b70c302f5338893759da467a7112fd34471b85daa7302c5b5bfdb4278112f78b9dcb9a5a39eb52d52ccdd3e399bbf580c5d98c45
6
+ metadata.gz: 902c91b99fc1ae7742a0b0060ea29eafb50b891c651377d727e293f4b37455118050539173b201754dcde4ce257851d6afc56afbc1fd57aac4402368d76e62b7
7
+ data.tar.gz: 9ec131e57e4cd270c7bcfc0ebefd71a7d47f2b33166d066910978ce92cc14929939347f6c4431e27c5592f64f0c4b2632c46a0a1eeff56d8a22ab958cbccf0a0
@@ -9,7 +9,7 @@ gemfile:
9
9
  deploy:
10
10
  provider: rubygems
11
11
  api_key:
12
- secure: rhnpzPKF7/SYka8XSo8ohtIT/YZB+eltG+uK1Yrup+RHYUvvjL5VbGuVXK71ouNtA5g0iA0xHB8lYyXBkC/DsovURjwhYQXymykqWz68yGjCQgl3i0IP8bgntAP5+PYbeOvYpy8DlH+6qakoTewa/cOhYvLLVlE91zk92UFORIW2b0TVxxMASB2cuKBOkI5a7vRpncpBYupIWLMIHwQd2IGPlWCPOx53QumZkuG1Xze8wuxGTdT+Oo4pIJsNZi1Oz5KKbOaYgYOZa29TlXesz43HcTruIIeMJgKuVM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euR3uTXfMScBkAA=
13
13
  gem: tp_client
14
14
  on:
15
15
  tags: true
data/Appraisals CHANGED
@@ -1,11 +1,11 @@
1
- appraise "activesupport-4" do
1
+ appraise 'activesupport-4' do
2
2
  gem 'activesupport', '~> 4.0'
3
3
  end
4
4
 
5
- appraise "activesupport-5" do
5
+ appraise 'activesupport-5' do
6
6
  gem 'activesupport', '~> 5.0'
7
7
  end
8
8
 
9
- appraise "activesupport-6" do
9
+ appraise 'activesupport-6' do
10
10
  gem 'activesupport', '~> 6.0'
11
11
  end
data/Rakefile CHANGED
@@ -1,4 +1,4 @@
1
- require "bundler/gem_tasks"
1
+ require 'bundler/gem_tasks'
2
2
  require 'rake/testtask'
3
3
  require 'yard'
4
4
 
@@ -16,11 +16,11 @@ end
16
16
 
17
17
  desc 'Build the gem'
18
18
  task gem: [:test] do
19
- sh 'gem build tiny_client.gemspec'
19
+ sh 'gem build tp_client.gemspec'
20
20
  end
21
21
 
22
22
  desc 'Clean up'
23
23
  task :clean do
24
24
  sh 'rm -rf docs'
25
- sh 'rm -f tiny_client*.gem'
25
+ sh 'rm -f tp_client*.gem'
26
26
  end
@@ -1,16 +1,16 @@
1
1
  # This file was generated by Appraisal
2
2
 
3
- source "https://rubygems.org"
3
+ source 'https://rubygems.org'
4
4
 
5
- gem "activesupport", "~> 4.0"
5
+ gem 'activesupport', '~> 4.0'
6
6
 
7
7
  group :test, :development do
8
- gem "byebug"
9
- gem "minitest"
10
- gem "mocha"
11
- gem "rake"
12
- gem "webmock"
13
- gem "yard"
8
+ gem 'byebug'
9
+ gem 'minitest'
10
+ gem 'mocha'
11
+ gem 'rake'
12
+ gem 'webmock'
13
+ gem 'yard'
14
14
  end
15
15
 
16
- gemspec path: "../"
16
+ gemspec path: '../'
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: ..
3
3
  specs:
4
- tp_client (0.2.2)
4
+ tp_client (0.2.3)
5
5
  activesupport (>= 4.0, < 7.0)
6
6
  curb (> 0.7.0, < 1.0.0)
7
7
 
@@ -1,16 +1,16 @@
1
1
  # This file was generated by Appraisal
2
2
 
3
- source "https://rubygems.org"
3
+ source 'https://rubygems.org'
4
4
 
5
- gem "activesupport", "~> 5.0"
5
+ gem 'activesupport', '~> 5.0'
6
6
 
7
7
  group :test, :development do
8
- gem "byebug"
9
- gem "minitest"
10
- gem "mocha"
11
- gem "rake"
12
- gem "webmock"
13
- gem "yard"
8
+ gem 'byebug'
9
+ gem 'minitest'
10
+ gem 'mocha'
11
+ gem 'rake'
12
+ gem 'webmock'
13
+ gem 'yard'
14
14
  end
15
15
 
16
- gemspec path: "../"
16
+ gemspec path: '../'
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: ..
3
3
  specs:
4
- tp_client (0.2.2)
4
+ tp_client (0.2.3)
5
5
  activesupport (>= 4.0, < 7.0)
6
6
  curb (> 0.7.0, < 1.0.0)
7
7
 
@@ -1,16 +1,16 @@
1
1
  # This file was generated by Appraisal
2
2
 
3
- source "https://rubygems.org"
3
+ source 'https://rubygems.org'
4
4
 
5
- gem "activesupport", "~> 6.0"
5
+ gem 'activesupport', '~> 6.0'
6
6
 
7
7
  group :test, :development do
8
- gem "byebug"
9
- gem "minitest"
10
- gem "mocha"
11
- gem "rake"
12
- gem "webmock"
13
- gem "yard"
8
+ gem 'byebug'
9
+ gem 'minitest'
10
+ gem 'mocha'
11
+ gem 'rake'
12
+ gem 'webmock'
13
+ gem 'yard'
14
14
  end
15
15
 
16
- gemspec path: "../"
16
+ gemspec path: '../'
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: ..
3
3
  specs:
4
- tp_client (0.2.2)
4
+ tp_client (0.2.3)
5
5
  activesupport (>= 4.0, < 7.0)
6
6
  curb (> 0.7.0, < 1.0.0)
7
7
 
@@ -43,29 +43,53 @@ module TinyClient
43
43
  @code >= 400
44
44
  end
45
45
 
46
+ # @return true if the HTTP status code of this response is 404
47
+ def not_found_error?
48
+ @code == 404
49
+ end
50
+
51
+ # @return true if the HTTP status code of this response correspond to an client error.
46
52
  def client_error?
47
53
  (400..499).cover?(@code)
48
54
  end
49
55
 
56
+ # @return true if the HTTP status code of this response correspond to a server error.
50
57
  def server_error?
51
58
  @code >= 500
52
59
  end
53
60
 
61
+ # @return true if the HTTP status code of this response correspond to a redirect.
54
62
  def redirect?
55
63
  (300..399).cover?(@code)
56
64
  end
57
65
 
58
- def to_s
66
+ # @return Hash with url, status, body and headers fields
67
+ def to_hash
59
68
  {
60
- url: url,
61
- status: status,
62
- body: body_str,
63
- headers: header_str
64
- }.to_s
69
+ 'url' => url,
70
+ 'status' => status,
71
+ 'body' => (parse_body rescue body_str),
72
+ 'headers' => (parse_headers rescue header_str)
73
+ }
74
+ end
75
+
76
+ # @return String of #to_hash
77
+ def to_s
78
+ to_hash.to_s
65
79
  end
66
80
 
67
81
  protected
68
82
 
83
+ def parse_headers
84
+ {}.tap do |headers|
85
+ header_str.to_s.each_line do |header|
86
+ next if header.index(':').nil?
87
+ key, value = header.split(':', 2)
88
+ headers[key] = value.to_s.strip
89
+ end
90
+ end
91
+ end
92
+
69
93
  def gzip_decompress
70
94
  ActiveSupport::Gzip.decompress(body_str)
71
95
  end
@@ -1,37 +1,37 @@
1
1
  Gem::Specification.new do |s|
2
- s.name = 'tp_client'
3
- s.authors = ['TINYpulse Devops']
4
- s.version = '0.2.2'
2
+ s.platform = Gem::Platform::RUBY
3
+ s.name = 'tp_client'
4
+ s.version = '0.2.3'
5
+ s.authors = ['TINYpulse Devops']
6
+ s.email = 'devops@tinypulse.com'
5
7
 
6
- s.summary = 'TINYclient, an HTTP/JSON crud client toolkit.'
7
- s.description = 'TINYclient is an HTTP/JSON crud toolkit inspired by ActiveRecord and based on Curb.'
8
- s.email = 'devops@tinypulse.com'
8
+ s.license = 'MIT'
9
9
 
10
- s.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
10
+ s.summary = 'TINYclient, an HTTP/JSON crud client toolkit.'
11
+ s.description = 'TINYclient is an HTTP/JSON crud toolkit inspired by ActiveRecord and based on Curb.'
12
+ s.homepage = 'https://github.com/TINYhr/tiny_client'
11
13
 
12
14
  if s.respond_to?(:metadata)
13
- s.metadata["allowed_push_host"] = 'https://rubygems.org'
15
+ s.metadata['allowed_push_host'] = 'https://rubygems.org'
16
+ s.metadata['homepage_uri'] = s.homepage
14
17
  else
15
- raise "RubyGems 2.0 or newer is required to protect against " \
16
- "public gem pushes."
18
+ raise 'RubyGems 2.0 or newer is required to protect against public gem pushes.'
17
19
  end
18
20
 
19
21
  #### Load-time details
20
- s.require_paths = %w(lib ext)
22
+ s.files = Dir.chdir(File.expand_path('..', __FILE__)) do
23
+ `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
24
+ end
25
+ s.require_paths = %w[lib ext]
21
26
  s.rubyforge_project = 'tiny_client'
22
- s.test_files = ['test/tiny_client/']
27
+ s.test_files = ['test/tiny_client/']
23
28
 
24
- #### Documentation and testing.
25
- s.has_rdoc = 'yard'
26
- s.homepage = 'https://github.com/TINYhr/tiny_client'
27
- s.rdoc_options = ['--main', 'README.md']
29
+ #### Documentation
30
+ s.rdoc_options = ['--main', 'README.md']
28
31
  s.extra_rdoc_files = ['LICENSE', 'README.md']
29
32
 
30
- s.platform = Gem::Platform::RUBY
31
- s.license = 'MIT'
32
-
33
- s.add_runtime_dependency 'curb', '> 0.7.0', '< 1.0.0'
34
- s.add_runtime_dependency 'activesupport', '>= 4.0', '< 7.0'
33
+ s.add_runtime_dependency 'curb', '> 0.7.0', '< 1.0.0'
34
+ s.add_runtime_dependency 'activesupport', '>= 4.0', '< 7.0'
35
35
 
36
- s.add_development_dependency "appraisal", '~> 2.2', '>= 2.2.0'
36
+ s.add_development_dependency 'appraisal', '~> 2.2', '>= 2.2.0'
37
37
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: tp_client
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.2
4
+ version: 0.2.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - TINYpulse Devops
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-09-06 00:00:00.000000000 Z
11
+ date: 2020-03-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: curb
@@ -113,6 +113,7 @@ licenses:
113
113
  - MIT
114
114
  metadata:
115
115
  allowed_push_host: https://rubygems.org
116
+ homepage_uri: https://github.com/TINYhr/tiny_client
116
117
  post_install_message:
117
118
  rdoc_options:
118
119
  - "--main"