kirgudu_refs 0.0.2
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 +7 -0
- data/MIT-LICENSE +20 -0
- data/README.rdoc +3 -0
- data/Rakefile +40 -0
- data/app/assets/javascripts/kirgudu_refs/application.js +15 -0
- data/app/assets/stylesheets/kirgudu_refs/application.css +13 -0
- data/app/helpers/kirgudu_refs/application_helper.rb +4 -0
- data/app/helpers/kirgudu_refs/model_basic_properties.rb +175 -0
- data/app/models/kirgudu_refs/base_model.rb +14 -0
- data/app/models/kirgudu_refs/globe/city.rb +78 -0
- data/app/models/kirgudu_refs/globe/country.rb +79 -0
- data/app/models/kirgudu_refs/globe/region.rb +76 -0
- data/app/models/kirgudu_refs/globe/state.rb +77 -0
- data/app/models/kirgudu_refs/globe/subway_line.rb +43 -0
- data/app/models/kirgudu_refs/globe/subway_station.rb +65 -0
- data/app/models/kirgudu_refs/globe/timezone.rb +8 -0
- data/app/models/kirgudu_refs/globe.rb +7 -0
- data/app/models/kirgudu_refs/it/encoding.rb +43 -0
- data/app/models/kirgudu_refs/it/operating_system.rb +40 -0
- data/app/models/kirgudu_refs/it/operating_system_family.rb +7 -0
- data/app/models/kirgudu_refs/it/processor_architecture.rb +7 -0
- data/app/models/kirgudu_refs/it.rb +7 -0
- data/app/models/kirgudu_refs/national/currency.rb +74 -0
- data/app/models/kirgudu_refs/national/language.rb +80 -0
- data/app/models/kirgudu_refs/national.rb +7 -0
- data/app/models/kirgudu_refs/shops/manufacturer.rb +54 -0
- data/app/models/kirgudu_refs/shops.rb +7 -0
- data/config/routes.rb +2 -0
- data/db/migrate/20130831122828_create_kirgudu_refs_it_operating_system_families.rb +29 -0
- data/db/migrate/20130831122900_create_kirgudu_refs_it_encodings.rb +26 -0
- data/db/migrate/20130831123418_create_kirgudu_refs_globe_cities.rb +37 -0
- data/db/migrate/20130831123443_create_kirgudu_refs_globe_regions.rb +40 -0
- data/db/migrate/20130831123613_create_kirgudu_refs_globe_states.rb +38 -0
- data/db/migrate/20130831123640_create_kirgudu_refs_globe_countries.rb +41 -0
- data/db/migrate/20130831124432_create_kirgudu_refs_globe_subway_lines.rb +28 -0
- data/db/migrate/20130831124648_create_kirgudu_refs_globe_subway_stations.rb +36 -0
- data/db/migrate/20130831125136_create_kirgudu_refs_globe_timezones.rb +29 -0
- data/db/migrate/20130831125626_create_kirgudu_refs_it_operating_systems.rb +29 -0
- data/db/migrate/20130831125703_create_kirgudu_refs_it_processor_architectures.rb +24 -0
- data/db/migrate/20130831130259_create_kirgudu_refs_national_currencies.rb +34 -0
- data/db/migrate/20130831130350_create_kirgudu_refs_national_languages.rb +30 -0
- data/db/migrate/20130831130436_create_kirgudu_refs_shops_manufacturers.rb +36 -0
- data/db/migrate/20130902065049_fix_id_in_it_operating_system_families.rb +9 -0
- data/db/migrate/20130902065101_fix_id_in_it_encodings.rb +9 -0
- data/db/migrate/20130902065111_fix_id_in_globe_cities.rb +10 -0
- data/db/migrate/20130902065117_fix_id_in_globe_countries.rb +9 -0
- data/db/migrate/20130902065123_fix_id_in_globe_states.rb +9 -0
- data/db/migrate/20130902065131_fix_id_in_globe_regions.rb +9 -0
- data/db/migrate/20130902065943_fix_id_in_globe_subway_lines.rb +9 -0
- data/db/migrate/20130902065951_fix_id_in_globe_subway_stations.rb +9 -0
- data/db/migrate/20130902070323_fix_id_in_globe_timezones.rb +9 -0
- data/db/migrate/20130902070557_fix_id_in_national_currency.rb +9 -0
- data/db/migrate/20130902070604_fix_id_in_national_language.rb +9 -0
- data/db/migrate/20130902070628_fix_id_in_it_operating_system.rb +9 -0
- data/db/migrate/20130902070640_fix_id_in_it_processor_architecture.rb +9 -0
- data/db/migrate/20130902070659_fix_id_in_shops_manufacturer.rb +9 -0
- data/lib/kirgudu_refs/engine.rb +5 -0
- data/lib/kirgudu_refs/version.rb +3 -0
- data/lib/kirgudu_refs.rb +4 -0
- data/lib/tasks/kirgudu_refs_tasks.rake +4 -0
- data/test/dummy/README.rdoc +261 -0
- data/test/dummy/Rakefile +7 -0
- data/test/dummy/app/assets/javascripts/application.js +15 -0
- data/test/dummy/app/assets/stylesheets/application.css +13 -0
- data/test/dummy/app/controllers/application_controller.rb +3 -0
- data/test/dummy/app/helpers/application_helper.rb +2 -0
- data/test/dummy/app/views/layouts/application.html.erb +14 -0
- data/test/dummy/config/application.rb +59 -0
- data/test/dummy/config/boot.rb +10 -0
- data/test/dummy/config/database.yml +25 -0
- data/test/dummy/config/environment.rb +5 -0
- data/test/dummy/config/environments/development.rb +37 -0
- data/test/dummy/config/environments/production.rb +67 -0
- data/test/dummy/config/environments/test.rb +37 -0
- data/test/dummy/config/initializers/backtrace_silencers.rb +7 -0
- data/test/dummy/config/initializers/inflections.rb +15 -0
- data/test/dummy/config/initializers/mime_types.rb +5 -0
- data/test/dummy/config/initializers/secret_token.rb +7 -0
- data/test/dummy/config/initializers/session_store.rb +8 -0
- data/test/dummy/config/initializers/wrap_parameters.rb +14 -0
- data/test/dummy/config/locales/en.yml +5 -0
- data/test/dummy/config/routes.rb +4 -0
- data/test/dummy/config.ru +4 -0
- data/test/dummy/public/404.html +26 -0
- data/test/dummy/public/422.html +26 -0
- data/test/dummy/public/500.html +25 -0
- data/test/dummy/public/favicon.ico +0 -0
- data/test/dummy/script/rails +6 -0
- data/test/fixtures/kirgudu_refs/globe/cities.yml +13 -0
- data/test/fixtures/kirgudu_refs/globe/countries.yml +7 -0
- data/test/fixtures/kirgudu_refs/globe/regions.yml +11 -0
- data/test/fixtures/kirgudu_refs/globe/states.yml +9 -0
- data/test/fixtures/kirgudu_refs/globe/subway_lines.yml +13 -0
- data/test/fixtures/kirgudu_refs/globe/subway_stations.yml +13 -0
- data/test/fixtures/kirgudu_refs/globe/timezones.yml +15 -0
- data/test/fixtures/kirgudu_refs/it/encodings.yml +11 -0
- data/test/fixtures/kirgudu_refs/it/operating_system_families.yml +9 -0
- data/test/fixtures/kirgudu_refs/it/operating_systems.yml +11 -0
- data/test/fixtures/kirgudu_refs/it/processor_architectures.yml +7 -0
- data/test/fixtures/kirgudu_refs/national/currencies.yml +9 -0
- data/test/fixtures/kirgudu_refs/national/languages.yml +9 -0
- data/test/fixtures/kirgudu_refs/shops/manufacturers.yml +9 -0
- data/test/integration/navigation_test.rb +10 -0
- data/test/kirgudu_refs_test.rb +7 -0
- data/test/test_helper.rb +15 -0
- data/test/unit/kirgudu_refs/globe/city_test.rb +9 -0
- data/test/unit/kirgudu_refs/globe/country_test.rb +9 -0
- data/test/unit/kirgudu_refs/globe/region_test.rb +9 -0
- data/test/unit/kirgudu_refs/globe/state_test.rb +9 -0
- data/test/unit/kirgudu_refs/globe/subway_line_test.rb +9 -0
- data/test/unit/kirgudu_refs/globe/subway_station_test.rb +9 -0
- data/test/unit/kirgudu_refs/globe/timezone_test.rb +9 -0
- data/test/unit/kirgudu_refs/it/encoding_test.rb +9 -0
- data/test/unit/kirgudu_refs/it/operating_system_family_test.rb +9 -0
- data/test/unit/kirgudu_refs/it/operating_system_test.rb +9 -0
- data/test/unit/kirgudu_refs/it/processor_architecture_test.rb +9 -0
- data/test/unit/kirgudu_refs/national/currency_test.rb +9 -0
- data/test/unit/kirgudu_refs/national/language_test.rb +9 -0
- data/test/unit/kirgudu_refs/shops/manufacturer_test.rb +9 -0
- metadata +318 -0
checksums.yaml
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
---
|
|
2
|
+
SHA1:
|
|
3
|
+
metadata.gz: c2921184033f761699f1a1a7a2c09378a020ce0f
|
|
4
|
+
data.tar.gz: 2a783224e7ae4cc4a01b600e038fae7b448d79eb
|
|
5
|
+
SHA512:
|
|
6
|
+
metadata.gz: 6d52401653a48fb69f30b9f934024206fc73f854af0deda6ecf5b72f2fbe162f05636f53009389ed9fc0ca6ffd884f9c0b39fe3082ee2869418222a72b38a769
|
|
7
|
+
data.tar.gz: 24e0c403836194ae67b061840a87d26cbffe376052c38b86dc2edbbc6342a485913136be13e807fc03de0214f85d484b6a71936702de1cddd9ec7099fb8416ac
|
data/MIT-LICENSE
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
Copyright 2013 YOURNAME
|
|
2
|
+
|
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
|
4
|
+
a copy of this software and associated documentation files (the
|
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
|
9
|
+
the following conditions:
|
|
10
|
+
|
|
11
|
+
The above copyright notice and this permission notice shall be
|
|
12
|
+
included in all copies or substantial portions of the Software.
|
|
13
|
+
|
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.rdoc
ADDED
data/Rakefile
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
#!/usr/bin/env rake
|
|
2
|
+
begin
|
|
3
|
+
require 'bundler/setup'
|
|
4
|
+
rescue LoadError
|
|
5
|
+
puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
|
|
6
|
+
end
|
|
7
|
+
begin
|
|
8
|
+
require 'rdoc/task'
|
|
9
|
+
rescue LoadError
|
|
10
|
+
require 'rdoc/rdoc'
|
|
11
|
+
require 'rake/rdoctask'
|
|
12
|
+
RDoc::Task = Rake::RDocTask
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
RDoc::Task.new(:rdoc) do |rdoc|
|
|
16
|
+
rdoc.rdoc_dir = 'rdoc'
|
|
17
|
+
rdoc.title = 'KirguduRefs'
|
|
18
|
+
rdoc.options << '--line-numbers'
|
|
19
|
+
rdoc.rdoc_files.include('README.rdoc')
|
|
20
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
APP_RAKEFILE = File.expand_path("../test/dummy/Rakefile", __FILE__)
|
|
24
|
+
load 'rails/tasks/engine.rake'
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
Bundler::GemHelper.install_tasks
|
|
29
|
+
|
|
30
|
+
require 'rake/testtask'
|
|
31
|
+
|
|
32
|
+
Rake::TestTask.new(:test) do |t|
|
|
33
|
+
t.libs << 'lib'
|
|
34
|
+
t.libs << 'test'
|
|
35
|
+
t.pattern = 'test/**/*_test.rb'
|
|
36
|
+
t.verbose = false
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
task :default => :test
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
// This is a manifest file that'll be compiled into application.js, which will include all the files
|
|
2
|
+
// listed below.
|
|
3
|
+
//
|
|
4
|
+
// Any JavaScript/Coffee file within this directory, lib/assets/javascripts, vendor/assets/javascripts,
|
|
5
|
+
// or vendor/assets/javascripts of plugins, if any, can be referenced here using a relative path.
|
|
6
|
+
//
|
|
7
|
+
// It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
|
|
8
|
+
// the compiled file.
|
|
9
|
+
//
|
|
10
|
+
// WARNING: THE FIRST BLANK LINE MARKS THE END OF WHAT'S TO BE PROCESSED, ANY BLANK LINE SHOULD
|
|
11
|
+
// GO AFTER THE REQUIRES BELOW.
|
|
12
|
+
//
|
|
13
|
+
//= require jquery
|
|
14
|
+
//= require jquery_ujs
|
|
15
|
+
//= require_tree .
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* This is a manifest file that'll be compiled into application.css, which will include all the files
|
|
3
|
+
* listed below.
|
|
4
|
+
*
|
|
5
|
+
* Any CSS and SCSS file within this directory, lib/assets/stylesheets, vendor/assets/stylesheets,
|
|
6
|
+
* or vendor/assets/stylesheets of plugins, if any, can be referenced here using a relative path.
|
|
7
|
+
*
|
|
8
|
+
* You're free to add application-wide styles to this file and they'll appear at the top of the
|
|
9
|
+
* compiled file, but it's generally better to create a new file per style scope.
|
|
10
|
+
*
|
|
11
|
+
*= require_self
|
|
12
|
+
*= require_tree .
|
|
13
|
+
*/
|
|
@@ -0,0 +1,175 @@
|
|
|
1
|
+
# -*- encoding : utf-8 -*-
|
|
2
|
+
|
|
3
|
+
module KirguduRefs
|
|
4
|
+
module ModelBasicProperties
|
|
5
|
+
|
|
6
|
+
module EncodingID
|
|
7
|
+
def self.included(base)
|
|
8
|
+
base.belongs_to :encoding, class_name: ::KirguduRefs::It::Encoding, foreign_key: :encoding_id
|
|
9
|
+
base.scope :by_encoding, lambda { |value| base.where(encoding_id: value) if value }
|
|
10
|
+
|
|
11
|
+
base.class_eval do
|
|
12
|
+
include InstanceMethods
|
|
13
|
+
end
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
module InstanceMethods
|
|
17
|
+
def encoding_name
|
|
18
|
+
encoding.name if encoding
|
|
19
|
+
end
|
|
20
|
+
end
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
module LanguageID
|
|
25
|
+
def self.included(base)
|
|
26
|
+
base.belongs_to :language, class_name: ::KirguduRefs::National::Language, foreign_key: :language_id
|
|
27
|
+
base.scope :by_language, lambda { |value| base.where(language_id: value) if value }
|
|
28
|
+
|
|
29
|
+
base.class_eval do
|
|
30
|
+
include InstanceMethods
|
|
31
|
+
end
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
module InstanceMethods
|
|
35
|
+
def language_name
|
|
36
|
+
language.name if language
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
def language_iso2
|
|
40
|
+
language.iso2 if language
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
def language_iso3
|
|
44
|
+
language.iso3 if language
|
|
45
|
+
end
|
|
46
|
+
end
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
module CurrencyID
|
|
50
|
+
def self.included(base)
|
|
51
|
+
base.belongs_to :currency, class_name: ::KirguduRefs::National::Currency, foreign_key: :currency_id
|
|
52
|
+
base.scope :by_currency, lambda { |value| base.where(currency_id: value) if value }
|
|
53
|
+
|
|
54
|
+
base.class_eval do
|
|
55
|
+
include InstanceMethods
|
|
56
|
+
end
|
|
57
|
+
end
|
|
58
|
+
|
|
59
|
+
module InstanceMethods
|
|
60
|
+
def currency_name
|
|
61
|
+
currency.name if currency
|
|
62
|
+
end
|
|
63
|
+
|
|
64
|
+
def currency_iso3
|
|
65
|
+
currency.iso3 if currency
|
|
66
|
+
end
|
|
67
|
+
end
|
|
68
|
+
end
|
|
69
|
+
|
|
70
|
+
|
|
71
|
+
module CountryID
|
|
72
|
+
def self.included(base)
|
|
73
|
+
base.belongs_to :country, class_name: ::KirguduRefs::Globe::Country, foreign_key: :country_id
|
|
74
|
+
base.scope :by_country, lambda { |value| base.where(country_id: value) if value }
|
|
75
|
+
|
|
76
|
+
base.class_eval do
|
|
77
|
+
include InstanceMethods
|
|
78
|
+
end
|
|
79
|
+
end
|
|
80
|
+
|
|
81
|
+
module InstanceMethods
|
|
82
|
+
def country_name
|
|
83
|
+
country.name if country
|
|
84
|
+
end
|
|
85
|
+
end
|
|
86
|
+
end
|
|
87
|
+
|
|
88
|
+
module StateID
|
|
89
|
+
def self.included(base)
|
|
90
|
+
base.belongs_to :state, class_name: ::KirguduRefs::Globe::State, foreign_key: :state_id
|
|
91
|
+
base.scope :by_state, lambda { |value| base.where(state_id: value) if value }
|
|
92
|
+
|
|
93
|
+
base.class_eval do
|
|
94
|
+
include InstanceMethods
|
|
95
|
+
end
|
|
96
|
+
end
|
|
97
|
+
|
|
98
|
+
module InstanceMethods
|
|
99
|
+
def state_name
|
|
100
|
+
state.name if state
|
|
101
|
+
end
|
|
102
|
+
end
|
|
103
|
+
end
|
|
104
|
+
|
|
105
|
+
module RegionID
|
|
106
|
+
def self.included(base)
|
|
107
|
+
base.belongs_to :region, class_name: ::KirguduRefs::Globe::Region, foreign_key: :region_id
|
|
108
|
+
base.scope :by_region, lambda { |value| base.where(region_id: value) if value }
|
|
109
|
+
|
|
110
|
+
base.class_eval do
|
|
111
|
+
include InstanceMethods
|
|
112
|
+
end
|
|
113
|
+
end
|
|
114
|
+
|
|
115
|
+
module InstanceMethods
|
|
116
|
+
def region_name
|
|
117
|
+
region.name if region
|
|
118
|
+
end
|
|
119
|
+
end
|
|
120
|
+
end
|
|
121
|
+
|
|
122
|
+
module CityID
|
|
123
|
+
def self.included(base)
|
|
124
|
+
base.belongs_to :city, class_name: ::KirguduRefs::Globe::City, foreign_key: :city_id
|
|
125
|
+
base.scope :by_city, lambda { |value| base.where(city_id: value) if value }
|
|
126
|
+
|
|
127
|
+
base.class_eval do
|
|
128
|
+
include InstanceMethods
|
|
129
|
+
end
|
|
130
|
+
end
|
|
131
|
+
|
|
132
|
+
module InstanceMethods
|
|
133
|
+
def city_name
|
|
134
|
+
city.name if city
|
|
135
|
+
end
|
|
136
|
+
end
|
|
137
|
+
end
|
|
138
|
+
|
|
139
|
+
module CapitalID
|
|
140
|
+
def self.included(base)
|
|
141
|
+
base.belongs_to :capital, class_name: ::KirguduRefs::Globe::City, foreign_key: :capital_id
|
|
142
|
+
base.scope :by_capital, lambda { |value| base.where(capital_id: value) if value }
|
|
143
|
+
|
|
144
|
+
base.class_eval do
|
|
145
|
+
include InstanceMethods
|
|
146
|
+
end
|
|
147
|
+
end
|
|
148
|
+
|
|
149
|
+
module InstanceMethods
|
|
150
|
+
def capital_name
|
|
151
|
+
capital.name if capital
|
|
152
|
+
end
|
|
153
|
+
end
|
|
154
|
+
end
|
|
155
|
+
|
|
156
|
+
module ManufacturerID
|
|
157
|
+
def self.included(base)
|
|
158
|
+
base.belongs_to :manufacturer, class_name: ::KirguduRefs::Shops::Manufacturer, foreign_key: :manufacturer_id
|
|
159
|
+
base.scope :by_manufacturer, lambda { |value| base.where(manufacturer_id: value) if value }
|
|
160
|
+
|
|
161
|
+
base.class_eval do
|
|
162
|
+
include InstanceMethods
|
|
163
|
+
end
|
|
164
|
+
end
|
|
165
|
+
|
|
166
|
+
module InstanceMethods
|
|
167
|
+
def manufacturer_name
|
|
168
|
+
manufacturer.name if manufacturer
|
|
169
|
+
end
|
|
170
|
+
end
|
|
171
|
+
end
|
|
172
|
+
|
|
173
|
+
|
|
174
|
+
end
|
|
175
|
+
end
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
module KirguduRefs
|
|
2
|
+
class Globe::City < ::KirguduRefs::BaseModel
|
|
3
|
+
attr_accessible :area, :coordinates, :country_id, :name, :phone_code, :population, :region_id, :slug, :state_id, :description, :meta_keywords, :meta_description, :image_id
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
validates_presence_of :name, :country_id, :state_id, :slug
|
|
8
|
+
validates_uniqueness_of :name, :slug, scope: :state_id
|
|
9
|
+
validate_as_seo_tag :slug
|
|
10
|
+
|
|
11
|
+
include ::KirguduRefs::ModelBasicProperties::CountryID
|
|
12
|
+
include ::KirguduRefs::ModelBasicProperties::StateID
|
|
13
|
+
include ::KirguduRefs::ModelBasicProperties::RegionID
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
has_many :subway_lines, class_name: ::KirguduRefs::Globe::SubwayLine, foreign_key: :city_id, dependent: :destroy
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
scope :with_area_min, lambda { |value| where { area >= value } if value }
|
|
20
|
+
scope :with_area_max, lambda { |value| where { area <= value } if value }
|
|
21
|
+
scope :with_population_min, lambda { |value| where { population >= value } if value }
|
|
22
|
+
scope :with_population_max, lambda { |value| where { population <= value } if value }
|
|
23
|
+
|
|
24
|
+
scope :with_keyword, lambda { |value|
|
|
25
|
+
if value
|
|
26
|
+
value = value.gsub('%', ' ').strip
|
|
27
|
+
like_value ="%#{value}%"
|
|
28
|
+
where { (name.like like_value) | (slug.like like_value) }
|
|
29
|
+
end
|
|
30
|
+
}
|
|
31
|
+
scope :with_name, lambda { |value|
|
|
32
|
+
if value
|
|
33
|
+
value = value.gsub('%', ' ').strip
|
|
34
|
+
like_value ="%#{value}%"
|
|
35
|
+
where { name.like like_value }
|
|
36
|
+
end
|
|
37
|
+
}
|
|
38
|
+
scope :with_slug, lambda { |value|
|
|
39
|
+
if value
|
|
40
|
+
value = value.gsub('%', ' ').strip
|
|
41
|
+
like_value ="%#{value}%"
|
|
42
|
+
where { slug.like like_value }
|
|
43
|
+
end
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
def self.apply_filters_to_query(query, filters={})
|
|
48
|
+
filters ||= {}
|
|
49
|
+
|
|
50
|
+
query = query
|
|
51
|
+
.with_keyword(filters[:keyword])
|
|
52
|
+
.with_area_min(filters[:area_min])
|
|
53
|
+
.with_area_max(filters[:area_max])
|
|
54
|
+
.with_population_min(filters[:population_min])
|
|
55
|
+
.with_population_max(filters[:population_max])
|
|
56
|
+
.by_country(filters[:country_id])
|
|
57
|
+
.by_state(filters[:state_id])
|
|
58
|
+
.by_region(filters[:region_id])
|
|
59
|
+
|
|
60
|
+
super(query, filters)
|
|
61
|
+
end
|
|
62
|
+
|
|
63
|
+
|
|
64
|
+
def capital_name
|
|
65
|
+
capital.name if capital
|
|
66
|
+
end
|
|
67
|
+
|
|
68
|
+
def name_with_country_name
|
|
69
|
+
"#{name} (#{country_name})"
|
|
70
|
+
end
|
|
71
|
+
|
|
72
|
+
def name_with_country_name_and_state
|
|
73
|
+
"#{name} (#{country_name}, #{region_name})"
|
|
74
|
+
end
|
|
75
|
+
|
|
76
|
+
|
|
77
|
+
end
|
|
78
|
+
end
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
module KirguduRefs
|
|
2
|
+
class Globe::Country < ::KirguduRefs::BaseModel
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
attr_accessible :area, :iso2, :iso3, :name, :phone_code, :population, :slug, :currency_id, :capital_id, :meta_description, :meta_keywords, :description, :image_id
|
|
6
|
+
|
|
7
|
+
before_validation :normalize_values
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
include ::KirguduRefs::ModelBasicProperties::CurrencyID
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
belongs_to :capital, class_name: ::KirguduRefs::Globe::City, foreign_key: :capital_id
|
|
15
|
+
#belongs_to :image, class_name: ::ErpZone::Common::Image, foreign_key: :image_id
|
|
16
|
+
|
|
17
|
+
has_many :states, class_name: ::KirguduRefs::Globe::State, foreign_key: :country_id, dependent: :destroy
|
|
18
|
+
has_many :regions, class_name: ::KirguduRefs::Globe::Region, foreign_key: :country_id, dependent: :destroy
|
|
19
|
+
has_many :cities, class_name: ::KirguduRefs::Globe::City, foreign_key: :country_id, dependent: :destroy
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
validates_presence_of :name, :slug, :iso2
|
|
23
|
+
validates_uniqueness_of :name, :slug, :iso2, case_sensitive: false
|
|
24
|
+
validate_as_seo_tag :slug
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
scope :by_currency, lambda { |value| where(currency_id: value) if value }
|
|
31
|
+
scope :by_capital, lambda { |value| where(capital_id: value) if value }
|
|
32
|
+
|
|
33
|
+
scope :with_area_min, lambda { |value| where{ area >= value } if value }
|
|
34
|
+
scope :with_area_max, lambda { |value| where{ area <= value } if value }
|
|
35
|
+
scope :with_population_min, lambda { |value| where{ population >= value } if value }
|
|
36
|
+
scope :with_population_max, lambda { |value| where{ population <= value } if value }
|
|
37
|
+
|
|
38
|
+
scope :with_keyword, lambda { |value|
|
|
39
|
+
if value
|
|
40
|
+
value = value.gsub('%', ' ').strip
|
|
41
|
+
like_value ="%#{value}%"
|
|
42
|
+
where { (name.like like_value) | (slug.like like_value) }
|
|
43
|
+
end
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
def self.apply_filters_to_query(query, filters={})
|
|
47
|
+
filters ||= {}
|
|
48
|
+
|
|
49
|
+
query = query
|
|
50
|
+
.with_keyword(filters[:keyword])
|
|
51
|
+
.with_area_min(filters[:area_min])
|
|
52
|
+
.with_area_max(filters[:area_max])
|
|
53
|
+
.with_population_min(filters[:population_min])
|
|
54
|
+
.with_population_max(filters[:population_max])
|
|
55
|
+
.by_currency(filters[:currency_id])
|
|
56
|
+
.by_capital(filters[:capital_id])
|
|
57
|
+
|
|
58
|
+
super(query, filters)
|
|
59
|
+
end
|
|
60
|
+
|
|
61
|
+
def capital_name
|
|
62
|
+
capital.name if capital
|
|
63
|
+
end
|
|
64
|
+
|
|
65
|
+
|
|
66
|
+
private
|
|
67
|
+
def normalize_values
|
|
68
|
+
|
|
69
|
+
iso2.upcase!
|
|
70
|
+
iso2.strip!
|
|
71
|
+
if iso3
|
|
72
|
+
iso3.strip!
|
|
73
|
+
iso3.upcase!
|
|
74
|
+
end
|
|
75
|
+
name.capitalize!
|
|
76
|
+
end
|
|
77
|
+
|
|
78
|
+
end
|
|
79
|
+
end
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
module KirguduRefs
|
|
2
|
+
module Globe
|
|
3
|
+
class Region < ::KirguduRefs::BaseModel
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
attr_accessible :area, :coordinates, :country_id, :name, :phone_code, :population, :slug, :state_id, :capital_id, :description, :image_id, :meta_keywords, :meta_description
|
|
7
|
+
|
|
8
|
+
validates_presence_of :name, :country_id, :state_id, :slug
|
|
9
|
+
validates_presence_of :name, scope: :state_id
|
|
10
|
+
validates_uniqueness_of :name, :slug, scope: :state_id
|
|
11
|
+
validate_as_seo_tag :slug
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
include ::KirguduRefs::ModelBasicProperties::CountryID
|
|
16
|
+
include ::KirguduRefs::ModelBasicProperties::StateID
|
|
17
|
+
include ::KirguduRefs::ModelBasicProperties::CapitalID
|
|
18
|
+
|
|
19
|
+
has_many :cities, class_name: ::KirguduRefs::Globe::City, foreign_key: :region_id
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
######################################### SCOPES #############################################
|
|
25
|
+
|
|
26
|
+
scope :by_country, lambda { |value| where(country_id: value) if value }
|
|
27
|
+
scope :by_state, lambda { |value| where(state_id: value) if value }
|
|
28
|
+
scope :by_capital, lambda { |value| where(capital_id: value) if value }
|
|
29
|
+
|
|
30
|
+
scope :with_area_min, lambda { |value| where { area >= value } if value }
|
|
31
|
+
scope :with_area_max, lambda { |value| where { area <= value } if value }
|
|
32
|
+
scope :with_population_min, lambda { |value| where { population >= value } if value }
|
|
33
|
+
scope :with_population_max, lambda { |value| where { population <= value } if value }
|
|
34
|
+
|
|
35
|
+
scope :with_keyword, lambda { |value|
|
|
36
|
+
if value
|
|
37
|
+
value = value.gsub('%', ' ').strip
|
|
38
|
+
like_value ="%#{value}%"
|
|
39
|
+
where { (name.like like_value) | (slug.like like_value) }
|
|
40
|
+
end
|
|
41
|
+
}
|
|
42
|
+
scope :with_name, lambda { |value|
|
|
43
|
+
if value
|
|
44
|
+
value = value.gsub('%', ' ').strip
|
|
45
|
+
like_value ="%#{value}%"
|
|
46
|
+
where { name.like like_value }
|
|
47
|
+
end
|
|
48
|
+
}
|
|
49
|
+
scope :with_slug, lambda { |value|
|
|
50
|
+
if value
|
|
51
|
+
value = value.gsub('%', ' ').strip
|
|
52
|
+
like_value ="%#{value}%"
|
|
53
|
+
where { slug.like like_value }
|
|
54
|
+
end
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
def self.apply_filters_to_query(query, filters={})
|
|
58
|
+
filters ||= {}
|
|
59
|
+
|
|
60
|
+
query = query
|
|
61
|
+
.with_keyword(filters[:keyword])
|
|
62
|
+
.with_area_min(filters[:area_min])
|
|
63
|
+
.with_area_max(filters[:area_max])
|
|
64
|
+
.with_population_min(filters[:population_min])
|
|
65
|
+
.with_population_max(filters[:population_max])
|
|
66
|
+
.by_country(filters[:country_id])
|
|
67
|
+
.by_capital(filters[:capital_id])
|
|
68
|
+
.by_state(filters[:state_id])
|
|
69
|
+
|
|
70
|
+
super(query, filters)
|
|
71
|
+
end
|
|
72
|
+
|
|
73
|
+
|
|
74
|
+
end
|
|
75
|
+
end
|
|
76
|
+
end
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
module KirguduRefs
|
|
2
|
+
class Globe::State < ::KirguduRefs::BaseModel
|
|
3
|
+
attr_accessible :area, :coordinates, :country_id, :name, :phone_code, :population, :slug, :capital_id, :description, :image_id, :meta_keywords, :meta_description, :car_code
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
validates_presence_of :name, :country_id, :slug
|
|
7
|
+
validates_uniqueness_of :name, scope: :country_id
|
|
8
|
+
validates_uniqueness_of :slug, scope: :country_id
|
|
9
|
+
validate_as_seo_tag :slug
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
include ::KirguduRefs::ModelBasicProperties::CountryID
|
|
13
|
+
include ::KirguduRefs::ModelBasicProperties::CapitalID
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
has_many :regions, class_name: ::KirguduRefs::Globe::Region, foreign_key: :state_id
|
|
17
|
+
has_many :cities, class_name: ::KirguduRefs::Globe::City, foreign_key: :region_id
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
scope :by_country, lambda { |value| where(country_id: value) if value }
|
|
23
|
+
scope :by_capital, lambda { |value| where(capital_id: value) if value }
|
|
24
|
+
|
|
25
|
+
scope :with_area_min, lambda { |value| where { area >= value } if value }
|
|
26
|
+
scope :with_area_max, lambda { |value| where { area <= value } if value }
|
|
27
|
+
scope :with_population_min, lambda { |value| where { population >= value } if value }
|
|
28
|
+
scope :with_population_max, lambda { |value| where { population <= value } if value }
|
|
29
|
+
|
|
30
|
+
scope :with_keyword, lambda { |value|
|
|
31
|
+
if value
|
|
32
|
+
value = value.gsub('%', ' ').strip
|
|
33
|
+
like_value ="%#{value}%"
|
|
34
|
+
where { (name.like like_value) | (slug.like like_value) | (car_code.like like_value) }
|
|
35
|
+
end
|
|
36
|
+
}
|
|
37
|
+
scope :with_name, lambda { |value|
|
|
38
|
+
if value
|
|
39
|
+
value = value.gsub('%', ' ').strip
|
|
40
|
+
like_value ="%#{value}%"
|
|
41
|
+
where { name.like like_value }
|
|
42
|
+
end
|
|
43
|
+
}
|
|
44
|
+
scope :with_slug, lambda { |value|
|
|
45
|
+
if value
|
|
46
|
+
value = value.gsub('%', ' ').strip
|
|
47
|
+
like_value ="%#{value}%"
|
|
48
|
+
where { slug.like like_value }
|
|
49
|
+
end
|
|
50
|
+
}
|
|
51
|
+
scope :with_car_code, lambda { |value|
|
|
52
|
+
if value
|
|
53
|
+
value = value.gsub('%', ' ').strip
|
|
54
|
+
like_value ="%#{value}%"
|
|
55
|
+
where { car_code.like like_value }
|
|
56
|
+
end
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
def self.apply_filters_to_query(query, filters={})
|
|
60
|
+
filters ||= {}
|
|
61
|
+
|
|
62
|
+
query = query
|
|
63
|
+
.with_keyword(filters[:keyword])
|
|
64
|
+
.with_name(filters[:name])
|
|
65
|
+
.with_area_min(filters[:area_min])
|
|
66
|
+
.with_area_max(filters[:area_max])
|
|
67
|
+
.with_population_min(filters[:population_min])
|
|
68
|
+
.with_population_max(filters[:population_max])
|
|
69
|
+
.with_slug(filters[:name])
|
|
70
|
+
.by_country(filters[:country_id])
|
|
71
|
+
.by_capital(filters[:capital_id])
|
|
72
|
+
.with_car_code(filters[:car_code])
|
|
73
|
+
|
|
74
|
+
super(query, filters)
|
|
75
|
+
end
|
|
76
|
+
end
|
|
77
|
+
end
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
module KirguduRefs
|
|
2
|
+
class Globe::SubwayLine < ::KirguduRefs::BaseModel
|
|
3
|
+
|
|
4
|
+
attr_accessible :city_id, :description, :name, :color, :slug, :meta_keywords, :meta_description
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
include ::KirguduRefs::ModelBasicProperties::CityID
|
|
9
|
+
|
|
10
|
+
has_many :stations, class_name: ::KirguduRefs::Globe::SubwayStation, foreign_key: :line_id, dependent: :destroy
|
|
11
|
+
|
|
12
|
+
validates_presence_of :city_id, :name, :slug
|
|
13
|
+
validates_uniqueness_of :name, :slug, scope: :city_id, case_sensitive: false
|
|
14
|
+
validate_as_seo_tag :slug
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
scope :with_keyword, lambda { |value|
|
|
19
|
+
if value
|
|
20
|
+
value = value.gsub('%', ' ').strip
|
|
21
|
+
like_value ="%#{value}%"
|
|
22
|
+
where { (name.like like_value) | (slug.like like_value) }
|
|
23
|
+
end
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
scope :by_city, lambda { |value| where(city_id: value) if value }
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
def self.apply_filters_to_query(query, filters={})
|
|
32
|
+
filters ||={}
|
|
33
|
+
|
|
34
|
+
query = query
|
|
35
|
+
.with_keyword(filters[:keyword])
|
|
36
|
+
.by_city(filters[:city_id])
|
|
37
|
+
|
|
38
|
+
super(query, filters)
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
end
|
|
43
|
+
end
|