ceritium-careerjetr 0.1.1

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.
@@ -0,0 +1,81 @@
1
+ = Careerjetr
2
+
3
+ == Description
4
+
5
+ Ruby interface to Careerjet's public search API
6
+
7
+ == Installation
8
+
9
+ sudo gem install careerjetr
10
+
11
+ == Usage
12
+
13
+ require 'careerjetr'
14
+
15
+
16
+ All options have default values and are not mandatory
17
+
18
+ keywords : Keywords to search in job offers. Example: 'java manager'
19
+ Default : none (All offers in the api country)
20
+
21
+ location : Location to search job offers in. Examples: 'London' , 'Yorkshire' ..
22
+ Default: none ( All offers in the api country)
23
+
24
+ sort : Type of sort. Can be:
25
+ 'relevance' (default) - most relevant first
26
+ 'date' - freshest offer first
27
+ 'salary' - biggest salary first
28
+
29
+ start_num : Num of first offer returned in entire result space
30
+ should be >= 1 and <= Number of hits
31
+ Default : 1
32
+
33
+ pagesize : Number of offers returned in one call
34
+ Default : 20
35
+
36
+ page : Number of the asked page.
37
+ should be >=1
38
+ The max number of page is given by $result->pages
39
+ If this value is set, the eventually given start_num is overrided
40
+
41
+ contracttype : Character code for contract type
42
+ 'p' - permanent job
43
+ 'c' - contract
44
+ 't' - temporary
45
+ 'i' - training
46
+ 'v' - voluntary
47
+ Default: none (all contract types)
48
+
49
+ contractperiod : Character code for contract work period:
50
+ 'f' - Full time
51
+ 'p' - Part time
52
+ Default: none (all work period)
53
+
54
+
55
+ Careerjetr.new(:es_ES, {:page => 3, :keywords => 'bullfighter'})
56
+
57
+
58
+ == License
59
+
60
+ Copyright (c) 2009 José Galisteo
61
+
62
+ Permission is hereby granted, free of charge, to any person
63
+ obtaining a copy of this software and associated documentation
64
+ files (the "Software"), to deal in the Software without
65
+ restriction, including without limitation the rights to use,
66
+ copy, modify, merge, publish, distribute, sublicense, and/or sell
67
+ copies of the Software, and to permit persons to whom the
68
+ Software is furnished to do so, subject to the following
69
+ conditions:
70
+
71
+ The above copyright notice and this permission notice shall be
72
+ included in all copies or substantial portions of the Software.
73
+
74
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
75
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
76
+ OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
77
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
78
+ HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
79
+ WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
80
+ FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
81
+ OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,40 @@
1
+ require 'rubygems'
2
+ require 'rake/gempackagetask'
3
+ require 'rake/testtask'
4
+
5
+ require 'lib/careerjetr/version'
6
+
7
+ task :default => :test
8
+
9
+ spec = Gem::Specification.new do |s|
10
+ s.name = 'careerjetr'
11
+ s.version = Careerjetr::Version.to_s
12
+ s.has_rdoc = true
13
+ s.extra_rdoc_files = %w(README.rdoc)
14
+ s.rdoc_options = %w(--main README.rdoc)
15
+ s.summary = "Ruby interface to Careerjet's public search API"
16
+ s.author = 'José Galisteo'
17
+ s.email = 'ceritium@gmail.com'
18
+ s.homepage = 'http://github.com/ceritium/careerjetr/tree/master'
19
+ s.files = %w(README.rdoc Rakefile) + Dir.glob("{lib,test}/**/*")
20
+ # s.executables = ['careerjetr']
21
+
22
+ # s.add_dependency('gem_name', '~> 0.0.1')
23
+ end
24
+
25
+ Rake::GemPackageTask.new(spec) do |pkg|
26
+ pkg.gem_spec = spec
27
+ end
28
+
29
+ Rake::TestTask.new do |t|
30
+ t.libs << 'test'
31
+ t.test_files = FileList["test/**/*_test.rb"]
32
+ t.verbose = true
33
+ end
34
+
35
+ desc 'Generate the gemspec to serve this Gem from Github'
36
+ task :github do
37
+ file = File.dirname(__FILE__) + "/#{spec.name}.gemspec"
38
+ File.open(file, 'w') {|f| f << spec.to_ruby }
39
+ puts "Created gemspec: #{file}"
40
+ end
@@ -0,0 +1,7 @@
1
+ $:.unshift File.dirname(__FILE__)
2
+
3
+
4
+ require 'net/http'
5
+ require 'rubygems'
6
+ require 'json'
7
+ require 'careerjetr/careerjetr'
@@ -0,0 +1,117 @@
1
+ class Careerjetr
2
+
3
+ LOCALES = {
4
+ :cs_CZ => {:language =>'Czech' , :location => 'Czech Republic' , :url => 'http://www.careerjet.cz' },
5
+ :da_DK => {:language =>'Danish' , :location => 'Denmark' , :url => 'http://www.careerjet.dk' },
6
+ :de_AT => {:language =>'German' , :location => 'Austria' , :url => 'http://www.careerjet.at' },
7
+ :de_CH => {:language =>'German' , :location => 'Switzerland' , :url => 'http://www.careerjet.ch' },
8
+ :de_DE => {:language =>'German' , :location => 'Germany' , :url => 'http://www.careerjet.de' },
9
+ :en_AE => {:language =>'English' , :location => 'United Arab Emirates', :url => 'http://www.careerjet.ae' },
10
+ :en_AU => {:language =>'English' , :location => 'Australia' , :url => 'http://www.careerjet.com.au' },
11
+ :en_CA => {:language =>'English' , :location => 'Canada' , :url => 'http://www.careerjet.ca' },
12
+ :en_CN => {:language =>'English' , :location => 'China' , :url => 'http://en.careerjet.cn' },
13
+ :en_HK => {:language =>'English' , :location => 'Hong Kong' , :url => 'http://www.careerjet.hk' },
14
+ :en_IE => {:language =>'English' , :location => 'Ireland' , :url => 'http://www.careerjet.ie' },
15
+ :en_IN => {:language =>'English' , :location => 'India' , :url => 'http://www.careerjet.co.in' },
16
+ :en_MY => {:language =>'English' , :location => 'Malaysia' , :url => 'http://www.careerjet.com.my' },
17
+ :en_NZ => {:language =>'English' , :location => 'New Zealand' , :url => 'http://www.careerjet.co.nz' },
18
+ :en_OM => {:language =>'English' , :location => 'Oman' , :url => 'http://www.careerjet.com.om' },
19
+ :en_PH => {:language =>'English' , :location => 'Philippines' , :url => 'http://www.careerjet.ph' },
20
+ :en_PK => {:language =>'English' , :location => 'Pakistan' , :url => 'http://www.careerjet.com.pk' },
21
+ :en_QA => {:language =>'English' , :location => 'Qatar' , :url => 'http://www.careerjet.com.qa' },
22
+ :en_SG => {:language =>'English' , :location => 'Singapore' , :url => 'http://www.careerjet.sg' },
23
+ :en_GB => {:language =>'English' , :location => 'United Kingdom' , :url => 'http://www.careerjet.co.uk' },
24
+ :en_US => {:language =>'English' , :location => 'United States' , :url => 'http://www.careerjet.com' },
25
+ :en_ZA => {:language =>'English' , :location => 'South Africa' , :url => 'http://www.careerjet.co.za' },
26
+ :en_TW => {:language =>'English' , :location => 'Taiwan' , :url => 'http://www.careerjet.com.tw' },
27
+ :en_VN => {:language =>'English' , :location => 'Vietnam' , :url => 'http://www.careerjet.vn' },
28
+ :es_AR => {:language =>'Spanish' , :location => 'Argentina' , :url => 'http://www.opcionempleo.com.ar' },
29
+ :es_BO => {:language =>'Spanish' , :location => 'Bolivia' , :url => 'http://www.opcionempleo.com.bo' },
30
+ :es_CL => {:language =>'Spanish' , :location => 'Chile' , :url => 'http://www.opcionempleo.cl' },
31
+ :es_CR => {:language =>'Spanish' , :location => 'Costa Rica' , :url => 'http://www.opcionempleo.co.cr' },
32
+ :es_DO => {:language =>'Spanish' , :location => 'Dominican Republic' , :url => 'http://www.opcionempleo.com.do' },
33
+ :es_EC => {:language =>'Spanish' , :location => 'Ecuador' , :url => 'http://www.opcionempleo.ec' },
34
+ :es_ES => {:language =>'Spanish' , :location => 'Spain' , :url => 'http://www.opcionempleo.com' },
35
+ :es_GT => {:language =>'Spanish' , :location => 'Guatemala' , :url => 'http://www.opcionempleo.com.gt' },
36
+ :es_MX => {:language =>'Spanish' , :location => 'Mexico' , :url => 'http://www.opcionempleo.com.mx' },
37
+ :es_PA => {:language =>'Spanish' , :location => 'Panama' , :url => 'http://www.opcionempleo.com.pa' },
38
+ :es_PE => {:language =>'Spanish' , :location => 'Peru' , :url => 'http://www.opcionempleo.com.pe' },
39
+ :es_PR => {:language =>'Spanish' , :location => 'Puerto Rico' , :url => 'http://www.opcionempleo.com.pr' },
40
+ :es_PY => {:language =>'Spanish' , :location => 'Paraguay' , :url => 'http://www.opcionempleo.com.py' },
41
+ :es_UY => {:language =>'Spanish' , :location => 'Uruguay' , :url => 'http://www.opcionempleo.com.uy' },
42
+ :es_VE => {:language =>'Spanish' , :location => 'Venezuela' , :url => 'http://www.opcionempleo.com.ve' },
43
+ :fi_FI => {:language =>'Finnish' , :location => 'Finland' , :url => 'http://www.careerjet.fi' },
44
+ :fr_CA => {:language =>'French' , :location => 'Canada' , :url => 'http://fr.careerjet.ca' },
45
+ :fr_BE => {:language =>'French' , :location => 'Belgium' , :url => 'http://www.optioncarriere.be' },
46
+ :fr_CH => {:language =>'French' , :location => 'Switzerland' , :url => 'http://www.optioncarriere.ch' },
47
+ :fr_FR => {:language =>'French' , :location => 'France' , :url => 'http://www.optioncarriere.com' },
48
+ :fr_LU => {:language =>'French' , :location => 'Luxembourg' , :url => 'http://www.optioncarriere.lu' },
49
+ :fr_MA => {:language =>'French' , :location => 'Morocco' , :url => 'http://www.optioncarriere.ma' },
50
+ :hu_HU => {:language =>'Hungarian' , :location => 'Hungary' , :url => 'http://www.careerjet.hu' },
51
+ :it_IT => {:language =>'Italian' , :location => 'Italy' , :url => 'http://www.careerjet.it' },
52
+ :ja_JP => {:language =>'Japanese' , :location => 'Japan' , :url => 'http://www.careerjet.jp' },
53
+ :ko_KR => {:language =>'Korean' , :location => 'Korea' , :url => 'http://www.careerjet.co.kr' },
54
+ :nl_BE => {:language =>'Dutch' , :location => 'Belgium' , :url => 'http://www.careerjet.be' },
55
+ :nl_NL => {:language =>'Dutch' , :location => 'Netherlands' , :url => 'http://www.careerjet.nl' },
56
+ :no_NO => {:language =>'Norwegian' , :location => 'Norway' , :url => 'http://www.careerjet.no' },
57
+ :pl_PL => {:language =>'Polish' , :location => 'Poland' , :url => 'http://www.careerjet.pl' },
58
+ :pt_PT => {:language =>'Portuguese' , :location => 'Portugal' , :url => 'http://www.careerjet.pt' },
59
+ :pt_BR => {:language =>'Portuguese' , :location => 'Brazil' , :url => 'http://www.careerjet.com.br' },
60
+ :ru_RU => {:language =>'Russian' , :location => 'Russia' , :url => 'http://www.careerjet.ru' },
61
+ :ru_UA => {:language =>'Russian' , :location => 'Ukraine' , :url => 'http://www.careerjet.com.ua' },
62
+ :sv_SE => {:language =>'Swedish' , :location => 'Sweden' , :url => 'http://www.careerjet.se' },
63
+ :sk_SK => {:language =>'Slovak' , :location => 'Slovakia' , :url => 'http://www.careerjet.sk' },
64
+ :tr_TR => {:language =>'Turkish' , :location => 'Turkey' , :url => 'http://www.careerjet.com.tr' },
65
+ :uk_UA => {:language =>'Ukrainian' , :location => 'Ukraine' , :url => 'http://www.careerjet.ua' },
66
+ :vi_VN => {:language =>'Vietnamese' , :location => 'Vietnam' , :url => 'http://www.careerjet.com.vn' },
67
+ :zh_CN => {:language =>'Chinese' , :location => 'China' , :url=> 'http://www.careerjet.cn' }
68
+ }
69
+
70
+ attr_reader :url, :pages, :jobs
71
+
72
+ def initialize(locale, params = {})
73
+ @url = get_url(locale, params)
74
+
75
+ json = parse_json
76
+
77
+ @current_page
78
+ @pages = json[:pages]
79
+ @jobs = json[:jobs]
80
+ @type = json[:type]
81
+ @hits = json[:hits]
82
+ end
83
+
84
+ # Generamos la url completa para la llamada a la api
85
+ def get_url(locale, params)
86
+ URI.escape(get_base(locale) + '?' + url_params(params))
87
+ end
88
+
89
+ # Devuelve un hash con la información disponible
90
+ def parse_json
91
+ hash = {}
92
+ json = JSON::Parser.new(Net::HTTP.get(URI.parse(@url))).parse
93
+ hash.store(:type, json['type'])
94
+ hash.store(:hits, json['hits'])
95
+ hash.store(:pages, json['pages'])
96
+ hash.store(:jobs, json['jobs'])
97
+
98
+ hash
99
+ end
100
+
101
+
102
+ private
103
+
104
+ # Obtenemos el dominio según el key del locale
105
+ def get_base(locale)
106
+ LOCALES[locale][:url] + '/devel/search.api'
107
+ end
108
+
109
+ # Pasamos a url los parametros de la busqueda
110
+ # NOTA: ¿Es necesario pasarle el urlencode?
111
+ def url_params(params)
112
+ params.to_a.collect{|x| "#{x.first}=#{x.last}"}.join('&')
113
+ end
114
+
115
+
116
+
117
+ end
@@ -0,0 +1,13 @@
1
+ module Careerjetr
2
+ module Version
3
+
4
+ MAJOR = 0
5
+ MINOR = 1
6
+ TINY = 1
7
+
8
+ def self.to_s # :nodoc:
9
+ [MAJOR, MINOR, TINY].join('.')
10
+ end
11
+
12
+ end
13
+ end
@@ -0,0 +1,10 @@
1
+ # http://sneaq.net/textmate-wtf
2
+ $:.reject! { |e| e.include? 'TextMate' }
3
+
4
+ require 'rubygems'
5
+ require 'test/unit'
6
+ require 'matchy'
7
+ require 'context'
8
+ require 'mocha'
9
+
10
+ require File.dirname(__FILE__) + '/../lib/careerjetr'
@@ -0,0 +1,13 @@
1
+ require File.dirname(__FILE__) + '/../test_helper'
2
+
3
+ class CareerjetrTest < Test::Unit::TestCase
4
+
5
+ describe "An instance of the Careerjetr class" do
6
+
7
+ it "should flunk" do
8
+ flunk "Please provide some tests"
9
+ end
10
+
11
+ end
12
+
13
+ end
metadata ADDED
@@ -0,0 +1,62 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: ceritium-careerjetr
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.1
5
+ platform: ruby
6
+ authors:
7
+ - "Jos\xC3\xA9 Galisteo"
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+
12
+ date: 2009-07-02 00:00:00 -07:00
13
+ default_executable:
14
+ dependencies: []
15
+
16
+ description:
17
+ email: ceritium@gmail.com
18
+ executables: []
19
+
20
+ extensions: []
21
+
22
+ extra_rdoc_files:
23
+ - README.rdoc
24
+ files:
25
+ - README.rdoc
26
+ - Rakefile
27
+ - lib/careerjetr
28
+ - lib/careerjetr/careerjetr.rb
29
+ - lib/careerjetr/version.rb
30
+ - lib/careerjetr.rb
31
+ - test/test_helper.rb
32
+ - test/unit
33
+ - test/unit/careerjetr_test.rb
34
+ has_rdoc: true
35
+ homepage: http://github.com/ceritium/careerjetr/tree/master
36
+ post_install_message:
37
+ rdoc_options:
38
+ - --main
39
+ - README.rdoc
40
+ require_paths:
41
+ - lib
42
+ required_ruby_version: !ruby/object:Gem::Requirement
43
+ requirements:
44
+ - - ">="
45
+ - !ruby/object:Gem::Version
46
+ version: "0"
47
+ version:
48
+ required_rubygems_version: !ruby/object:Gem::Requirement
49
+ requirements:
50
+ - - ">="
51
+ - !ruby/object:Gem::Version
52
+ version: "0"
53
+ version:
54
+ requirements: []
55
+
56
+ rubyforge_project:
57
+ rubygems_version: 1.2.0
58
+ signing_key:
59
+ specification_version: 2
60
+ summary: Ruby interface to Careerjet's public search API
61
+ test_files: []
62
+