fcc 1.0.0 → 1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile +15 -3
- data/Gemfile.lock +18 -16
- data/README.md +24 -70
- data/VERSION +1 -0
- data/fcc.gemspec +3 -3
- data/lib/fcc/station/cache.rb +14 -20
- data/lib/fcc/station/extended_info/parser.rb +66 -0
- data/lib/fcc/station/extended_info.rb +22 -28
- data/lib/fcc/station/index.rb +1 -1
- data/lib/fcc/station/info.rb +2 -9
- data/lib/fcc/station/result_delegate.rb +24 -0
- data/lib/fcc/station.rb +71 -9
- data/lib/fcc.rb +1 -22
- data/lib/version.rb +1 -1
- metadata +30 -52
- data/.github/workflows/release.yml +0 -27
- data/.github/workflows/tests.yml +0 -53
- data/CHANGELOG.md +0 -11
- data/lib/fcc/station/lms_data.rb +0 -139
- data/lib/fcc/station/parsers/extended_info.rb +0 -78
- data/lib/fcc/station/parsers/lms_data.rb +0 -13
- data/lib/fcc/station/record_delegate.rb +0 -121
- data/lib/fcc/station/record_group.rb +0 -49
- data/lib/fcc/station/result.rb +0 -180
- data/package.json +0 -92
data/lib/fcc/station/result.rb
DELETED
@@ -1,180 +0,0 @@
|
|
1
|
-
require 'zip'
|
2
|
-
|
3
|
-
module FCC
|
4
|
-
module Station
|
5
|
-
class Result
|
6
|
-
EXTENDED_ATTRIBUTES = %i[band signal_strength latitude longitude station_class file_number effective_radiated_power haat_horizontal haat_vertical antenna_type operating_hours licensed_to city state country] # these take a long time to query
|
7
|
-
BASIC_ATTRIBUTES = %i[id call_sign status rf_channel license_expiration_date facility_type frequency band]
|
8
|
-
|
9
|
-
def initialize(service, call_sign, options = {})
|
10
|
-
@call_sign = call_sign.upcase
|
11
|
-
@service = service
|
12
|
-
@options = options
|
13
|
-
|
14
|
-
data
|
15
|
-
|
16
|
-
self
|
17
|
-
end
|
18
|
-
|
19
|
-
def details_available?
|
20
|
-
exists? && data.latitude.present?
|
21
|
-
end
|
22
|
-
|
23
|
-
def licensed?
|
24
|
-
exists? && data.status == 'LICENSED' && data.license_expiration_date && Time.parse(data.license_expiration_date) > Time.now
|
25
|
-
end
|
26
|
-
|
27
|
-
def exists?
|
28
|
-
grouped_records.any?
|
29
|
-
end
|
30
|
-
|
31
|
-
def to_json(*_args)
|
32
|
-
[].tap do |records|
|
33
|
-
grouped_records.each do |rg|
|
34
|
-
records << rg.to_json
|
35
|
-
end
|
36
|
-
end.flatten.compact.uniq
|
37
|
-
end
|
38
|
-
|
39
|
-
def coordinates_url
|
40
|
-
"https://www.google.com/maps/search/#{latitude},#{longitude}" if latitude.present? && longitude.present?
|
41
|
-
end
|
42
|
-
|
43
|
-
def extended_data_url
|
44
|
-
"https://transition.fcc.gov/fcc-bin/#{@service.to_s.downcase}q?list=4&facid=#{id}"
|
45
|
-
end
|
46
|
-
|
47
|
-
def enterprise_data_url
|
48
|
-
"https://enterpriseefiling.fcc.gov/dataentry/public/tv/publicFacilityDetails.html?facilityId=#{id}"
|
49
|
-
end
|
50
|
-
|
51
|
-
def data
|
52
|
-
@data ||= RecordDelegate.new(Info.new(@service).find(@call_sign))
|
53
|
-
end
|
54
|
-
alias public_data data
|
55
|
-
|
56
|
-
def grouped_records
|
57
|
-
grouped = all_records.group_by do |record|
|
58
|
-
[record.id, record.call_sign, record.band, record.frequency].compact.join('/')
|
59
|
-
end
|
60
|
-
|
61
|
-
[].tap do |res|
|
62
|
-
grouped.each do |_key, values|
|
63
|
-
res << RecordGroup.new(values)
|
64
|
-
end
|
65
|
-
end
|
66
|
-
end
|
67
|
-
alias records grouped_records
|
68
|
-
|
69
|
-
def all_records
|
70
|
-
[public_records, transition_records, related_translators].flatten.compact.filter { |f| f.has_data? }
|
71
|
-
end
|
72
|
-
|
73
|
-
def related_translators
|
74
|
-
@related_translators ||= begin
|
75
|
-
records = lms_data.find_translators_for(call_sign: @call_sign)
|
76
|
-
records.keys.map do |call|
|
77
|
-
RecordDelegate.new(ExtendedInfo.new(@service).find(call))
|
78
|
-
end.select { |f| f.status.upcase == "LIC" }
|
79
|
-
rescue
|
80
|
-
[]
|
81
|
-
end
|
82
|
-
end
|
83
|
-
|
84
|
-
def related_stations
|
85
|
-
@related_stations ||= begin
|
86
|
-
records = lms_data.find_related_stations(call_sign: @call_sign)
|
87
|
-
records.keys.map do |call|
|
88
|
-
RecordDelegate.new(ExtendedInfo.new(@service).find(call))
|
89
|
-
end.select { |f| f.status.upcase == "LIC" }
|
90
|
-
end
|
91
|
-
end
|
92
|
-
|
93
|
-
def related
|
94
|
-
@related ||= begin
|
95
|
-
records = lms_data.find_all_related(call_sign: @call_sign)
|
96
|
-
records.keys.map do |call|
|
97
|
-
ExtendedInfo.new(@service).find(call).collect do |info|
|
98
|
-
RecordDelegate.new(info)
|
99
|
-
end
|
100
|
-
end.flatten.select { |f| f.status.upcase == "LIC" }
|
101
|
-
end
|
102
|
-
end
|
103
|
-
|
104
|
-
def print_broadcast_summary
|
105
|
-
FCC.log "[primary]"
|
106
|
-
transition_records.each do |record|
|
107
|
-
FCC.log "[#{record.band}] #{record.frequency} #{record.call_sign} — #{record.community.city} #{record.community.state}"
|
108
|
-
end
|
109
|
-
|
110
|
-
FCC.log "[translators]"
|
111
|
-
related_translators.each do |record|
|
112
|
-
FCC.log "[#{record.band}] #{record.frequency} #{record.call_sign} — #{record.community.city} #{record.community.state}"
|
113
|
-
end
|
114
|
-
|
115
|
-
FCC.log "[related stations]"
|
116
|
-
related_stations.each do |record|
|
117
|
-
FCC.log "[#{record.band}] #{record.frequency} #{record.call_sign} — #{record.community.city} #{record.community.state}"
|
118
|
-
end
|
119
|
-
|
120
|
-
FCC.log "[all related]"
|
121
|
-
related.each do |record|
|
122
|
-
FCC.log "[#{record.band}] #{record.frequency} #{record.call_sign} — #{record.community.city} #{record.community.state}"
|
123
|
-
end
|
124
|
-
|
125
|
-
nil
|
126
|
-
end
|
127
|
-
|
128
|
-
def lms_data
|
129
|
-
@lms_data ||= LmsData.new
|
130
|
-
end
|
131
|
-
|
132
|
-
def call_signs_match?(ours, theirs)
|
133
|
-
theirs.to_s.upcase.to_s == ours.to_s.upcase.to_s || theirs.to_s.upcase =~ Regexp.new("^#{ours.to_s.upcase}[-—–][A-Z0-9]+$")
|
134
|
-
end
|
135
|
-
|
136
|
-
private
|
137
|
-
|
138
|
-
def public_records
|
139
|
-
public_data_info.map { |r| RecordDelegate.new(r) }
|
140
|
-
end
|
141
|
-
|
142
|
-
def transition_records
|
143
|
-
transition_data_info.map { |r| RecordDelegate.new(r) }
|
144
|
-
end
|
145
|
-
|
146
|
-
def related_records
|
147
|
-
results = related.keys.collect do |call_sign|
|
148
|
-
RecordDelegate.new(ExtendedInfo.new(@service).find(call_sign))
|
149
|
-
end
|
150
|
-
end
|
151
|
-
|
152
|
-
def public_data_info
|
153
|
-
@public_data_info ||= [Info.new(@service).find(@call_sign)]
|
154
|
-
end
|
155
|
-
|
156
|
-
def transition_data_info
|
157
|
-
@transition_data_info ||= ExtendedInfo.new(@service).find(@call_sign)
|
158
|
-
end
|
159
|
-
|
160
|
-
def method_missing(m, *_args)
|
161
|
-
service = if @service == :fm
|
162
|
-
fm_record = grouped_records.find { |gr| FCC::FM_FULL_SERVICE == gr.band.upcase }
|
163
|
-
fm_low_power = grouped_records.find { |gr| FCC::FM_LOW_POWER == gr.band.upcase }
|
164
|
-
fm_booster = grouped_records.find { |gr| FCC::FM_BOOSTER == gr.band.upcase }
|
165
|
-
fm_translator = grouped_records.find { |gr| FCC::FM_TRANSLATOR == gr.band.upcase }
|
166
|
-
|
167
|
-
[fm_record, fm_low_power, fm_booster, fm_translator].compact.find { |r| r.send(m.to_sym) }
|
168
|
-
else
|
169
|
-
grouped_records.find { |r| r.send(m.to_sym) }
|
170
|
-
end
|
171
|
-
|
172
|
-
result = service.send(m.to_sym) if service
|
173
|
-
|
174
|
-
result = result.first if result.is_a?(Array) && result.size == 1
|
175
|
-
|
176
|
-
result
|
177
|
-
end
|
178
|
-
end
|
179
|
-
end
|
180
|
-
end
|
data/package.json
DELETED
@@ -1,92 +0,0 @@
|
|
1
|
-
{
|
2
|
-
"name": "fcc",
|
3
|
-
"version": "1.x.x-semantic-release",
|
4
|
-
"repository": {
|
5
|
-
"type": "git",
|
6
|
-
"url": "git+https://github.com/jkeen/fcc.git"
|
7
|
-
},
|
8
|
-
"author": "jkeen",
|
9
|
-
"license": "MIT",
|
10
|
-
"bugs": {
|
11
|
-
"url": "https://github.com/jkeen/fcc/issues"
|
12
|
-
},
|
13
|
-
"homepage": "https://github.com/jkeen/fcc#readme",
|
14
|
-
"scripts": {
|
15
|
-
"semantic-release": "semantic-release"
|
16
|
-
},
|
17
|
-
"devDependencies": {
|
18
|
-
"semantic-release-rubygem": "^1.2.0",
|
19
|
-
"semantic-release": "^19.0.3",
|
20
|
-
"@semantic-release/changelog": "^6.0.1",
|
21
|
-
"@semantic-release/git": "^10.0.1"
|
22
|
-
},
|
23
|
-
"release": {
|
24
|
-
"branches": ["main"],
|
25
|
-
"plugins": [
|
26
|
-
[
|
27
|
-
"@semantic-release/commit-analyzer",
|
28
|
-
{
|
29
|
-
"releaseRules": [
|
30
|
-
{
|
31
|
-
"type": "*!",
|
32
|
-
"release": "major"
|
33
|
-
},
|
34
|
-
{
|
35
|
-
"type": "feat",
|
36
|
-
"release": "minor"
|
37
|
-
},
|
38
|
-
{
|
39
|
-
"type": "build",
|
40
|
-
"release": "patch"
|
41
|
-
},
|
42
|
-
{
|
43
|
-
"type": "ci",
|
44
|
-
"release": "patch"
|
45
|
-
},
|
46
|
-
{
|
47
|
-
"type": "chore",
|
48
|
-
"release": "patch"
|
49
|
-
},
|
50
|
-
{
|
51
|
-
"type": "docs",
|
52
|
-
"release": "patch"
|
53
|
-
},
|
54
|
-
{
|
55
|
-
"type": "refactor",
|
56
|
-
"release": "patch"
|
57
|
-
},
|
58
|
-
{
|
59
|
-
"type": "style",
|
60
|
-
"release": "patch"
|
61
|
-
},
|
62
|
-
{
|
63
|
-
"type": "test",
|
64
|
-
"release": "patch"
|
65
|
-
}
|
66
|
-
],
|
67
|
-
"parserOpts": {
|
68
|
-
"noteKeywords": ["BREAKING CHANGE", "BREAKING CHANGES", "BREAKING"]
|
69
|
-
}
|
70
|
-
}
|
71
|
-
],
|
72
|
-
"@semantic-release/release-notes-generator",
|
73
|
-
[
|
74
|
-
"@semantic-release/changelog",
|
75
|
-
{
|
76
|
-
"changelogTitle": "fcc changelog",
|
77
|
-
"changelogFile": "CHANGELOG.md"
|
78
|
-
}
|
79
|
-
],
|
80
|
-
"semantic-release-rubygem",
|
81
|
-
"@semantic-release/github",
|
82
|
-
[
|
83
|
-
"@semantic-release/git",
|
84
|
-
{
|
85
|
-
"assets": ["CHANGELOG.md"],
|
86
|
-
"message": "${nextRelease.version} CHANGELOG [skip ci]\n\n${nextRelease.notes}"
|
87
|
-
}
|
88
|
-
]
|
89
|
-
],
|
90
|
-
"debug": false,
|
91
|
-
"dryRun": false
|
92
|
-
}}
|