world_time_api 0.1.2 → 0.1.4

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: 1b6420d0428f5de938fe22c845b39cbbc9816ff5ce4262b2cbaa89c18c397a2e
4
- data.tar.gz: 53ba3476af00bc51c3b01a78082d89a3485ea5e244fee5f6c7fe951b742fdce3
3
+ metadata.gz: 1a07c38ca8b3c1b3f90de1eb502924a65c1430eee681ff040ae9bf7e4135f168
4
+ data.tar.gz: 69f7536f3483dd8e0a25a2e4a5db82c686eb095db380dd98a8d8a7f3cb6689cb
5
5
  SHA512:
6
- metadata.gz: 63372ccb083ad7c9265f94331d7e59715517d4602e41aef16146a694a4bb9d997e7c252bb70446ef3744d8244e61b6da1721c82bebc2b702d5d65511df86fa64
7
- data.tar.gz: ac358cbf36d2695978e7e60ddb3fe88e504fae8543c91d711b994142feb4978b7dfec055eac4a5f307dfbb5d1dcbe09eda18c111336479a14c524b9c83c02d6e
6
+ metadata.gz: f87097a455ed233f09c273bb5ab726e10ce663ada0bdafa199d64e484e53033ae8aac3808d38ff85c204251463143d1e8c1ce489302c75f364475ccd6125297e
7
+ data.tar.gz: 9653883401724d52ae46c673d1b5a620bc1606280fdc1b6999fc21c9b2d6cc570eb63a1964105b82d0aa277ccea3a31b257dc0e93ef37a71b4ec80837fab2b75
data/CHANGELOG.md CHANGED
@@ -7,3 +7,11 @@
7
7
  ## [0.1.1] - 2021-11-22
8
8
 
9
9
  - add methods :time and :timezones
10
+
11
+ ## [0.1.2] - 2023-02-06
12
+
13
+ - Fix response
14
+
15
+ ## [0.1.3] - 2023-02-12
16
+
17
+ * add new method :client_ip
data/README.md CHANGED
@@ -12,24 +12,26 @@ gem 'world_time_api'
12
12
 
13
13
  And then execute:
14
14
 
15
- ```
16
- $ bundle install
15
+ ```bash
16
+ bundle install
17
17
  ```
18
18
 
19
19
  Or install it yourself as:
20
20
 
21
- ```
22
- $ gem install world_time_api
21
+ ```bash
22
+ gem install world_time_api
23
23
  ```
24
24
 
25
25
  ## Usage
26
26
 
27
27
  ```ruby
28
- WorldTimeApi.timezones # list timezones
28
+ WorldTimeApi::Timezones.call # list timezones
29
29
 
30
- WorldTimeApi.time(time_zone) # get datetime of the timezone
30
+ WorldTimeApi::Time.call(time_zone) # get datetime of the timezone
31
31
 
32
+ WorldTimeApi::ClientIp.call # get datetime by your client ip
32
33
 
34
+ WorldTimeApi::ClientIp.call(ip_address) # get datatime by ip address
33
35
  ```
34
36
 
35
37
  ## Development
@@ -0,0 +1,5 @@
1
+ # frozen_string_literal: true
2
+
3
+ module WorldTimeApi
4
+ Error = -> (message) { { error: message } }
5
+ end
@@ -0,0 +1,25 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "response"
4
+ require_relative "error"
5
+ require 'httparty'
6
+
7
+ module WorldTimeApi
8
+ module Request
9
+ include HTTParty
10
+
11
+ base_uri "http://worldtimeapi.org/api"
12
+
13
+ Call = ->(url) {
14
+ begin
15
+ response = get(url)
16
+
17
+ return WorldTimeApi::Error["Invalid timezone"] if response.code != 200
18
+
19
+ WorldTimeApi::Response[response]
20
+ rescue StandardError
21
+ WorldTimeApi::Error["Connection error"]
22
+ end
23
+ }
24
+ end
25
+ end
@@ -0,0 +1,7 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'json'
4
+
5
+ module WorldTimeApi
6
+ Response = -> (response) { JSON.parse(response.body) }
7
+ end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module WorldTimeApi
4
- VERSION = "0.1.2"
4
+ VERSION = "0.1.4"
5
5
  end
@@ -1,29 +1,16 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require_relative "world_time_api/version"
4
+ require_relative "world_time_api/request"
5
+
4
6
  require "httparty"
5
7
 
6
8
  # module WorldTimeAPi
7
9
  module WorldTimeApi
8
- include HTTParty
9
-
10
- base_uri "http://worldtimeapi.org/api/timezone"
11
-
12
- def self.timezones
13
- response = get("/")
14
- return "Consult Error" if response.code != 200
15
10
 
16
- response.parsed_response
17
- rescue StandardError
18
- "Error of connection"
19
- end
11
+ Timezones = -> { Request::Call["/timezone"] }
20
12
 
21
- def self.time(zone_name)
22
- response = get("/#{zone_name}")
23
- return "Invalid Zone Name" if response.code != 200
13
+ Time = -> (timezone) { Request::Call["/timezone/#{timezone}"] }
24
14
 
25
- response.parsed_response
26
- rescue StandardError
27
- "Error of connection"
28
- end
15
+ ClientIp = -> (ip = nil) { Request::Call["/ip#{ip ? "/#{ip}" : ''}"] }
29
16
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: world_time_api
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.1.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Alef Ojeda de Oliveira
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2023-02-06 00:00:00.000000000 Z
11
+ date: 2023-02-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake
@@ -59,18 +59,14 @@ executables: []
59
59
  extensions: []
60
60
  extra_rdoc_files: []
61
61
  files:
62
- - ".rspec"
63
- - ".rubocop.yml"
64
62
  - CHANGELOG.md
65
63
  - CODE_OF_CONDUCT.md
66
- - Gemfile
67
- - Gemfile.lock
68
64
  - LICENSE.txt
69
65
  - README.md
70
- - Rakefile
71
- - bin/console
72
- - bin/setup
73
66
  - lib/world_time_api.rb
67
+ - lib/world_time_api/error.rb
68
+ - lib/world_time_api/request.rb
69
+ - lib/world_time_api/response.rb
74
70
  - lib/world_time_api/version.rb
75
71
  homepage: https://github.com/nemuba/world_time_api
76
72
  licenses:
@@ -94,7 +90,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
94
90
  - !ruby/object:Gem::Version
95
91
  version: '0'
96
92
  requirements: []
97
- rubygems_version: 3.1.2
93
+ rubygems_version: 3.0.9
98
94
  signing_key:
99
95
  specification_version: 4
100
96
  summary: Api World Time
data/.rspec DELETED
@@ -1,3 +0,0 @@
1
- --require spec_helper
2
- --color
3
- --format documentation
data/.rubocop.yml DELETED
@@ -1,13 +0,0 @@
1
- AllCops:
2
- TargetRubyVersion: 2.6
3
-
4
- Style/StringLiterals:
5
- Enabled: true
6
- EnforcedStyle: double_quotes
7
-
8
- Style/StringLiteralsInInterpolation:
9
- Enabled: true
10
- EnforcedStyle: double_quotes
11
-
12
- Layout/LineLength:
13
- Max: 120
data/Gemfile DELETED
@@ -1,9 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- source "https://rubygems.org"
4
-
5
- # Specify your gem's dependencies in world_time_api.gemspec
6
- gemspec
7
-
8
- gem "rspec"
9
- gem "rspec-expectations"
data/Gemfile.lock DELETED
@@ -1,63 +0,0 @@
1
- PATH
2
- remote: .
3
- specs:
4
- world_time_api (0.1.2)
5
- httparty (~> 0.20)
6
-
7
- GEM
8
- remote: https://rubygems.org/
9
- specs:
10
- ast (2.4.2)
11
- diff-lcs (1.4.4)
12
- httparty (0.21.0)
13
- mini_mime (>= 1.0.0)
14
- multi_xml (>= 0.5.2)
15
- mini_mime (1.1.2)
16
- multi_xml (0.6.0)
17
- parallel (1.21.0)
18
- parser (3.0.2.0)
19
- ast (~> 2.4.1)
20
- rainbow (3.0.0)
21
- rake (13.0.6)
22
- regexp_parser (2.1.1)
23
- rexml (3.2.5)
24
- rspec (3.10.0)
25
- rspec-core (~> 3.10.0)
26
- rspec-expectations (~> 3.10.0)
27
- rspec-mocks (~> 3.10.0)
28
- rspec-core (3.10.1)
29
- rspec-support (~> 3.10.0)
30
- rspec-expectations (3.10.1)
31
- diff-lcs (>= 1.2.0, < 2.0)
32
- rspec-support (~> 3.10.0)
33
- rspec-mocks (3.10.2)
34
- diff-lcs (>= 1.2.0, < 2.0)
35
- rspec-support (~> 3.10.0)
36
- rspec-support (3.10.3)
37
- rubocop (1.23.0)
38
- parallel (~> 1.10)
39
- parser (>= 3.0.0.0)
40
- rainbow (>= 2.2.2, < 4.0)
41
- regexp_parser (>= 1.8, < 3.0)
42
- rexml
43
- rubocop-ast (>= 1.12.0, < 2.0)
44
- ruby-progressbar (~> 1.7)
45
- unicode-display_width (>= 1.4.0, < 3.0)
46
- rubocop-ast (1.13.0)
47
- parser (>= 3.0.1.1)
48
- ruby-progressbar (1.11.0)
49
- unicode-display_width (2.1.0)
50
-
51
- PLATFORMS
52
- ruby
53
- x86_64-linux
54
-
55
- DEPENDENCIES
56
- rake (~> 13.0)
57
- rspec
58
- rspec-expectations
59
- rubocop (~> 1.21)
60
- world_time_api!
61
-
62
- BUNDLED WITH
63
- 2.2.30
data/Rakefile DELETED
@@ -1,8 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require "bundler/gem_tasks"
4
- require "rubocop/rake_task"
5
-
6
- RuboCop::RakeTask.new
7
-
8
- task default: :rubocop
data/bin/console DELETED
@@ -1,15 +0,0 @@
1
- #!/usr/bin/env ruby
2
- # frozen_string_literal: true
3
-
4
- require "bundler/setup"
5
- require "world_time_api"
6
-
7
- # You can add fixtures and/or initialization code here to make experimenting
8
- # with your gem easier. You can also use a different console, if you like.
9
-
10
- # (If you use this, don't forget to add pry to your Gemfile!)
11
- # require "pry"
12
- # Pry.start
13
-
14
- require "irb"
15
- IRB.start(__FILE__)
data/bin/setup DELETED
@@ -1,8 +0,0 @@
1
- #!/usr/bin/env bash
2
- set -euo pipefail
3
- IFS=$'\n\t'
4
- set -vx
5
-
6
- bundle install
7
-
8
- # Do any other automated setup that you need to do here