unclekryon 0.4.10 → 0.4.11

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.
Files changed (53) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile +6 -19
  3. data/Gemfile.lock +19 -23
  4. data/README.md +3 -2
  5. data/Rakefile +11 -30
  6. data/bin/unclekryon +4 -15
  7. data/hax/kryon.yaml +28 -0
  8. data/hax/kryon_aums_2002-2005.yaml +460 -0
  9. data/hax/kryon_aums_2006.yaml +601 -0
  10. data/hax/kryon_aums_2007.yaml +1024 -0
  11. data/hax/kryon_aums_2008.yaml +950 -0
  12. data/hax/kryon_aums_2009.yaml +496 -0
  13. data/hax/kryon_aums_2010.yaml +1443 -0
  14. data/hax/kryon_aums_2011.yaml +1458 -0
  15. data/hax/kryon_aums_2012.yaml +2123 -0
  16. data/hax/kryon_aums_2013.yaml +1647 -0
  17. data/hax/kryon_aums_2014.yaml +2478 -0
  18. data/hax/kryon_aums_2015.yaml +3386 -0
  19. data/hax/kryon_aums_2016.yaml +3476 -0
  20. data/hax/kryon_aums_2017.yaml +3712 -0
  21. data/hax/kryon_aums_2018.yaml +3654 -0
  22. data/lib/unclekryon.rb +165 -165
  23. data/lib/unclekryon/data/album_data.rb +74 -82
  24. data/lib/unclekryon/data/artist_data.rb +24 -36
  25. data/lib/unclekryon/data/artist_data_data.rb +29 -41
  26. data/lib/unclekryon/data/aum_data.rb +20 -32
  27. data/lib/unclekryon/data/base_data.rb +27 -39
  28. data/lib/unclekryon/data/pic_data.rb +25 -37
  29. data/lib/unclekryon/data/release_data.rb +14 -26
  30. data/lib/unclekryon/data/social_data.rb +6 -18
  31. data/lib/unclekryon/data/timespan_data.rb +16 -28
  32. data/lib/unclekryon/dev_opts.rb +7 -19
  33. data/lib/unclekryon/hacker.rb +119 -133
  34. data/lib/unclekryon/iso.rb +128 -138
  35. data/lib/unclekryon/iso/base_iso.rb +69 -81
  36. data/lib/unclekryon/iso/can_prov_terr.rb +34 -47
  37. data/lib/unclekryon/iso/country.rb +36 -49
  38. data/lib/unclekryon/iso/language.rb +86 -96
  39. data/lib/unclekryon/iso/region.rb +11 -25
  40. data/lib/unclekryon/iso/subregion.rb +11 -25
  41. data/lib/unclekryon/iso/usa_state.rb +28 -41
  42. data/lib/unclekryon/jsoner.rb +31 -50
  43. data/lib/unclekryon/log.rb +34 -46
  44. data/lib/unclekryon/parsers/kryon_aum_year_album_parser.rb +163 -167
  45. data/lib/unclekryon/parsers/kryon_aum_year_parser.rb +122 -127
  46. data/lib/unclekryon/server.rb +8 -17
  47. data/lib/unclekryon/trainer.rb +69 -83
  48. data/lib/unclekryon/uploader.rb +8 -17
  49. data/lib/unclekryon/util.rb +80 -92
  50. data/lib/unclekryon/version.rb +4 -16
  51. data/train/kryon.yaml +6077 -0
  52. data/unclekryon.gemspec +44 -42
  53. metadata +59 -16
@@ -1,28 +1,14 @@
1
- #!/usr/bin/env ruby
2
1
  # encoding: UTF-8
3
2
  # frozen_string_literal: true
4
3
 
5
4
  #--
6
5
  # 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/>.
6
+ # Copyright (c) 2018-2021 Jonathan Bradley Whited
7
+ #
8
+ # SPDX-License-Identifier: GPL-3.0-or-later
21
9
  #++
22
10
 
23
11
 
24
- require 'bundler/setup'
25
-
26
12
  require 'unclekryon/iso/base_iso'
27
13
 
28
14
  ##
@@ -30,24 +16,24 @@ require 'unclekryon/iso/base_iso'
30
16
  ##
31
17
  module UncleKryon
32
18
  class Region < BaseIso
33
- def initialize()
19
+ def initialize
34
20
  super()
35
21
  end
36
22
  end
37
-
23
+
38
24
  class Regions < BaseIsos
39
25
  DEFAULT_FILEPATH = "#{DEFAULT_DIR}/regions.yaml"
40
-
41
- def initialize()
26
+
27
+ def initialize
42
28
  super()
43
29
  end
44
-
30
+
45
31
  def self.load_file(filepath=DEFAULT_FILEPATH)
46
- return Regions.new().load_file(filepath)
32
+ return Regions.new.load_file(filepath)
47
33
  end
48
34
  end
49
35
  end
50
36
 
51
- if $0 == __FILE__
52
- puts UncleKryon::Regions.load_file().to_s()
37
+ if $PROGRAM_NAME == __FILE__
38
+ puts UncleKryon::Regions.load_file.to_s
53
39
  end
@@ -1,28 +1,14 @@
1
- #!/usr/bin/env ruby
2
1
  # encoding: UTF-8
3
2
  # frozen_string_literal: true
4
3
 
5
4
  #--
6
5
  # 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/>.
6
+ # Copyright (c) 2019-2021 Jonathan Bradley Whited
7
+ #
8
+ # SPDX-License-Identifier: GPL-3.0-or-later
21
9
  #++
22
10
 
23
11
 
24
- require 'bundler/setup'
25
-
26
12
  require 'unclekryon/iso/base_iso'
27
13
 
28
14
  ##
@@ -30,24 +16,24 @@ require 'unclekryon/iso/base_iso'
30
16
  ##
31
17
  module UncleKryon
32
18
  class Subregion < BaseIso
33
- def initialize()
19
+ def initialize
34
20
  super()
35
21
  end
36
22
  end
37
-
23
+
38
24
  class Subregions < BaseIsos
39
25
  DEFAULT_FILEPATH = "#{DEFAULT_DIR}/subregions.yaml"
40
-
41
- def initialize()
26
+
27
+ def initialize
42
28
  super()
43
29
  end
44
-
30
+
45
31
  def self.load_file(filepath=DEFAULT_FILEPATH)
46
- return Subregions.new().load_file(filepath)
32
+ return Subregions.new.load_file(filepath)
47
33
  end
48
34
  end
49
35
  end
50
36
 
51
- if $0 == __FILE__
52
- puts UncleKryon::Subregions.load_file().to_s()
37
+ if $PROGRAM_NAME == __FILE__
38
+ puts UncleKryon::Subregions.load_file.to_s
53
39
  end
@@ -1,28 +1,14 @@
1
- #!/usr/bin/env ruby
2
1
  # encoding: UTF-8
3
2
  # frozen_string_literal: true
4
3
 
5
4
  #--
6
5
  # 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/>.
6
+ # Copyright (c) 2018-2021 Jonathan Bradley Whited
7
+ #
8
+ # SPDX-License-Identifier: GPL-3.0-or-later
21
9
  #++
22
10
 
23
11
 
24
- require 'bundler/setup'
25
-
26
12
  require 'nokogiri'
27
13
  require 'open-uri'
28
14
  require 'yaml'
@@ -37,68 +23,69 @@ module UncleKryon
37
23
  class UsaState < BaseIso
38
24
  def initialize(row=nil)
39
25
  super()
40
-
26
+
41
27
  if row.is_a?(Array)
42
28
  @name = self.class.simplify_name(row[2])
43
29
  @code = self.class.simplify_code(row[1])
44
30
  end
45
31
  end
46
32
  end
47
-
33
+
48
34
  class UsaStates < BaseIsos
49
35
  DEFAULT_FILEPATH = "#{DEFAULT_DIR}/usa_states.yaml"
50
-
51
- def initialize()
36
+
37
+ def initialize
52
38
  super()
53
-
39
+
54
40
  @id = 'USA States'
55
41
  end
56
-
42
+
57
43
  def self.load_file(filepath=DEFAULT_FILEPATH)
58
- return UsaStates.new().load_file(filepath)
44
+ return UsaStates.new.load_file(filepath)
59
45
  end
60
-
61
- # @param parse_filepath [String] use web browser's developer tools to copy & paste table HTML into local file
46
+
47
+ # @param parse_filepath [String] use web browser's developer tools to copy & paste table HTML
48
+ # into local file
62
49
  # @param save_filepath [String] local file to save YAML to
63
50
  # @see https://www.iso.org/obp/ui/#iso:code:3166:US
64
51
  def self.parse_and_save_to_file(parse_filepath,save_filepath=DEFAULT_FILEPATH)
65
- doc = Nokogiri::HTML(open(parse_filepath),nil,'utf-8')
52
+ doc = Nokogiri::HTML(URI(parse_filepath).open,nil,'utf-8')
66
53
  tds = doc.css('td')
67
-
68
- states = UsaStates.new()
54
+
55
+ states = UsaStates.new
69
56
  i = 0
70
57
  tr = []
71
-
58
+
72
59
  tds.each do |td|
73
60
  c = td.content
74
61
  c.gsub!(/[[:space:]]+/,' ')
75
- c.strip!()
62
+ c.strip!
76
63
  tr.push(c)
77
-
64
+
78
65
  if (i += 1) >= 7
79
66
  #puts tr.inspect()
80
67
  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|
68
+ raise "USA state already exists: #{state.inspect}" if states.key?(state.code)
69
+
70
+ states.values.each_value do |v|
84
71
  puts "Duplicate USA state names: #{v.name}" if v.name == state.name
85
72
  end
86
-
73
+
87
74
  states[state.code] = state
88
- tr.clear()
75
+ tr.clear
89
76
  i = 0
90
77
  end
91
78
  end
92
-
93
- states.sort_keys!()
79
+
80
+ states.sort_keys!
94
81
  states.save_to_file(save_filepath)
95
82
  end
96
83
  end
97
84
  end
98
85
 
99
- if $0 == __FILE__
86
+ if $PROGRAM_NAME == __FILE__
100
87
  if ARGV.length < 1
101
- puts UncleKryon::UsaStates.load_file().to_s()
88
+ puts UncleKryon::UsaStates.load_file.to_s
102
89
  else
103
90
  UncleKryon::UsaStates.parse_and_save_to_file(ARGV[0],(ARGV.length >= 2) ? ARGV[1] :
104
91
  UncleKryon::UsaStates::DEFAULT_FILEPATH)
@@ -1,33 +1,14 @@
1
- #!/usr/bin/env ruby
2
1
  # encoding: UTF-8
3
2
  # frozen_string_literal: true
4
3
 
5
4
  #--
6
5
  # 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/>.
6
+ # Copyright (c) 2020-2021 Jonathan Bradley Whited
7
+ #
8
+ # SPDX-License-Identifier: GPL-3.0-or-later
21
9
  #++
22
10
 
23
11
 
24
- IS_SCRIPT = $0 == __FILE__
25
-
26
- if IS_SCRIPT
27
- require 'rubygems'
28
- require 'bundler/setup'
29
- end
30
-
31
12
  require 'json'
32
13
  require 'yaml'
33
14
 
@@ -41,84 +22,84 @@ module UncleKryon
41
22
  class Jsoner
42
23
  def jsonify_all(pretty=false)
43
24
  json = {}
44
-
25
+
45
26
  #jsonify_iso(json)
46
27
  jsonify_artists(json)
47
-
48
- return pretty ? JSON.pretty_generate(json) : json.to_json()
28
+
29
+ return pretty ? JSON.pretty_generate(json) : json.to_json
49
30
  end
50
-
31
+
51
32
  def jsonify_artists(json)
52
33
  json['aum'] = {}
53
34
  json['scroll'] = {}
54
35
  json['vision'] = {}
55
36
  json['pic'] = {}
56
-
37
+
57
38
  kryon = to_hash(ArtistData.load_file(File.join('hax','kryon.yaml')))
58
-
39
+
59
40
  kryon['release'] = {}
60
41
  kryon['album'] = {}
61
-
42
+
62
43
  jsonify_artist_data(json,kryon,File.join('hax','kryon_aums_2002-2005.yaml'))
63
-
44
+
64
45
  json['artist'] = {
65
46
  kryon['id'] => kryon
66
47
  }
67
48
  end
68
-
49
+
69
50
  def jsonify_artist_data(json,artist,file)
70
51
  data = ArtistDataData.load_file(file)
71
-
72
- data.albums.each() do |album_id,album|
73
- album.aums.each() do |aum_id,aum|
52
+
53
+ data.albums.each do |album_id,album|
54
+ album.aums.each do |aum_id,aum|
74
55
  json[ArtistDataData::AUMS_ID][aum_id] = to_hash(aum)
75
56
  end
76
57
  album.aums = album.aums.keys
77
-
78
- album.pics.each() do |pic_id,pic|
58
+
59
+ album.pics.each do |pic_id,pic|
79
60
  json[ArtistDataData::PICS_ID][pic_id] = to_hash(pic)
80
61
  end
81
62
  album.pics = album.pics.keys
82
63
  end
83
-
64
+
84
65
  artist[ArtistDataData::ALBUMS_ID] = to_hash(data.albums)
85
-
66
+
86
67
  #attr_accessor :scrolls
87
68
  #attr_accessor :visions
88
69
  end
89
-
70
+
90
71
  def jsonify_iso(json)
91
72
  json['iso'] = to_hash(Iso.iso)
92
- json['can_proter'] = to_hash(Iso.can_provs_terrs.values)
73
+ json['can_proterr'] = to_hash(Iso.can_provs_terrs.values)
93
74
  json['country'] = to_hash(Iso.countries.values)
94
75
  json['language'] = to_hash(Iso.languages.values)
95
76
  json['region'] = to_hash(Iso.regions.values)
96
77
  json['subregion'] = to_hash(Iso.subregions.values)
97
78
  json['usa_state'] = to_hash(Iso.usa_states.values)
98
79
  end
99
-
80
+
100
81
  def to_hash(obj)
101
82
  hash = {}
102
-
83
+
103
84
  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))
85
+ obj.instance_variables.each do |var|
86
+ hash[var.to_s.delete('@')] = to_hash(obj.instance_variable_get(var))
106
87
  end
107
88
  elsif obj.is_a?(Hash)
108
- obj.each() do |k,v|
89
+ obj.each do |k,v|
109
90
  hash[k] = to_hash(v)
110
91
  end
111
92
  else
112
- return Util.empty_s?(obj.to_s()) ? nil : obj
93
+ return Util.empty_s?(obj.to_s) ? nil : obj
113
94
  end
114
-
95
+
115
96
  return hash
116
97
  end
117
98
  end
118
99
  end
119
100
 
120
- if IS_SCRIPT
121
- j = UncleKryon::Jsoner.new()
122
-
101
+ if $PROGRAM_NAME == __FILE__
102
+ j = UncleKryon::Jsoner.new
103
+
123
104
  puts j.jsonify_all(true)
124
105
  end
@@ -1,23 +1,11 @@
1
- #!/usr/bin/env ruby
2
1
  # encoding: UTF-8
3
2
  # frozen_string_literal: true
4
3
 
5
4
  #--
6
5
  # 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/>.
6
+ # Copyright (c) 2017-2021 Jonathan Bradley Whited
7
+ #
8
+ # SPDX-License-Identifier: GPL-3.0-or-later
21
9
  #++
22
10
 
23
11
 
@@ -27,83 +15,83 @@ require 'singleton'
27
15
  module UncleKryon
28
16
  class UncleKryonLogger < Logger
29
17
  def initialize
30
- super(STDOUT)
31
-
32
- @progname = self.class.to_s()
18
+ super($stdout)
19
+
20
+ @progname = self.class.to_s
33
21
  end
34
-
22
+
35
23
  def build_message(message,error: nil,**options)
36
24
  # Don't use mutable methods
37
- message += error.backtrace().map(){|e| "\n > " + e}.join('') if !error.nil?
38
-
25
+ message += error.backtrace.map{|e| "\n > " + e}.join('') if !error.nil?
26
+
39
27
  return message
40
28
  end
41
-
29
+
42
30
  def error(message,error: nil,**options)
43
31
  super(build_message(message,error: error,**options))
44
32
  end
45
-
33
+
46
34
  def fatal(message,error: nil,**options)
47
35
  super(build_message(message,error: error,**options))
48
36
  end
49
-
37
+
50
38
  def unknown(message,error: nil,**options)
51
39
  super(build_message(message,error: error,**options))
52
40
  end
53
-
41
+
54
42
  def warn(message,error: nil,**options)
55
43
  super(build_message(message,error: error,**options))
56
44
  end
57
45
  end
58
-
46
+
59
47
  # Global for non-class use
60
48
  class Log < UncleKryonLogger
61
49
  include Singleton
62
-
50
+
63
51
  # Do NOT define vars here; had problems with @dev/@test breaking this class
64
52
  end
65
-
53
+
66
54
  # Mixin for class use
67
55
  module Logging
68
- def init_log()
56
+ def init_log
69
57
  end
70
-
71
- def log()
58
+
59
+ def log
72
60
  if !@log
73
- @log = UncleKryonLogger.new()
74
- @log.progname = self.class.to_s()
75
-
76
- init_log()
61
+ @log = UncleKryonLogger.new
62
+ @log.progname = self.class.to_s
63
+
64
+ init_log
77
65
  end
78
66
  return @log
79
67
  end
80
68
  end
81
69
  end
82
70
 
83
- if $0 == __FILE__
71
+ if $PROGRAM_NAME == __FILE__
84
72
  class Tester
85
73
  include UncleKryon::Logging
86
-
87
- def init_log()
88
- @log.progname.prepend("[Risky]")
74
+
75
+ def init_log
76
+ @log.progname.prepend('[Risky]')
89
77
  end
90
-
91
- def take_risk()
78
+
79
+ def take_risk
92
80
  log.fatal('Risky! Risky! Risky!')
93
81
  end
94
82
  end
95
-
83
+
96
84
  begin
97
- t = Tester.new()
98
- t.take_risk()
99
-
85
+ t = Tester.new
86
+ t.take_risk
87
+
100
88
  raise 'Oops!'
101
89
  rescue StandardError => e
102
90
  UncleKryon::Log.instance.error(e.message,error: e)
103
91
  UncleKryon::Log.instance.fatal(e.message,error: e)
104
92
  UncleKryon::Log.instance.unknown(e.message,error: e)
105
93
  UncleKryon::Log.instance.warn(e.message,error: e)
106
-
94
+
107
95
  UncleKryon::Log.instance.warn("Don't Worry") do
108
96
  'This still works'
109
97
  end