shack_kit 0.1.1 → 0.1.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,6 +1,7 @@
1
1
  require 'fileutils'
2
2
  require 'sqlite3'
3
3
  require 'sequel'
4
+ require 'simple-spreadsheet'
4
5
 
5
6
  module ShackKit
6
7
  module Data
@@ -25,11 +26,15 @@ module ShackKit
25
26
 
26
27
  def db_load
27
28
  SOTACalls.update
29
+ SOTASummits.update
28
30
  SPCalls.update
29
31
  end
30
32
  end
31
33
  end
32
34
  end
33
35
 
36
+ ShackKit::Data.schema_update
37
+
34
38
  require 'shack_kit/data/sota_calls'
39
+ require 'shack_kit/data/sota_summits'
35
40
  require 'shack_kit/data/sp_calls'
@@ -1,7 +1,7 @@
1
1
  module ShackKit
2
2
  module Data
3
3
  class SOTACalls
4
- def self.update(source_file=SOURCES_DIR+"/masterSOTA.scp")
4
+ def self.update(source_file = SOURCES_DIR + "/masterSOTA.scp")
5
5
  calls = DB[:sota_calls]
6
6
  calls.delete
7
7
  File.foreach(source_file) do |line|
@@ -0,0 +1,37 @@
1
+ module ShackKit
2
+ module Data
3
+ class SOTASummits
4
+ def self.update(source_file = SOURCES_DIR + "/summitslist.csv")
5
+ summits = DB[:sota_summits]
6
+ summits.delete
7
+ csv = SimpleSpreadsheet::Workbook.read(source_file, ".csv")
8
+ 3.upto(csv.last_row) do |line|
9
+ summits.insert(
10
+ summit_code: csv.cell(line, 1),
11
+ association_name: csv.cell(line, 2),
12
+ region_name: csv.cell(line, 3),
13
+ summit_name: csv.cell(line, 4),
14
+ alt_m: csv.cell(line, 5).to_i,
15
+ alt_ft: csv.cell(line, 6).to_i,
16
+ grid_ref1: csv.cell(line, 7),
17
+ grid_ref2: csv.cell(line, 8),
18
+ longitude: csv.cell(line, 9).to_f,
19
+ latitude: csv.cell(line, 10).to_f,
20
+ points: csv.cell(line, 11).to_i,
21
+ bonus_points: csv.cell(line, 12).to_i,
22
+ valid_from: Date.parse(csv.cell(line, 13)),
23
+ valid_to: Date.parse(csv.cell(line, 14)),
24
+ activation_count: csv.cell(line, 15).to_i,
25
+ activation_date: csv.cell(line, 16).nil? ? nil : Date.parse(csv.cell(line, 16)),
26
+ activation_call: csv.cell(line, 17)
27
+ )
28
+ end
29
+ summits.count
30
+ end
31
+
32
+ def self.check(reference)
33
+ DB[:sota_summits].where(summit_code: reference).first
34
+ end
35
+ end
36
+ end
37
+ end
@@ -1,28 +1,22 @@
1
- require 'simple-spreadsheet'
2
-
3
1
  module ShackKit
4
2
  module Data
5
3
  class SPCalls
6
- SOURCE_SHEETS = %w(Indywidualne Kluby)
7
-
8
- def self.update(source_file=SOURCES_DIR+"/201511\ -\ RA2WWW_ok.xls")
4
+ def self.update(source_file = SOURCES_DIR + "/individuals_2016-04-01.csv", *other_source_files)
5
+ sources = [source_file] + other_source_files
9
6
  calls = DB[:sp_calls]
10
7
  calls.delete
11
- xls = SimpleSpreadsheet::Workbook.read(source_file)
12
- SOURCE_SHEETS.each do |sheet_name|
13
- sheet_index = xls.sheets.index(sheet_name)
14
- xls.selected_sheet = xls.sheets[sheet_index]
15
- xls.first_row.upto(xls.last_row) do |row|
16
- next if xls.cell(row,1) == "nazwa_uke"
8
+ sources.each do |source_file|
9
+ CSV.foreach(source_file, col_sep: ";", encoding: "Windows-1250:UTF-8", headers: true) do |row|
10
+ individual = row["operator_1"].nil?
17
11
  calls.insert(
18
- callsign: xls.cell(row, 4),
19
- station_type: sheet_name == "Kluby" ? 'club' : 'individual',
20
- uke_branch: xls.cell(row, 1),
21
- licence_number: xls.cell(row, 2),
22
- valid_until: xls.cell(row, 3),
23
- licence_category: xls.cell(row, 5),
24
- tx_power: xls.cell(row, 6).to_i,
25
- station_location: xls.cell(row, sheet_name == "Kluby" ? 20 : 7)
12
+ callsign: row["call_sign"],
13
+ station_type: individual ? "individual" : "club",
14
+ uke_branch: row["department"],
15
+ licence_number: row["number"],
16
+ valid_until: Date.parse(row["valid_to"]),
17
+ licence_category: row["category"],
18
+ tx_power: row["transmitter_power"].to_i,
19
+ station_location: individual ? row["station_location"] : row["station_city"]
26
20
  )
27
21
  end
28
22
  end
@@ -1,3 +1,3 @@
1
1
  module ShackKit
2
- VERSION = "0.1.1"
2
+ VERSION = "0.1.2"
3
3
  end
data/shack_kit.gemspec CHANGED
@@ -10,10 +10,12 @@ Gem::Specification.new do |spec|
10
10
  spec.email = ["bajer@tigana.pl"]
11
11
 
12
12
  spec.summary = "Set of HAM radio tools packaged by SQ9OZM"
13
- spec.description = "currently limited to SP and SOTA-related stuff"
13
+ spec.description = "Set of HAM radio tools, currently limited to SP and SOTA-related stuff"
14
14
  spec.homepage = "https://github.com/rrrodrigo/shack_kit"
15
15
  spec.license = "MIT"
16
16
 
17
+ spec.required_ruby_version = '>= 2.0.0'
18
+
17
19
  # Prevent pushing this gem to RubyGems.org by setting 'allowed_push_host', or
18
20
  # delete this section to allow pushing this gem to any host.
19
21
  if spec.respond_to?(:metadata)
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: shack_kit
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Marcin Bajer
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2015-11-27 00:00:00.000000000 Z
11
+ date: 2016-04-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -126,7 +126,7 @@ dependencies:
126
126
  - - ">="
127
127
  - !ruby/object:Gem::Version
128
128
  version: 0.4.1
129
- description: currently limited to SP and SOTA-related stuff
129
+ description: Set of HAM radio tools, currently limited to SP and SOTA-related stuff
130
130
  email:
131
131
  - bajer@tigana.pl
132
132
  executables: []
@@ -137,6 +137,7 @@ files:
137
137
  - ".ruby-gemset"
138
138
  - ".ruby-version"
139
139
  - ".travis.yml"
140
+ - CHANGELOG.md
140
141
  - Gemfile
141
142
  - LICENSE.txt
142
143
  - README.md
@@ -145,11 +146,16 @@ files:
145
146
  - bin/setup
146
147
  - db/migrations/001_create_sota_calls.rb
147
148
  - db/migrations/002_create_sp_calls.rb
149
+ - db/migrations/003_create_sota_summits.rb
148
150
  - db/sources/201511 - RA2WWW_ok.xls
151
+ - db/sources/clubs_2016-04-01.csv
152
+ - db/sources/individuals_2016-04-01.csv
149
153
  - db/sources/masterSOTA.scp
154
+ - db/sources/summitslist.csv
150
155
  - lib/shack_kit.rb
151
156
  - lib/shack_kit/data/base.rb
152
157
  - lib/shack_kit/data/sota_calls.rb
158
+ - lib/shack_kit/data/sota_summits.rb
153
159
  - lib/shack_kit/data/sp_calls.rb
154
160
  - lib/shack_kit/version.rb
155
161
  - shack_kit.gemspec
@@ -166,7 +172,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
166
172
  requirements:
167
173
  - - ">="
168
174
  - !ruby/object:Gem::Version
169
- version: '0'
175
+ version: 2.0.0
170
176
  required_rubygems_version: !ruby/object:Gem::Requirement
171
177
  requirements:
172
178
  - - ">="
@@ -174,7 +180,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
174
180
  version: '0'
175
181
  requirements: []
176
182
  rubyforge_project:
177
- rubygems_version: 2.4.5.1
183
+ rubygems_version: 2.4.6
178
184
  signing_key:
179
185
  specification_version: 4
180
186
  summary: Set of HAM radio tools packaged by SQ9OZM