unclekryon 0.4.9.pre.alpha
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/Gemfile +34 -0
- data/Gemfile.lock +43 -0
- data/LICENSE +674 -0
- data/README.md +55 -0
- data/Rakefile +59 -0
- data/bin/unclekryon +30 -0
- data/iso/can_provs_terrs.yaml +54 -0
- data/iso/countries.yaml +3050 -0
- data/iso/iso.yaml +8 -0
- data/iso/languages.yaml +5641 -0
- data/iso/regions.yaml +42 -0
- data/iso/subregions.yaml +6 -0
- data/iso/usa_states.yaml +230 -0
- data/lib/unclekryon.rb +384 -0
- data/lib/unclekryon/data/album_data.rb +147 -0
- data/lib/unclekryon/data/artist_data.rb +109 -0
- data/lib/unclekryon/data/artist_data_data.rb +146 -0
- data/lib/unclekryon/data/aum_data.rb +75 -0
- data/lib/unclekryon/data/base_data.rb +79 -0
- data/lib/unclekryon/data/pic_data.rb +76 -0
- data/lib/unclekryon/data/release_data.rb +57 -0
- data/lib/unclekryon/data/social_data.rb +39 -0
- data/lib/unclekryon/data/timespan_data.rb +70 -0
- data/lib/unclekryon/dev_opts.rb +41 -0
- data/lib/unclekryon/hacker.rb +327 -0
- data/lib/unclekryon/iso.rb +341 -0
- data/lib/unclekryon/iso/base_iso.rb +196 -0
- data/lib/unclekryon/iso/can_prov_terr.rb +113 -0
- data/lib/unclekryon/iso/country.rb +133 -0
- data/lib/unclekryon/iso/language.rb +241 -0
- data/lib/unclekryon/iso/region.rb +53 -0
- data/lib/unclekryon/iso/subregion.rb +53 -0
- data/lib/unclekryon/iso/usa_state.rb +106 -0
- data/lib/unclekryon/jsoner.rb +124 -0
- data/lib/unclekryon/log.rb +111 -0
- data/lib/unclekryon/parsers/kryon_aum_year_album_parser.rb +499 -0
- data/lib/unclekryon/parsers/kryon_aum_year_parser.rb +413 -0
- data/lib/unclekryon/server.rb +29 -0
- data/lib/unclekryon/trainer.rb +231 -0
- data/lib/unclekryon/uploader.rb +29 -0
- data/lib/unclekryon/util.rb +228 -0
- data/lib/unclekryon/version.rb +26 -0
- data/unclekryon.gemspec +67 -0
- metadata +189 -0
@@ -0,0 +1,53 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# encoding: UTF-8
|
3
|
+
# frozen_string_literal: true
|
4
|
+
|
5
|
+
#--
|
6
|
+
# This file is part of UncleKryon-server.
|
7
|
+
# Copyright (c) 2018-2019 Jonathan Bradley Whited (@esotericpig)
|
8
|
+
#
|
9
|
+
# UncleKryon-server is free software: you can redistribute it and/or modify
|
10
|
+
# it under the terms of the GNU General Public License as published by
|
11
|
+
# the Free Software Foundation, either version 3 of the License, or
|
12
|
+
# (at your option) any later version.
|
13
|
+
#
|
14
|
+
# UncleKryon-server is distributed in the hope that it will be useful,
|
15
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
16
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
17
|
+
# GNU General Public License for more details.
|
18
|
+
#
|
19
|
+
# You should have received a copy of the GNU General Public License
|
20
|
+
# along with UncleKryon-server. If not, see <https://www.gnu.org/licenses/>.
|
21
|
+
#++
|
22
|
+
|
23
|
+
|
24
|
+
require 'bundler/setup'
|
25
|
+
|
26
|
+
require 'unclekryon/iso/base_iso'
|
27
|
+
|
28
|
+
##
|
29
|
+
# @see https://en.wikipedia.org/wiki/Continent
|
30
|
+
##
|
31
|
+
module UncleKryon
|
32
|
+
class Region < BaseIso
|
33
|
+
def initialize()
|
34
|
+
super()
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
class Regions < BaseIsos
|
39
|
+
DEFAULT_FILEPATH = "#{DEFAULT_DIR}/regions.yaml"
|
40
|
+
|
41
|
+
def initialize()
|
42
|
+
super()
|
43
|
+
end
|
44
|
+
|
45
|
+
def self.load_file(filepath=DEFAULT_FILEPATH)
|
46
|
+
return Regions.new().load_file(filepath)
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
if $0 == __FILE__
|
52
|
+
puts UncleKryon::Regions.load_file().to_s()
|
53
|
+
end
|
@@ -0,0 +1,53 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# encoding: UTF-8
|
3
|
+
# frozen_string_literal: true
|
4
|
+
|
5
|
+
#--
|
6
|
+
# This file is part of UncleKryon-server.
|
7
|
+
# Copyright (c) 2019 Jonathan Bradley Whited (@esotericpig)
|
8
|
+
#
|
9
|
+
# UncleKryon-server is free software: you can redistribute it and/or modify
|
10
|
+
# it under the terms of the GNU General Public License as published by
|
11
|
+
# the Free Software Foundation, either version 3 of the License, or
|
12
|
+
# (at your option) any later version.
|
13
|
+
#
|
14
|
+
# UncleKryon-server is distributed in the hope that it will be useful,
|
15
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
16
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
17
|
+
# GNU General Public License for more details.
|
18
|
+
#
|
19
|
+
# You should have received a copy of the GNU General Public License
|
20
|
+
# along with UncleKryon-server. If not, see <https://www.gnu.org/licenses/>.
|
21
|
+
#++
|
22
|
+
|
23
|
+
|
24
|
+
require 'bundler/setup'
|
25
|
+
|
26
|
+
require 'unclekryon/iso/base_iso'
|
27
|
+
|
28
|
+
##
|
29
|
+
# @see https://en.wikipedia.org/wiki/Subregion
|
30
|
+
##
|
31
|
+
module UncleKryon
|
32
|
+
class Subregion < BaseIso
|
33
|
+
def initialize()
|
34
|
+
super()
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
class Subregions < BaseIsos
|
39
|
+
DEFAULT_FILEPATH = "#{DEFAULT_DIR}/subregions.yaml"
|
40
|
+
|
41
|
+
def initialize()
|
42
|
+
super()
|
43
|
+
end
|
44
|
+
|
45
|
+
def self.load_file(filepath=DEFAULT_FILEPATH)
|
46
|
+
return Subregions.new().load_file(filepath)
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
if $0 == __FILE__
|
52
|
+
puts UncleKryon::Subregions.load_file().to_s()
|
53
|
+
end
|
@@ -0,0 +1,106 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# encoding: UTF-8
|
3
|
+
# frozen_string_literal: true
|
4
|
+
|
5
|
+
#--
|
6
|
+
# This file is part of UncleKryon-server.
|
7
|
+
# Copyright (c) 2018-2019 Jonathan Bradley Whited (@esotericpig)
|
8
|
+
#
|
9
|
+
# UncleKryon-server is free software: you can redistribute it and/or modify
|
10
|
+
# it under the terms of the GNU General Public License as published by
|
11
|
+
# the Free Software Foundation, either version 3 of the License, or
|
12
|
+
# (at your option) any later version.
|
13
|
+
#
|
14
|
+
# UncleKryon-server is distributed in the hope that it will be useful,
|
15
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
16
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
17
|
+
# GNU General Public License for more details.
|
18
|
+
#
|
19
|
+
# You should have received a copy of the GNU General Public License
|
20
|
+
# along with UncleKryon-server. If not, see <https://www.gnu.org/licenses/>.
|
21
|
+
#++
|
22
|
+
|
23
|
+
|
24
|
+
require 'bundler/setup'
|
25
|
+
|
26
|
+
require 'nokogiri'
|
27
|
+
require 'open-uri'
|
28
|
+
require 'yaml'
|
29
|
+
|
30
|
+
require 'unclekryon/iso/base_iso'
|
31
|
+
|
32
|
+
##
|
33
|
+
# @see https://en.wikipedia.org/wiki/ISO_3166-2:US
|
34
|
+
# @see https://www.iso.org/obp/ui/#iso:code:3166:US
|
35
|
+
##
|
36
|
+
module UncleKryon
|
37
|
+
class UsaState < BaseIso
|
38
|
+
def initialize(row=nil)
|
39
|
+
super()
|
40
|
+
|
41
|
+
if row.is_a?(Array)
|
42
|
+
@name = self.class.simplify_name(row[2])
|
43
|
+
@code = self.class.simplify_code(row[1])
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
class UsaStates < BaseIsos
|
49
|
+
DEFAULT_FILEPATH = "#{DEFAULT_DIR}/usa_states.yaml"
|
50
|
+
|
51
|
+
def initialize()
|
52
|
+
super()
|
53
|
+
|
54
|
+
@id = 'USA States'
|
55
|
+
end
|
56
|
+
|
57
|
+
def self.load_file(filepath=DEFAULT_FILEPATH)
|
58
|
+
return UsaStates.new().load_file(filepath)
|
59
|
+
end
|
60
|
+
|
61
|
+
# @param parse_filepath [String] use web browser's developer tools to copy & paste table HTML into local file
|
62
|
+
# @param save_filepath [String] local file to save YAML to
|
63
|
+
# @see https://www.iso.org/obp/ui/#iso:code:3166:US
|
64
|
+
def self.parse_and_save_to_file(parse_filepath,save_filepath=DEFAULT_FILEPATH)
|
65
|
+
doc = Nokogiri::HTML(open(parse_filepath),nil,'utf-8')
|
66
|
+
tds = doc.css('td')
|
67
|
+
|
68
|
+
states = UsaStates.new()
|
69
|
+
i = 0
|
70
|
+
tr = []
|
71
|
+
|
72
|
+
tds.each do |td|
|
73
|
+
c = td.content
|
74
|
+
c.gsub!(/[[:space:]]+/,' ')
|
75
|
+
c.strip!()
|
76
|
+
tr.push(c)
|
77
|
+
|
78
|
+
if (i += 1) >= 7
|
79
|
+
#puts tr.inspect()
|
80
|
+
state = UsaState.new(tr)
|
81
|
+
raise "USA state already exists: #{state.inspect()}" if states.key?(state.code)
|
82
|
+
|
83
|
+
states.values.each_value() do |v|
|
84
|
+
puts "Duplicate USA state names: #{v.name}" if v.name == state.name
|
85
|
+
end
|
86
|
+
|
87
|
+
states[state.code] = state
|
88
|
+
tr.clear()
|
89
|
+
i = 0
|
90
|
+
end
|
91
|
+
end
|
92
|
+
|
93
|
+
states.sort_keys!()
|
94
|
+
states.save_to_file(save_filepath)
|
95
|
+
end
|
96
|
+
end
|
97
|
+
end
|
98
|
+
|
99
|
+
if $0 == __FILE__
|
100
|
+
if ARGV.length < 1
|
101
|
+
puts UncleKryon::UsaStates.load_file().to_s()
|
102
|
+
else
|
103
|
+
UncleKryon::UsaStates.parse_and_save_to_file(ARGV[0],(ARGV.length >= 2) ? ARGV[1] :
|
104
|
+
UncleKryon::UsaStates::DEFAULT_FILEPATH)
|
105
|
+
end
|
106
|
+
end
|
@@ -0,0 +1,124 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# encoding: UTF-8
|
3
|
+
# frozen_string_literal: true
|
4
|
+
|
5
|
+
#--
|
6
|
+
# This file is part of UncleKryon-server.
|
7
|
+
# Copyright (c) 2020 Jonathan Bradley Whited (@esotericpig)
|
8
|
+
#
|
9
|
+
# UncleKryon-server is free software: you can redistribute it and/or modify
|
10
|
+
# it under the terms of the GNU General Public License as published by
|
11
|
+
# the Free Software Foundation, either version 3 of the License, or
|
12
|
+
# (at your option) any later version.
|
13
|
+
#
|
14
|
+
# UncleKryon-server is distributed in the hope that it will be useful,
|
15
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
16
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
17
|
+
# GNU General Public License for more details.
|
18
|
+
#
|
19
|
+
# You should have received a copy of the GNU General Public License
|
20
|
+
# along with UncleKryon-server. If not, see <https://www.gnu.org/licenses/>.
|
21
|
+
#++
|
22
|
+
|
23
|
+
|
24
|
+
IS_SCRIPT = $0 == __FILE__
|
25
|
+
|
26
|
+
if IS_SCRIPT
|
27
|
+
require 'rubygems'
|
28
|
+
require 'bundler/setup'
|
29
|
+
end
|
30
|
+
|
31
|
+
require 'json'
|
32
|
+
require 'yaml'
|
33
|
+
|
34
|
+
require 'unclekryon/iso'
|
35
|
+
require 'unclekryon/util'
|
36
|
+
|
37
|
+
require 'unclekryon/data/artist_data'
|
38
|
+
require 'unclekryon/data/artist_data_data'
|
39
|
+
|
40
|
+
module UncleKryon
|
41
|
+
class Jsoner
|
42
|
+
def jsonify_all(pretty=false)
|
43
|
+
json = {}
|
44
|
+
|
45
|
+
#jsonify_iso(json)
|
46
|
+
jsonify_artists(json)
|
47
|
+
|
48
|
+
return pretty ? JSON.pretty_generate(json) : json.to_json()
|
49
|
+
end
|
50
|
+
|
51
|
+
def jsonify_artists(json)
|
52
|
+
json['aum'] = {}
|
53
|
+
json['scroll'] = {}
|
54
|
+
json['vision'] = {}
|
55
|
+
json['pic'] = {}
|
56
|
+
|
57
|
+
kryon = to_hash(ArtistData.load_file(File.join('hax','kryon.yaml')))
|
58
|
+
|
59
|
+
kryon['release'] = {}
|
60
|
+
kryon['album'] = {}
|
61
|
+
|
62
|
+
jsonify_artist_data(json,kryon,File.join('hax','kryon_aums_2002-2005.yaml'))
|
63
|
+
|
64
|
+
json['artist'] = {
|
65
|
+
kryon['id'] => kryon
|
66
|
+
}
|
67
|
+
end
|
68
|
+
|
69
|
+
def jsonify_artist_data(json,artist,file)
|
70
|
+
data = ArtistDataData.load_file(file)
|
71
|
+
|
72
|
+
data.albums.each() do |album_id,album|
|
73
|
+
album.aums.each() do |aum_id,aum|
|
74
|
+
json[ArtistDataData::AUMS_ID][aum_id] = to_hash(aum)
|
75
|
+
end
|
76
|
+
album.aums = album.aums.keys
|
77
|
+
|
78
|
+
album.pics.each() do |pic_id,pic|
|
79
|
+
json[ArtistDataData::PICS_ID][pic_id] = to_hash(pic)
|
80
|
+
end
|
81
|
+
album.pics = album.pics.keys
|
82
|
+
end
|
83
|
+
|
84
|
+
artist[ArtistDataData::ALBUMS_ID] = to_hash(data.albums)
|
85
|
+
|
86
|
+
#attr_accessor :scrolls
|
87
|
+
#attr_accessor :visions
|
88
|
+
end
|
89
|
+
|
90
|
+
def jsonify_iso(json)
|
91
|
+
json['iso'] = to_hash(Iso.iso)
|
92
|
+
json['can_proter'] = to_hash(Iso.can_provs_terrs.values)
|
93
|
+
json['country'] = to_hash(Iso.countries.values)
|
94
|
+
json['language'] = to_hash(Iso.languages.values)
|
95
|
+
json['region'] = to_hash(Iso.regions.values)
|
96
|
+
json['subregion'] = to_hash(Iso.subregions.values)
|
97
|
+
json['usa_state'] = to_hash(Iso.usa_states.values)
|
98
|
+
end
|
99
|
+
|
100
|
+
def to_hash(obj)
|
101
|
+
hash = {}
|
102
|
+
|
103
|
+
if obj.respond_to?(:instance_variables) && obj.instance_variables.length > 0
|
104
|
+
obj.instance_variables.each() do |var|
|
105
|
+
hash[var.to_s().delete('@')] = to_hash(obj.instance_variable_get(var))
|
106
|
+
end
|
107
|
+
elsif obj.is_a?(Hash)
|
108
|
+
obj.each() do |k,v|
|
109
|
+
hash[k] = to_hash(v)
|
110
|
+
end
|
111
|
+
else
|
112
|
+
return Util.empty_s?(obj.to_s()) ? nil : obj
|
113
|
+
end
|
114
|
+
|
115
|
+
return hash
|
116
|
+
end
|
117
|
+
end
|
118
|
+
end
|
119
|
+
|
120
|
+
if IS_SCRIPT
|
121
|
+
j = UncleKryon::Jsoner.new()
|
122
|
+
|
123
|
+
puts j.jsonify_all(true)
|
124
|
+
end
|
@@ -0,0 +1,111 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# encoding: UTF-8
|
3
|
+
# frozen_string_literal: true
|
4
|
+
|
5
|
+
#--
|
6
|
+
# This file is part of UncleKryon-server.
|
7
|
+
# Copyright (c) 2017-2019 Jonathan Bradley Whited (@esotericpig)
|
8
|
+
#
|
9
|
+
# UncleKryon-server is free software: you can redistribute it and/or modify
|
10
|
+
# it under the terms of the GNU General Public License as published by
|
11
|
+
# the Free Software Foundation, either version 3 of the License, or
|
12
|
+
# (at your option) any later version.
|
13
|
+
#
|
14
|
+
# UncleKryon-server is distributed in the hope that it will be useful,
|
15
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
16
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
17
|
+
# GNU General Public License for more details.
|
18
|
+
#
|
19
|
+
# You should have received a copy of the GNU General Public License
|
20
|
+
# along with UncleKryon-server. If not, see <https://www.gnu.org/licenses/>.
|
21
|
+
#++
|
22
|
+
|
23
|
+
|
24
|
+
require 'logger'
|
25
|
+
require 'singleton'
|
26
|
+
|
27
|
+
module UncleKryon
|
28
|
+
class UncleKryonLogger < Logger
|
29
|
+
def initialize
|
30
|
+
super(STDOUT)
|
31
|
+
|
32
|
+
@progname = self.class.to_s()
|
33
|
+
end
|
34
|
+
|
35
|
+
def build_message(message,error: nil,**options)
|
36
|
+
# Don't use mutable methods
|
37
|
+
message += error.backtrace().map(){|e| "\n > " + e}.join('') if !error.nil?
|
38
|
+
|
39
|
+
return message
|
40
|
+
end
|
41
|
+
|
42
|
+
def error(message,error: nil,**options)
|
43
|
+
super(build_message(message,error: error,**options))
|
44
|
+
end
|
45
|
+
|
46
|
+
def fatal(message,error: nil,**options)
|
47
|
+
super(build_message(message,error: error,**options))
|
48
|
+
end
|
49
|
+
|
50
|
+
def unknown(message,error: nil,**options)
|
51
|
+
super(build_message(message,error: error,**options))
|
52
|
+
end
|
53
|
+
|
54
|
+
def warn(message,error: nil,**options)
|
55
|
+
super(build_message(message,error: error,**options))
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
59
|
+
# Global for non-class use
|
60
|
+
class Log < UncleKryonLogger
|
61
|
+
include Singleton
|
62
|
+
|
63
|
+
# Do NOT define vars here; had problems with @dev/@test breaking this class
|
64
|
+
end
|
65
|
+
|
66
|
+
# Mixin for class use
|
67
|
+
module Logging
|
68
|
+
def init_log()
|
69
|
+
end
|
70
|
+
|
71
|
+
def log()
|
72
|
+
if !@log
|
73
|
+
@log = UncleKryonLogger.new()
|
74
|
+
@log.progname = self.class.to_s()
|
75
|
+
|
76
|
+
init_log()
|
77
|
+
end
|
78
|
+
return @log
|
79
|
+
end
|
80
|
+
end
|
81
|
+
end
|
82
|
+
|
83
|
+
if $0 == __FILE__
|
84
|
+
class Tester
|
85
|
+
include UncleKryon::Logging
|
86
|
+
|
87
|
+
def init_log()
|
88
|
+
@log.progname.prepend("[Risky]")
|
89
|
+
end
|
90
|
+
|
91
|
+
def take_risk()
|
92
|
+
log.fatal('Risky! Risky! Risky!')
|
93
|
+
end
|
94
|
+
end
|
95
|
+
|
96
|
+
begin
|
97
|
+
t = Tester.new()
|
98
|
+
t.take_risk()
|
99
|
+
|
100
|
+
raise 'Oops!'
|
101
|
+
rescue StandardError => e
|
102
|
+
UncleKryon::Log.instance.error(e.message,error: e)
|
103
|
+
UncleKryon::Log.instance.fatal(e.message,error: e)
|
104
|
+
UncleKryon::Log.instance.unknown(e.message,error: e)
|
105
|
+
UncleKryon::Log.instance.warn(e.message,error: e)
|
106
|
+
|
107
|
+
UncleKryon::Log.instance.warn("Don't Worry") do
|
108
|
+
'This still works'
|
109
|
+
end
|
110
|
+
end
|
111
|
+
end
|