kirgudu_refs 0.0.2 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/helpers/kirgudu_refs/model_basic_properties.rb +69 -0
- data/app/models/kirgudu_refs/base_model.rb +0 -8
- data/app/models/kirgudu_refs/finances.rb +7 -0
- data/app/models/kirgudu_refs/finances/bank.rb +116 -0
- data/app/models/kirgudu_refs/globe/city.rb +57 -57
- data/app/models/kirgudu_refs/globe/country.rb +69 -53
- data/app/models/kirgudu_refs/globe/region.rb +20 -25
- data/app/models/kirgudu_refs/globe/state.rb +58 -61
- data/app/models/kirgudu_refs/globe/subway_line.rb +29 -25
- data/app/models/kirgudu_refs/globe/subway_station.rb +43 -40
- data/app/models/kirgudu_refs/globe/timezone.rb +40 -5
- data/app/models/kirgudu_refs/it.rb +1 -1
- data/app/models/kirgudu_refs/it/encoding.rb +31 -28
- data/app/models/kirgudu_refs/it/hosting_type.rb +50 -0
- data/app/models/kirgudu_refs/it/operating_system.rb +34 -24
- data/app/models/kirgudu_refs/it/operating_system_family.rb +55 -4
- data/app/models/kirgudu_refs/it/processor_architecture.rb +32 -5
- data/app/models/kirgudu_refs/it/top_level_domain.rb +26 -0
- data/app/models/kirgudu_refs/it/website_type.rb +49 -0
- data/app/models/kirgudu_refs/national/currency.rb +59 -52
- data/app/models/kirgudu_refs/national/language.rb +84 -79
- data/app/models/kirgudu_refs/shops.rb +1 -1
- data/app/models/kirgudu_refs/shops/manufacturer.rb +37 -33
- data/config/database.yml +10 -0
- data/db/migrate/20130831122828_create_kirgudu_refs_it_operating_system_families.rb +12 -4
- data/db/migrate/20130831122900_create_kirgudu_refs_it_encodings.rb +12 -3
- data/db/migrate/20130831123418_create_kirgudu_refs_globe_cities.rb +17 -7
- data/db/migrate/20130831123443_create_kirgudu_refs_globe_regions.rb +17 -10
- data/db/migrate/20130831123613_create_kirgudu_refs_globe_states.rb +15 -8
- data/db/migrate/20130831123640_create_kirgudu_refs_globe_countries.rb +15 -7
- data/db/migrate/20130831124432_create_kirgudu_refs_globe_subway_lines.rb +18 -5
- data/db/migrate/20130831124648_create_kirgudu_refs_globe_subway_stations.rb +15 -6
- data/db/migrate/20130831125136_create_kirgudu_refs_globe_timezones.rb +13 -4
- data/db/migrate/20130831125626_create_kirgudu_refs_it_operating_systems.rb +14 -6
- data/db/migrate/20130831125703_create_kirgudu_refs_it_processor_architectures.rb +12 -3
- data/db/migrate/20130831130259_create_kirgudu_refs_national_currencies.rb +14 -6
- data/db/migrate/20130831130350_create_kirgudu_refs_national_languages.rb +11 -4
- data/db/migrate/20130831130436_create_kirgudu_refs_shops_manufacturers.rb +18 -6
- data/db/migrate/20140111155321_create_kirgudu_refs_it_website_types.rb +32 -0
- data/db/migrate/20140111155332_create_kirgudu_refs_it_hosting_types.rb +34 -0
- data/db/migrate/20140113072335_create_kirgudu_refs_it_top_level_domains.rb +36 -0
- data/db/migrate/20140215071954_create_kirgudu_refs_finances_banks.rb +60 -0
- data/test/dummy/config/application.rb +1 -1
- data/test/dummy/db/development.sqlite3 +0 -0
- data/test/dummy/db/schema.rb +551 -0
- data/test/dummy/log/development.log +285 -0
- data/test/fixtures/kirgudu_refs/finances/banks.yml +7 -0
- data/test/fixtures/kirgudu_refs/it/top_level_domains.yml +11 -0
- data/test/models/kirgudu_refs/finances/bank_test.rb +9 -0
- data/test/models/kirgudu_refs/it/top_level_domain_test.rb +9 -0
- metadata +37 -27
- data/db/migrate/20130902065049_fix_id_in_it_operating_system_families.rb +0 -9
- data/db/migrate/20130902065101_fix_id_in_it_encodings.rb +0 -9
- data/db/migrate/20130902065111_fix_id_in_globe_cities.rb +0 -10
- data/db/migrate/20130902065117_fix_id_in_globe_countries.rb +0 -9
- data/db/migrate/20130902065123_fix_id_in_globe_states.rb +0 -9
- data/db/migrate/20130902065131_fix_id_in_globe_regions.rb +0 -9
- data/db/migrate/20130902065943_fix_id_in_globe_subway_lines.rb +0 -9
- data/db/migrate/20130902065951_fix_id_in_globe_subway_stations.rb +0 -9
- data/db/migrate/20130902070323_fix_id_in_globe_timezones.rb +0 -9
- data/db/migrate/20130902070557_fix_id_in_national_currency.rb +0 -9
- data/db/migrate/20130902070604_fix_id_in_national_language.rb +0 -9
- data/db/migrate/20130902070628_fix_id_in_it_operating_system.rb +0 -9
- data/db/migrate/20130902070640_fix_id_in_it_processor_architecture.rb +0 -9
- data/db/migrate/20130902070659_fix_id_in_shops_manufacturer.rb +0 -9
@@ -2,29 +2,39 @@ module KirguduRefs
|
|
2
2
|
module Globe
|
3
3
|
class Region < ::KirguduRefs::BaseModel
|
4
4
|
|
5
|
+
########################################## RELATIONS ########################################
|
5
6
|
|
6
|
-
|
7
|
+
include ::KirguduBase::Models::BasicProperties::Portal
|
8
|
+
include ::KirguduBase::Models::BasicProperties::CreatedBy
|
9
|
+
include ::KirguduBase::Models::BasicProperties::UpdatedBy
|
7
10
|
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
validate_as_seo_tag :slug
|
12
|
-
|
13
|
-
|
11
|
+
include ::KirguduRefs::ModelBasicProperties::CountryID
|
12
|
+
include ::KirguduRefs::ModelBasicProperties::StateID
|
13
|
+
include ::KirguduRefs::ModelBasicProperties::RegionID
|
14
14
|
|
15
15
|
include ::KirguduRefs::ModelBasicProperties::CountryID
|
16
16
|
include ::KirguduRefs::ModelBasicProperties::StateID
|
17
17
|
include ::KirguduRefs::ModelBasicProperties::CapitalID
|
18
|
-
|
18
|
+
|
19
19
|
has_many :cities, class_name: ::KirguduRefs::Globe::City, foreign_key: :region_id
|
20
20
|
|
21
|
+
########################################## VALIDATIONS #######################################
|
21
22
|
|
23
|
+
validates_presence_of :name, :country_id, :state_id, :slug
|
24
|
+
validates_presence_of :name, scope: :state_id
|
25
|
+
validates_uniqueness_of :name, :slug, scope: :country_id
|
26
|
+
|
27
|
+
validates_length_of :name, maximum: 128
|
28
|
+
validates_length_of :slug, maximum: 128
|
29
|
+
validate_as_seo_tag :slug, allow_blank: true
|
22
30
|
|
23
31
|
|
24
32
|
######################################### SCOPES #############################################
|
25
33
|
|
26
|
-
|
27
|
-
|
34
|
+
include ::KirguduBase::Models::Scopes::WithName
|
35
|
+
include ::KirguduBase::Models::Scopes::WithSlug
|
36
|
+
|
37
|
+
|
28
38
|
scope :by_capital, lambda { |value| where(capital_id: value) if value }
|
29
39
|
|
30
40
|
scope :with_area_min, lambda { |value| where { area >= value } if value }
|
@@ -39,26 +49,11 @@ module KirguduRefs
|
|
39
49
|
where { (name.like like_value) | (slug.like like_value) }
|
40
50
|
end
|
41
51
|
}
|
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
52
|
|
57
53
|
def self.apply_filters_to_query(query, filters={})
|
58
54
|
filters ||= {}
|
59
55
|
|
60
56
|
query = query
|
61
|
-
.with_keyword(filters[:keyword])
|
62
57
|
.with_area_min(filters[:area_min])
|
63
58
|
.with_area_max(filters[:area_max])
|
64
59
|
.with_population_min(filters[:population_min])
|
@@ -1,77 +1,74 @@
|
|
1
1
|
module KirguduRefs
|
2
|
-
|
3
|
-
|
2
|
+
module Globe
|
3
|
+
class State < ::KirguduRefs::BaseModel
|
4
4
|
|
5
|
+
########################################## RELATIONS ########################################
|
5
6
|
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
validate_as_seo_tag :slug
|
7
|
+
include ::KirguduBase::Models::BasicProperties::Portal
|
8
|
+
include ::KirguduBase::Models::BasicProperties::CreatedBy
|
9
|
+
include ::KirguduBase::Models::BasicProperties::UpdatedBy
|
10
10
|
|
11
11
|
|
12
|
-
|
13
|
-
|
12
|
+
include ::KirguduRefs::ModelBasicProperties::CountryID
|
13
|
+
include ::KirguduRefs::ModelBasicProperties::CapitalID
|
14
14
|
|
15
|
+
has_many :regions, class_name: ::KirguduRefs::Globe::Region, foreign_key: :state_id
|
16
|
+
has_many :cities, class_name: ::KirguduRefs::Globe::City, foreign_key: :region_id
|
15
17
|
|
16
|
-
|
17
|
-
has_many :cities, class_name: ::KirguduRefs::Globe::City, foreign_key: :region_id
|
18
|
+
########################################## VALIDATIONS #######################################
|
18
19
|
|
20
|
+
validates_presence_of :name, :country_id, :slug
|
21
|
+
validates_uniqueness_of :name, scope: :country_id, case_sensitive: false
|
22
|
+
validates_uniqueness_of :slug, scope: :country_id, case_sensitive: false
|
19
23
|
|
24
|
+
validates_length_of :name, maximum: 128, allow_blank: true
|
25
|
+
validates_length_of :slug, maximum: 128, allow_blank: true
|
26
|
+
validate_as_seo_tag :slug, allow_nil: true
|
20
27
|
|
28
|
+
validates_length_of :meta_keywords, maximum: 200, allow_blank: true
|
29
|
+
validates_length_of :meta_description, maximum: 200, allow_blank: true
|
21
30
|
|
22
|
-
|
23
|
-
scope :by_capital, lambda { |value| where(capital_id: value) if value }
|
31
|
+
######################################### SCOPES #############################################
|
24
32
|
|
25
|
-
|
26
|
-
|
27
|
-
scope :with_population_min, lambda { |value| where { population >= value } if value }
|
28
|
-
scope :with_population_max, lambda { |value| where { population <= value } if value }
|
33
|
+
include ::KirguduBase::Models::Scopes::WithName
|
34
|
+
include ::KirguduBase::Models::Scopes::WithSlug
|
29
35
|
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
36
|
+
scope :by_capital, lambda { |value| where(capital_id: value) if value }
|
37
|
+
|
38
|
+
scope :with_area_min, lambda { |value| where { area >= value } if value }
|
39
|
+
scope :with_area_max, lambda { |value| where { area <= value } if value }
|
40
|
+
scope :with_population_min, lambda { |value| where { population >= value } if value }
|
41
|
+
scope :with_population_max, lambda { |value| where { population <= value } if value }
|
42
|
+
|
43
|
+
scope :with_keyword, lambda { |value|
|
44
|
+
if value
|
45
|
+
value = value.gsub('%', ' ').strip
|
46
|
+
like_value ="%#{value}%"
|
47
|
+
where { (name.like like_value) | (slug.like like_value) | (car_code.like like_value) }
|
48
|
+
end
|
49
|
+
}
|
50
|
+
scope :with_car_code, lambda { |value|
|
51
|
+
if value
|
52
|
+
value = value.gsub('%', ' ').strip
|
53
|
+
like_value ="%#{value}%"
|
54
|
+
where { car_code.like like_value }
|
55
|
+
end
|
56
|
+
}
|
57
|
+
|
58
|
+
def self.apply_filters_to_query(query, filters={})
|
59
|
+
filters ||= {}
|
60
|
+
|
61
|
+
query = query
|
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
|
+
.with_car_code(filters[:car_code])
|
69
|
+
|
70
|
+
super(query, filters)
|
56
71
|
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
72
|
end
|
76
73
|
end
|
77
|
-
end
|
74
|
+
end
|
@@ -1,43 +1,47 @@
|
|
1
1
|
module KirguduRefs
|
2
|
-
|
2
|
+
module Globe
|
3
|
+
class SubwayLine < ::KirguduRefs::BaseModel
|
3
4
|
|
4
|
-
|
5
|
+
########################################## RELATIONS ########################################
|
5
6
|
|
7
|
+
include ::KirguduBase::Models::BasicProperties::Portal
|
8
|
+
include ::KirguduBase::Models::BasicProperties::CreatedBy
|
9
|
+
include ::KirguduBase::Models::BasicProperties::UpdatedBy
|
6
10
|
|
11
|
+
include ::KirguduRefs::ModelBasicProperties::CityID
|
7
12
|
|
8
|
-
|
13
|
+
has_many :stations, class_name: ::KirguduRefs::Globe::SubwayStation, foreign_key: :line_id, dependent: :destroy
|
9
14
|
|
10
|
-
|
15
|
+
######################################### SCOPES #############################################
|
11
16
|
|
12
|
-
|
13
|
-
|
14
|
-
validate_as_seo_tag :slug
|
17
|
+
validates_presence_of :city_id, :name, :slug
|
18
|
+
validates_uniqueness_of :name, :slug, scope: :city_id, case_sensitive: false
|
15
19
|
|
20
|
+
validates_length_of :name, maximum: 128, allow_blank: true
|
21
|
+
validates_length_of :slug, maximum: 128, allow_blank: true
|
22
|
+
validate_as_seo_tag :slug, allow_nil: true
|
16
23
|
|
24
|
+
########################################## VALIDATIONS #######################################
|
17
25
|
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
+
scope :with_keyword, lambda { |value|
|
27
|
+
if value
|
28
|
+
value = value.gsub('%', ' ').strip
|
29
|
+
like_value ="%#{value}%"
|
30
|
+
where { (name.like like_value) | (slug.like like_value) }
|
31
|
+
end
|
32
|
+
}
|
26
33
|
|
27
34
|
|
28
|
-
|
35
|
+
def self.apply_filters_to_query(query, filters={})
|
36
|
+
filters ||={}
|
29
37
|
|
38
|
+
query = query
|
39
|
+
.by_city(filters[:city_id])
|
30
40
|
|
31
|
-
|
32
|
-
|
41
|
+
super(query, filters)
|
42
|
+
end
|
33
43
|
|
34
|
-
query = query
|
35
|
-
.with_keyword(filters[:keyword])
|
36
|
-
.by_city(filters[:city_id])
|
37
44
|
|
38
|
-
super(query, filters)
|
39
45
|
end
|
40
|
-
|
41
|
-
|
42
46
|
end
|
43
|
-
end
|
47
|
+
end
|
@@ -1,65 +1,68 @@
|
|
1
1
|
module KirguduRefs
|
2
|
-
|
2
|
+
module Globe
|
3
|
+
class SubwayStation < ::KirguduRefs::BaseModel
|
3
4
|
|
5
|
+
########################################## RELATIONS ########################################
|
4
6
|
|
5
|
-
|
7
|
+
include ::KirguduBase::Models::BasicProperties::Portal
|
8
|
+
include ::KirguduBase::Models::BasicProperties::CreatedBy
|
9
|
+
include ::KirguduBase::Models::BasicProperties::UpdatedBy
|
6
10
|
|
11
|
+
include ::KirguduRefs::ModelBasicProperties::CityID
|
7
12
|
|
8
|
-
|
13
|
+
belongs_to :line, class_name: ::KirguduRefs::Globe::SubwayLine, foreign_key: :line_id
|
9
14
|
|
10
|
-
|
15
|
+
belongs_to :previous_station, class_name: ::KirguduRefs::Globe::SubwayStation, foreign_key: :prev_id
|
16
|
+
belongs_to :next_station, class_name: ::KirguduRefs::Globe::SubwayStation, foreign_key: :next_id
|
11
17
|
|
12
|
-
|
13
|
-
belongs_to :next_station, class_name: ::KirguduRefs::Globe::SubwayStation, foreign_key: :next_id
|
18
|
+
########################################## VALIDATIONS #######################################
|
14
19
|
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
validate_as_seo_tag :slug
|
20
|
+
validates_presence_of :line_id, :name, :slug
|
21
|
+
validates_uniqueness_of :slug, scope: :line_id, case_sensitive: false
|
22
|
+
validates_uniqueness_of :name, scope: :line_id, case_sensitive: false
|
19
23
|
|
20
24
|
|
21
|
-
|
25
|
+
validates_length_of :name, maximum: 128, allow_blank: true
|
26
|
+
validates_length_of :slug, maximum: 128, allow_blank: true
|
27
|
+
validate_as_seo_tag :slug, allow_nil: true
|
22
28
|
|
29
|
+
######################################### SCOPES #############################################
|
23
30
|
|
31
|
+
scope :with_keyword, lambda { |value|
|
32
|
+
if value
|
33
|
+
value = value.gsub('%', ' ').strip
|
34
|
+
like_value ="%#{value}%"
|
35
|
+
where { (name.like like_value) | (slug.like like_value) }
|
36
|
+
end
|
37
|
+
}
|
24
38
|
|
25
39
|
|
40
|
+
scope :by_line, lambda { |value| where(line_id: value) if value }
|
26
41
|
|
27
|
-
scope :with_keyword, lambda { |value|
|
28
|
-
if value
|
29
|
-
value = value.gsub('%', ' ').strip
|
30
|
-
like_value ="%#{value}%"
|
31
|
-
where { (name.like like_value) | (slug.like like_value) }
|
32
|
-
end
|
33
|
-
}
|
34
|
-
|
35
|
-
|
36
|
-
scope :by_line, lambda { |value| where(line_id: value) if value }
|
37
42
|
|
43
|
+
def self.apply_filters_to_query(query, filters={})
|
44
|
+
filters ||={}
|
38
45
|
|
39
|
-
|
40
|
-
|
46
|
+
query = query
|
47
|
+
.by_line(filters[:line_id])
|
48
|
+
.by_city(filters[:city_id])
|
41
49
|
|
42
|
-
|
43
|
-
|
44
|
-
.by_line(filters[:line_id])
|
45
|
-
.by_city(filters[:city_id])
|
46
|
-
|
47
|
-
super(query, filters)
|
48
|
-
end
|
50
|
+
super(query, filters)
|
51
|
+
end
|
49
52
|
|
50
53
|
|
54
|
+
def line_name
|
55
|
+
line.name if line
|
56
|
+
end
|
51
57
|
|
52
|
-
|
53
|
-
|
54
|
-
|
58
|
+
def prev_name
|
59
|
+
previous_station.name if previous_station
|
60
|
+
end
|
55
61
|
|
56
|
-
|
57
|
-
|
58
|
-
|
62
|
+
def next_name
|
63
|
+
next_station.name if next_station
|
64
|
+
end
|
59
65
|
|
60
|
-
def next_name
|
61
|
-
next_station.name if next_station
|
62
66
|
end
|
63
|
-
|
64
67
|
end
|
65
|
-
end
|
68
|
+
end
|
@@ -1,8 +1,43 @@
|
|
1
1
|
module KirguduRefs
|
2
|
-
|
3
|
-
|
2
|
+
module Globe
|
3
|
+
class Timezone < ::KirguduRefs::BaseModel
|
4
4
|
|
5
|
+
########################################## RELATIONS ########################################
|
5
6
|
|
6
|
-
|
7
|
-
|
8
|
-
|
7
|
+
include ::KirguduBase::Models::BasicProperties::Portal
|
8
|
+
include ::KirguduBase::Models::BasicProperties::CreatedBy
|
9
|
+
include ::KirguduBase::Models::BasicProperties::UpdatedBy
|
10
|
+
|
11
|
+
include ::KirguduRefs::ModelBasicProperties::CountryID
|
12
|
+
|
13
|
+
########################################## VALIDATIONS #######################################
|
14
|
+
|
15
|
+
validates_presence_of :name, :slug, :country_id
|
16
|
+
validates_uniqueness_of :name, :slug, case_sensitive: false, scope: :portal_id
|
17
|
+
|
18
|
+
validates_length_of :name, maximum: 128, allow_blank: true
|
19
|
+
validates_length_of :slug, maximum: 128, allow_blank: true
|
20
|
+
validate_as_seo_tag :slug, allow_nil: true
|
21
|
+
|
22
|
+
######################################### SCOPES #############################################
|
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
|
+
|
32
|
+
def self.apply_filters_to_query(query, filters={})
|
33
|
+
filters ||={}
|
34
|
+
|
35
|
+
query = query
|
36
|
+
.by_country(filters[:country_id])
|
37
|
+
|
38
|
+
super(query, filters)
|
39
|
+
end
|
40
|
+
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|