ip2geo 0.0.2 → 0.0.4

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: 9ee64a44d70af371c8e118e89eeb1d6f975f289835c67dfc1695e7e750985df1
4
- data.tar.gz: 16f87bf015c8f85a14b51e22b8e336838d9cb9f12ca3ea2b125dd19f7d368ceb
3
+ metadata.gz: 1f351a6f513382254a1df63bc64e6d233c8e2aceb5d4c55bc05e5ff15a4a6a93
4
+ data.tar.gz: c591a9431462958e4318caf0f77ef5dbb41044e5eaf769f6409047548e42c348
5
5
  SHA512:
6
- metadata.gz: bbcb5312ccb091395e24a694deb5c4eb1118c66caf00cbd3c993d47146e29529f41d886b5aff731208df87a0de5fc64ca5600cfe0e48feb6da9da6550b4a4c81
7
- data.tar.gz: 10502431e5289199d0e4eadbd31fb41e46707534233dbe64574e6c56d6dcf14edc0d50a8461a57b3423e18d4388166eb46c3c5bc6dea73a6880359db3d9025ae
6
+ metadata.gz: 41bae8ece7beef8885fc0db59c4547ead255a226943994ada71d3b25903480dbdb49d7314c47b897c4aecf00d926368da30221f5a331d549921951630300112b
7
+ data.tar.gz: 2c95e88aed0728cd15ff2155e4a5a2aa0cb617877e24e813e3cc98243c491ea1c80d5a26076540614d538d2a66d3f7ad309406c3908dc0531dacce8fefb259c6
data/README.md CHANGED
@@ -1,5 +1,5 @@
1
1
  <div align='center'>
2
- <a href='https://axios-http.com'>
2
+ <a href='https://ip2geo.dev'>
3
3
  <img
4
4
  src='https://cdn-prod.ip2geo.dev/assets/ruby/generals/ip2geo.svg'
5
5
  alt='Ip2Geo Logo'
@@ -10,7 +10,7 @@
10
10
  </div>
11
11
 
12
12
  <p align='center'>
13
- Your go-to IP-to-Geo cloud service — fast, accurate, and built for developers. Start free with 1,000 monthly stored conversions.
13
+ Your go-to IP-to-Geo cloud service, fast, accurate, and built for developers. Start free with 1,000 monthly stored conversions.
14
14
  </p>
15
15
 
16
16
  <p align='center'>
@@ -20,15 +20,15 @@
20
20
  </b>
21
21
  </a>
22
22
  •
23
- <a href='https://app.ip2geo.dev'>
23
+ <a href='https://ip2geo.dev/dashboard'>
24
24
  <b>
25
25
  Dashboard
26
26
  </b>
27
27
  </a>
28
28
  •
29
- <a href='https://docs.ip2geo.dev'>
29
+ <a href='https://ip2geo.dev/docs'>
30
30
  <b>
31
- Documentation
31
+ Docs
32
32
  </b>
33
33
  </a>
34
34
  •
@@ -45,6 +45,8 @@
45
45
 
46
46
  This gem provides a lightweight way to integrate Ip2Geo into your Ruby applications.
47
47
 
48
+ Working from a terminal instead? The [ip2geo CLI](https://ip2geo.dev/docs/cli/introduction) (`npm i -g @ip2geo/cli`) makes the same calls, and everything the dashboard does, from the command line.
49
+
48
50
  ### Installing
49
51
  ```bash
50
52
  gem install ip2geo
data/ip2geo.gemspec CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  Gem::Specification.new do |spec|
4
4
  spec.name = 'ip2geo'
5
- spec.version = '0.0.2'
5
+ spec.version = '0.0.4'
6
6
  spec.authors = ['Ip2Geo']
7
7
  spec.email = ['support@ip2geo.dev']
8
8
 
@@ -14,8 +14,8 @@ Gem::Specification.new do |spec|
14
14
  spec.license = 'Nonstandard'
15
15
 
16
16
  spec.metadata['homepage_uri'] = spec.homepage
17
- spec.metadata['changelog_uri'] = 'https://docs.ip2geo.dev/changelog'
18
- spec.metadata['documentation_uri'] = 'https://docs.ip2geo.dev'
17
+ spec.metadata['changelog_uri'] = 'https://ip2geo.dev/docs/sdk/changelogs'
18
+ spec.metadata['documentation_uri'] = 'https://ip2geo.dev/docs'
19
19
 
20
20
  spec.files = Dir.glob('lib/**/*') + ['ip2geo.gemspec', 'README.md', 'LICENSE']
21
21
  spec.require_paths = ['lib']
@@ -3,7 +3,7 @@
3
3
  module Ip2Geo
4
4
  module Data
5
5
  API_ENDPOINT = 'https://api.ip2geo.dev'
6
- DOCS_URL = 'https://docs.ip2geo.dev'
6
+ DOCS_URL = 'https://ip2geo.dev/docs'
7
7
  RUBYGEMS_URL = 'https://rubygems.org/api/v1/gems/ip2geo.json'
8
8
 
9
9
  IP_TYPES = {
@@ -43,6 +43,10 @@ module Ip2Geo
43
43
  }.freeze
44
44
  }.freeze
45
45
 
46
+ # The stored fields of a conversion, which `select` names as they are; every other field is read under `data.`.
47
+ CONVERSION_COLUMNS = %w[id uniqueId data status startedAt completedAt createdAt].freeze
48
+ SELECT_DATA_PREFIX = 'data.'
49
+
46
50
  SELECT = {
47
51
  IP: 'ip',
48
52
  TYPE: 'type',
@@ -54,7 +54,7 @@ module Ip2Geo
54
54
  '',
55
55
  top_border,
56
56
  center_text("\e[1m\e[33mUpdate available\e[0m \e[2m#{current_version} \u2192 #{latest_version}\e[0m", box_width),
57
- center_text("Changelog: \e[36mhttps://docs.ip2geo.dev/sdk/changelogs\e[0m", box_width),
57
+ center_text("Changelog: \e[36mhttps://ip2geo.dev/docs/sdk/changelogs\e[0m", box_width),
58
58
  center_text("Run \e[32m`gem update ip2geo`\e[0m to update.", box_width),
59
59
  center_text('', box_width),
60
60
  center_text("Disable this warning using: \e[36mversion_update_message: false\e[0m on init.", box_width),
@@ -0,0 +1,25 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Ip2Geo
4
+ module Helpers
5
+ class Select
6
+ class << self
7
+ # Build the `select` query value of the conversions routes. Stored fields (id, uniqueId, status,
8
+ # createdAt, ...) are sent as they are and geolocation fields (the SELECT constants) under `data.`,
9
+ # comma-separated. A field already written with the prefix is left alone. The API always returns
10
+ # `uniqueId` alongside the selected fields.
11
+ #
12
+ # @param select [Array<String>] The fields to return
13
+ # @return [String] The value of the `select` query parameter
14
+ def build(select)
15
+ select.map do |field|
16
+ field = field.to_s
17
+ stored = Data::CONVERSION_COLUMNS.include?(field) || field.start_with?(Data::SELECT_DATA_PREFIX)
18
+
19
+ stored ? field : "#{Data::SELECT_DATA_PREFIX}#{field}"
20
+ end.join(',')
21
+ end
22
+ end
23
+ end
24
+ end
25
+ end
@@ -20,13 +20,13 @@ module Ip2Geo
20
20
  )
21
21
  end
22
22
 
23
- params = []
24
- params << "select=#{select.map { |f| "data.#{f}" }.join(',')}" if select.is_a?(Array) && !select.empty?
23
+ params = ["conversionId=#{conversion_id}"]
24
+ params << "select=#{Helpers::Select.build(select)}" if select.is_a?(Array) && !select.empty?
25
25
 
26
- query_string = params.empty? ? '' : "?#{params.join('&')}"
26
+ query_string = "?#{params.join('&')}"
27
27
  url = "#{Data::API_ENDPOINT}#{Data::ENDPOINTS[:CONVERSIONS][:GET]}#{query_string}"
28
28
 
29
- Helpers::Http.request(url, { conversionId: conversion_id })
29
+ Helpers::Http.request(url)
30
30
  rescue StandardError => e
31
31
  warn "[Ip2Geo::GetConversion] Error: #{e.message}"
32
32
  nil
@@ -21,7 +21,7 @@ module Ip2Geo
21
21
  end
22
22
 
23
23
  params = []
24
- params << "select=#{select.map { |f| "data.#{f}" }.join(',')}" if select.is_a?(Array) && !select.empty?
24
+ params << "select=#{Helpers::Select.build(select)}" if select.is_a?(Array) && !select.empty?
25
25
 
26
26
  query_string = params.empty? ? '' : "?#{params.join('&')}"
27
27
  url = "#{Data::API_ENDPOINT}#{Data::ENDPOINTS[:CONVERSIONS][:GET]}#{query_string}"
@@ -21,7 +21,7 @@ module Ip2Geo
21
21
  params = []
22
22
  params << "offset=#{offset}" if offset.positive?
23
23
  params << "limit=#{limit}" if limit != 50
24
- params << "select=#{select.map { |f| "data.#{f}" }.join(',')}" if select.is_a?(Array) && !select.empty?
24
+ params << "select=#{Helpers::Select.build(select)}" if select.is_a?(Array) && !select.empty?
25
25
  params << "ipSearch=#{ip_search}" if ip_search
26
26
 
27
27
  query_string = params.empty? ? '' : "?#{params.join('&')}"
data/lib/ip2geo.rb CHANGED
@@ -24,6 +24,7 @@ require_relative 'ip2geo/data/messages'
24
24
  require_relative 'ip2geo/helpers/cache'
25
25
  require_relative 'ip2geo/helpers/http'
26
26
  require_relative 'ip2geo/helpers/ip_validation'
27
+ require_relative 'ip2geo/helpers/select'
27
28
  require_relative 'ip2geo/helpers/check_version'
28
29
  require_relative 'ip2geo/methods/init'
29
30
  require_relative 'ip2geo/methods/convert_ip'
@@ -33,7 +34,7 @@ require_relative 'ip2geo/methods/get_conversions'
33
34
  require_relative 'ip2geo/methods/list_conversions'
34
35
 
35
36
  module Ip2Geo
36
- VERSION = '0.0.1'
37
+ VERSION = '0.0.4'
37
38
 
38
39
  class << self
39
40
  # Initializes the SDK with the given API key.
metadata CHANGED
@@ -1,14 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ip2geo
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ip2Geo
8
- autorequire:
9
8
  bindir: bin
10
9
  cert_chain: []
11
- date: 2026-04-19 00:00:00.000000000 Z
10
+ date: 2026-10-27 00:00:00.000000000 Z
12
11
  dependencies:
13
12
  - !ruby/object:Gem::Dependency
14
13
  name: json
@@ -44,6 +43,7 @@ files:
44
43
  - lib/ip2geo/helpers/check_version.rb
45
44
  - lib/ip2geo/helpers/http.rb
46
45
  - lib/ip2geo/helpers/ip_validation.rb
46
+ - lib/ip2geo/helpers/select.rb
47
47
  - lib/ip2geo/methods/convert_ip.rb
48
48
  - lib/ip2geo/methods/convert_ips.rb
49
49
  - lib/ip2geo/methods/get_conversion.rb
@@ -55,9 +55,8 @@ licenses:
55
55
  - Nonstandard
56
56
  metadata:
57
57
  homepage_uri: https://ip2geo.dev
58
- changelog_uri: https://docs.ip2geo.dev/changelog
59
- documentation_uri: https://docs.ip2geo.dev
60
- post_install_message:
58
+ changelog_uri: https://ip2geo.dev/docs/sdk/changelogs
59
+ documentation_uri: https://ip2geo.dev/docs
61
60
  rdoc_options: []
62
61
  require_paths:
63
62
  - lib
@@ -72,8 +71,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
72
71
  - !ruby/object:Gem::Version
73
72
  version: '0'
74
73
  requirements: []
75
- rubygems_version: 3.0.3.1
76
- signing_key:
74
+ rubygems_version: 3.6.3
77
75
  specification_version: 4
78
76
  summary: Official Ruby SDK for Ip2Geo - IP to Geolocation API.
79
77
  test_files: []