world_time_api 0.1.1 → 0.1.3

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 49610b7c90783b18113773e0afc48c0384926f015e638d5c11ffe8cbf492be0f
4
- data.tar.gz: 5cdb06ed27be594b9c515728355d5805bd9fd7f04b8af7e7f491fc93516d33c9
3
+ metadata.gz: 688543e3e6815aded60389f8381436089c6eb712fc5f65468679f7c5e46a5791
4
+ data.tar.gz: a9d28f71ad6119736a10ef6a65d93319df4b0cd644730f25b5a66be952a1d176
5
5
  SHA512:
6
- metadata.gz: 8ceea121f51f4c73d0c848aee0e828075aa6c12fa45ec4c5929d0442926e6dfc13ce97242ccf30c85dc2b3c923c1f4cd7cdc1a8de54c31d2a0d44efc8251d472
7
- data.tar.gz: 183b10f775d8fc15fff5bfe5945a5a387ffdc70e45b21fb79676985e0d7963eb122dc428bec1dfd6a61578f24803d5b8c3d14b5505e7fbd1b8d42c6a6b8a894d
6
+ metadata.gz: f8ae900b130a2aceffed6da40ea2a3e5e21d1503e86d144d08fed88da6dfb230f64cc514130f0ccc290c3aba02f64bf3fed2cde30ed55698d65f84eec6f7a620
7
+ data.tar.gz: d113975484b37528c64d2d78c97a755c223ec8d9442cfb5aa96a496dd5b6ced41b2d51b9b72ec95aeb0ca5ebae12325576cd43f8b4396cd59777de98a0b4475a
data/CHANGELOG.md CHANGED
@@ -1,5 +1,13 @@
1
- ## [Unreleased]
1
+ ## [WorldTimeAPi]
2
2
 
3
3
  ## [0.1.0] - 2021-11-22
4
4
 
5
5
  - Initial release
6
+
7
+ ## [0.1.1] - 2021-11-22
8
+
9
+ - add methods :time and :timezones
10
+
11
+ # [0.1.2] - 2023-02-06
12
+
13
+ - Fix response
data/README.md CHANGED
@@ -2,8 +2,6 @@
2
2
 
3
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/world_time_api`. To experiment with that code, run `bin/console` for an interactive prompt.
4
4
 
5
- TODO: Delete this and the text above, and describe your gem
6
-
7
5
  ## Installation
8
6
 
9
7
  Add this line to your application's Gemfile:
@@ -14,15 +12,25 @@ gem 'world_time_api'
14
12
 
15
13
  And then execute:
16
14
 
17
- $ bundle install
15
+ ```
16
+ $ bundle install
17
+ ```
18
18
 
19
19
  Or install it yourself as:
20
20
 
21
- $ gem install world_time_api
21
+ ```
22
+ $ gem install world_time_api
23
+ ```
22
24
 
23
25
  ## Usage
24
26
 
25
- TODO: Write usage instructions here
27
+ ```ruby
28
+ WorldTimeApi.timezones # list timezones
29
+
30
+ WorldTimeApi.time(time_zone) # get datetime of the timezone
31
+
32
+
33
+ ```
26
34
 
27
35
  ## Development
28
36
 
@@ -32,7 +40,7 @@ To install this gem onto your local machine, run `bundle exec rake install`. To
32
40
 
33
41
  ## Contributing
34
42
 
35
- Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/world_time_api. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct](https://github.com/[USERNAME]/world_time_api/blob/master/CODE_OF_CONDUCT.md).
43
+ Bug reports and pull requests are welcome on GitHub at https://github.com/nemuba/world_time_api. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct](https://github.com/[USERNAME]/world_time_api/blob/master/CODE_OF_CONDUCT.md).
36
44
 
37
45
  ## License
38
46
 
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module WorldTimeApi
4
- VERSION = "0.1.1"
4
+ VERSION = "0.1.3"
5
5
  end
@@ -7,23 +7,32 @@ require "httparty"
7
7
  module WorldTimeApi
8
8
  include HTTParty
9
9
 
10
- base_uri "http://worldtimeapi.org/api/timezone"
10
+ base_uri "http://worldtimeapi.org/api"
11
11
 
12
12
  def self.timezones
13
- response = get("/")
13
+ response = get("/timezone")
14
14
  return "Consult Error" if response.code != 200
15
15
 
16
- response
17
- rescue Net::OpenTimeout
18
- "Error time out connection"
16
+ response.parsed_response
17
+ rescue StandardError
18
+ "Error of connection"
19
19
  end
20
20
 
21
21
  def self.time(zone_name)
22
- response = get("/#{zone_name}")
22
+ response = get("/timezone/#{zone_name}")
23
23
  return "Invalid Zone Name" if response.code != 200
24
24
 
25
- response
26
- rescue Net::OpenTimeout
27
- "Error time out connection"
25
+ response.parsed_response
26
+ rescue StandardError
27
+ "Error of connection"
28
+ end
29
+
30
+ def self.client_ip(ip = nil)
31
+ response = ip.nil? ? get("/ip") : get("/ip/#{ip}")
32
+ return "Invalid IP" if response.code != 200
33
+
34
+ response.parsed_response
35
+ rescue StandardError
36
+ "Error of connection"
28
37
  end
29
38
  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.1
4
+ version: 0.1.3
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: 2021-11-22 00:00:00.000000000 Z
11
+ date: 2023-02-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake
@@ -59,19 +59,12 @@ executables: []
59
59
  extensions: []
60
60
  extra_rdoc_files: []
61
61
  files:
62
- - ".rubocop.yml"
63
62
  - CHANGELOG.md
64
63
  - CODE_OF_CONDUCT.md
65
- - Gemfile
66
- - Gemfile.lock
67
64
  - LICENSE.txt
68
65
  - README.md
69
- - Rakefile
70
- - bin/console
71
- - bin/setup
72
66
  - lib/world_time_api.rb
73
67
  - lib/world_time_api/version.rb
74
- - world_time_api.gemspec
75
68
  homepage: https://github.com/nemuba/world_time_api
76
69
  licenses:
77
70
  - MIT
@@ -94,7 +87,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
94
87
  - !ruby/object:Gem::Version
95
88
  version: '0'
96
89
  requirements: []
97
- rubygems_version: 3.2.30
90
+ rubygems_version: 3.0.9
98
91
  signing_key:
99
92
  specification_version: 4
100
93
  summary: Api World Time
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,6 +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
data/Gemfile.lock DELETED
@@ -1,48 +0,0 @@
1
- PATH
2
- remote: .
3
- specs:
4
- world_time_api (0.1.1)
5
- httparty (~> 0.20)
6
-
7
- GEM
8
- remote: https://rubygems.org/
9
- specs:
10
- ast (2.4.2)
11
- httparty (0.20.0)
12
- mime-types (~> 3.0)
13
- multi_xml (>= 0.5.2)
14
- mime-types (3.4.1)
15
- mime-types-data (~> 3.2015)
16
- mime-types-data (3.2021.1115)
17
- multi_xml (0.6.0)
18
- parallel (1.21.0)
19
- parser (3.0.2.0)
20
- ast (~> 2.4.1)
21
- rainbow (3.0.0)
22
- rake (13.0.6)
23
- regexp_parser (2.1.1)
24
- rexml (3.2.5)
25
- rubocop (1.23.0)
26
- parallel (~> 1.10)
27
- parser (>= 3.0.0.0)
28
- rainbow (>= 2.2.2, < 4.0)
29
- regexp_parser (>= 1.8, < 3.0)
30
- rexml
31
- rubocop-ast (>= 1.12.0, < 2.0)
32
- ruby-progressbar (~> 1.7)
33
- unicode-display_width (>= 1.4.0, < 3.0)
34
- rubocop-ast (1.13.0)
35
- parser (>= 3.0.1.1)
36
- ruby-progressbar (1.11.0)
37
- unicode-display_width (2.1.0)
38
-
39
- PLATFORMS
40
- x86_64-linux
41
-
42
- DEPENDENCIES
43
- rake (~> 13.0)
44
- rubocop (~> 1.21)
45
- world_time_api!
46
-
47
- BUNDLED WITH
48
- 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
@@ -1,39 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require_relative "lib/world_time_api/version"
4
-
5
- Gem::Specification.new do |spec|
6
- spec.name = "world_time_api"
7
- spec.version = WorldTimeApi::VERSION
8
- spec.authors = ["Alef Ojeda de Oliveira"]
9
- spec.email = ["alef.oliveira@inovamind.com.br"]
10
-
11
- spec.summary = "Api World Time"
12
- spec.description = "A API to get world time"
13
- spec.homepage = "https://github.com/nemuba/world_time_api"
14
- spec.license = "MIT"
15
- spec.required_ruby_version = ">= 2.6.0"
16
-
17
- spec.metadata["homepage_uri"] = spec.homepage
18
- spec.metadata["source_code_uri"] = spec.homepage
19
- spec.metadata["changelog_uri"] = "https://github.com/nemuba/world_time_api/blob/main/CHANGELOG.md"
20
-
21
- # Specify which files should be added to the gem when it is released.
22
- # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
23
- spec.files = Dir.chdir(File.expand_path(__dir__)) do
24
- `git ls-files -z`.split("\x0").reject do |f|
25
- (f == __FILE__) || f.match(%r{\A(?:(?:test|spec|features)/|\.(?:git|travis|circleci)|appveyor)})
26
- end
27
- end
28
- spec.bindir = "exe"
29
- spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) }
30
- spec.require_paths = ["lib"]
31
-
32
- # Uncomment to register a new dependency of your gem
33
- spec.add_development_dependency "rake", "~> 13.0"
34
- spec.add_development_dependency "rubocop", "~> 1.21"
35
- spec.add_dependency "httparty", "~> 0.20"
36
-
37
- # For more information and examples about making a new gem, checkout our
38
- # guide at: https://bundler.io/guides/creating_gem.html
39
- end