insuggest 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: d5a8c2eff302b8f1b57dc43e529ca265bd6de977
4
+ data.tar.gz: ba44cb8de19603fe7f6fcb59523a5e759bc3003e
5
+ SHA512:
6
+ metadata.gz: 9a75d3134efdcbe9660b0841deca74e11ba77f4b77ee4d5dc4b57e54c2716a17239f37ade38b6b53d3ca28d3bd96e1efa1e202bee7c3eb81831cf119f2935d6f
7
+ data.tar.gz: 71b4dc58a212686f6a46da50fc20431b669a5ce2fb001164a2d41ace462615b9bb5d2299fc86373a49993f55df8bcd38aa9f3c2a359ef3ff242c60706b27ae3d
@@ -0,0 +1,14 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
10
+ *.bundle
11
+ *.so
12
+ *.o
13
+ *.a
14
+ mkmf.log
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in insuggest.gemspec
4
+ gemspec
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2015 Shailesh Patil
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.
@@ -0,0 +1,31 @@
1
+ # Insuggest
2
+
3
+ TODO: Write a gem description
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ ```ruby
10
+ gem 'insuggest'
11
+ ```
12
+
13
+ And then execute:
14
+
15
+ $ bundle
16
+
17
+ Or install it yourself as:
18
+
19
+ $ gem install insuggest
20
+
21
+ ## Usage
22
+
23
+ TODO: Write usage instructions here
24
+
25
+ ## Contributing
26
+
27
+ 1. Fork it ( https://github.com/[my-github-username]/insuggest/fork )
28
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
29
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
30
+ 4. Push to the branch (`git push origin my-new-feature`)
31
+ 5. Create a new Pull Request
@@ -0,0 +1,2 @@
1
+ require "bundler/gem_tasks"
2
+
@@ -0,0 +1,28 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'insuggest/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "insuggest"
8
+ spec.version = Insuggest::VERSION
9
+ spec.authors = ["Shailesh Patil"]
10
+ spec.email = ["shailesh@joshsoftware.com"]
11
+ spec.summary = "Find the insurance discounts and depreciations"
12
+ spec.description = "This gem will provide a way to find the accurate discounts and depreciations from the uploaded data"
13
+ spec.homepage = ""
14
+ spec.license = "MIT"
15
+
16
+ spec.files = `git ls-files -z`.split("\x0")
17
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
+ spec.require_paths = ["lib"]
20
+
21
+ spec.add_runtime_dependency 'elasticsearch', '~> 1.0.5'
22
+ spec.add_dependency 'elasticsearch-model', '~> 0.1.5'
23
+ spec.add_dependency 'elasticsearch-persistence', '~> 0.1.5'
24
+ spec.add_dependency 'elasticsearch-rails', '~> 0.1.5'
25
+
26
+ spec.add_development_dependency "bundler", "~> 1.7"
27
+ spec.add_development_dependency "rake", "~> 10.0"
28
+ end
@@ -0,0 +1,8 @@
1
+ require 'elasticsearch'
2
+ require 'elasticsearch/model'
3
+ require 'elasticsearch/persistence'
4
+ require "insuggest/discount"
5
+ require "insuggest/depreciation"
6
+ require "insuggest/gcv/discount"
7
+ require "insuggest/gcv/depreciation"
8
+ require "insuggest/version"
@@ -0,0 +1,72 @@
1
+ module Insuggest
2
+ module Depreciation
3
+ attr_reader :attributes
4
+
5
+ def initialize(attributes={})
6
+ @attributes = attributes
7
+ end
8
+
9
+ def to_hash
10
+ @attributes
11
+ end
12
+
13
+ module ClassMethods
14
+
15
+ def get_index_name
16
+ "depreciations"
17
+ end
18
+
19
+ def repository
20
+ index_name = get_index_name
21
+ Elasticsearch::Persistence::Repository.new do
22
+ index index_name
23
+ type :depreciation
24
+ settings number_of_shards: 4 do
25
+ mapping do
26
+ indexes :suggest_make, type: 'completion',
27
+ payloads: true,
28
+ index_analyzer: "simple",
29
+ search_analyzer: "simple"
30
+ indexes :suggest_model, type: 'completion',
31
+ payloads: true,
32
+ index_analyzer: "simple",
33
+ search_analyzer: "simple"
34
+ end
35
+ end
36
+ end
37
+ end
38
+
39
+ def search(query=[], size= 100, age=1, percent)
40
+ self.repository.search({
41
+ size: size,
42
+ query: {
43
+ bool: {
44
+ must: [
45
+ {
46
+ match: {
47
+ make: {
48
+ query: query[0],
49
+ minimum_should_match: '30%'
50
+ }
51
+ }
52
+ },
53
+ {
54
+ match: {
55
+ model: {
56
+ query: query[1],
57
+ minimum_should_match: '40%'
58
+ }
59
+ }
60
+ }
61
+ ]
62
+ }
63
+ }
64
+ })
65
+ end
66
+ end
67
+
68
+ def self.included(base)
69
+ base.extend(ClassMethods)
70
+ end
71
+ end
72
+ end
@@ -0,0 +1,74 @@
1
+ module Insuggest
2
+ module Discount
3
+ attr_reader :attributes
4
+
5
+ def initialize(attributes={})
6
+ @attributes = attributes
7
+ end
8
+
9
+ def to_hash
10
+ @attributes
11
+ end
12
+
13
+ module ClassMethods
14
+
15
+ def get_index_name
16
+ "discounts"
17
+ end
18
+
19
+ def repository
20
+ index_name = get_index_name
21
+ Elasticsearch::Persistence::Repository.new do
22
+ index index_name
23
+ type :discount
24
+ settings number_of_shards: 4 do
25
+ mapping do
26
+ indexes :suggest_make, type: 'completion',
27
+ payloads: true,
28
+ index_analyzer: "simple",
29
+ search_analyzer: "simple"
30
+ indexes :suggest_model, type: 'completion',
31
+ payloads: true,
32
+ index_analyzer: "simple",
33
+ search_analyzer: "simple"
34
+ end
35
+ end
36
+ end
37
+ end
38
+
39
+ def search(query=[], size= 100, age=1, percent)
40
+ self.repository.search({
41
+ size: size,
42
+ query: {
43
+ bool: {
44
+ must: [
45
+ {
46
+ match: {
47
+ make: {
48
+ query: query[0],
49
+ minimum_should_match: percent[0]
50
+ }
51
+ }
52
+ },
53
+ {
54
+ match: {
55
+ model_and_available_model: {
56
+ query: query[1],
57
+ minimum_should_match: percent[1]
58
+ }
59
+ }
60
+ },
61
+ {range: {from: {lte: age}}},
62
+ {range: {to: {gte: age}}}
63
+ ]
64
+ }
65
+ }
66
+ })
67
+ end
68
+ end
69
+
70
+ def self.included(base)
71
+ base.extend(ClassMethods)
72
+ end
73
+ end
74
+ end
@@ -0,0 +1,25 @@
1
+ module Insuggest
2
+ module Gcv
3
+ module Depreciation
4
+ module ClassMethods
5
+ def get_index_name
6
+ "gcv_depreciations"
7
+ end
8
+
9
+ def repository
10
+ index_name = get_index_name
11
+ Elasticsearch::Persistence::Repository.new do
12
+ index index_name
13
+ type :depreciation
14
+ settings number_of_shards: 2
15
+ end
16
+ end
17
+ end
18
+
19
+ def self.included(base)
20
+ base.send :include, Insuggest::Gcv::Discount
21
+ base.extend(ClassMethods)
22
+ end
23
+ end
24
+ end
25
+ end
@@ -0,0 +1,49 @@
1
+ module Insuggest
2
+ module Gcv
3
+ module Discount
4
+ def initialize(attributes={})
5
+ @attributes = attributes
6
+ end
7
+
8
+ def to_hash
9
+ @attributes
10
+ end
11
+
12
+ module ClassMethods
13
+
14
+ def get_index_name
15
+ "gcv_discounts"
16
+ end
17
+
18
+ def repository
19
+ index_name = get_index_name
20
+ Elasticsearch::Persistence::Repository.new do
21
+ index index_name
22
+ type :discount
23
+ settings number_of_shards: 2
24
+ end
25
+ end
26
+
27
+ def search(age=1, capacity=0, size: 100)
28
+ self.repository.search({
29
+ size: size,
30
+ query: {
31
+ bool: {
32
+ must: [
33
+ { range: {capacity_from: {lte: capacity}}},
34
+ { range: {capacity_to: {gte: capacity}}},
35
+ { range: {from: {lte: age}}},
36
+ { range: {to: {gte: age}}}
37
+ ]
38
+ }
39
+ }
40
+ })
41
+ end
42
+ end
43
+
44
+ def self.included(base)
45
+ base.extend(ClassMethods)
46
+ end
47
+ end
48
+ end
49
+ end
@@ -0,0 +1,3 @@
1
+ module Insuggest
2
+ VERSION = "0.0.2"
3
+ end
metadata ADDED
@@ -0,0 +1,141 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: insuggest
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.2
5
+ platform: ruby
6
+ authors:
7
+ - Shailesh Patil
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2015-11-17 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: elasticsearch
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: 1.0.5
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: 1.0.5
27
+ - !ruby/object:Gem::Dependency
28
+ name: elasticsearch-model
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: 0.1.5
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: 0.1.5
41
+ - !ruby/object:Gem::Dependency
42
+ name: elasticsearch-persistence
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: 0.1.5
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: 0.1.5
55
+ - !ruby/object:Gem::Dependency
56
+ name: elasticsearch-rails
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: 0.1.5
62
+ type: :runtime
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: 0.1.5
69
+ - !ruby/object:Gem::Dependency
70
+ name: bundler
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: '1.7'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: '1.7'
83
+ - !ruby/object:Gem::Dependency
84
+ name: rake
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - "~>"
88
+ - !ruby/object:Gem::Version
89
+ version: '10.0'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - "~>"
95
+ - !ruby/object:Gem::Version
96
+ version: '10.0'
97
+ description: This gem will provide a way to find the accurate discounts and depreciations
98
+ from the uploaded data
99
+ email:
100
+ - shailesh@joshsoftware.com
101
+ executables: []
102
+ extensions: []
103
+ extra_rdoc_files: []
104
+ files:
105
+ - ".gitignore"
106
+ - Gemfile
107
+ - LICENSE.txt
108
+ - README.md
109
+ - Rakefile
110
+ - insuggest.gemspec
111
+ - lib/insuggest.rb
112
+ - lib/insuggest/depreciation.rb
113
+ - lib/insuggest/discount.rb
114
+ - lib/insuggest/gcv/depreciation.rb
115
+ - lib/insuggest/gcv/discount.rb
116
+ - lib/insuggest/version.rb
117
+ homepage: ''
118
+ licenses:
119
+ - MIT
120
+ metadata: {}
121
+ post_install_message:
122
+ rdoc_options: []
123
+ require_paths:
124
+ - lib
125
+ required_ruby_version: !ruby/object:Gem::Requirement
126
+ requirements:
127
+ - - ">="
128
+ - !ruby/object:Gem::Version
129
+ version: '0'
130
+ required_rubygems_version: !ruby/object:Gem::Requirement
131
+ requirements:
132
+ - - ">="
133
+ - !ruby/object:Gem::Version
134
+ version: '0'
135
+ requirements: []
136
+ rubyforge_project:
137
+ rubygems_version: 2.4.5
138
+ signing_key:
139
+ specification_version: 4
140
+ summary: Find the insurance discounts and depreciations
141
+ test_files: []