project_euler_cli 1.1.3 → 1.2.0
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 +4 -4
- data/Gemfile.lock +1 -1
- data/lib/project_euler_cli/archive_searcher.rb +12 -8
- data/lib/project_euler_cli/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d24479bc8b7da8a9224cd9fbed31f5719d55f8470631661ef1854aa4f72456c7
|
4
|
+
data.tar.gz: 1c2019b22c5b6f7dbac1f4831b51ffc1d16961a4294f20bf70965307e238ace7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9b407f362003ada505414c27c933abd6d92a2e60569e97eac901349a9d09a5751401f6ec8d936391a36b389b8019725638d190ff64b0fe9d0d59c84ddc93d7c7
|
7
|
+
data.tar.gz: 3f920320f2902c8e232c79fef65a3a03c90050600d3815e8c7c354740d44b066fa36ac7c47a70ac1d55f35339eff74f3074d6ee5434989a0102037789b93f50e
|
data/Gemfile.lock
CHANGED
@@ -18,26 +18,30 @@ class ArchiveSearcher
|
|
18
18
|
end
|
19
19
|
|
20
20
|
# Loads the problem numbers and titles for every page that is not loaded.
|
21
|
-
def
|
21
|
+
def load_keywords
|
22
22
|
puts "updating keywords..."
|
23
23
|
|
24
24
|
0.upto(Page.total) { |page| load_page(page, @problems) }
|
25
25
|
end
|
26
26
|
|
27
|
-
# Performs a simple search of the problems. It accepts multiple terms
|
28
|
-
# will contain *all* of the search terms.
|
27
|
+
# Performs a simple search of the problems. It accepts multiple terms and
|
28
|
+
# recognizes quoted phrases. Results will contain *all* of the search terms.
|
29
29
|
#
|
30
30
|
# * +terms+ - String of search terms
|
31
|
-
def search(
|
32
|
-
|
31
|
+
def search(terms_string)
|
32
|
+
load_keywords if Page.visited != (0..Page.total).to_a
|
33
33
|
|
34
34
|
puts "searching..."
|
35
35
|
@searching = true
|
36
36
|
|
37
|
+
terms_string.downcase!
|
38
|
+
terms = terms_string.scan(/"[^"]*"/)
|
39
|
+
terms.each { |term| terms_string.slice!(term) }
|
40
|
+
terms.collect! { |term| term.gsub("\"", '') }
|
41
|
+
terms += terms_string.split(' ')
|
42
|
+
|
37
43
|
@results = (1..Problem.total).select do |i|
|
38
|
-
terms.
|
39
|
-
@problems[i].title.downcase.include?(term)
|
40
|
-
end
|
44
|
+
terms.all? { |term| @problems[i].title.downcase.include?(term) }
|
41
45
|
end
|
42
46
|
end
|
43
47
|
|