wfhcli 0.4.0 → 0.5.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.
Files changed (4) hide show
  1. checksums.yaml +7 -0
  2. data/bin/wfhcli +7 -5
  3. data/lib/wfhcli.rb +55 -28
  4. metadata +14 -22
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 26921457339d1ca1534046e3c60168f8f720d06d
4
+ data.tar.gz: a16efb4be608a12f16d9424d93ab2406b368c5fc
5
+ SHA512:
6
+ metadata.gz: d5817c8531226bf71cc8076dbae70dafcd3f7bea16078eeb3e23026fa3f630985aa9d33df268637e25f840fc3879d5f0e530ecbdd3a7e2912ce41d325ab46091
7
+ data.tar.gz: 338e99a57009df4c5a72cf79b6a2bd4f3fbcdb9263b44dec1189316e45aa8aa40fd2a14f6dc5714aaa8fe7ee55d6a4bbf7c42dcb14becfc1e07a4f1a84c84e9a
data/bin/wfhcli CHANGED
@@ -25,15 +25,17 @@ class WfhCli < Thor
25
25
  puts @wfh.display_company(id)
26
26
  end
27
27
 
28
+ desc 'sources', 'List sources'
29
+ def sources
30
+ puts @wfh.display_sources
31
+ end
32
+
28
33
  desc 'jobs', 'List jobs'
29
34
  option :category
35
+ option :source
30
36
  option :page, default: 1
31
37
  def jobs
32
- if options[:category]
33
- puts @wfh.display_jobs(options[:page], options[:category])
34
- else
35
- puts @wfh.display_jobs(options[:page])
36
- end
38
+ puts @wfh.display_jobs(options[:page], options[:category], options[:source])
37
39
  end
38
40
 
39
41
  desc 'job ID', 'Show job with ID'
@@ -44,24 +44,22 @@ class WfhLib
44
44
  end
45
45
 
46
46
  def display_company(company_id)
47
- output = ''
47
+ content = []
48
48
  company = self.company(company_id)
49
49
 
50
- output << generate_header_and_body('Name', company['name'])
51
- output << generate_header_and_body('URL', company['url'])
50
+ content << ['Name', company['name']]
51
+ content << ['URL', company['url']]
52
52
  unless company['country'].nil?
53
- output << generate_header_and_body('Headquarters',
54
- company['country']['name'])
53
+ content << ['Headquarters', company['country']['name']]
55
54
  end
56
55
  unless company['twitter'].nil? || company['twitter'].empty?
57
- output << generate_header_and_body('Twitter', company['twitter'])
56
+ content << ['Twitter', company['twitter']]
58
57
  end
59
58
  unless company['showcase_url'].nil? || company['showcase_url'].empty?
60
- output << generate_header_and_body('Showcase URL',
61
- company['showcase_url'])
59
+ content << ['Showcase URL', company['showcase_url']]
62
60
  end
63
61
 
64
- return output
62
+ return generate_header_and_body(content)
65
63
  end
66
64
 
67
65
  def display_companies(page)
@@ -82,7 +80,7 @@ class WfhLib
82
80
  end
83
81
 
84
82
  def display_job(job_id)
85
- output = ''
83
+ content = []
86
84
  job = self.job(job_id)
87
85
 
88
86
  if job['country'].nil? || job['country'].empty?
@@ -96,22 +94,22 @@ class WfhLib
96
94
  category = "#{job['category']['name']} (#{job['category']['id']})"
97
95
  posted = format_date(job['created_at'], true)
98
96
 
99
- output << generate_header_and_body('Title', title)
100
- output << generate_header_and_body('Category', category)
101
- output << generate_header_and_body('Posted', posted)
102
- output << generate_header_and_body('Description', job['description'])
103
- output << generate_header_and_body('Application Info',
104
- job['application_info'])
105
- output << generate_header_and_body('Country', country)
97
+ content << ['Title', title]
98
+ content << ['Category', category]
99
+ content << ['Posted', posted]
100
+ content << ['Description', job['description']]
101
+ content << ['Application Info', job['application_info']]
102
+ content << ['Country', country]
106
103
  unless job['location'].nil? || job['location'].empty?
107
- output << generate_header_and_body('Location', job['location'])
104
+ content << ['Location', job['location']]
108
105
  end
106
+ content << ['Source', job['source']['name']]
109
107
 
110
- return output
108
+ return generate_header_and_body(content)
111
109
  end
112
110
 
113
- def display_jobs(page, category_id=nil)
114
- jobs = self.jobs(page, category_id)
111
+ def display_jobs(page, category_id=nil, source_id=nil)
112
+ jobs = self.jobs(page, category_id, source_id)
115
113
 
116
114
  if jobs.size > 0
117
115
  content = []
@@ -131,20 +129,43 @@ class WfhLib
131
129
  end
132
130
  end
133
131
 
132
+ def display_sources
133
+ categories = self.sources
134
+
135
+ if sources.size > 0
136
+ content = []
137
+ content[0] = %w{ID Name URL}
138
+
139
+ sources.each do |source|
140
+ content << [source['id'], source['name'], source['url']]
141
+ end
142
+
143
+ generate_table(content)
144
+ else
145
+ 'No sources found'
146
+ end
147
+ end
148
+
134
149
  def job(id)
135
150
  get_json("/jobs/#{id}")
136
151
  end
137
152
 
138
- def jobs(page=1, category_id=nil)
139
- if category_id.nil?
140
- uri = "/jobs?page=#{page}"
141
- else
142
- uri = "/categories/#{category_id}/jobs?page=#{page}"
153
+ def jobs(page=1, category_id=nil, source_id=nil)
154
+ uri = "/jobs?page=#{page}&"
155
+ unless category_id.nil?
156
+ uri = uri + "category_id=#{category_id}&"
157
+ end
158
+ unless source_id.nil?
159
+ uri = uri + "source_id=#{source_id}"
143
160
  end
144
161
 
145
162
  get_json(uri)
146
163
  end
147
164
 
165
+ def sources
166
+ get_json('/sources')
167
+ end
168
+
148
169
  private
149
170
 
150
171
  def format_date(str, inc_time=false)
@@ -154,8 +175,14 @@ class WfhLib
154
175
  d.strftime(format)
155
176
  end
156
177
 
157
- def generate_header_and_body(title, body)
158
- "#{@shell.set_color(title, @title_colour)}\n#{body}\n"
178
+ def generate_header_and_body(content)
179
+ output = ''
180
+
181
+ content.each do |header, body|
182
+ output << "#{@shell.set_color(header, @title_colour)}\n#{body}\n"
183
+ end
184
+
185
+ return output
159
186
  end
160
187
 
161
188
  def generate_table(content)
metadata CHANGED
@@ -1,62 +1,55 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: wfhcli
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.0
5
- prerelease:
4
+ version: 0.5.0
6
5
  platform: ruby
7
6
  authors:
8
7
  - Matt Thompson
9
8
  autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
- date: 2015-01-12 00:00:00.000000000 Z
11
+ date: 2015-10-06 00:00:00.000000000 Z
13
12
  dependencies:
14
13
  - !ruby/object:Gem::Dependency
15
14
  name: rest-client
16
15
  requirement: !ruby/object:Gem::Requirement
17
- none: false
18
16
  requirements:
19
- - - ~>
17
+ - - "~>"
20
18
  - !ruby/object:Gem::Version
21
19
  version: 1.7.2
22
20
  type: :runtime
23
21
  prerelease: false
24
22
  version_requirements: !ruby/object:Gem::Requirement
25
- none: false
26
23
  requirements:
27
- - - ~>
24
+ - - "~>"
28
25
  - !ruby/object:Gem::Version
29
26
  version: 1.7.2
30
27
  - !ruby/object:Gem::Dependency
31
28
  name: thor
32
29
  requirement: !ruby/object:Gem::Requirement
33
- none: false
34
30
  requirements:
35
- - - ~>
31
+ - - "~>"
36
32
  - !ruby/object:Gem::Version
37
33
  version: 0.19.1
38
34
  type: :runtime
39
35
  prerelease: false
40
36
  version_requirements: !ruby/object:Gem::Requirement
41
- none: false
42
37
  requirements:
43
- - - ~>
38
+ - - "~>"
44
39
  - !ruby/object:Gem::Version
45
40
  version: 0.19.1
46
41
  - !ruby/object:Gem::Dependency
47
42
  name: webmock
48
43
  requirement: !ruby/object:Gem::Requirement
49
- none: false
50
44
  requirements:
51
- - - ~>
45
+ - - "~>"
52
46
  - !ruby/object:Gem::Version
53
47
  version: 1.11.0
54
48
  type: :development
55
49
  prerelease: false
56
50
  version_requirements: !ruby/object:Gem::Requirement
57
- none: false
58
51
  requirements:
59
- - - ~>
52
+ - - "~>"
60
53
  - !ruby/object:Gem::Version
61
54
  version: 1.11.0
62
55
  description: A CLI wrapper around the WFH.io (https://www.wfh.io) remote job board
@@ -67,31 +60,30 @@ extensions: []
67
60
  extra_rdoc_files: []
68
61
  files:
69
62
  - README.md
70
- - lib/wfhcli.rb
71
63
  - bin/wfhcli
64
+ - lib/wfhcli.rb
72
65
  homepage: https://github.com/wfhio/wfhcli
73
66
  licenses:
74
67
  - MIT
68
+ metadata: {}
75
69
  post_install_message:
76
70
  rdoc_options: []
77
71
  require_paths:
78
72
  - lib
79
73
  required_ruby_version: !ruby/object:Gem::Requirement
80
- none: false
81
74
  requirements:
82
- - - ! '>='
75
+ - - ">="
83
76
  - !ruby/object:Gem::Version
84
77
  version: '0'
85
78
  required_rubygems_version: !ruby/object:Gem::Requirement
86
- none: false
87
79
  requirements:
88
- - - ! '>='
80
+ - - ">="
89
81
  - !ruby/object:Gem::Version
90
82
  version: '0'
91
83
  requirements: []
92
84
  rubyforge_project:
93
- rubygems_version: 1.8.23
85
+ rubygems_version: 2.4.5
94
86
  signing_key:
95
- specification_version: 3
87
+ specification_version: 4
96
88
  summary: A CLI wrapper around the WFH.io (https://www.wfh.io) remote job board
97
89
  test_files: []