ruby-pota-csv-to-adif 0.0.1

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 ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 88b6691fc7f3ae4eaf7f54422b5db20a2fdb50653a30bc6a431c93da04329cd3
4
+ data.tar.gz: '0688ff4ce576e0a54b69a6b3ab1133a0d6937d783356602cc38e775b14517ada'
5
+ SHA512:
6
+ metadata.gz: 10268ce00497132bb11871cc4e41236af6fd48fa02156b8e3fab92e98fbc48ef8da3e97fccb1959f636a10c8a17e7cf315a9067cdf27f6e0b08d9d14bd41dae7
7
+ data.tar.gz: 2c17835f5ca7faa66a32dcacbd8aad922384925e56dad4b3f92f61cf2b7cbe1aec4b4bb7271ae1104435d43c1f4cfcacf4db99f5cbe0895b2128cc3d94ea0a9d
@@ -0,0 +1,6 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'ruby-pota-csv-to-adif'
4
+
5
+ log_file = ::PotaCsvToAdif::LogFile.new(ARGV[0])
6
+ log_file.convert
@@ -0,0 +1,65 @@
1
+ # Copyright (c) 2021 Edward Copony
2
+ #
3
+ # Permission is hereby granted, free of charge, to any person obtaining a copy
4
+ # of this software and associated documentation files (the "Software"), to deal
5
+ # in the Software without restriction, including without limitation the rights
6
+ # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7
+ # copies of the Software, and to permit persons to whom the Software is
8
+ # furnished to do so, subject to the following conditions:
9
+ #
10
+ # The above copyright notice and this permission notice shall be included in all
11
+ # copies or substantial portions of the Software.
12
+ #
13
+ # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14
+ # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15
+ # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16
+ # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17
+ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18
+ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
19
+ # SOFTWARE.
20
+
21
+ require 'csv'
22
+
23
+ module PotaCsvToAdif
24
+ class LogFile
25
+ def initialize(file_path)
26
+ @file_path = file_path
27
+ end
28
+
29
+ def convert
30
+ file = File.open(file_path)
31
+ csv = CSV.new(file, headers: true)
32
+ adif_file = File.new("#{file_path[0...file_path.rindex('.')]}.adi", 'w')
33
+
34
+ adif_file.puts header
35
+
36
+ csv.each do |row|
37
+ adif_file.puts "#{field('CALL', row)}#{field('QSO_DATE', row)}#{field('TIME_ON', row)}#{field('BAND', row)}#{field('MODE', row)}#{field('OPERATOR', row)}<MY_SIG:4>POTA #{field('MY_SIG_INFO', row)}#{field('SIG_INFO', row)}#{field('STATION_CALLSIGN', row)}<EOR>"
38
+ end
39
+ end
40
+
41
+ private
42
+
43
+ attr_reader :file_path
44
+
45
+ def header
46
+ <<-ADIF_HEAD
47
+ ADIF Export from ruby-pota-csv-to-adif v[0.1]
48
+ https://github.com/ecopony/ruby-pota-csv-to-adif
49
+ Copyright (C) 2021 Edward Copony
50
+ File generated on #{Time.now.getutc.strftime('%d %b, %Y at %I:%M')}
51
+ <ADIF_VER:5>3.1.0
52
+ <PROGRAMID:21>ruby-pota-csv-to-adif
53
+ <PROGRAMVERSION:3>0.1
54
+ <EOH>
55
+
56
+ ADIF_HEAD
57
+ end
58
+
59
+ def field(name, row)
60
+ value = row[name]
61
+ return if value.nil?
62
+ "<#{name.upcase}:#{value.size}>#{value} "
63
+ end
64
+ end
65
+ end
metadata ADDED
@@ -0,0 +1,45 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: ruby-pota-csv-to-adif
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Edward Copony
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2021-02-27 00:00:00.000000000 Z
12
+ dependencies: []
13
+ description: Converts a CSV file of a Parks on the Air log to ADIF
14
+ email: ecopony@gmail.com
15
+ executables:
16
+ - ruby-pota-csv-to-adif
17
+ extensions: []
18
+ extra_rdoc_files: []
19
+ files:
20
+ - bin/ruby-pota-csv-to-adif
21
+ - lib/ruby-pota-csv-to-adif.rb
22
+ homepage: https://rubygems.org/gems/ruby-pota-csv-to-adif
23
+ licenses:
24
+ - MIT
25
+ metadata: {}
26
+ post_install_message:
27
+ rdoc_options: []
28
+ require_paths:
29
+ - lib
30
+ required_ruby_version: !ruby/object:Gem::Requirement
31
+ requirements:
32
+ - - ">="
33
+ - !ruby/object:Gem::Version
34
+ version: '0'
35
+ required_rubygems_version: !ruby/object:Gem::Requirement
36
+ requirements:
37
+ - - ">="
38
+ - !ruby/object:Gem::Version
39
+ version: '0'
40
+ requirements: []
41
+ rubygems_version: 3.1.4
42
+ signing_key:
43
+ specification_version: 4
44
+ summary: Converts a CSV file of a Parks on the Air log to ADIF
45
+ test_files: []