jobs_api_gem 0.1.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 +7 -0
- data/.gitignore +9 -0
- data/.rspec +2 -0
- data/.travis.yml +3 -0
- data/Gemfile +4 -0
- data/README.md +39 -0
- data/Rakefile +1 -0
- data/bin/console +4 -0
- data/bin/jobs_api_parser +5 -0
- data/bin/setup +7 -0
- data/jobs_api_gem.gemspec +26 -0
- data/lib/jobs_api_gem.rb +63 -0
- data/lib/jobs_api_gem/binary.rb +17 -0
- data/lib/jobs_api_gem/version.rb +3 -0
- metadata +112 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 42ccd68a421dfdc2a8b8d35decd114bd378785dc
|
4
|
+
data.tar.gz: d3c342cee98e8b8b1300e8dc03eccde0a4ee6acb
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 64e8690e5651ee8e908504e7242d308f7962809515d4cf7cd26e826597ba9d9e2772f67c161969a875ef832b8e5c165fc258dc1aeace3ec5767691df70d64ec9
|
7
|
+
data.tar.gz: fc2d50811731d8c2b591909f1178e1394dda6e1d2a5ad7171b4f40cfc6cbf90dab5bf848ca4802cd31f7a061c5bcbe767e84738e39a826dbdce0eb715a64de6f
|
data/.gitignore
ADDED
data/.rspec
ADDED
data/.travis.yml
ADDED
data/Gemfile
ADDED
data/README.md
ADDED
@@ -0,0 +1,39 @@
|
|
1
|
+
# jobs_api_gem
|
2
|
+
|
3
|
+
Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/jobs_api_gem`. To experiment with that code, run `bin/console` for an interactive prompt.
|
4
|
+
|
5
|
+
TODO: Delete this and the text above, and describe your gem
|
6
|
+
|
7
|
+
## Installation
|
8
|
+
|
9
|
+
Add this line to your application's Gemfile:
|
10
|
+
|
11
|
+
```ruby
|
12
|
+
gem 'jobs_api_gem'
|
13
|
+
```
|
14
|
+
|
15
|
+
And then execute:
|
16
|
+
|
17
|
+
$ bundle
|
18
|
+
|
19
|
+
Or install it yourself as:
|
20
|
+
|
21
|
+
$ gem install jobs_api_gem
|
22
|
+
|
23
|
+
## Usage
|
24
|
+
|
25
|
+
TODO: Write usage instructions here
|
26
|
+
|
27
|
+
## Development
|
28
|
+
|
29
|
+
After checking out the repo, run `bin/setup` to install dependencies. Then, run `bin/console` for an interactive prompt that will allow you to experiment.
|
30
|
+
|
31
|
+
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release` to create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
32
|
+
|
33
|
+
## Contributing
|
34
|
+
|
35
|
+
1. Fork it ( https://github.com/[my-github-username]/jobs_api_gem/fork )
|
36
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
37
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
38
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
39
|
+
5. Create a new Pull Request
|
data/Rakefile
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require "bundler/gem_tasks"
|
data/bin/console
ADDED
data/bin/jobs_api_parser
ADDED
data/bin/setup
ADDED
@@ -0,0 +1,26 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'jobs_api_gem/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "jobs_api_gem"
|
8
|
+
spec.version = JobsApiGem::VERSION
|
9
|
+
spec.authors = ["Adam Smith"]
|
10
|
+
spec.email = ["adamsmith910@aol.com"]
|
11
|
+
|
12
|
+
spec.summary = "bad summary"
|
13
|
+
spec.description = "bad description"
|
14
|
+
spec.homepage = "http://www.wingheads.com"
|
15
|
+
|
16
|
+
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
17
|
+
spec.bindir = "exe"
|
18
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
19
|
+
spec.require_paths = ["lib"]
|
20
|
+
|
21
|
+
spec.add_dependency "faraday"
|
22
|
+
spec.add_dependency "json"
|
23
|
+
|
24
|
+
spec.add_development_dependency "bundler", "~> 1.9"
|
25
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
26
|
+
end
|
data/lib/jobs_api_gem.rb
ADDED
@@ -0,0 +1,63 @@
|
|
1
|
+
require 'jobs_api_gem/version'
|
2
|
+
require 'faraday'
|
3
|
+
require 'json'
|
4
|
+
require 'pry'
|
5
|
+
|
6
|
+
class JobsApiGem
|
7
|
+
|
8
|
+
def initialize(endpoint)
|
9
|
+
@ruby_connection = Faraday.new(url: "https://jobs.github.com/positions.json?postion=ruby")
|
10
|
+
@ruby_on_rails_connection = Faraday.new(url: "https://jobs.github.com/positions.json?postion=ruby+on+rails")
|
11
|
+
@javascript_connection = Faraday.new(url: "https://jobs.github.com/positions.json?postion=javascript")
|
12
|
+
@post_connection = Faraday.new(url: "http://localhost:3000")
|
13
|
+
@jobs = []
|
14
|
+
@posted_jobs = 0
|
15
|
+
@endpoint = endpoint
|
16
|
+
@search_terms = [@ruby_connection, @ruby_on_rails_connection, @javascript_connection]
|
17
|
+
end
|
18
|
+
|
19
|
+
|
20
|
+
def iterate_search_terms
|
21
|
+
@search_terms.each do |term|
|
22
|
+
get_data(term)
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
def get_data(term)
|
27
|
+
connection = term
|
28
|
+
response = connection.get
|
29
|
+
body = response.body
|
30
|
+
rbody = JSON.parse(body, quirks_mode: true)
|
31
|
+
rbody.each_with_index do |job, i|
|
32
|
+
job = {
|
33
|
+
company: job["company"],
|
34
|
+
location: job["location"],
|
35
|
+
description: job["description"],
|
36
|
+
url: job["url"],
|
37
|
+
posting_date: job["created_at"]
|
38
|
+
}
|
39
|
+
@jobs << job
|
40
|
+
puts "Job #{i + 1} pulled."
|
41
|
+
end
|
42
|
+
if term == @ruby_connection
|
43
|
+
puts "Pulled Ruby job summaries"
|
44
|
+
elsif term == @ruby_on_rails_connection
|
45
|
+
puts "Pulled Ruby on Rails job summaries"
|
46
|
+
else
|
47
|
+
puts "Pulled JavaScript job summaries"
|
48
|
+
end
|
49
|
+
send_to_server
|
50
|
+
end
|
51
|
+
|
52
|
+
def send_to_server
|
53
|
+
@jobs.each_with_index do |job, i|
|
54
|
+
new_job = {
|
55
|
+
location: job[:location],
|
56
|
+
description: job[:description],
|
57
|
+
source: job[:url],
|
58
|
+
position: 'n/a',
|
59
|
+
}
|
60
|
+
response = @post_connection.post(@endpoint, job: new_job)
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
require 'jobs_api_gem'
|
2
|
+
|
3
|
+
class JobsApiGem
|
4
|
+
class Binary
|
5
|
+
def self.call(argv, outstream, errstream)
|
6
|
+
outstream.puts "GitHub Job API Parser"
|
7
|
+
outstream.puts "---------------------------------------------"
|
8
|
+
outstream.puts "Started parsing..."
|
9
|
+
endpoint = argv.first
|
10
|
+
outstream.puts "Sending post requests to #{endpoint}"
|
11
|
+
jobs_scraped, jobs_saved = JobsApiGem.new(endpoint).iterate_search_terms
|
12
|
+
outstream.puts "Parsed #{jobs_scraped} jobs, succesfully posted #{jobs_saved} jobs."
|
13
|
+
outstream.puts "---------------------------------------------"
|
14
|
+
outstream.puts "Completed!"
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
metadata
ADDED
@@ -0,0 +1,112 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: jobs_api_gem
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Adam Smith
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2015-05-04 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: faraday
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: json
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: bundler
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '1.9'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '1.9'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: rake
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '10.0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '10.0'
|
69
|
+
description: bad description
|
70
|
+
email:
|
71
|
+
- adamsmith910@aol.com
|
72
|
+
executables: []
|
73
|
+
extensions: []
|
74
|
+
extra_rdoc_files: []
|
75
|
+
files:
|
76
|
+
- ".gitignore"
|
77
|
+
- ".rspec"
|
78
|
+
- ".travis.yml"
|
79
|
+
- Gemfile
|
80
|
+
- README.md
|
81
|
+
- Rakefile
|
82
|
+
- bin/console
|
83
|
+
- bin/jobs_api_parser
|
84
|
+
- bin/setup
|
85
|
+
- jobs_api_gem.gemspec
|
86
|
+
- lib/jobs_api_gem.rb
|
87
|
+
- lib/jobs_api_gem/binary.rb
|
88
|
+
- lib/jobs_api_gem/version.rb
|
89
|
+
homepage: http://www.wingheads.com
|
90
|
+
licenses: []
|
91
|
+
metadata: {}
|
92
|
+
post_install_message:
|
93
|
+
rdoc_options: []
|
94
|
+
require_paths:
|
95
|
+
- lib
|
96
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
97
|
+
requirements:
|
98
|
+
- - ">="
|
99
|
+
- !ruby/object:Gem::Version
|
100
|
+
version: '0'
|
101
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
102
|
+
requirements:
|
103
|
+
- - ">="
|
104
|
+
- !ruby/object:Gem::Version
|
105
|
+
version: '0'
|
106
|
+
requirements: []
|
107
|
+
rubyforge_project:
|
108
|
+
rubygems_version: 2.4.5
|
109
|
+
signing_key:
|
110
|
+
specification_version: 4
|
111
|
+
summary: bad summary
|
112
|
+
test_files: []
|