chamba_search_mx 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +4 -0
- data/lib/chamba_search_mx/finder.rb +25 -5
- data/lib/chamba_search_mx/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8339f6912ab4bd03564b235ac3e2d25a1840afd7
|
4
|
+
data.tar.gz: 2332f435f2a53e99af4a871d3e70a78ce940f770
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c9c2889694025b8adebb2b92df5e53246fc0cb390e28e46fe886190e3c438a91f098b273a0d176fd4d9361e1505dba3ff40a82c387aa8c78c0758fd647a277b1
|
7
|
+
data.tar.gz: a03a9d067007cba52b83d2d2a8c5e1ffc3efb37fb29a430ef375f20e3f0d9958bd7ddd6f2430cfd968cce9171f67e98cab0bf1b839e617a04e6457ef082d83ef
|
data/CHANGELOG.md
CHANGED
@@ -4,6 +4,9 @@ All notable changes to this project will be documented in this file.
|
|
4
4
|
The format is based on [Keep a Changelog](http://keepachangelog.com/)
|
5
5
|
and this project adheres to [Semantic Versioning](http://semver.org/).
|
6
6
|
|
7
|
+
## [v0.1.1]
|
8
|
+
- More documentation added
|
9
|
+
|
7
10
|
## [v0.1.0]
|
8
11
|
### Added
|
9
12
|
- ChambaSearchMx module added by @richistron
|
@@ -11,4 +14,5 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
|
|
11
14
|
- rspec tests added by @richistron
|
12
15
|
|
13
16
|
[v0.1.0]:https://github.com/richistron/chamba_search_mx/tree/v0.1.0
|
17
|
+
[v0.1.1]:https://github.com/richistron/chamba_search_mx/tree/v0.1.0
|
14
18
|
|
@@ -2,6 +2,8 @@ module ChambaSearchMx
|
|
2
2
|
##
|
3
3
|
# finds jobs and returns simplified objects of them selfs
|
4
4
|
class Finder
|
5
|
+
##
|
6
|
+
# @attribute <Array>
|
5
7
|
attr_reader :jobs
|
6
8
|
def initialize(options = {})
|
7
9
|
@formatter = options[:formatter] || ChambaSearchMx::UrlFormatter.new
|
@@ -10,6 +12,10 @@ module ChambaSearchMx
|
|
10
12
|
@job = options[:job] || ChambaSearchMx::JobPage.new
|
11
13
|
end
|
12
14
|
|
15
|
+
##
|
16
|
+
# @param <String> search
|
17
|
+
# @param <Hash> options
|
18
|
+
# @return <Class> self
|
13
19
|
def find(search, options = {})
|
14
20
|
@search = search
|
15
21
|
@options = options
|
@@ -18,36 +24,50 @@ module ChambaSearchMx
|
|
18
24
|
self
|
19
25
|
end
|
20
26
|
|
27
|
+
private
|
28
|
+
|
29
|
+
##
|
30
|
+
# @raise <ArgumentError>
|
21
31
|
def validate_arguments
|
22
32
|
error_msg = 'search must be a non empty string'
|
23
33
|
raise ArgumentError, error_msg unless search_valid?
|
24
34
|
end
|
25
35
|
|
36
|
+
##
|
37
|
+
# @return <Boolean>
|
26
38
|
def search_valid?
|
27
|
-
if @search.class != String
|
28
|
-
|
29
|
-
|
30
|
-
true
|
31
|
-
end
|
39
|
+
return false if @search.class != String
|
40
|
+
return false if @search.empty?
|
41
|
+
true
|
32
42
|
end
|
33
43
|
|
44
|
+
##
|
45
|
+
# @return <Array>
|
34
46
|
def find_jobs
|
35
47
|
@jobs = job_urls.map { |url| @job.load(url).data }
|
36
48
|
end
|
37
49
|
|
50
|
+
##
|
51
|
+
# @return <Array>
|
38
52
|
def job_urls
|
39
53
|
pagination_urls.map { |url| @search_page.load(url).job_urls }.flatten
|
40
54
|
end
|
41
55
|
|
56
|
+
##
|
57
|
+
# @return <Array>
|
42
58
|
def pagination_urls
|
43
59
|
@pagination.load(format_url).urls
|
44
60
|
end
|
45
61
|
|
62
|
+
##
|
63
|
+
# @returm <string>
|
46
64
|
def format_url
|
47
65
|
opts = search_options
|
48
66
|
@formatter.format @search, opts
|
49
67
|
end
|
50
68
|
|
69
|
+
##
|
70
|
+
# @return <Hash>
|
51
71
|
def search_options
|
52
72
|
{
|
53
73
|
location: @options[:location] || 'default',
|