earth 0.0.28 → 0.0.29

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.
@@ -3,6 +3,19 @@ class Sector < ActiveRecord::Base
3
3
 
4
4
  has_many :product_lines_sectors, :class_name => 'ProductLinesSectors', :foreign_key => 'io_code'
5
5
 
6
+ class << self
7
+ def key_map
8
+ @key_map ||= sector_map.values.sort
9
+ end
10
+
11
+ def sector_map
12
+ @sector_map ||= Sector.all.inject({}) do |map, sector|
13
+ map[sector.description] = sector.io_code
14
+ map
15
+ end
16
+ end
17
+ end
18
+
6
19
  data_miner do
7
20
  schema Earth.database_options do
8
21
  string 'io_code'
@@ -0,0 +1,81 @@
1
+ require 'spec_helper'
2
+ Earth.init :industry, :apply_schemas => true
3
+
4
+ describe Sector do
5
+ def stub_sector
6
+ Sector.stub!(:all).
7
+ and_return([
8
+ mock(Sector, :io_code => '1', :description => 'Staples'),
9
+ mock(Sector, :io_code => '2', :description => 'Example'),
10
+ mock(Sector, :io_code => '3', :description => 'Pencils'),
11
+ mock(Sector, :io_code => '4', :description => 'Pens'),
12
+ mock(Sector, :io_code => '5', :description => 'Rulers'),
13
+ mock(Sector, :io_code => '6', :description => 'Printers'),
14
+ mock(Sector, :io_code => '7', :description => 'Computers'),
15
+ mock(Sector, :io_code => '8', :description => 'Ink'),
16
+ mock(Sector, :io_code => '9', :description => 'Paper'),
17
+ mock(Sector, :io_code => '10', :description => 'Furniture'),
18
+ mock(Sector, :io_code => '11', :description => 'Trucking'),
19
+ mock(Sector, :io_code => '12', :description => 'Sales'),
20
+ mock(Sector, :io_code => '13', :description => 'Strip Malls'),
21
+ mock(Sector, :io_code => '14', :description => 'Displays'),
22
+ mock(Sector, :io_code => '15', :description => 'Cameras'),
23
+ mock(Sector, :io_code => '16', :description => 'Scanners'),
24
+ mock(Sector, :io_code => '17', :description => 'Disks'),
25
+ mock(Sector, :io_code => '18', :description => 'Media'),
26
+ mock(Sector, :io_code => '19', :description => 'Hotel Industry'),
27
+ mock(Sector, :io_code => '20', :description => 'Example'),
28
+ mock(Sector, :io_code => 'A', :description => 'Young fantasy creature processing'),
29
+ mock(Sector, :io_code => 'B', :description => 'Adult fantasy creature processing'),
30
+ mock(Sector, :io_code => 'C', :description => 'Young fantasy creature freezing'),
31
+ mock(Sector, :io_code => 'D', :description => 'Adult fantasy creature freezing')
32
+ ])
33
+ end
34
+
35
+ describe 'key_map' do
36
+ before do
37
+ stub_sector
38
+ end
39
+
40
+ it 'should return a sorted list of keys' do
41
+ Sector.key_map[0..1].should == ['1','10']
42
+ Sector.key_map[21..22].should == ['C','D']
43
+ end
44
+ end
45
+
46
+ describe 'sector_map' do
47
+ before do
48
+ stub_sector
49
+ end
50
+
51
+ it 'should generate a hash mapping sector names to io codes' do
52
+ Sector.sector_map.should == {
53
+ 'Staples' => '1',
54
+ 'Example' => '2',
55
+ 'Pencils' => '3',
56
+ 'Pens' => '4',
57
+ 'Rulers' => '5',
58
+ 'Printers' => '6',
59
+ 'Computers' => '7',
60
+ 'Ink' => '8',
61
+ 'Paper' => '9',
62
+ 'Furniture' => '10',
63
+ 'Trucking' => '11',
64
+ 'Sales' => '12',
65
+ 'Strip Malls' => '13',
66
+ 'Displays' => '14',
67
+ 'Cameras' => '15',
68
+ 'Scanners' => '16',
69
+ 'Disks' => '17',
70
+ 'Media' => '18',
71
+ 'Hotel Industry' => '19',
72
+ 'Example' => '20',
73
+ 'Young fantasy creature processing' => 'A',
74
+ 'Adult fantasy creature processing' => 'B',
75
+ 'Young fantasy creature freezing' => 'C',
76
+ 'Adult fantasy creature freezing' => 'D'
77
+ }
78
+ end
79
+ end
80
+ end
81
+
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: earth
3
3
  version: !ruby/object:Gem::Version
4
- hash: 39
4
+ hash: 37
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 0
9
- - 28
10
- version: 0.0.28
9
+ - 29
10
+ version: 0.0.29
11
11
  platform: ruby
12
12
  authors:
13
13
  - Seamus Abshere
@@ -17,7 +17,7 @@ autorequire:
17
17
  bindir: bin
18
18
  cert_chain: []
19
19
 
20
- date: 2010-08-31 00:00:00 -04:00
20
+ date: 2010-09-03 00:00:00 -04:00
21
21
  default_executable:
22
22
  dependencies:
23
23
  - !ruby/object:Gem::Dependency
@@ -396,6 +396,7 @@ files:
396
396
  - vendor/geokit-rails/test/schema.rb
397
397
  - vendor/geokit-rails/test/tasks.rake
398
398
  - vendor/geokit-rails/test/test_helper.rb
399
+ - spec/lib/earth/industry/sector_spec.rb
399
400
  - spec/lib/earth_spec.rb
400
401
  - spec/spec_helper.rb
401
402
  - Gemfile
@@ -435,6 +436,7 @@ signing_key:
435
436
  specification_version: 3
436
437
  summary: Land, sky, and sea
437
438
  test_files:
439
+ - spec/lib/earth/industry/sector_spec.rb
438
440
  - spec/lib/earth_spec.rb
439
441
  - spec/spec_helper.rb
440
442
  - Gemfile