world_time_api 0.1.4 → 0.1.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -4,22 +4,29 @@ require_relative "response"
4
4
  require_relative "error"
5
5
  require 'httparty'
6
6
 
7
+ # The WorldTimeApi module contains methods for making requests to the World Time API.
7
8
  module WorldTimeApi
9
+
10
+ # The Request module contains methods for making HTTP requests to the World Time API.
8
11
  module Request
9
12
  include HTTParty
10
13
 
11
14
  base_uri "http://worldtimeapi.org/api"
12
15
 
16
+ # Makes an HTTP GET request to the specified URL and returns the response as a hash.
17
+ #
18
+ # @param url [String] The URL to make the request to.
19
+ # @return [Hash] A hash representing the response body, or an error hash if there was a problem with the request.
13
20
  Call = ->(url) {
14
21
  begin
15
22
  response = get(url)
16
23
 
17
- return WorldTimeApi::Error["Invalid timezone"] if response.code != 200
24
+ return WorldTimeApi::Error["Invalid timezone"] if response.code != 200
18
25
 
19
- WorldTimeApi::Response[response]
20
- rescue StandardError
21
- WorldTimeApi::Error["Connection error"]
22
- end
26
+ WorldTimeApi::Response[response]
27
+ rescue StandardError
28
+ WorldTimeApi::Error["Connection error"]
29
+ end
23
30
  }
24
31
  end
25
32
  end
@@ -2,6 +2,12 @@
2
2
 
3
3
  require 'json'
4
4
 
5
+ # The WorldTimeApi module contains methods for making requests to the World Time API.
5
6
  module WorldTimeApi
7
+
8
+ # Converts the HTTParty response object into a hash.
9
+ #
10
+ # @param response [HTTParty::Response] The HTTParty response object to convert.
11
+ # @return [Hash] A hash representation of the response body.
6
12
  Response = -> (response) { JSON.parse(response.body) }
7
13
  end
@@ -1,5 +1,8 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ # The WorldTimeApi module contains methods for making requests to the World Time API.
3
4
  module WorldTimeApi
4
- VERSION = "0.1.4"
5
+
6
+ # The current version number of the WorldTimeApi gem.
7
+ VERSION = "0.1.5"
5
8
  end
@@ -1,16 +1,28 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require "httparty"
3
4
  require_relative "world_time_api/version"
4
5
  require_relative "world_time_api/request"
6
+ require_relative "world_time_api/response"
7
+ require_relative "world_time_api/error"
5
8
 
6
- require "httparty"
7
-
8
- # module WorldTimeAPi
9
+ # The WorldTimeApi module contains methods for making requests to the World Time API.
9
10
  module WorldTimeApi
10
11
 
12
+ # Returns a list of all timezones supported by the World Time API.
13
+ #
14
+ # @return [WorldTimeApi::Response] The API response.
11
15
  Timezones = -> { Request::Call["/timezone"] }
12
16
 
17
+ # Returns the current time for the specified timezone.
18
+ #
19
+ # @param timezone [String] The timezone ID.
20
+ # @return [WorldTimeApi::Response] The API response.
13
21
  Time = -> (timezone) { Request::Call["/timezone/#{timezone}"] }
14
22
 
23
+ # Returns the current time for the client's IP address, or for the specified IP address if provided.
24
+ #
25
+ # @param ip [String] (optional) The IP address to lookup.
26
+ # @return [WorldTimeApi::Response] The API response.
15
27
  ClientIp = -> (ip = nil) { Request::Call["/ip#{ip ? "/#{ip}" : ''}"] }
16
28
  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.4
4
+ version: 0.1.5
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-13 00:00:00.000000000 Z
11
+ date: 2023-02-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake
@@ -63,6 +63,22 @@ files:
63
63
  - CODE_OF_CONDUCT.md
64
64
  - LICENSE.txt
65
65
  - README.md
66
+ - doc/WorldTimeApi.html
67
+ - doc/WorldTimeApi/Request.html
68
+ - doc/_index.html
69
+ - doc/class_list.html
70
+ - doc/css/common.css
71
+ - doc/css/full_list.css
72
+ - doc/css/style.css
73
+ - doc/file.README.html
74
+ - doc/file_list.html
75
+ - doc/frames.html
76
+ - doc/index.html
77
+ - doc/js/app.js
78
+ - doc/js/full_list.js
79
+ - doc/js/jquery.js
80
+ - doc/method_list.html
81
+ - doc/top-level-namespace.html
66
82
  - lib/world_time_api.rb
67
83
  - lib/world_time_api/error.rb
68
84
  - lib/world_time_api/request.rb
@@ -75,6 +91,7 @@ metadata:
75
91
  homepage_uri: https://github.com/nemuba/world_time_api
76
92
  source_code_uri: https://github.com/nemuba/world_time_api
77
93
  changelog_uri: https://github.com/nemuba/world_time_api/blob/main/CHANGELOG.md
94
+ documentation_uri: https://rubydoc.info/github/nemuba/world_time_api/blob/main/doc/index.html
78
95
  post_install_message:
79
96
  rdoc_options: []
80
97
  require_paths:
@@ -90,7 +107,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
90
107
  - !ruby/object:Gem::Version
91
108
  version: '0'
92
109
  requirements: []
93
- rubygems_version: 3.0.9
110
+ rubygems_version: 3.4.7
94
111
  signing_key:
95
112
  specification_version: 4
96
113
  summary: Api World Time