atlasq 0.1.0 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/cache/formatted_output/country_title.json +1 -0
- data/cache/formatted_output/multiline_country.json +1 -0
- data/cache/formatted_output/one_line_country.json +1 -0
- data/cache/formatted_output/one_line_currency.json +1 -0
- data/cache/list/all_countries.json +1 -0
- data/cache/list/all_subregions.json +1 -0
- data/cache/search_index/countries_by_currency.json +1 -0
- data/cache/search_index/countries_by_region.json +1 -0
- data/cache/search_index/direct_match_country.json +1 -0
- data/cache/search_index/direct_match_currency.json +1 -0
- data/cache/search_index/partial_match_country.json +1 -0
- data/cache/search_index/partial_match_currency.json +1 -0
- data/lib/atlasq/cache.rb +27 -0
- data/lib/atlasq/command/any.rb +7 -5
- data/lib/atlasq/command/base.rb +1 -1
- data/lib/atlasq/command/country.rb +6 -6
- data/lib/atlasq/command/help.rb +2 -0
- data/lib/atlasq/command/money.rb +6 -5
- data/lib/atlasq/command/region.rb +3 -4
- data/lib/atlasq/command.rb +1 -0
- data/lib/atlasq/data.rb +34 -91
- data/lib/atlasq/format.rb +53 -126
- data/lib/atlasq/partial_match.rb +19 -0
- data/lib/atlasq/util/string.rb +42 -6
- data/lib/atlasq/util/word_map.rb +34 -0
- data/lib/atlasq/util.rb +1 -0
- data/lib/atlasq/version.rb +1 -1
- data/lib/atlasq.rb +2 -0
- metadata +17 -60
- data/lib/atlasq/data/currency.rb +0 -20
- data/lib/atlasq/data/region.rb +0 -24
@@ -0,0 +1,34 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "set"
|
4
|
+
require "unaccent"
|
5
|
+
|
6
|
+
module Atlasq
|
7
|
+
module Util
|
8
|
+
# This data structure provides partial match support for words in sentences.
|
9
|
+
#
|
10
|
+
# For example, if we take a country like "Bonaire, Sint Eustatius and Saba"
|
11
|
+
# the searches "Bonaire", "Sint Eustatius" and "saba bonaire" should all match
|
12
|
+
# while the searches "bonaire france" and "saba bolivia" should not because
|
13
|
+
# they include words not found in the original sentence.
|
14
|
+
class WordMap
|
15
|
+
# @param index [Hash<String, Array<String>>]
|
16
|
+
def initialize(index:)
|
17
|
+
@index = index
|
18
|
+
end
|
19
|
+
|
20
|
+
# Search for ids that include all of the search term words.
|
21
|
+
#
|
22
|
+
# @param search_term [String]
|
23
|
+
# @return [Array<String>] list of ids
|
24
|
+
def search(search_term)
|
25
|
+
search_term
|
26
|
+
.then(&Util::String.method(:word_split))
|
27
|
+
.uniq
|
28
|
+
.map { |word| @index.fetch(word, []) }
|
29
|
+
.inject(&:intersection)
|
30
|
+
.sort
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
data/lib/atlasq/util.rb
CHANGED
data/lib/atlasq/version.rb
CHANGED
data/lib/atlasq.rb
CHANGED
@@ -6,9 +6,11 @@ module Atlasq
|
|
6
6
|
class Error < StandardError; end
|
7
7
|
DEBUG = ENV.key?("ATLASQ_DEBUG")
|
8
8
|
|
9
|
+
autoload :Cache, "atlasq/cache"
|
9
10
|
autoload :Command, "atlasq/command"
|
10
11
|
autoload :Data, "atlasq/data"
|
11
12
|
autoload :Format, "atlasq/format"
|
13
|
+
autoload :PartialMatch, "atlasq/partial_match"
|
12
14
|
autoload :Shell, "atlasq/shell"
|
13
15
|
autoload :Util, "atlasq/util"
|
14
16
|
|
metadata
CHANGED
@@ -1,71 +1,15 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: atlasq
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Kevin Robell
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-
|
11
|
+
date: 2023-12-31 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
|
-
- !ruby/object:Gem::Dependency
|
14
|
-
name: countries
|
15
|
-
requirement: !ruby/object:Gem::Requirement
|
16
|
-
requirements:
|
17
|
-
- - "~>"
|
18
|
-
- !ruby/object:Gem::Version
|
19
|
-
version: '5.7'
|
20
|
-
type: :runtime
|
21
|
-
prerelease: false
|
22
|
-
version_requirements: !ruby/object:Gem::Requirement
|
23
|
-
requirements:
|
24
|
-
- - "~>"
|
25
|
-
- !ruby/object:Gem::Version
|
26
|
-
version: '5.7'
|
27
|
-
- !ruby/object:Gem::Dependency
|
28
|
-
name: iso-639
|
29
|
-
requirement: !ruby/object:Gem::Requirement
|
30
|
-
requirements:
|
31
|
-
- - "~>"
|
32
|
-
- !ruby/object:Gem::Version
|
33
|
-
version: '0.3'
|
34
|
-
type: :runtime
|
35
|
-
prerelease: false
|
36
|
-
version_requirements: !ruby/object:Gem::Requirement
|
37
|
-
requirements:
|
38
|
-
- - "~>"
|
39
|
-
- !ruby/object:Gem::Version
|
40
|
-
version: '0.3'
|
41
|
-
- !ruby/object:Gem::Dependency
|
42
|
-
name: money
|
43
|
-
requirement: !ruby/object:Gem::Requirement
|
44
|
-
requirements:
|
45
|
-
- - "~>"
|
46
|
-
- !ruby/object:Gem::Version
|
47
|
-
version: '6.9'
|
48
|
-
type: :runtime
|
49
|
-
prerelease: false
|
50
|
-
version_requirements: !ruby/object:Gem::Requirement
|
51
|
-
requirements:
|
52
|
-
- - "~>"
|
53
|
-
- !ruby/object:Gem::Version
|
54
|
-
version: '6.9'
|
55
|
-
- !ruby/object:Gem::Dependency
|
56
|
-
name: money-heuristics
|
57
|
-
requirement: !ruby/object:Gem::Requirement
|
58
|
-
requirements:
|
59
|
-
- - "~>"
|
60
|
-
- !ruby/object:Gem::Version
|
61
|
-
version: 0.1.1
|
62
|
-
type: :runtime
|
63
|
-
prerelease: false
|
64
|
-
version_requirements: !ruby/object:Gem::Requirement
|
65
|
-
requirements:
|
66
|
-
- - "~>"
|
67
|
-
- !ruby/object:Gem::Version
|
68
|
-
version: 0.1.1
|
69
13
|
- !ruby/object:Gem::Dependency
|
70
14
|
name: tty-pager
|
71
15
|
requirement: !ruby/object:Gem::Requirement
|
@@ -90,8 +34,21 @@ executables:
|
|
90
34
|
extensions: []
|
91
35
|
extra_rdoc_files: []
|
92
36
|
files:
|
37
|
+
- cache/formatted_output/country_title.json
|
38
|
+
- cache/formatted_output/multiline_country.json
|
39
|
+
- cache/formatted_output/one_line_country.json
|
40
|
+
- cache/formatted_output/one_line_currency.json
|
41
|
+
- cache/list/all_countries.json
|
42
|
+
- cache/list/all_subregions.json
|
43
|
+
- cache/search_index/countries_by_currency.json
|
44
|
+
- cache/search_index/countries_by_region.json
|
45
|
+
- cache/search_index/direct_match_country.json
|
46
|
+
- cache/search_index/direct_match_currency.json
|
47
|
+
- cache/search_index/partial_match_country.json
|
48
|
+
- cache/search_index/partial_match_currency.json
|
93
49
|
- exe/atlasq
|
94
50
|
- lib/atlasq.rb
|
51
|
+
- lib/atlasq/cache.rb
|
95
52
|
- lib/atlasq/command.rb
|
96
53
|
- lib/atlasq/command/any.rb
|
97
54
|
- lib/atlasq/command/base.rb
|
@@ -102,12 +59,12 @@ files:
|
|
102
59
|
- lib/atlasq/command/usage.rb
|
103
60
|
- lib/atlasq/command/version.rb
|
104
61
|
- lib/atlasq/data.rb
|
105
|
-
- lib/atlasq/data/currency.rb
|
106
|
-
- lib/atlasq/data/region.rb
|
107
62
|
- lib/atlasq/format.rb
|
63
|
+
- lib/atlasq/partial_match.rb
|
108
64
|
- lib/atlasq/shell.rb
|
109
65
|
- lib/atlasq/util.rb
|
110
66
|
- lib/atlasq/util/string.rb
|
67
|
+
- lib/atlasq/util/word_map.rb
|
111
68
|
- lib/atlasq/version.rb
|
112
69
|
homepage:
|
113
70
|
licenses:
|
data/lib/atlasq/data/currency.rb
DELETED
@@ -1,20 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module Atlasq
|
4
|
-
module Data
|
5
|
-
class Currency
|
6
|
-
# @return [String]
|
7
|
-
attr_reader :currency_code
|
8
|
-
|
9
|
-
# @return [Array<Hash>]
|
10
|
-
attr_reader :countries
|
11
|
-
|
12
|
-
# @param countries [Array<Hash>]
|
13
|
-
# @param currency_code [String] ISO4217 currency code
|
14
|
-
def initialize(countries:, currency_code:)
|
15
|
-
@countries = countries
|
16
|
-
@currency_code = currency_code
|
17
|
-
end
|
18
|
-
end
|
19
|
-
end
|
20
|
-
end
|
data/lib/atlasq/data/region.rb
DELETED
@@ -1,24 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module Atlasq
|
4
|
-
module Data
|
5
|
-
class Region
|
6
|
-
# @return [Symbol]
|
7
|
-
attr_reader :type
|
8
|
-
|
9
|
-
# @return [String, nil]
|
10
|
-
attr_reader :name
|
11
|
-
|
12
|
-
# @return [Array<Hash>]
|
13
|
-
attr_reader :countries
|
14
|
-
|
15
|
-
# @param countries [Array<Hash>]
|
16
|
-
# @param type [Symbol] in Atlasq::Data::REGION_TYPES
|
17
|
-
def initialize(countries:, type:)
|
18
|
-
@type = type
|
19
|
-
@name = countries.dig(0, @type.to_s)
|
20
|
-
@countries = countries
|
21
|
-
end
|
22
|
-
end
|
23
|
-
end
|
24
|
-
end
|