jobvite 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
data/.gitignore ADDED
@@ -0,0 +1,17 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
data/.rvmrc ADDED
@@ -0,0 +1,48 @@
1
+ #!/usr/bin/env bash
2
+
3
+ # This is an RVM Project .rvmrc file, used to automatically load the ruby
4
+ # development environment upon cd'ing into the directory
5
+
6
+ # First we specify our desired <ruby>[@<gemset>], the @gemset name is optional,
7
+ # Only full ruby name is supported here, for short names use:
8
+ # echo "rvm use ree" > .rvmrc
9
+ environment_id="ree-1.8.7-2012.02@rm-jobvite"
10
+
11
+ # Uncomment the following lines if you want to verify rvm version per project
12
+ # rvmrc_rvm_version="1.10.3" # 1.10.1 seams as a safe start
13
+ # eval "$(echo ${rvm_version}.${rvmrc_rvm_version} | awk -F. '{print "[[ "$1*65536+$2*256+$3" -ge "$4*65536+$5*256+$6" ]]"}' )" || {
14
+ # echo "This .rvmrc file requires at least RVM ${rvmrc_rvm_version}, aborting loading."
15
+ # return 1
16
+ # }
17
+
18
+ # First we attempt to load the desired environment directly from the environment
19
+ # file. This is very fast and efficient compared to running through the entire
20
+ # CLI and selector. If you want feedback on which environment was used then
21
+ # insert the word 'use' after --create as this triggers verbose mode.
22
+ if [[ -d "${rvm_path:-$HOME/.rvm}/environments"
23
+ && -s "${rvm_path:-$HOME/.rvm}/environments/$environment_id" ]]
24
+ then
25
+ \. "${rvm_path:-$HOME/.rvm}/environments/$environment_id"
26
+ [[ -s "${rvm_path:-$HOME/.rvm}/hooks/after_use" ]] &&
27
+ \. "${rvm_path:-$HOME/.rvm}/hooks/after_use" || true
28
+ else
29
+ # If the environment file has not yet been created, use the RVM CLI to select.
30
+ rvm --create "$environment_id" || {
31
+ echo "Failed to create RVM environment '${environment_id}'."
32
+ return 1
33
+ }
34
+ fi
35
+
36
+ # If you use bundler, this might be useful to you:
37
+ # if [[ -s Gemfile ]] && {
38
+ # ! builtin command -v bundle >/dev/null ||
39
+ # builtin command -v bundle | grep $rvm_path/bin/bundle >/dev/null
40
+ # }
41
+ # then
42
+ # printf "%b" "The rubygem 'bundler' is not installed. Installing it now.\n"
43
+ # gem install bundler
44
+ # fi
45
+ # if [[ -s Gemfile ]] && builtin command -v bundle >/dev/null
46
+ # then
47
+ # bundle install | grep -vE '^Using|Your bundle is complete'
48
+ # fi
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in jobvite.gemspec
4
+ gemspec
data/LICENSE ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2012 Michael Guterl
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,32 @@
1
+ # Jobvite
2
+
3
+ Fetch jobs from Jobvite.
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ gem 'jobvite'
10
+
11
+ And then execute:
12
+
13
+ $ bundle
14
+
15
+ Or install it yourself as:
16
+
17
+ $ gem install jobvite
18
+
19
+ ## Usage
20
+
21
+ ```ruby
22
+ jobvite = Jobvite.new('COMPANY_ID')
23
+ jobvite.jobs
24
+ ```
25
+
26
+ ## Contributing
27
+
28
+ 1. Fork it
29
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
30
+ 3. Commit your changes (`git commit -am 'Added some feature'`)
31
+ 4. Push to the branch (`git push origin my-new-feature`)
32
+ 5. Create new Pull Request
data/Rakefile ADDED
@@ -0,0 +1,2 @@
1
+ #!/usr/bin/env rake
2
+ require "bundler/gem_tasks"
data/jobvite.gemspec ADDED
@@ -0,0 +1,20 @@
1
+ # -*- encoding: utf-8 -*-
2
+ require File.expand_path('../lib/jobvite/version', __FILE__)
3
+
4
+ Gem::Specification.new do |gem|
5
+ gem.authors = ["Michael Guterl"]
6
+ gem.email = ["michael@diminishing.org"]
7
+ gem.description = %q{Fetch jobs from Jobvite}
8
+ gem.summary = %q{Simple ruby wrapper for fetching jobs from Jobvite}
9
+ gem.homepage = "http://github.com/recruitmilitary/jobvite"
10
+
11
+ gem.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
12
+ gem.files = `git ls-files`.split("\n")
13
+ gem.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
14
+ gem.name = "jobvite"
15
+ gem.require_paths = ["lib"]
16
+ gem.version = Jobvite::VERSION
17
+
18
+ gem.add_development_dependency 'rspec'
19
+ gem.add_dependency 'nokogiri'
20
+ end
data/lib/jobvite.rb ADDED
@@ -0,0 +1,12 @@
1
+ require 'jobvite/version'
2
+ require 'jobvite/job'
3
+ require 'jobvite/client'
4
+
5
+ module Jobvite
6
+
7
+ # Public: Helper method to return an instance of a Jobvite::Client
8
+ def self.new(company_id)
9
+ Client.new(company_id)
10
+ end
11
+
12
+ end
@@ -0,0 +1,50 @@
1
+ require 'open-uri'
2
+ require 'date'
3
+ require 'nokogiri'
4
+
5
+ module Jobvite
6
+
7
+ class Client
8
+
9
+ DEFAULT_BASE_URL = 'http://www.jobvite.com/CompanyJobs/Xml.aspx?c='
10
+
11
+ def initialize(company_id, base_url = DEFAULT_BASE_URL)
12
+ @company_id = company_id
13
+ @url = base_url + @company_id
14
+ end
15
+
16
+ # Public: Returns a collection of jobs for the company specified
17
+ def jobs
18
+ doc = Nokogiri::XML open(@url)
19
+
20
+ doc.search('//job').map { |node|
21
+ Job.new(attributes_from(node))
22
+ }
23
+ end
24
+
25
+ def attributes_from(node)
26
+ {
27
+ :id => extract_text(node, 'id'),
28
+ :title => extract_text(node, 'title'),
29
+ :requisition_id => extract_text(node, 'requisitionid'),
30
+ :category => extract_text(node, 'category'),
31
+ :location => extract_text(node, 'location'),
32
+ :job_type => extract_text(node, 'jobtype'),
33
+ :date => extract_date(node, 'date'),
34
+ :detail_url => extract_text(node, 'detail-url'),
35
+ :apply_url => extract_text(node, 'apply-url'),
36
+ :description => extract_text(node, 'description'),
37
+ :brief_description => extract_text(node, 'briefdescription'),
38
+ }
39
+ end
40
+
41
+ def extract_text(node, name)
42
+ node.at(name).text
43
+ end
44
+
45
+ def extract_date(node, name)
46
+ Date.parse extract_text(node, name)
47
+ end
48
+ end
49
+
50
+ end
@@ -0,0 +1,18 @@
1
+ module Jobvite
2
+ class Job
3
+ instance_methods.each { |m| undef_method m unless m =~ /^__/ || m =~ /inspect/ }
4
+
5
+ def initialize(attributes)
6
+ @attributes = attributes
7
+ end
8
+
9
+ def method_missing(meth, *args, &block)
10
+ if @attributes.has_key?(meth)
11
+ @attributes[meth]
12
+ else
13
+ super
14
+ end
15
+ end
16
+
17
+ end
18
+ end
@@ -0,0 +1,3 @@
1
+ module Jobvite
2
+ VERSION = '0.0.1'
3
+ end
@@ -0,0 +1,29 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <result>
3
+ <job>
4
+ <id>or1DVfwK</id>
5
+ <title>Customer Support Representative</title>
6
+ <requisitionid>or1DVfwK</requisitionid>
7
+ <category>Customer Service</category>
8
+ <jobtype>Full-Time Hourly</jobtype>
9
+ <location>Sydney, Australia</location>
10
+ <date>4/8/2012</date>
11
+ <detail-url><![CDATA[http://hire.jobvite.com/CompanyJobs/Job.aspx?c=qD09Vfwr&j=or1DVfwK]]></detail-url>
12
+ <apply-url><![CDATA[http://hire.jobvite.com/CompanyJobs/Apply.aspx?c=qD09Vfwr&j=or1DVfwK]]></apply-url>
13
+ <description>is a new and exciting online business that promotes fun things to do</description>
14
+ <briefdescription>&lt;li&gt;&lt;strong&gt;Great city location&lt;/strong&gt;&lt;/li&gt;</briefdescription>
15
+ </job>
16
+ <job>
17
+ <id>oxhzVfw2</id>
18
+ <title>Business Development Manager - Inside</title>
19
+ <requisitionid/>
20
+ <category>Sales</category>
21
+ <jobtype>Full-Time Hourly</jobtype>
22
+ <location>Sydney, Australia</location>
23
+ <date>4/8/2012</date>
24
+ <detail-url><![CDATA[http://hire.jobvite.com/CompanyJobs/Job.aspx?c=qD09Vfwr&j=oxhzVfw2]]></detail-url>
25
+ <apply-url><![CDATA[http://hire.jobvite.com/CompanyJobs/Apply.aspx?c=qD09Vfwr&j=oxhzVfw2]]></apply-url>
26
+ <description>Company is looking for experienced sales and business development professionals</description>
27
+ <briefdescription>Are you good at convincing people to try new opportunities and ideas?</briefdescription>
28
+ </job>
29
+ </result>
@@ -0,0 +1,37 @@
1
+ require 'jobvite'
2
+
3
+ describe Jobvite do
4
+
5
+ def read_fixture(filename)
6
+ File.read(File.join(File.dirname(__FILE__), 'fixtures', filename))
7
+ end
8
+
9
+ describe '#jobs' do
10
+ before { jobvite.stub(:open) { read_fixture('jobs.xml') } }
11
+ let(:jobvite) { Jobvite.new('asdf1234') }
12
+
13
+ it 'has the correct number of jobs' do
14
+ jobvite.jobs.size.should == 2
15
+ end
16
+ it 'parses attributes for each job' do
17
+ jobvite.jobs.map(&:id).should == ['or1DVfwK', 'oxhzVfw2']
18
+ end
19
+
20
+ describe 'attributes 'do
21
+ subject { jobvite.jobs.first }
22
+
23
+ it { subject.id.should == 'or1DVfwK' }
24
+ it { subject.title.should == 'Customer Support Representative' }
25
+ it { subject.requisition_id.should == 'or1DVfwK' }
26
+ it { subject.category.should == 'Customer Service' }
27
+ it { subject.job_type.should == 'Full-Time Hourly' }
28
+ it { subject.location.should == 'Sydney, Australia' }
29
+ it { subject.date.should == Date.new(2012, 4, 8) }
30
+ it { subject.detail_url.should == 'http://hire.jobvite.com/CompanyJobs/Job.aspx?c=qD09Vfwr&j=or1DVfwK' }
31
+ it { subject.apply_url.should == 'http://hire.jobvite.com/CompanyJobs/Apply.aspx?c=qD09Vfwr&j=or1DVfwK' }
32
+ it { subject.description.should == 'is a new and exciting online business that promotes fun things to do' }
33
+ it { subject.brief_description.should == '<li><strong>Great city location</strong></li>' }
34
+ end
35
+ end
36
+
37
+ end
metadata ADDED
@@ -0,0 +1,106 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: jobvite
3
+ version: !ruby/object:Gem::Version
4
+ hash: 29
5
+ prerelease:
6
+ segments:
7
+ - 0
8
+ - 0
9
+ - 1
10
+ version: 0.0.1
11
+ platform: ruby
12
+ authors:
13
+ - Michael Guterl
14
+ autorequire:
15
+ bindir: bin
16
+ cert_chain: []
17
+
18
+ date: 2012-05-04 00:00:00 Z
19
+ dependencies:
20
+ - !ruby/object:Gem::Dependency
21
+ name: rspec
22
+ prerelease: false
23
+ requirement: &id001 !ruby/object:Gem::Requirement
24
+ none: false
25
+ requirements:
26
+ - - ">="
27
+ - !ruby/object:Gem::Version
28
+ hash: 3
29
+ segments:
30
+ - 0
31
+ version: "0"
32
+ type: :development
33
+ version_requirements: *id001
34
+ - !ruby/object:Gem::Dependency
35
+ name: nokogiri
36
+ prerelease: false
37
+ requirement: &id002 !ruby/object:Gem::Requirement
38
+ none: false
39
+ requirements:
40
+ - - ">="
41
+ - !ruby/object:Gem::Version
42
+ hash: 3
43
+ segments:
44
+ - 0
45
+ version: "0"
46
+ type: :runtime
47
+ version_requirements: *id002
48
+ description: Fetch jobs from Jobvite
49
+ email:
50
+ - michael@diminishing.org
51
+ executables: []
52
+
53
+ extensions: []
54
+
55
+ extra_rdoc_files: []
56
+
57
+ files:
58
+ - .gitignore
59
+ - .rvmrc
60
+ - Gemfile
61
+ - LICENSE
62
+ - README.md
63
+ - Rakefile
64
+ - jobvite.gemspec
65
+ - lib/jobvite.rb
66
+ - lib/jobvite/client.rb
67
+ - lib/jobvite/job.rb
68
+ - lib/jobvite/version.rb
69
+ - spec/fixtures/jobs.xml
70
+ - spec/jobvite_spec.rb
71
+ homepage: http://github.com/recruitmilitary/jobvite
72
+ licenses: []
73
+
74
+ post_install_message:
75
+ rdoc_options: []
76
+
77
+ require_paths:
78
+ - lib
79
+ required_ruby_version: !ruby/object:Gem::Requirement
80
+ none: false
81
+ requirements:
82
+ - - ">="
83
+ - !ruby/object:Gem::Version
84
+ hash: 3
85
+ segments:
86
+ - 0
87
+ version: "0"
88
+ required_rubygems_version: !ruby/object:Gem::Requirement
89
+ none: false
90
+ requirements:
91
+ - - ">="
92
+ - !ruby/object:Gem::Version
93
+ hash: 3
94
+ segments:
95
+ - 0
96
+ version: "0"
97
+ requirements: []
98
+
99
+ rubyforge_project:
100
+ rubygems_version: 1.8.17
101
+ signing_key:
102
+ specification_version: 3
103
+ summary: Simple ruby wrapper for fetching jobs from Jobvite
104
+ test_files:
105
+ - spec/fixtures/jobs.xml
106
+ - spec/jobvite_spec.rb