unclekryon 0.4.9.pre.alpha

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 (45) hide show
  1. checksums.yaml +7 -0
  2. data/Gemfile +34 -0
  3. data/Gemfile.lock +43 -0
  4. data/LICENSE +674 -0
  5. data/README.md +55 -0
  6. data/Rakefile +59 -0
  7. data/bin/unclekryon +30 -0
  8. data/iso/can_provs_terrs.yaml +54 -0
  9. data/iso/countries.yaml +3050 -0
  10. data/iso/iso.yaml +8 -0
  11. data/iso/languages.yaml +5641 -0
  12. data/iso/regions.yaml +42 -0
  13. data/iso/subregions.yaml +6 -0
  14. data/iso/usa_states.yaml +230 -0
  15. data/lib/unclekryon.rb +384 -0
  16. data/lib/unclekryon/data/album_data.rb +147 -0
  17. data/lib/unclekryon/data/artist_data.rb +109 -0
  18. data/lib/unclekryon/data/artist_data_data.rb +146 -0
  19. data/lib/unclekryon/data/aum_data.rb +75 -0
  20. data/lib/unclekryon/data/base_data.rb +79 -0
  21. data/lib/unclekryon/data/pic_data.rb +76 -0
  22. data/lib/unclekryon/data/release_data.rb +57 -0
  23. data/lib/unclekryon/data/social_data.rb +39 -0
  24. data/lib/unclekryon/data/timespan_data.rb +70 -0
  25. data/lib/unclekryon/dev_opts.rb +41 -0
  26. data/lib/unclekryon/hacker.rb +327 -0
  27. data/lib/unclekryon/iso.rb +341 -0
  28. data/lib/unclekryon/iso/base_iso.rb +196 -0
  29. data/lib/unclekryon/iso/can_prov_terr.rb +113 -0
  30. data/lib/unclekryon/iso/country.rb +133 -0
  31. data/lib/unclekryon/iso/language.rb +241 -0
  32. data/lib/unclekryon/iso/region.rb +53 -0
  33. data/lib/unclekryon/iso/subregion.rb +53 -0
  34. data/lib/unclekryon/iso/usa_state.rb +106 -0
  35. data/lib/unclekryon/jsoner.rb +124 -0
  36. data/lib/unclekryon/log.rb +111 -0
  37. data/lib/unclekryon/parsers/kryon_aum_year_album_parser.rb +499 -0
  38. data/lib/unclekryon/parsers/kryon_aum_year_parser.rb +413 -0
  39. data/lib/unclekryon/server.rb +29 -0
  40. data/lib/unclekryon/trainer.rb +231 -0
  41. data/lib/unclekryon/uploader.rb +29 -0
  42. data/lib/unclekryon/util.rb +228 -0
  43. data/lib/unclekryon/version.rb +26 -0
  44. data/unclekryon.gemspec +67 -0
  45. metadata +189 -0
@@ -0,0 +1,147 @@
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 'unclekryon/util'
25
+
26
+ require 'unclekryon/data/base_data'
27
+
28
+ module UncleKryon
29
+ class AlbumData < BaseData
30
+ attr_accessor :date_begin
31
+ attr_accessor :date_end
32
+ attr_accessor :title
33
+ attr_accessor :locations
34
+ attr_accessor :languages
35
+
36
+ attr_accessor :url
37
+ attr_accessor :mirrors
38
+
39
+ attr_accessor :desc
40
+
41
+ attr_accessor :pics
42
+ attr_accessor :aums
43
+ attr_accessor :scrolls
44
+ attr_accessor :visions
45
+
46
+ attr_accessor :dump
47
+
48
+ def initialize()
49
+ super()
50
+
51
+ @date_begin = ''
52
+ @date_end = ''
53
+ @title = ''
54
+ @locations = []
55
+ @languages = []
56
+
57
+ @url = ''
58
+ @mirrors = {}
59
+
60
+ @desc = ''
61
+
62
+ @pics = {}
63
+ @aums = {}
64
+ @scrolls = {}
65
+ @visions = {}
66
+
67
+ @dump = []
68
+ end
69
+
70
+ def initialize_copy(original)
71
+ super(original)
72
+
73
+ @date_begin = @date_begin.clone()
74
+ @date_end = @date_end.clone()
75
+ @title = @title.clone()
76
+ @locations = @locations.clone()
77
+ @languages = @languages.clone()
78
+
79
+ @url = @url.clone()
80
+ @mirrors = @mirrors.clone()
81
+
82
+ @desc = @desc.clone()
83
+
84
+ @pics = @pics.clone()
85
+ @aums = @aums.clone()
86
+ @scrolls = @scrolls.clone()
87
+ @visions = @visions.clone()
88
+
89
+ @dump = @dump.clone()
90
+ end
91
+
92
+ def set_if_not_empty!(album)
93
+ @date_begin = album.date_begin unless Util.empty_s?(album.date_begin)
94
+ @date_end = album.date_end unless Util.empty_s?(album.date_end)
95
+ @title = album.title unless Util.empty_s?(album.title)
96
+ @locations |= album.locations unless album.locations.nil?()
97
+ @languages |= album.languages unless album.languages.nil?()
98
+
99
+ @desc = album.desc unless Util.empty_s?(album.desc)
100
+
101
+ @pics |= album.pics unless album.pics.nil?()
102
+ @aums |= album.aums unless album.aums.nil?()
103
+ @scrolls |= album.scrolls unless album.scrolls.nil?()
104
+ @visions |= album.visions unless album.visions.nil?()
105
+
106
+ @dump |= album.dump unless album.dump.nil?()
107
+ end
108
+
109
+ # Excludes @updated_on and @dump
110
+ def ==(y)
111
+ return @date_begin == y.date_begin &&
112
+ @date_end == y.date_end &&
113
+ @title == y.title &&
114
+ @locations == y.locations &&
115
+ @languages == y.languages &&
116
+ @url == y.url &&
117
+ @mirrors == y.mirrors &&
118
+ @desc == y.desc &&
119
+ @pics == y.pics &&
120
+ @aums == y.aums &&
121
+ @scrolls == y.scrolls &&
122
+ @visions == y.visions
123
+ end
124
+
125
+ def to_mini_s()
126
+ return to_s(true)
127
+ end
128
+
129
+ def to_s(mini=false)
130
+ s = ''
131
+ s << ('%-10s=>%-10s' % [@date_begin,@date_end])
132
+ s << (' | %60s' % [@title])
133
+ s << (' | %25s' % [@locations.join(';')])
134
+ s << (' | %10s' % [@languages.join(';')])
135
+
136
+ s << "\n- #{@desc}" unless mini
137
+
138
+ #s << (mini ? (' | pics:%3d' % [@pics.length()]) : ("\n- Pics:\n - " << @pics.join("\n - ")))
139
+ #s << (mini ? (' | aums:%3d' % [@aums.length()]) : ("\n- Aums:\n - " << @aums.join("\n - ")))
140
+ #s << (mini ? (' | scrolls:%3d' % [@scrolls.length()]) : ("\n- Scrolls:\n - " << @scrolls.join("\n - ")))
141
+ #s << (mini ? (' | visions:%3d' % [@visions.length()]) : ("\n- Visions:\n - " << @visions.join("\n - ")))
142
+
143
+ s << (mini ? (' | dump:%3d' % [@dump.length()]) : ("\n- Dump:\n - " << @dump.join("\n - ")))
144
+ return s
145
+ end
146
+ end
147
+ end
@@ -0,0 +1,109 @@
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 'yaml'
25
+
26
+ require 'unclekryon/util'
27
+
28
+ require 'unclekryon/data/base_data'
29
+ require 'unclekryon/data/social_data'
30
+
31
+ module UncleKryon
32
+ class ArtistData < BaseData
33
+ ID = 'Artist'
34
+
35
+ attr_accessor :updated_releases_on
36
+ attr_accessor :updated_albums_on
37
+ attr_accessor :updated_aums_on
38
+ attr_accessor :updated_scrolls_on
39
+ attr_accessor :updated_visions_on
40
+ attr_accessor :updated_pics_on
41
+
42
+ attr_accessor :id
43
+ attr_accessor :name
44
+ attr_accessor :long_name
45
+ attr_accessor :desc
46
+
47
+ attr_accessor :url
48
+ attr_accessor :mirrors
49
+
50
+ attr_accessor :facebook
51
+ attr_accessor :twitter
52
+ attr_accessor :youtube
53
+
54
+ def initialize()
55
+ super()
56
+
57
+ @updated_releases_on = ''
58
+ @updated_albums_on = ''
59
+ @updated_aums_on = ''
60
+ @updated_scrolls_on = ''
61
+ @updated_visions_on = ''
62
+ @updated_pics_on = ''
63
+
64
+ @id = ''
65
+ @name = ''
66
+ @long_name = ''
67
+ @desc = ''
68
+
69
+ @url = ''
70
+ @mirrors = {}
71
+
72
+ @facebook = SocialData.new()
73
+ @twitter = SocialData.new()
74
+ @youtube = SocialData.new()
75
+ end
76
+
77
+ def self.load_file(filepath)
78
+ y = YAML.load_file(filepath)
79
+ artist = y[ID]
80
+ return artist
81
+ end
82
+
83
+ def save_to_file(filepath,**options)
84
+ raise "Empty filepath: #{filepath}" if filepath.nil?() || (filepath = filepath.strip()).empty?()
85
+
86
+ Util.mk_dirs_from_filepath(filepath)
87
+ File.open(filepath,'w') do |f|
88
+ artist = {ID=>self}
89
+ YAML.dump(artist,f)
90
+ end
91
+ end
92
+
93
+ def to_mini_s()
94
+ return to_s(true)
95
+ end
96
+
97
+ def to_s(mini=false)
98
+ s = ''
99
+ s << ('%-5s' % [@id])
100
+ s << (' | %15s' % [@name])
101
+ s << (' | %25s' % [@long_name])
102
+ s << (' | %s' % [@desc])
103
+ s << (' | fb: @%-20s' % [@facebook.username])
104
+ s << (' | tw: @%-20s' % [@twitter.username])
105
+ s << (' | yt: @%-35s' % [@youtube.username])
106
+ return s
107
+ end
108
+ end
109
+ end
@@ -0,0 +1,146 @@
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 'yaml'
25
+
26
+ require 'unclekryon/util'
27
+
28
+ require 'unclekryon/data/album_data'
29
+ require 'unclekryon/data/aum_data'
30
+ require 'unclekryon/data/base_data'
31
+ require 'unclekryon/data/pic_data'
32
+ require 'unclekryon/data/release_data'
33
+
34
+ ###
35
+ # Don't extend BaseData, as updated_aums_on is stored in ArtistData.
36
+ ###
37
+ module UncleKryon
38
+ class ArtistDataData
39
+ ID = 'ArtistData'
40
+ RELEASES_ID = 'Releases'
41
+ ALBUMS_ID = 'Albums'
42
+ AUMS_ID = 'Aums'
43
+ SCROLLS_ID = 'Scrolls'
44
+ VISIONS_ID = 'Visions'
45
+ PICS_ID = 'Pics'
46
+
47
+ attr_accessor :releases
48
+ attr_accessor :albums
49
+ #attr_accessor :aums
50
+ #attr_accessor :scrolls
51
+ #attr_accessor :visions
52
+ #attr_accessor :pics
53
+
54
+ def initialize()
55
+ super()
56
+
57
+ @releases = {}
58
+ @albums = {}
59
+ #@aums = {}
60
+ #@scrolls = {}
61
+ #@visions = {}
62
+ #@pics = {}
63
+ end
64
+
65
+ def self.load_file(filepath)
66
+ filedata = YAML.load_file(filepath) if File.exist?(filepath)
67
+ filedata = {} if !filedata
68
+
69
+ artist = ArtistDataData.new()
70
+ Util.hash_def(filedata,[ID],{})
71
+ artist.releases = Util.hash_def(filedata,[ID,RELEASES_ID],artist.releases)
72
+ artist.albums = Util.hash_def(filedata,[ID,ALBUMS_ID],artist.albums)
73
+ #artist.aums = Util.hash_def(filedata,[ID,AUMS_ID],artist.aums)
74
+ #artist.scrolls = Util.hash_def(filedata,[ID,SCROLLS_ID],artist.scrolls)
75
+ #artist.visions = Util.hash_def(filedata,[ID,VISIONS_ID],artist.visions)
76
+ #artist.pics = Util.hash_def(filedata,[ID,PICS_ID],artist.pics)
77
+
78
+ return artist
79
+ end
80
+
81
+ def save_to_file(filepath,**options)
82
+ raise "Empty filepath: #{filepath}" if filepath.nil?() || (filepath = filepath.strip()).empty?()
83
+
84
+ filedata = {ID=>{}}
85
+ filedata[ID][RELEASES_ID] = @releases
86
+ filedata[ID][ALBUMS_ID] = @albums
87
+ #filedata[ID][AUMS_ID] = @aums
88
+ #filedata[ID][SCROLLS_ID] = @scrolls
89
+ #filedata[ID][VISIONS_ID] = @visions
90
+ #filedata[ID][PICS_ID] = @pics
91
+
92
+ Util.mk_dirs_from_filepath(filepath)
93
+ File.open(filepath,'w') do |f|
94
+ YAML.dump(filedata,f)
95
+ end
96
+ end
97
+
98
+ def max_updated_on()
99
+ max = nil
100
+ max = Util.safe_max(max,BaseData.max_updated_on(@releases))
101
+ max = Util.safe_max(max,BaseData.max_updated_on(@albums))
102
+ #max = Util.safe_max(max,BaseData.max_updated_on(@aums))
103
+ #max = Util.safe_max(max,BaseData.max_updated_on(@scrolls))
104
+ #max = Util.safe_max(max,BaseData.max_updated_on(@visions))
105
+ #max = Util.safe_max(max,BaseData.max_updated_on(@pics))
106
+
107
+ return Util.format_datetime(max)
108
+ end
109
+
110
+ def to_mini_s()
111
+ return to_s(true)
112
+ end
113
+
114
+ def to_s(mini=false)
115
+ s = ''
116
+
117
+ s << "- Releases:\n"
118
+ @releases.each() do |k,v|
119
+ s << " - " << v.to_s(mini).gsub("\n","\n ") << "\n"
120
+ end
121
+ s << "- Albums:\n"
122
+ @albums.each() do |k,v|
123
+ s << " - " << v.to_s(mini).gsub("\n","\n ") << "\n"
124
+ end
125
+
126
+ #s << "- Aums:\n"
127
+ #@aums.each() do |k,v|
128
+ # s << " - #{v.to_s()}\n"
129
+ #end
130
+ #s << "- Scrolls:\n"
131
+ #@scrolls.each() do |k,v|
132
+ # s << " - #{v.to_s()}\n"
133
+ #end
134
+ #s << "- Visions:\n"
135
+ #@visions.each() do |k,v|
136
+ # s << " - #{v.to_s()}\n"
137
+ #end
138
+ #s << "- Pics:\n"
139
+ #@pics.each() do |k,v|
140
+ # s << " - #{v.to_s()}\n"
141
+ #end
142
+
143
+ return s
144
+ end
145
+ end
146
+ end
@@ -0,0 +1,75 @@
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 'unclekryon/data/base_data'
25
+
26
+ module UncleKryon
27
+ class AumData < BaseData
28
+ attr_accessor :title
29
+ attr_accessor :subtitle
30
+ attr_accessor :languages
31
+ attr_accessor :timespan
32
+ attr_accessor :filesize
33
+ attr_accessor :filename
34
+
35
+ attr_accessor :url
36
+ attr_accessor :mirrors
37
+
38
+ def initialize()
39
+ super()
40
+
41
+ @title = ''
42
+ @subtitle = ''
43
+ @languages = []
44
+ @timespan = ''
45
+ @filesize = ''
46
+ @filename = ''
47
+
48
+ @url = ''
49
+ @mirrors = {}
50
+ end
51
+
52
+ # Excludes @updated_on
53
+ def ==(y)
54
+ return @title == y.title &&
55
+ @subtitle == y.subtitle &&
56
+ @languages == y.languages &&
57
+ @timespan == y.timespan &&
58
+ @filesize == y.filesize &&
59
+ @filename == y.filename &&
60
+ @url == y.url &&
61
+ @mirrors == y.mirrors
62
+ end
63
+
64
+ def to_s()
65
+ s = ''
66
+ s << ('%-40s' % [@title])
67
+ s << (' | %30s' % [@subtitle])
68
+ s << (' | %10s' % [@languages.join(';')])
69
+ s << (' | %10s' % [@timespan])
70
+ s << (' | %10s' % [@filesize])
71
+ s << (' | %30s' % [@filename])
72
+ return s
73
+ end
74
+ end
75
+ end