kirgudu_refs 0.0.2 → 0.0.3

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.
Files changed (66) hide show
  1. checksums.yaml +4 -4
  2. data/app/helpers/kirgudu_refs/model_basic_properties.rb +69 -0
  3. data/app/models/kirgudu_refs/base_model.rb +0 -8
  4. data/app/models/kirgudu_refs/finances.rb +7 -0
  5. data/app/models/kirgudu_refs/finances/bank.rb +116 -0
  6. data/app/models/kirgudu_refs/globe/city.rb +57 -57
  7. data/app/models/kirgudu_refs/globe/country.rb +69 -53
  8. data/app/models/kirgudu_refs/globe/region.rb +20 -25
  9. data/app/models/kirgudu_refs/globe/state.rb +58 -61
  10. data/app/models/kirgudu_refs/globe/subway_line.rb +29 -25
  11. data/app/models/kirgudu_refs/globe/subway_station.rb +43 -40
  12. data/app/models/kirgudu_refs/globe/timezone.rb +40 -5
  13. data/app/models/kirgudu_refs/it.rb +1 -1
  14. data/app/models/kirgudu_refs/it/encoding.rb +31 -28
  15. data/app/models/kirgudu_refs/it/hosting_type.rb +50 -0
  16. data/app/models/kirgudu_refs/it/operating_system.rb +34 -24
  17. data/app/models/kirgudu_refs/it/operating_system_family.rb +55 -4
  18. data/app/models/kirgudu_refs/it/processor_architecture.rb +32 -5
  19. data/app/models/kirgudu_refs/it/top_level_domain.rb +26 -0
  20. data/app/models/kirgudu_refs/it/website_type.rb +49 -0
  21. data/app/models/kirgudu_refs/national/currency.rb +59 -52
  22. data/app/models/kirgudu_refs/national/language.rb +84 -79
  23. data/app/models/kirgudu_refs/shops.rb +1 -1
  24. data/app/models/kirgudu_refs/shops/manufacturer.rb +37 -33
  25. data/config/database.yml +10 -0
  26. data/db/migrate/20130831122828_create_kirgudu_refs_it_operating_system_families.rb +12 -4
  27. data/db/migrate/20130831122900_create_kirgudu_refs_it_encodings.rb +12 -3
  28. data/db/migrate/20130831123418_create_kirgudu_refs_globe_cities.rb +17 -7
  29. data/db/migrate/20130831123443_create_kirgudu_refs_globe_regions.rb +17 -10
  30. data/db/migrate/20130831123613_create_kirgudu_refs_globe_states.rb +15 -8
  31. data/db/migrate/20130831123640_create_kirgudu_refs_globe_countries.rb +15 -7
  32. data/db/migrate/20130831124432_create_kirgudu_refs_globe_subway_lines.rb +18 -5
  33. data/db/migrate/20130831124648_create_kirgudu_refs_globe_subway_stations.rb +15 -6
  34. data/db/migrate/20130831125136_create_kirgudu_refs_globe_timezones.rb +13 -4
  35. data/db/migrate/20130831125626_create_kirgudu_refs_it_operating_systems.rb +14 -6
  36. data/db/migrate/20130831125703_create_kirgudu_refs_it_processor_architectures.rb +12 -3
  37. data/db/migrate/20130831130259_create_kirgudu_refs_national_currencies.rb +14 -6
  38. data/db/migrate/20130831130350_create_kirgudu_refs_national_languages.rb +11 -4
  39. data/db/migrate/20130831130436_create_kirgudu_refs_shops_manufacturers.rb +18 -6
  40. data/db/migrate/20140111155321_create_kirgudu_refs_it_website_types.rb +32 -0
  41. data/db/migrate/20140111155332_create_kirgudu_refs_it_hosting_types.rb +34 -0
  42. data/db/migrate/20140113072335_create_kirgudu_refs_it_top_level_domains.rb +36 -0
  43. data/db/migrate/20140215071954_create_kirgudu_refs_finances_banks.rb +60 -0
  44. data/test/dummy/config/application.rb +1 -1
  45. data/test/dummy/db/development.sqlite3 +0 -0
  46. data/test/dummy/db/schema.rb +551 -0
  47. data/test/dummy/log/development.log +285 -0
  48. data/test/fixtures/kirgudu_refs/finances/banks.yml +7 -0
  49. data/test/fixtures/kirgudu_refs/it/top_level_domains.yml +11 -0
  50. data/test/models/kirgudu_refs/finances/bank_test.rb +9 -0
  51. data/test/models/kirgudu_refs/it/top_level_domain_test.rb +9 -0
  52. metadata +37 -27
  53. data/db/migrate/20130902065049_fix_id_in_it_operating_system_families.rb +0 -9
  54. data/db/migrate/20130902065101_fix_id_in_it_encodings.rb +0 -9
  55. data/db/migrate/20130902065111_fix_id_in_globe_cities.rb +0 -10
  56. data/db/migrate/20130902065117_fix_id_in_globe_countries.rb +0 -9
  57. data/db/migrate/20130902065123_fix_id_in_globe_states.rb +0 -9
  58. data/db/migrate/20130902065131_fix_id_in_globe_regions.rb +0 -9
  59. data/db/migrate/20130902065943_fix_id_in_globe_subway_lines.rb +0 -9
  60. data/db/migrate/20130902065951_fix_id_in_globe_subway_stations.rb +0 -9
  61. data/db/migrate/20130902070323_fix_id_in_globe_timezones.rb +0 -9
  62. data/db/migrate/20130902070557_fix_id_in_national_currency.rb +0 -9
  63. data/db/migrate/20130902070604_fix_id_in_national_language.rb +0 -9
  64. data/db/migrate/20130902070628_fix_id_in_it_operating_system.rb +0 -9
  65. data/db/migrate/20130902070640_fix_id_in_it_processor_architecture.rb +0 -9
  66. 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
- attr_accessible :area, :coordinates, :country_id, :name, :phone_code, :population, :slug, :state_id, :capital_id, :description, :image_id, :meta_keywords, :meta_description
7
+ include ::KirguduBase::Models::BasicProperties::Portal
8
+ include ::KirguduBase::Models::BasicProperties::CreatedBy
9
+ include ::KirguduBase::Models::BasicProperties::UpdatedBy
7
10
 
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
-
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
- scope :by_country, lambda { |value| where(country_id: value) if value }
27
- scope :by_state, lambda { |value| where(state_id: value) if value }
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
- 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
2
+ module Globe
3
+ class State < ::KirguduRefs::BaseModel
4
4
 
5
+ ########################################## RELATIONS ########################################
5
6
 
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
7
+ include ::KirguduBase::Models::BasicProperties::Portal
8
+ include ::KirguduBase::Models::BasicProperties::CreatedBy
9
+ include ::KirguduBase::Models::BasicProperties::UpdatedBy
10
10
 
11
11
 
12
- include ::KirguduRefs::ModelBasicProperties::CountryID
13
- include ::KirguduRefs::ModelBasicProperties::CapitalID
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
- 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
+ ########################################## 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
- scope :by_country, lambda { |value| where(country_id: value) if value }
23
- scope :by_capital, lambda { |value| where(capital_id: value) if value }
31
+ ######################################### SCOPES #############################################
24
32
 
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 }
33
+ include ::KirguduBase::Models::Scopes::WithName
34
+ include ::KirguduBase::Models::Scopes::WithSlug
29
35
 
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 }
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
- class Globe::SubwayLine < ::KirguduRefs::BaseModel
2
+ module Globe
3
+ class SubwayLine < ::KirguduRefs::BaseModel
3
4
 
4
- attr_accessible :city_id, :description, :name, :color, :slug, :meta_keywords, :meta_description
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
- include ::KirguduRefs::ModelBasicProperties::CityID
13
+ has_many :stations, class_name: ::KirguduRefs::Globe::SubwayStation, foreign_key: :line_id, dependent: :destroy
9
14
 
10
- has_many :stations, class_name: ::KirguduRefs::Globe::SubwayStation, foreign_key: :line_id, dependent: :destroy
15
+ ######################################### SCOPES #############################################
11
16
 
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
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
- 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
+ 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
- scope :by_city, lambda { |value| where(city_id: value) if value }
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
- def self.apply_filters_to_query(query, filters={})
32
- filters ||={}
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
- class Globe::SubwayStation < ::KirguduRefs::BaseModel
2
+ module Globe
3
+ class SubwayStation < ::KirguduRefs::BaseModel
3
4
 
5
+ ########################################## RELATIONS ########################################
4
6
 
5
- attr_accessible :description, :latitude, :line_id, :longitude, :name, :next_station_id, :previous_station_id, :slug, :meta_keywords, :meta_description
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
- include ::KirguduRefs::ModelBasicProperties::CityID
13
+ belongs_to :line, class_name: ::KirguduRefs::Globe::SubwayLine, foreign_key: :line_id
9
14
 
10
- belongs_to :line, class_name: ::KirguduRefs::Globe::SubwayLine, foreign_key: :line_id
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
- belongs_to :previous_station, class_name: ::KirguduRefs::Globe::SubwayStation, foreign_key: :prev_id
13
- belongs_to :next_station, class_name: ::KirguduRefs::Globe::SubwayStation, foreign_key: :next_id
18
+ ########################################## VALIDATIONS #######################################
14
19
 
15
- validates_presence_of :line_id, :name, :slug
16
- validates_uniqueness_of :slug, scope: :line_id, case_sensitive: false
17
- validates_uniqueness_of :name, scope: :line_id, case_sensitive: false
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
- #in_transaction_after_create :process_prev_next_after_update
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
- def self.apply_filters_to_query(query, filters={})
40
- filters ||={}
46
+ query = query
47
+ .by_line(filters[:line_id])
48
+ .by_city(filters[:city_id])
41
49
 
42
- query = query
43
- .with_keyword(filters[:keyword])
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
- def line_name
53
- line.name if line
54
- end
58
+ def prev_name
59
+ previous_station.name if previous_station
60
+ end
55
61
 
56
- def prev_name
57
- previous_station.name if previous_station
58
- end
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
- class Globe::Timezone < ::KirguduRefs::BaseModel
3
- attr_accessible :country_id, :dst_offset, :gmt_offset, :name, :raw_offset
2
+ module Globe
3
+ class Timezone < ::KirguduRefs::BaseModel
4
4
 
5
+ ########################################## RELATIONS ########################################
5
6
 
6
- validate_as_seo_tag :slug
7
- end
8
- end
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
@@ -1,7 +1,7 @@
1
1
  module KirguduRefs
2
2
  module It
3
3
  def self.table_name_prefix
4
- 'it_'
4
+ 'kirgudu_refs_it_'
5
5
  end
6
6
  end
7
7
  end