glassdoor-api 0.1.2 → 0.1.3

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: e8dd83e4e42d72e38e7506f01ba2ad752830f75d
4
- data.tar.gz: b401c679f1104aa77cd5a6e796088714f63f8b98
3
+ metadata.gz: 2991d9e4fcf741922cb359f95d56ce1ab24e44a4
4
+ data.tar.gz: 895b858793a7b2769a02cbda7a7d0e95bfb75408
5
5
  SHA512:
6
- metadata.gz: 2dad57474ec87e9bbd8385c39b3d73420f4b87baeff3408ab006a6e2745c488437ceab1ba28b47ed612ea7af757c6958683bd2ae16b1b760b14b12fce5d47c3e
7
- data.tar.gz: 4e80779616cd216ecfa2989a1e54ccabe3ca7af4b1447c70287e0e2d914b021f0ebb11afcc5b8de733957beb297913b3ceb380620549366ba3bd0d32b15901d8
6
+ metadata.gz: a55935b00063d47b33287d9fb36b6afd493ca6ddd5f6642ec3a0c204147f030b756e71541cc5b3c8fcf0e4c9f5921f056ec30854fa39d2b8f576785e5dd88294
7
+ data.tar.gz: 96923436400c55cc052b7d8f642943c605e575965ad70adaed0f1c324b6743c8255b64901fd11ec2b469426c2b8eaf74bcebcfaa6bfec993b2f1325d81fd5ed2
@@ -0,0 +1,21 @@
1
+ require "glassdoor/version"
2
+ require "glassdoor/config"
3
+ require "glassdoor/convenience"
4
+
5
+ def require_directory(relative_path)
6
+ Dir[File.dirname(__FILE__) + relative_path].each { |file| require file }
7
+ end
8
+
9
+ %w(/glassdoor/utils/*.rb /glassdoor/clients/*.rb /glassdoor/models/*.rb).each { |path| require_directory path }
10
+
11
+ module Glassdoor
12
+ extend Convenience::ClassMethods
13
+
14
+ def self.configure
15
+ yield configuration
16
+ end
17
+
18
+ def self.configuration
19
+ @configuration ||= Glassdoor::Config.new
20
+ end
21
+ end
@@ -0,0 +1,17 @@
1
+ module Glassdoor
2
+ module Clients
3
+ module Company
4
+ def self.find_by_title(title)
5
+ api = Glassdoor::Utils::Api.instance
6
+ hash = api.gd_get(action: 'employers', q: title)
7
+
8
+ if hash['employers'].any?
9
+ company = hash['employers'].find { |h| h['exactMatch'] }
10
+ Models::Company.new(company)
11
+ else
12
+ nil
13
+ end
14
+ end
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,17 @@
1
+ module Glassdoor
2
+ module Clients
3
+ module Review
4
+ def self.find_by_company_id(company_id)
5
+ api = Glassdoor::Utils::Api.instance
6
+ hash = api.gd_get(action: 'employer-overview', employerId: company_id)
7
+
8
+ # if hash['employers'].any?
9
+ # company = hash['employers'].find { |h| h['exactMatch'] }
10
+ # Models::Review.new(company)
11
+ # else
12
+ # nil
13
+ # end
14
+ end
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,31 @@
1
+ module Glassdoor
2
+ class Config
3
+ attr_accessor :partner_id, :partner_key, :base_uri, :time_out, :format, :version_api
4
+
5
+ def initialize
6
+ set_defaults
7
+ end
8
+
9
+ def to_hash
10
+ {
11
+ :partner_id => @partner_id,
12
+ :partner_key => @partner_key,
13
+ :time_out => @time_out,
14
+ :format => @format,
15
+ :version_api => @version_api
16
+ }
17
+ end
18
+
19
+ protected
20
+ #################################################################
21
+
22
+ def set_defaults
23
+ @partner_id = 'ruby-glassdoor-api' # Get a developer key at https://www.glassdoor.com/api/index.htm
24
+ @partner_key = 'ruby-glassdoor-api'
25
+ @base_uri = 'http://api.glassdoor.com/api/api.htm'
26
+ @time_out = 5
27
+ @format = 'json'
28
+ @version_api = '1'
29
+ end
30
+ end
31
+ end
@@ -0,0 +1,10 @@
1
+ module Glassdoor
2
+ module Convenience
3
+ module ClassMethods
4
+
5
+ def company
6
+ Glassdoor::Clients::Company
7
+ end
8
+ end
9
+ end
10
+ end
@@ -0,0 +1,27 @@
1
+ module Glassdoor
2
+ module Models
3
+ class Company
4
+ attr_accessor :id, :name, :url, :industry, :logo,
5
+ :overall_rating, :culture_and_values_rating, :senior_leadership_rating,
6
+ :compensation_and_benefits_rating, :career_opportunities_rating,
7
+ :work_life_balance_rating, :recommend_to_friend_rating, :review
8
+
9
+ def initialize(args = {})
10
+ return if args.nil?
11
+ @id = args['id'] || ''
12
+ @name = args['name'] || ''
13
+ @url = args['website'] || ''
14
+ @industry = args['industry'] || ''
15
+ @overall_rating = args['overallRating'].to_f
16
+ @culture_and_values_rating = args['cultureAndValuesRating'].to_f
17
+ @senior_leadership_rating = args['seniorLeadershipRating'].to_f
18
+ @compensation_and_benefits_rating = args['compensationAndBenefitsRating'].to_f
19
+ @career_opportunities_rating = args['careerOpportunitiesRating'].to_f
20
+ @work_life_balance_rating = args['workLifeBalanceRating'].to_f
21
+ @recommend_to_friend_rating = args['recommendToFriendRating'].to_f
22
+ @logo = args['squareLogo'] || ''
23
+ @review = Models::Review.new(args['featuredReview'] || nil)
24
+ end
25
+ end
26
+ end
27
+ end
@@ -0,0 +1,22 @@
1
+ module Glassdoor
2
+ module Models
3
+ class Review
4
+ attr_accessor :id, :date, :job_title, :location, :logo,
5
+
6
+ :headline, :pros, :cons, :overall
7
+
8
+ def initialize(args = {})
9
+ return if args.nil?
10
+ @id = args['id'] || ''
11
+ @date = args['reviewDateTime'] || ''
12
+ @job_title = args['jobTitle'] || ''
13
+ @industry = args['industry'] || ''
14
+ @location = args['location']
15
+ @headline = args['headline']
16
+ @pros = args['pros']
17
+ @cons = args['cons']
18
+ @overall = args['overall'].to_f
19
+ end
20
+ end
21
+ end
22
+ end
@@ -0,0 +1,51 @@
1
+ require 'httparty'
2
+
3
+ module Glassdoor
4
+ module Utils
5
+ class RequestError < Exception; end
6
+ class ResponseUnsuccessError < Exception; end
7
+
8
+ class Api
9
+ include HTTParty
10
+
11
+ base_uri 'http://api.glassdoor.com/api/api.htm'
12
+
13
+ def self.instance
14
+ api = Glassdoor::Utils::Api.new
15
+ api
16
+ end
17
+
18
+ def initialize
19
+ self.class.default_params 't.p' => Glassdoor.configuration.partner_id,
20
+ 't.k' => Glassdoor.configuration.partner_key,
21
+ userip: '0.0.0.0',
22
+ useragent: '',
23
+ v: Glassdoor.configuration.version_api,
24
+ format: 'json',
25
+ page: ''
26
+
27
+
28
+ self.class.default_timeout Glassdoor.configuration.time_out
29
+ end
30
+
31
+ def gd_get(options={})
32
+ self.class.base_uri Glassdoor.configuration.base_uri
33
+ options = options.merge(self.class.default_params)
34
+ response = self.class.get('', query: options)
35
+ validate_response(response)
36
+ end
37
+
38
+ def validate_response(response)
39
+ if response.code == 200
40
+ hash = JSON.parse(response.body)
41
+ unless hash['success']
42
+ raise ResponseUnsuccessError.new hash['status']
43
+ end
44
+ hash['response']
45
+ else
46
+ raise RequestError.new response.message
47
+ end
48
+ end
49
+ end
50
+ end
51
+ end
@@ -0,0 +1,3 @@
1
+ module Glassdoor
2
+ VERSION = "0.1.3"
3
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: glassdoor-api
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ilya Bazylchuk
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-06-10 00:00:00.000000000 Z
11
+ date: 2015-06-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -121,19 +121,17 @@ executables: []
121
121
  extensions: []
122
122
  extra_rdoc_files: []
123
123
  files:
124
- - ".gitignore"
125
- - ".rspec"
126
- - ".ruby-gemset"
127
- - ".ruby-version"
128
- - ".travis.yml"
129
124
  - CODE_OF_CONDUCT.md
130
- - Gemfile
131
- - LICENSE.txt
132
125
  - README.md
133
- - Rakefile
134
- - bin/console
135
- - bin/setup
136
- - glassdoor-api.gemspec
126
+ - lib/glassdoor.rb
127
+ - lib/glassdoor/clients/company.rb
128
+ - lib/glassdoor/clients/review.rb
129
+ - lib/glassdoor/config.rb
130
+ - lib/glassdoor/convenience.rb
131
+ - lib/glassdoor/models/company.rb
132
+ - lib/glassdoor/models/review.rb
133
+ - lib/glassdoor/utils/api.rb
134
+ - lib/glassdoor/version.rb
137
135
  homepage: https://github.com/IBazylchuk/ruby-glassdoor-api
138
136
  licenses:
139
137
  - MIT
data/.gitignore DELETED
@@ -1,44 +0,0 @@
1
- *.gem
2
- *.rbc
3
- /.config
4
- /coverage/
5
- /InstalledFiles
6
- /pkg/
7
- /spec/reports/
8
- /test/tmp/
9
- /test/version_tmp/
10
- /tmp/
11
-
12
- ## Specific to RubyMotion:
13
- .dat*
14
- .repl_history
15
- build/
16
-
17
- ## Documentation cache and generated files:
18
- /.yardoc/
19
- /_yardoc/
20
- /doc/
21
- /rdoc/
22
-
23
- ## Environment normalisation:
24
- /.bundle/
25
- /vendor/bundle
26
- /lib/bundler/man/
27
-
28
- # for a library or gem, you might want to ignore these files since the code is
29
- # intended to run in multiple environments; otherwise, check them in:
30
- # Gemfile.lock
31
- # .ruby-version
32
- # .ruby-gemset
33
-
34
- # unless supporting rvm < 1.11.0 or doing something fancy, ignore this:
35
- .rvmrc
36
- /.bundle/
37
- /.yardoc
38
- /Gemfile.lock
39
- /_yardoc/
40
- /coverage/
41
- /doc/
42
- /pkg/
43
- /spec/reports/
44
- /tmp/
data/.rspec DELETED
@@ -1,2 +0,0 @@
1
- --format documentation
2
- --color
@@ -1 +0,0 @@
1
- ruby-glassdoor-api
@@ -1 +0,0 @@
1
- ruby-2.1.2
@@ -1,3 +0,0 @@
1
- language: ruby
2
- rvm:
3
- - 2.1.2
data/Gemfile DELETED
@@ -1,4 +0,0 @@
1
- source 'https://rubygems.org'
2
-
3
- # Specify your gem's dependencies in glassdoor-api.gemspec
4
- gemspec
@@ -1,21 +0,0 @@
1
- The MIT License (MIT)
2
-
3
- Copyright (c) 2015 Ilya Bazylchuk
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining a copy
6
- of this software and associated documentation files (the "Software"), to deal
7
- in the Software without restriction, including without limitation the rights
8
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- copies of the Software, and to permit persons to whom the Software is
10
- furnished to do so, subject to the following conditions:
11
-
12
- The above copyright notice and this permission notice shall be included in
13
- all copies or substantial portions of the Software.
14
-
15
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
- THE SOFTWARE.
data/Rakefile DELETED
@@ -1 +0,0 @@
1
- require "bundler/gem_tasks"
@@ -1,21 +0,0 @@
1
- #!/usr/bin/env ruby
2
-
3
- require "bundler/setup"
4
- require "glassdoor"
5
-
6
- require 'pry'
7
- require 'awesome_print'
8
- require 'logger'
9
- require 'http_logger'
10
-
11
- # You can add fixtures and/or initialization code here to make experimenting
12
- # with your gem easier. You can also use a different console, if you like.
13
-
14
- # (If you use this, don't forget to add pry to your Gemfile!)
15
- # require "pry"
16
- # Pry.start
17
-
18
- require "irb"
19
- logger = Logger.new(STDOUT)
20
- HttpLogger.logger = logger
21
- IRB.start
data/bin/setup DELETED
@@ -1,7 +0,0 @@
1
- #!/bin/bash
2
- set -euo pipefail
3
- IFS=$'\n\t'
4
-
5
- bundle install
6
-
7
- # Do any other automated setup that you need to do here
@@ -1,30 +0,0 @@
1
- # coding: utf-8
2
- lib = File.expand_path('../lib', __FILE__)
3
- $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
- require 'glassdoor/version'
5
-
6
- Gem::Specification.new do |spec|
7
- spec.name = "glassdoor-api"
8
- spec.version = Glassdoor::VERSION
9
- spec.platform = Gem::Platform::RUBY
10
- spec.authors = ["Ilya Bazylchuk"]
11
- spec.email = ["ilya.bazylchuk@gmail.com"]
12
-
13
- spec.summary = %q{Wrapper for Glassdoor API}
14
- spec.description = %q{Wrapper for Glassdoor API}
15
- spec.homepage = "https://github.com/IBazylchuk/ruby-glassdoor-api"
16
- spec.license = "MIT"
17
-
18
- spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features|lib)/}) }
19
- spec.require_paths = ["lib"]
20
-
21
- spec.add_development_dependency "bundler", "~> 1.9"
22
- spec.add_development_dependency "rake", "~> 10.0"
23
- spec.add_development_dependency 'pry'
24
- spec.add_development_dependency 'http_logger'
25
- spec.add_development_dependency 'awesome_print'
26
-
27
-
28
- spec.add_dependency 'httparty', '~> 0.11'
29
- spec.add_dependency 'json', '~> 1.7', '>= 1.7.7'
30
- end