cb-api 0.1.11 → 0.1.12
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/cb.rb +0 -7
- data/lib/cb/models/branding/media.rb +12 -11
- data/lib/cb/models/branding/section.rb +16 -14
- data/lib/cb/models/branding/style.rb +12 -10
- data/lib/cb/models/branding/styles/base.rb +14 -10
- data/lib/cb/models/branding/styles/buttons.rb +8 -4
- data/lib/cb/models/branding/styles/company_info.rb +15 -12
- data/lib/cb/models/branding/styles/container.rb +9 -5
- data/lib/cb/models/branding/styles/content.rb +8 -5
- data/lib/cb/models/branding/styles/css_adapter.rb +48 -47
- data/lib/cb/models/branding/styles/headings.rb +8 -5
- data/lib/cb/models/branding/styles/job_details.rb +14 -11
- data/lib/cb/models/branding/styles/page.rb +8 -5
- data/lib/cb/models/branding/widget.rb +10 -9
- data/lib/cb/utils/api.rb +101 -0
- data/lib/cb/utils/country.rb +26 -0
- data/lib/cb/utils/fluid_attributes.rb +28 -0
- data/lib/cb/utils/meta_values.rb +15 -0
- data/lib/cb/{Utils → utils}/string.rb +0 -0
- data/lib/cb/version.rb +1 -1
- metadata +7 -7
- data/lib/cb/Utils/api.rb +0 -99
- data/lib/cb/Utils/country.rb +0 -24
- data/lib/cb/Utils/fluid_attributes.rb +0 -26
- data/lib/cb/Utils/meta_values.rb +0 -13
data/lib/cb.rb
CHANGED
@@ -1,17 +1,18 @@
|
|
1
|
-
module Cb
|
1
|
+
module Cb
|
2
|
+
module Branding
|
2
3
|
|
3
|
-
|
4
|
+
class Media
|
4
5
|
|
5
|
-
|
6
|
+
attr_accessor :header, :header_type, :tablet_banner, :mobile_logo, :footer
|
6
7
|
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
8
|
+
def initialize args = {}
|
9
|
+
@header = args['Header'] || ''
|
10
|
+
@header_type = args['HeaderType'] || ''
|
11
|
+
@tablet_banner = args['TabletBanner'] || ''
|
12
|
+
@mobile_logo = args['MobileLogo'] || ''
|
13
|
+
@footer = args['Footer'] || ''
|
14
|
+
end
|
14
15
|
|
16
|
+
end
|
15
17
|
end
|
16
|
-
|
17
18
|
end
|
@@ -1,20 +1,22 @@
|
|
1
|
-
module Cb
|
1
|
+
module Cb
|
2
|
+
module Branding
|
2
3
|
|
3
|
-
|
4
|
-
|
5
|
-
|
4
|
+
class Section
|
5
|
+
# Might be changing?
|
6
|
+
attr_accessor :type, :section_1, :section_2, :section_3, :description, :requirements, :snapshot
|
6
7
|
|
7
|
-
|
8
|
-
|
8
|
+
def initialize type, args = {}
|
9
|
+
@type = type
|
9
10
|
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
11
|
+
@section_1 = args['Section1'] || ''
|
12
|
+
@section_2 = args['Section2'] || ''
|
13
|
+
@section_3 = args['Section3'] || ''
|
14
|
+
@description = args['Description'] || ''
|
15
|
+
@requirements = args['Requirements'] || ''
|
16
|
+
@snapshot = args['Snapshot'] || ''
|
17
|
+
end
|
17
18
|
|
18
|
-
|
19
|
+
end
|
20
|
+
end
|
19
21
|
|
20
22
|
end
|
@@ -1,15 +1,17 @@
|
|
1
|
-
module Cb
|
1
|
+
module Cb
|
2
|
+
module Branding
|
2
3
|
|
3
|
-
|
4
|
+
class Style
|
4
5
|
|
5
|
-
|
6
|
+
attr_accessor :page, :job_details, :company_info
|
6
7
|
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
8
|
+
def initialize args = {}
|
9
|
+
@page = Cb::Branding::Styles::Page.new args['Page']
|
10
|
+
@job_details = Cb::Branding::Styles::JobDetails.new args['JobDetails']
|
11
|
+
@company_info = Cb::Branding::Styles::CompanyInfo.new args['CompanyInfo']
|
12
|
+
end
|
12
13
|
|
13
|
-
|
14
|
-
|
14
|
+
end
|
15
|
+
|
16
|
+
end
|
15
17
|
end
|
@@ -1,15 +1,19 @@
|
|
1
|
-
module Cb
|
1
|
+
module Cb
|
2
|
+
module Branding
|
3
|
+
module Styles
|
2
4
|
|
3
|
-
|
4
|
-
|
5
|
+
class Base
|
6
|
+
attr_writer :styles
|
5
7
|
|
6
|
-
|
7
|
-
|
8
|
-
|
8
|
+
def initialize args = {}
|
9
|
+
@styles = args
|
10
|
+
end
|
9
11
|
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
12
|
+
def raw
|
13
|
+
@styles
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
14
18
|
|
15
19
|
end
|
@@ -1,16 +1,19 @@
|
|
1
|
-
module Cb
|
1
|
+
module Cb
|
2
|
+
module Branding
|
3
|
+
module Styles
|
2
4
|
|
3
|
-
|
4
|
-
|
5
|
+
class CompanyInfo < Base
|
6
|
+
attr_accessor :buttons, :container, :content, :headings
|
5
7
|
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
@buttons = Buttons.new args
|
10
|
-
@container = Container.new args
|
11
|
-
@content = Content.new args
|
12
|
-
@headings = Headings.new args
|
13
|
-
end
|
14
|
-
end
|
8
|
+
def initialize args = {}
|
9
|
+
super
|
15
10
|
|
11
|
+
@buttons = Buttons.new args
|
12
|
+
@container = Container.new args
|
13
|
+
@content = Content.new args
|
14
|
+
@headings = Headings.new args
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
16
19
|
end
|
@@ -1,48 +1,49 @@
|
|
1
|
-
module Cb
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
1
|
+
module Cb
|
2
|
+
module Branding
|
3
|
+
|
4
|
+
module Styles
|
5
|
+
|
6
|
+
module CssAdapter
|
7
|
+
|
8
|
+
def to_css
|
9
|
+
css = ''
|
10
|
+
|
11
|
+
@styles.each do |style, value|
|
12
|
+
css += generate_style style, value
|
13
|
+
end
|
14
|
+
|
15
|
+
css
|
16
|
+
end
|
17
|
+
|
18
|
+
private
|
19
|
+
def generate_style style, value
|
20
|
+
{
|
21
|
+
'BackgroundColor' => "background-color: #{value};",
|
22
|
+
'BackgroundImage' => "background-image: url(#{value});",
|
23
|
+
'BackgroundGradient' => "background: #{value['Color1']};
|
24
|
+
background: -moz-linear-gradient(#{value['Orientation'] == 'Vertical' ? 'top' : 'left'}, #{value['Color1']} 0%, #{value['Color2']} 100%);
|
25
|
+
background: -webkit-gradient(linear, left top, #{value['Orientation'] == 'Vertical' ? 'left bottom' : 'right top'}, color-stop(0%,#{value['Color1']}), color-stop(100%,#{value['Color2']}));
|
26
|
+
background: -webkit-linear-gradient(#{value['Orientation'] == 'Vertical' ? 'top' : 'left'}, #{value['Color1']} 0%,#{value['Color2']} 100%);
|
27
|
+
background: -o-linear-gradient(#{value['Orientation'] == 'Vertical' ? 'top' : 'left'}, #{value['Color1']} 0%,#{value['Color2']} 100%);
|
28
|
+
background: -ms-linear-gradient(#{value['Orientation'] == 'Vertical' ? 'top' : 'left'}, #{value['Color1']} 0%,#{value['Color2']} 100%);
|
29
|
+
background: linear-gradient(to #{value['Orientation'] == 'Vertical' ? 'bottom' : 'right'}, #{value['Color1']} 0%,#{value['Color2']} 100%);
|
30
|
+
filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#{value['Color1']}', endColorstr='#{value['Color2']}',GradientType=#{value['Orientation'] == 'Vertical' ? '0' : '1'} );",
|
31
|
+
'BorderSize' => "border-width: #{value};",
|
32
|
+
'BorderColor' => "border-color: #{value};",
|
33
|
+
'BorderRadius' => "-webkit-border-radius: #{value};
|
34
|
+
-moz-border-radius: #{value};
|
35
|
+
border-radius: #{value};",
|
36
|
+
'BoxShadow' => "-webkit-box-shadow: #{value};
|
37
|
+
-moz-box-shadow: #{value};
|
38
|
+
box-shadow: #{value};",
|
39
|
+
'FontColor' => "color: #{value};",
|
40
|
+
'FontSize' => "font-size: #{value};",
|
41
|
+
'FontStyle' => "font-family: #{value};"
|
42
|
+
}[style].gsub(/\s+/, '')
|
43
|
+
end
|
44
|
+
|
45
|
+
end
|
46
|
+
|
47
|
+
end
|
48
|
+
end
|
48
49
|
end
|
@@ -1,16 +1,19 @@
|
|
1
|
-
module Cb
|
1
|
+
module Cb
|
2
|
+
module Branding
|
3
|
+
module Styles
|
2
4
|
|
3
|
-
|
4
|
-
|
5
|
+
class JobDetails < Base
|
6
|
+
attr_accessor :container, :content, :headings
|
5
7
|
|
6
|
-
|
7
|
-
|
8
|
+
def initialize args = {}
|
9
|
+
super
|
8
10
|
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
end
|
11
|
+
@container = Container.new args
|
12
|
+
@content = Content.new args
|
13
|
+
@headings = Headings.new args
|
14
|
+
end
|
15
15
|
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
16
19
|
end
|
@@ -1,13 +1,14 @@
|
|
1
|
-
module Cb
|
1
|
+
module Cb
|
2
|
+
module Branding
|
2
3
|
|
3
|
-
|
4
|
-
|
4
|
+
class Widget
|
5
|
+
attr_accessor :type, :url
|
5
6
|
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
end
|
7
|
+
def initialize type, url
|
8
|
+
@type = type
|
9
|
+
@url = url
|
10
|
+
end
|
12
11
|
|
12
|
+
end
|
13
|
+
end
|
13
14
|
end
|
data/lib/cb/utils/api.rb
ADDED
@@ -0,0 +1,101 @@
|
|
1
|
+
require 'httparty'
|
2
|
+
|
3
|
+
module Cb
|
4
|
+
module Utils
|
5
|
+
class Api
|
6
|
+
include HTTParty
|
7
|
+
base_uri 'http://api.careerbuilder.com'
|
8
|
+
|
9
|
+
def initialize
|
10
|
+
self.class.debug_output $stderr if Cb.configuration.debug_api
|
11
|
+
self.class.default_params :developerkey => Cb.configuration.dev_key,
|
12
|
+
:outputjson => Cb.configuration.use_json.to_s
|
13
|
+
|
14
|
+
self.class.default_timeout Cb.configuration.time_out
|
15
|
+
end
|
16
|
+
|
17
|
+
def cb_get(*args, &block)
|
18
|
+
self.class.base_uri 'http://api.careerbuilder.com'
|
19
|
+
self.class.get(*args, &block)
|
20
|
+
end
|
21
|
+
|
22
|
+
def cb_post(*args, &block)
|
23
|
+
self.class.base_uri 'https://api.careerbuilder.com'
|
24
|
+
self.class.post(*args, &block)
|
25
|
+
end
|
26
|
+
|
27
|
+
def append_api_responses(obj, resp)
|
28
|
+
if obj.respond_to?('cb_response')
|
29
|
+
meta_class = obj.cb_response
|
30
|
+
else
|
31
|
+
meta_class = Cb::Utils::MetaValues.new()
|
32
|
+
end
|
33
|
+
|
34
|
+
resp.each do | api_key, api_value |
|
35
|
+
meta_name = get_meta_name_for api_key
|
36
|
+
|
37
|
+
unless meta_name.empty?
|
38
|
+
if meta_name == 'errors' && api_value.is_a?(Hash)
|
39
|
+
api_value = api_value.values
|
40
|
+
elsif self.class.is_numeric?(api_value)
|
41
|
+
api_value = api_value.to_i
|
42
|
+
end
|
43
|
+
|
44
|
+
meta_class.class.send(:attr_reader, meta_name)
|
45
|
+
meta_class.instance_variable_set(:"@#{meta_name}", api_value)
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
obj.class.send(:attr_reader, 'cb_response')
|
50
|
+
obj.instance_variable_set(:@cb_response, meta_class)
|
51
|
+
end
|
52
|
+
|
53
|
+
def self.criteria_to_hash(criteria)
|
54
|
+
params = Hash.new
|
55
|
+
if criteria.respond_to?(:instance_variables)
|
56
|
+
criteria.instance_variables.each do |var|
|
57
|
+
var_name = var.to_s
|
58
|
+
var_name.slice!(0)
|
59
|
+
var_name_hash_safe = camelize(var_name)
|
60
|
+
params["#{var_name_hash_safe}"] = criteria.instance_variable_get(var)
|
61
|
+
end
|
62
|
+
end
|
63
|
+
return params
|
64
|
+
end
|
65
|
+
|
66
|
+
def self.is_numeric?(obj)
|
67
|
+
true if Float(obj) rescue false
|
68
|
+
end
|
69
|
+
|
70
|
+
private
|
71
|
+
#############################################################################
|
72
|
+
def self.camelize(input)
|
73
|
+
input.sub!(/^[a-z\d]*/) { $&.capitalize }
|
74
|
+
input.gsub(/(?:_|(\/))([a-z\d]*)/) { "#{$2.capitalize}" }.gsub('/', '::')
|
75
|
+
end
|
76
|
+
|
77
|
+
def get_meta_name_for(api_key)
|
78
|
+
key_map = {
|
79
|
+
'Errors' => 'errors',
|
80
|
+
'TimeResponseSent' => 'time_sent',
|
81
|
+
'TimeElapsed' => 'time_elapsed',
|
82
|
+
'TotalPages' => 'total_pages',
|
83
|
+
'TotalCount' => 'total_count',
|
84
|
+
'FirstItemIndex' => 'first_item_index',
|
85
|
+
'LastItemIndex' => 'last_item_index',
|
86
|
+
'CountryCode' => 'country_code',
|
87
|
+
'DeveloperKey' => 'developer_key',
|
88
|
+
'SiteID' => 'site_id',
|
89
|
+
'CoBrand' => 'co_brand',
|
90
|
+
'CountLimit' => 'count_limit',
|
91
|
+
'MinQualityLimit' => 'min_quality',
|
92
|
+
'RecommendationsAvailable' => 'recs_available',
|
93
|
+
'ApplicationStatus' => 'application_status',
|
94
|
+
'Status' => 'status'
|
95
|
+
}
|
96
|
+
|
97
|
+
key_map["#{api_key}"] ||= ''
|
98
|
+
end
|
99
|
+
end
|
100
|
+
end
|
101
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
module Cb
|
2
|
+
module Utils
|
3
|
+
class Country
|
4
|
+
# These aren't all country codes. We get it. Our naming scheme didn't hold up over time.
|
5
|
+
def self.get_supported
|
6
|
+
%w(AH BE CA CC CE CH CN CP CS CY DE DK E1 ER ES EU F1
|
7
|
+
FR GC GR I1 IE IN IT J1 JC JS LJ M1 MY NL NO PD PI
|
8
|
+
PL RM RO RX S1 SE SF SG T1 T2 UK US WH WM WR)
|
9
|
+
end
|
10
|
+
|
11
|
+
def self.is_valid?(country)
|
12
|
+
get_supported.include? country
|
13
|
+
end
|
14
|
+
|
15
|
+
def self.inject_convenience_methods
|
16
|
+
get_supported.each do |country|
|
17
|
+
unless self.respond_to? "#{country}"
|
18
|
+
self.define_singleton_method "#{country}" do
|
19
|
+
return country
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
module Cb
|
2
|
+
module Utils
|
3
|
+
module FluidAttributes
|
4
|
+
|
5
|
+
def fluid_attr_accessor(*names)
|
6
|
+
names.each do |name|
|
7
|
+
|
8
|
+
define_method :"#{name}" do |*args|
|
9
|
+
return instance_variable_get(:"@#{name}") if args.length == 0
|
10
|
+
|
11
|
+
if args.length == 1
|
12
|
+
instance_variable_set(:"@#{name}", args[0])
|
13
|
+
return self
|
14
|
+
end
|
15
|
+
|
16
|
+
raise ArgumentError.new("Wrong number of arguments (#{args.length} for 1)")
|
17
|
+
end
|
18
|
+
|
19
|
+
define_method :"#{name}=" do |*args|
|
20
|
+
instance_variable_set(:"@#{name}", args[0]) if args.length == 1
|
21
|
+
return self
|
22
|
+
raise ArgumentError, "Wrong number of arguments (#{args.length} for 1)"
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
module Cb
|
2
|
+
module Utils
|
3
|
+
class MetaValues
|
4
|
+
# This class will be dynamically constructed at run time.
|
5
|
+
# I don't want values that don't make sense to the API call you made to be accessible
|
6
|
+
# I'm not dynamically creating the class because we may want to add functionality at some point
|
7
|
+
|
8
|
+
# This class, with its dynamically created attr_accr's will be dynamically appended to api
|
9
|
+
# entities, like job and company. It will contain things like errors, time elapsed, and
|
10
|
+
# any other meta values that the API may return.
|
11
|
+
|
12
|
+
# The mapping for allowed values, and what they translate to on this object live in Cb::utils::Api
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
File without changes
|
data/lib/cb/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cb-api
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.12
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -15,7 +15,7 @@ authors:
|
|
15
15
|
autorequire:
|
16
16
|
bindir: bin
|
17
17
|
cert_chain: []
|
18
|
-
date: 2013-07-
|
18
|
+
date: 2013-07-10 00:00:00.000000000 Z
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|
21
21
|
name: httparty
|
@@ -113,11 +113,11 @@ files:
|
|
113
113
|
- lib/cb/models/cb_job.rb
|
114
114
|
- lib/cb/models/cb_job_branding.rb
|
115
115
|
- lib/cb/models/cb_user.rb
|
116
|
-
- lib/cb/
|
117
|
-
- lib/cb/
|
118
|
-
- lib/cb/
|
119
|
-
- lib/cb/
|
120
|
-
- lib/cb/
|
116
|
+
- lib/cb/utils/api.rb
|
117
|
+
- lib/cb/utils/country.rb
|
118
|
+
- lib/cb/utils/fluid_attributes.rb
|
119
|
+
- lib/cb/utils/meta_values.rb
|
120
|
+
- lib/cb/utils/string.rb
|
121
121
|
- lib/cb/version.rb
|
122
122
|
- lib/cb.rb
|
123
123
|
- README.md
|
data/lib/cb/Utils/api.rb
DELETED
@@ -1,99 +0,0 @@
|
|
1
|
-
require 'httparty'
|
2
|
-
|
3
|
-
module Cb::Utils
|
4
|
-
class Api
|
5
|
-
include HTTParty
|
6
|
-
base_uri 'http://api.careerbuilder.com'
|
7
|
-
|
8
|
-
def initialize
|
9
|
-
self.class.debug_output $stderr if Cb.configuration.debug_api
|
10
|
-
self.class.default_params :developerkey => Cb.configuration.dev_key,
|
11
|
-
:outputjson => Cb.configuration.use_json.to_s
|
12
|
-
|
13
|
-
self.class.default_timeout Cb.configuration.time_out
|
14
|
-
end
|
15
|
-
|
16
|
-
def cb_get(*args, &block)
|
17
|
-
self.class.base_uri 'http://api.careerbuilder.com'
|
18
|
-
self.class.get(*args, &block)
|
19
|
-
end
|
20
|
-
|
21
|
-
def cb_post(*args, &block)
|
22
|
-
self.class.base_uri 'https://api.careerbuilder.com'
|
23
|
-
self.class.post(*args, &block)
|
24
|
-
end
|
25
|
-
|
26
|
-
def append_api_responses(obj, resp)
|
27
|
-
if obj.respond_to?('cb_response')
|
28
|
-
meta_class = obj.cb_response
|
29
|
-
else
|
30
|
-
meta_class = Cb::Utils::MetaValues.new()
|
31
|
-
end
|
32
|
-
|
33
|
-
resp.each do | api_key, api_value |
|
34
|
-
meta_name = get_meta_name_for api_key
|
35
|
-
|
36
|
-
unless meta_name.empty?
|
37
|
-
if meta_name == 'errors' && api_value.is_a?(Hash)
|
38
|
-
api_value = api_value.values
|
39
|
-
elsif self.class.is_numeric?(api_value)
|
40
|
-
api_value = api_value.to_i
|
41
|
-
end
|
42
|
-
|
43
|
-
meta_class.class.send(:attr_reader, meta_name)
|
44
|
-
meta_class.instance_variable_set(:"@#{meta_name}", api_value)
|
45
|
-
end
|
46
|
-
end
|
47
|
-
|
48
|
-
obj.class.send(:attr_reader, 'cb_response')
|
49
|
-
obj.instance_variable_set(:@cb_response, meta_class)
|
50
|
-
end
|
51
|
-
|
52
|
-
def self.criteria_to_hash(criteria)
|
53
|
-
params = Hash.new
|
54
|
-
if criteria.respond_to?(:instance_variables)
|
55
|
-
criteria.instance_variables.each do |var|
|
56
|
-
var_name = var.to_s
|
57
|
-
var_name.slice!(0)
|
58
|
-
var_name_hash_safe = camelize(var_name)
|
59
|
-
params["#{var_name_hash_safe}"] = criteria.instance_variable_get(var)
|
60
|
-
end
|
61
|
-
end
|
62
|
-
return params
|
63
|
-
end
|
64
|
-
|
65
|
-
def self.is_numeric?(obj)
|
66
|
-
true if Float(obj) rescue false
|
67
|
-
end
|
68
|
-
|
69
|
-
private
|
70
|
-
#############################################################################
|
71
|
-
def self.camelize(input)
|
72
|
-
input.sub!(/^[a-z\d]*/) { $&.capitalize }
|
73
|
-
input.gsub(/(?:_|(\/))([a-z\d]*)/) { "#{$2.capitalize}" }.gsub('/', '::')
|
74
|
-
end
|
75
|
-
|
76
|
-
def get_meta_name_for(api_key)
|
77
|
-
key_map = {
|
78
|
-
'Errors' => 'errors',
|
79
|
-
'TimeResponseSent' => 'time_sent',
|
80
|
-
'TimeElapsed' => 'time_elapsed',
|
81
|
-
'TotalPages' => 'total_pages',
|
82
|
-
'TotalCount' => 'total_count',
|
83
|
-
'FirstItemIndex' => 'first_item_index',
|
84
|
-
'LastItemIndex' => 'last_item_index',
|
85
|
-
'CountryCode' => 'country_code',
|
86
|
-
'DeveloperKey' => 'developer_key',
|
87
|
-
'SiteID' => 'site_id',
|
88
|
-
'CoBrand' => 'co_brand',
|
89
|
-
'CountLimit' => 'count_limit',
|
90
|
-
'MinQualityLimit' => 'min_quality',
|
91
|
-
'RecommendationsAvailable' => 'recs_available',
|
92
|
-
'ApplicationStatus' => 'application_status',
|
93
|
-
'Status' => 'status'
|
94
|
-
}
|
95
|
-
|
96
|
-
key_map["#{api_key}"] ||= ''
|
97
|
-
end
|
98
|
-
end
|
99
|
-
end
|
data/lib/cb/Utils/country.rb
DELETED
@@ -1,24 +0,0 @@
|
|
1
|
-
module Cb::Utils
|
2
|
-
class Country
|
3
|
-
# These aren't all country codes. We get it. Our naming scheme didn't hold up over time.
|
4
|
-
def self.get_supported
|
5
|
-
%w(AH BE CA CC CE CH CN CP CS CY DE DK E1 ER ES EU F1
|
6
|
-
FR GC GR I1 IE IN IT J1 JC JS LJ M1 MY NL NO PD PI
|
7
|
-
PL RM RO RX S1 SE SF SG T1 T2 UK US WH WM WR)
|
8
|
-
end
|
9
|
-
|
10
|
-
def self.is_valid?(country)
|
11
|
-
get_supported.include? country
|
12
|
-
end
|
13
|
-
|
14
|
-
def self.inject_convenience_methods
|
15
|
-
get_supported.each do |country|
|
16
|
-
unless self.respond_to? "#{country}"
|
17
|
-
self.define_singleton_method "#{country}" do
|
18
|
-
return country
|
19
|
-
end
|
20
|
-
end
|
21
|
-
end
|
22
|
-
end
|
23
|
-
end
|
24
|
-
end
|
@@ -1,26 +0,0 @@
|
|
1
|
-
module Cb::Utils
|
2
|
-
module FluidAttributes
|
3
|
-
|
4
|
-
def fluid_attr_accessor(*names)
|
5
|
-
names.each do |name|
|
6
|
-
|
7
|
-
define_method :"#{name}" do |*args|
|
8
|
-
return instance_variable_get(:"@#{name}") if args.length == 0
|
9
|
-
|
10
|
-
if args.length == 1
|
11
|
-
instance_variable_set(:"@#{name}", args[0])
|
12
|
-
return self
|
13
|
-
end
|
14
|
-
|
15
|
-
raise ArgumentError.new("Wrong number of arguments (#{args.length} for 1)")
|
16
|
-
end
|
17
|
-
|
18
|
-
define_method :"#{name}=" do |*args|
|
19
|
-
instance_variable_set(:"@#{name}", args[0]) if args.length == 1
|
20
|
-
return self
|
21
|
-
raise ArgumentError, "Wrong number of arguments (#{args.length} for 1)"
|
22
|
-
end
|
23
|
-
end
|
24
|
-
end
|
25
|
-
end
|
26
|
-
end
|
data/lib/cb/Utils/meta_values.rb
DELETED
@@ -1,13 +0,0 @@
|
|
1
|
-
module Cb::Utils
|
2
|
-
class MetaValues
|
3
|
-
# This class will be dynamically constructed at run time.
|
4
|
-
# I don't want values that don't make sense to the API call you made to be accessible
|
5
|
-
# I'm not dynamically creating the class because we may want to add functionality at some point
|
6
|
-
|
7
|
-
# This class, with its dynamically created attr_accr's will be dynamically appended to api
|
8
|
-
# entities, like job and company. It will contain things like errors, time elapsed, and
|
9
|
-
# any other meta values that the API may return.
|
10
|
-
|
11
|
-
# The mapping for allowed values, and what they translate to on this object live in Cb::Utils::Api
|
12
|
-
end
|
13
|
-
end
|