vinbot 2.0.0 → 2.0.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 8d7d9bc70a337ff3bfaf9ca8efde07268cabb0be
4
- data.tar.gz: 9cefd45d2872c8e5db992851f2456ba64daa52b4
3
+ metadata.gz: 7262314ebac0036897b9039b2434dc0873a7184e
4
+ data.tar.gz: d752760f0543d142f12f99727ea73d13f5f149dd
5
5
  SHA512:
6
- metadata.gz: 89b34b5a9fa7ea796492cfd576e8fbbc31ba08f63df45b2ad60f3e5ad76f26c11c3e83cc74cba2ba0cb68adbdf83ce963331aa856f12f5d67fce7a151b4ecfaf
7
- data.tar.gz: ada02084a4201351ec72be334a99e421f32ab188b29bdca99b6aa55a0202baad7722ad865a58c0c6114cfabae070533dddba2541b2c26bddc67195b6cfbf1bd5
6
+ metadata.gz: 3b1632c7444fb4fc4619c76bf2778a3f709da1d7fd528017976fa8b0a1821bdea592b5f78bc5986e17c6b2d8d73a98659338512688f8995b19546e779326a866
7
+ data.tar.gz: de404a35d468479ef1f321ed98711f85ce40c228ace198355456737475b0125f412e5d92c7589025ec4dc6aa98a8d585a044726f2c88a6f95b13100842f258ee
data/lib/data/vehicle.rb CHANGED
@@ -12,6 +12,24 @@ module Vinbot
12
12
  many_to_one :interior_color
13
13
  many_to_one :transmission
14
14
  many_to_one :vehicle_type
15
+
16
+ def self.get_vehicle(params)
17
+ return get_random_vehicle if params.empty?
18
+ join_query = perform_joins(params)
19
+ add_conditions_to_join(join_query, params).order(Sequel.lit('RANDOM()')).limit(1).first
20
+ end
21
+
22
+ def self.perform_joins(params)
23
+ params.keys.inject(from(:vehicles)) { |r, e| r.join("#{e}s".to_sym, :id => "vehicles__#{e}_id".to_sym) }
24
+ end
25
+
26
+ def self.add_conditions_to_join(join_query, params)
27
+ params.inject(join_query) { |r, e| r.where("#{e.first}s__name".to_sym => e.last) }
28
+ end
29
+
30
+ def self.get_random_vehicle
31
+ ::Vinbot::Data::Vehicle.order(Sequel.lit('RANDOM()')).limit(1).first
32
+ end
15
33
  end
16
34
  end
17
35
  end
@@ -4,8 +4,8 @@ module Vinbot
4
4
  attr_accessor :year, :make, :model, :trim, :engine_type, :transmission, :body_type, :vehicle_type, :drivetrain,
5
5
  :interior_colors, :exterior_colors, :vin
6
6
 
7
- def initialize
8
- vehicle = ::Vinbot::Data::Vehicle.order(Sequel.lit('RANDOM()')).limit(1).first
7
+ def initialize(params = {})
8
+ vehicle = ::Vinbot::Data::Vehicle.get_vehicle(params)
9
9
  @year = vehicle.year.name
10
10
  @make = vehicle.make.name
11
11
  @model = vehicle.model.name
@@ -1,3 +1,3 @@
1
1
  module Vinbot
2
- VERSION = "2.0.0"
2
+ VERSION = "2.0.2"
3
3
  end
data/lib/vinbot.rb CHANGED
@@ -1,12 +1,18 @@
1
1
  require 'securerandom'
2
2
  require 'sequel'
3
- require 'sqlite3'
4
3
  require 'vin_bank'
5
4
  require 'vinbot/vehicle'
6
5
  require 'vinbot/vin'
7
6
 
8
- DB = Sequel.sqlite(VinBank.db_path)
9
- Dir["#{File.dirname(__FILE__)}/data/*.rb"].each {|file| require file }
7
+ if RUBY_PLATFORM == 'java'
8
+ require 'jdbc/sqlite3'
9
+ DB = Sequel.connect("jdbc:sqlite:///#{VinBank.db_path}")
10
+ else
11
+ require 'sqlite3'
12
+ DB = Sequel.sqlite(VinBank.db_path)
13
+ end
14
+
15
+ Dir["#{File.dirname(__FILE__)}/data/*.rb"].each { |file| require file }
10
16
 
11
17
  module Vinbot
12
18
 
metadata CHANGED
@@ -1,135 +1,135 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: vinbot
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.0
4
+ version: 2.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jarod Adair, Umair Chagani
8
- autorequire:
8
+ autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2016-01-21 00:00:00.000000000 Z
11
+ date: 2016-02-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
15
- requirement: !ruby/object:Gem::Requirement
15
+ version_requirements: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - ">"
17
+ - - '>'
18
18
  - !ruby/object:Gem::Version
19
19
  version: '1.8'
20
- type: :development
21
- prerelease: false
22
- version_requirements: !ruby/object:Gem::Requirement
20
+ requirement: !ruby/object:Gem::Requirement
23
21
  requirements:
24
- - - ">"
22
+ - - '>'
25
23
  - !ruby/object:Gem::Version
26
24
  version: '1.8'
25
+ prerelease: false
26
+ type: :development
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: rake
29
- requirement: !ruby/object:Gem::Requirement
29
+ version_requirements: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - "~>"
31
+ - - ~>
32
32
  - !ruby/object:Gem::Version
33
33
  version: '10.0'
34
- type: :development
35
- prerelease: false
36
- version_requirements: !ruby/object:Gem::Requirement
34
+ requirement: !ruby/object:Gem::Requirement
37
35
  requirements:
38
- - - "~>"
36
+ - - ~>
39
37
  - !ruby/object:Gem::Version
40
38
  version: '10.0'
39
+ prerelease: false
40
+ type: :development
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: rspec
43
+ version_requirements: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - '>='
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
43
48
  requirement: !ruby/object:Gem::Requirement
44
49
  requirements:
45
- - - ">="
50
+ - - '>='
46
51
  - !ruby/object:Gem::Version
47
52
  version: '0'
48
- type: :development
49
53
  prerelease: false
54
+ type: :development
55
+ - !ruby/object:Gem::Dependency
56
+ name: pry
50
57
  version_requirements: !ruby/object:Gem::Requirement
51
58
  requirements:
52
- - - ">="
59
+ - - '>='
53
60
  - !ruby/object:Gem::Version
54
61
  version: '0'
55
- - !ruby/object:Gem::Dependency
56
- name: pry
57
62
  requirement: !ruby/object:Gem::Requirement
58
63
  requirements:
59
- - - ">="
64
+ - - '>='
60
65
  - !ruby/object:Gem::Version
61
66
  version: '0'
62
- type: :development
63
67
  prerelease: false
68
+ type: :development
69
+ - !ruby/object:Gem::Dependency
70
+ name: pry-nav
64
71
  version_requirements: !ruby/object:Gem::Requirement
65
72
  requirements:
66
- - - ">="
73
+ - - '>='
67
74
  - !ruby/object:Gem::Version
68
75
  version: '0'
69
- - !ruby/object:Gem::Dependency
70
- name: pry-nav
71
76
  requirement: !ruby/object:Gem::Requirement
72
77
  requirements:
73
- - - ">="
78
+ - - '>='
74
79
  - !ruby/object:Gem::Version
75
80
  version: '0'
76
- type: :development
77
81
  prerelease: false
82
+ type: :development
83
+ - !ruby/object:Gem::Dependency
84
+ name: sqlite3
78
85
  version_requirements: !ruby/object:Gem::Requirement
79
86
  requirements:
80
- - - ">="
87
+ - - '>='
81
88
  - !ruby/object:Gem::Version
82
89
  version: '0'
83
- - !ruby/object:Gem::Dependency
84
- name: sqlite3
85
90
  requirement: !ruby/object:Gem::Requirement
86
91
  requirements:
87
- - - ">="
92
+ - - '>='
88
93
  - !ruby/object:Gem::Version
89
94
  version: '0'
90
- type: :runtime
91
95
  prerelease: false
96
+ type: :runtime
97
+ - !ruby/object:Gem::Dependency
98
+ name: sequel
92
99
  version_requirements: !ruby/object:Gem::Requirement
93
100
  requirements:
94
- - - ">="
101
+ - - '>='
95
102
  - !ruby/object:Gem::Version
96
103
  version: '0'
97
- - !ruby/object:Gem::Dependency
98
- name: sequel
99
104
  requirement: !ruby/object:Gem::Requirement
100
105
  requirements:
101
- - - ">="
106
+ - - '>='
102
107
  - !ruby/object:Gem::Version
103
108
  version: '0'
104
- type: :runtime
105
109
  prerelease: false
110
+ type: :runtime
111
+ - !ruby/object:Gem::Dependency
112
+ name: vin_bank
106
113
  version_requirements: !ruby/object:Gem::Requirement
107
114
  requirements:
108
- - - ">="
115
+ - - '>='
109
116
  - !ruby/object:Gem::Version
110
- version: '0'
111
- - !ruby/object:Gem::Dependency
112
- name: vin_bank
117
+ version: 3.1.0
113
118
  requirement: !ruby/object:Gem::Requirement
114
119
  requirements:
115
- - - ">="
120
+ - - '>='
116
121
  - !ruby/object:Gem::Version
117
- version: 3.0.0
118
- type: :runtime
122
+ version: 3.1.0
119
123
  prerelease: false
120
- version_requirements: !ruby/object:Gem::Requirement
121
- requirements:
122
- - - ">="
123
- - !ruby/object:Gem::Version
124
- version: 3.0.0
125
- description: Vinbot generates decodeable vins and provides a vehicle object that includes
126
- real vehicle data.
124
+ type: :runtime
125
+ description: Vinbot generates decodeable vins and provides a vehicle object that includes real vehicle data.
127
126
  email:
128
127
  - jarod.adair@manheim.com, umair.chagani@manheim.com
129
128
  executables: []
130
129
  extensions: []
131
130
  extra_rdoc_files: []
132
131
  files:
132
+ - lib/vinbot.rb
133
133
  - lib/data/body_type.rb
134
134
  - lib/data/constants.rb
135
135
  - lib/data/drivetrain.rb
@@ -143,7 +143,6 @@ files:
143
143
  - lib/data/vehicle.rb
144
144
  - lib/data/vehicle_type.rb
145
145
  - lib/data/year.rb
146
- - lib/vinbot.rb
147
146
  - lib/vinbot/vehicle.rb
148
147
  - lib/vinbot/version.rb
149
148
  - lib/vinbot/vin.rb
@@ -151,25 +150,24 @@ homepage: https://github.com/manheim/vinbot
151
150
  licenses:
152
151
  - MIT
153
152
  metadata: {}
154
- post_install_message:
153
+ post_install_message:
155
154
  rdoc_options: []
156
155
  require_paths:
157
156
  - lib
158
157
  required_ruby_version: !ruby/object:Gem::Requirement
159
158
  requirements:
160
- - - ">="
159
+ - - '>='
161
160
  - !ruby/object:Gem::Version
162
161
  version: '0'
163
162
  required_rubygems_version: !ruby/object:Gem::Requirement
164
163
  requirements:
165
- - - ">="
164
+ - - '>='
166
165
  - !ruby/object:Gem::Version
167
166
  version: '0'
168
167
  requirements: []
169
- rubyforge_project:
170
- rubygems_version: 2.2.2
171
- signing_key:
168
+ rubyforge_project:
169
+ rubygems_version: 2.1.9
170
+ signing_key:
172
171
  specification_version: 4
173
- summary: Vinbot generates decodeable vins and provides a vehicle object that includes
174
- real vehicle data.
172
+ summary: Vinbot generates decodeable vins and provides a vehicle object that includes real vehicle data.
175
173
  test_files: []