wonko_the_sane 0.1.4 → 0.1.5
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 +4 -4
- data/bin/wonko_the_sane +3 -3
- data/lib/wonko_the_sane.rb +4 -7
- data/lib/wonko_the_sane/new_format.rb +10 -10
- data/lib/wonko_the_sane/util/configuration.rb +19 -28
- data/lib/wonko_the_sane/util/deep_storage_cache.rb +1 -1
- data/lib/wonko_the_sane/util/http_cache.rb +1 -1
- data/lib/wonko_the_sane/util/task_stack.rb +28 -20
- data/lib/wonko_the_sane/util/version_parser.rb +95 -99
- data/lib/wonko_the_sane/version.rb +1 -1
- data/lib/wonko_the_sane/versionlists/vanilla_legacy_version_list.rb +2 -3
- data/lib/wonko_the_sane/wonko_version.rb +3 -3
- metadata +2 -3
- data/lib/wonko_the_sane/util.rb +0 -17
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8aae6ec1255ccf32e504d0d7e8e6cf1faaf4d835
|
4
|
+
data.tar.gz: c8426ad171f4b69585999bf476b2b2c1533fc3ea
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7c0d69626c46d2764b174cfc43f301c431246d71f8e70588190dd2fe5be41a55c2b73d68e73ecf87dd9b7bcab01c4a28658f3d9bc797a26bd0e19c54e646ec87
|
7
|
+
data.tar.gz: cfd8cd641b7cc9380810632145c260f4545e4b41e0b2fe85e6f3591903331b826fb854e49215a22fbcea3f2fef4dacdbe75a26cf2de92a512be1fd8397cc077f
|
data/bin/wonko_the_sane
CHANGED
@@ -38,7 +38,7 @@ OptionParser.new do |opts|
|
|
38
38
|
if list.nil?
|
39
39
|
Logging.logger['General'].warn "Couldn't find the specified list #{id.cyan}"
|
40
40
|
else
|
41
|
-
|
41
|
+
WonkoTheSane.tasks.push(Proc.new do
|
42
42
|
Logging.logger[list.artifact].info 'Refreshing'
|
43
43
|
list.refresh
|
44
44
|
Logging.logger[list.artifact].error list.last_error if list.last_error
|
@@ -47,7 +47,7 @@ OptionParser.new do |opts|
|
|
47
47
|
end
|
48
48
|
opts.on '-a', '--refresh-all', 'Refresh all lists' do
|
49
49
|
WonkoTheSane.lists.each do |list|
|
50
|
-
|
50
|
+
WonkoTheSane.tasks.push(Proc.new do
|
51
51
|
Logging.logger[list.artifact].info 'Refreshing'
|
52
52
|
list.refresh
|
53
53
|
Logging.logger[list.artifact].error list.last_error if list.last_error
|
@@ -83,4 +83,4 @@ OptionParser.new do |opts|
|
|
83
83
|
end
|
84
84
|
end.parse!
|
85
85
|
|
86
|
-
|
86
|
+
WonkoTheSane.tasks.pop_all
|
data/lib/wonko_the_sane.rb
CHANGED
@@ -10,6 +10,7 @@ require 'digest'
|
|
10
10
|
require 'date'
|
11
11
|
require 'time'
|
12
12
|
require 'oga'
|
13
|
+
require 'pathname'
|
13
14
|
require 'active_support/core_ext/hash/indifferent_access'
|
14
15
|
require 'active_support/core_ext/object/blank'
|
15
16
|
|
@@ -49,20 +50,16 @@ require 'wonko_the_sane/version_index'
|
|
49
50
|
require 'wonko_the_sane/wonko_version'
|
50
51
|
|
51
52
|
module WonkoTheSane
|
52
|
-
def self.wonkoweb_uploader
|
53
|
-
@uploader ||= WonkoWebUploader.new
|
54
|
-
end
|
55
|
-
|
56
53
|
def self.lists
|
57
54
|
configuration.lists
|
58
55
|
end
|
59
56
|
|
60
|
-
def self.
|
61
|
-
|
57
|
+
def self.tasks
|
58
|
+
@tasks ||= WonkoTheSane::Util::TaskStack.new
|
62
59
|
end
|
63
60
|
|
64
61
|
def self.data(file)
|
65
|
-
configuration.data_path +
|
62
|
+
Pathname.new(configuration.data_path) + file
|
66
63
|
end
|
67
64
|
|
68
65
|
def self.data_json(file)
|
@@ -98,20 +98,20 @@ module Writer
|
|
98
98
|
def write_resource(side, resource, out)
|
99
99
|
data = {}
|
100
100
|
|
101
|
-
data[:'general.traits'] = resource.traits
|
102
|
-
data[:'general.launcher'] = resource.launchMethod
|
103
|
-
data[:'general.folders'] = resource.folders
|
101
|
+
data[:'general.traits'] = resource.traits unless resource.traits.blank?
|
102
|
+
data[:'general.launcher'] = resource.launchMethod unless resource.launchMethod.blank?
|
103
|
+
data[:'general.folders'] = resource.folders unless resource.folders.blank?
|
104
104
|
resource.downloads.each do |dl|
|
105
105
|
data[dl.type] = [] unless data[dl.type]
|
106
106
|
data[dl.type] << dl.to_json
|
107
107
|
end
|
108
|
-
data[:'java.mainClass'] = resource.mainClass
|
109
|
-
data[:'mc.jarModTarget'] = resource.jarModTarget
|
108
|
+
data[:'java.mainClass'] = resource.mainClass unless resource.mainClass.blank?
|
109
|
+
data[:'mc.jarModTarget'] = resource.jarModTarget unless resource.jarModTarget.blank?
|
110
110
|
|
111
|
-
data[:'mc.tweakers'] = resource.tweakers
|
112
|
-
data[:'mc.appletClass'] = resource.appletClass
|
113
|
-
data[:'mc.assets'] = resource.assets
|
114
|
-
data[:'mc.arguments'] = resource.minecraftArguments
|
111
|
+
data[:'mc.tweakers'] = resource.tweakers unless resource.tweakers.blank?
|
112
|
+
data[:'mc.appletClass'] = resource.appletClass unless resource.appletClass.blank?
|
113
|
+
data[:'mc.assets'] = resource.assets unless resource.assets.blank?
|
114
|
+
data[:'mc.arguments'] = resource.minecraftArguments unless resource.minecraftArguments.blank?
|
115
115
|
|
116
116
|
unless data.empty?
|
117
117
|
if side == :client || side == :server
|
@@ -139,7 +139,7 @@ module Writer
|
|
139
139
|
obj = { uid: req.uid }
|
140
140
|
obj[:version] = req.version if req.version
|
141
141
|
obj
|
142
|
-
end
|
142
|
+
end unless version.requires.blank?
|
143
143
|
|
144
144
|
write_resource(:client, version.client, json[:data]) if version.is_complete
|
145
145
|
write_resource(:server, version.server, json[:data]) if version.is_complete
|
@@ -1,4 +1,5 @@
|
|
1
1
|
require 'yaml'
|
2
|
+
require 'active_support/core_ext/string/inflections'
|
2
3
|
|
3
4
|
module WonkoTheSane
|
4
5
|
module Util
|
@@ -9,13 +10,6 @@ module WonkoTheSane
|
|
9
10
|
attr_accessor :bucket
|
10
11
|
end
|
11
12
|
|
12
|
-
class WonkoWeb
|
13
|
-
attr_accessor :host
|
14
|
-
attr_accessor :email
|
15
|
-
attr_accessor :token
|
16
|
-
attr_accessor :name
|
17
|
-
end
|
18
|
-
|
19
13
|
attr_reader :aws
|
20
14
|
attr_reader :wonkoweb
|
21
15
|
attr_reader :lists
|
@@ -25,7 +19,7 @@ module WonkoTheSane
|
|
25
19
|
def initialize
|
26
20
|
@lists = []
|
27
21
|
@aws = Aws.new
|
28
|
-
@
|
22
|
+
@data_path = Dir.pwd + '/data'
|
29
23
|
end
|
30
24
|
|
31
25
|
def load_from_env
|
@@ -33,35 +27,28 @@ module WonkoTheSane
|
|
33
27
|
@aws.client_secret = ENV['WTS_AWS_CLIENT_SECRET'] if ENV['WTS_AWS_CLIENT_SECRET']
|
34
28
|
@aws.bucket = ENV['WTS_AWS_BUCKET'] if ENV['WTS_AWS_BUCKET']
|
35
29
|
|
36
|
-
@wonkoweb.host = ENV['WTS_WONKOWEB_HOST'] if ENV['WTS_WONKOWEB_HOST']
|
37
|
-
@wonkoweb.email = ENV['WTS_WONKOWEB_EMAIL'] if ENV['WTS_WONKOWEB_EMAIL']
|
38
|
-
@wonkoweb.token = ENV['WTS_WONKOWEB_TOKEN'] if ENV['WTS_WONKOWEB_TOKEN']
|
39
|
-
@wonkoweb.token = ENV['WTS_WONKOWEB_NAME'] if ENV['WTS_WONKOWEB_NAME']
|
40
|
-
|
41
30
|
@data_path = ENV['WTS_DATA_PATH'] if ENV['WTS_DATA_PATH']
|
42
31
|
@out_dir = ENV['WTS_OUT_DIR'] if ENV['WTS_OUT_DIR']
|
43
32
|
end
|
44
33
|
|
45
34
|
def load_from_file(filename)
|
46
|
-
raw = YAML.load_file
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
@wonkoweb.token = raw['wonkoweb']['token']
|
54
|
-
@wonkoweb.name = raw['wonkoweb']['name']
|
35
|
+
raw = YAML.load_file(filename).with_indifferent_access
|
36
|
+
if raw.key? 'aws'
|
37
|
+
aws = raw['aws']
|
38
|
+
@aws.client_id = aws['client_id'] if aws.key? 'client_id'
|
39
|
+
@aws.client_secret = aws['client_secret'] if aws.key? 'client_secret'
|
40
|
+
@aws.bucket = aws['bucket'] if aws.key? 'bucket'
|
41
|
+
end
|
55
42
|
|
56
|
-
@data_path = raw['data_path']
|
57
|
-
@out_dir = raw['out_dir']
|
43
|
+
@data_path = raw['data_path'] if raw.key? 'data_path'
|
44
|
+
@out_dir = raw['out_dir'] if raw.key? 'out_dir'
|
58
45
|
end
|
59
46
|
|
60
47
|
def register_list(list)
|
61
48
|
case list
|
62
|
-
when String
|
63
|
-
register_list list.to_sym
|
64
49
|
when Symbol
|
50
|
+
register_list list.to_s.constantize
|
51
|
+
when String
|
65
52
|
register_list list.constantize
|
66
53
|
when Class
|
67
54
|
register_list list.new
|
@@ -70,8 +57,12 @@ module WonkoTheSane
|
|
70
57
|
end
|
71
58
|
end
|
72
59
|
|
73
|
-
def register_lists_from_sources
|
74
|
-
sources =
|
60
|
+
def register_lists_from_sources(filename = 'sources.json')
|
61
|
+
sources = if filename.is_a? String
|
62
|
+
WonkoTheSane.data_json filename
|
63
|
+
else
|
64
|
+
filename
|
65
|
+
end
|
75
66
|
sources[:forgefiles].each do |uid, urlId|
|
76
67
|
register_list ForgeFilesModsList.new(uid.to_s, urlId)
|
77
68
|
end if sources[:forgefiles]
|
@@ -29,7 +29,7 @@ module WonkoTheSane
|
|
29
29
|
|
30
30
|
object = @bucket.object info[:file]
|
31
31
|
unless object.exists? && object.size == info[:size]
|
32
|
-
|
32
|
+
WonkoTheSane.tasks.in_background do
|
33
33
|
# convert the hex-encoded md5 to a base64-encoded md5, which is what S3 expects
|
34
34
|
# http://anthonylewis.com/2011/02/09/to-hex-and-back-with-ruby/
|
35
35
|
md5 = [info[:md5].scan(/../).map { |x| x.hex.chr }.join].pack 'm0'
|
@@ -37,7 +37,7 @@ class HTTPCache
|
|
37
37
|
|
38
38
|
return if File.exists?(cached_path) && !check_stale
|
39
39
|
|
40
|
-
|
40
|
+
WonkoTheSane.tasks.in_background do
|
41
41
|
uri = URI.parse url
|
42
42
|
host = URI::HTTP.new(uri.scheme, uri.userinfo, uri.host, uri.port, nil, nil, nil, nil, nil).to_s
|
43
43
|
|
@@ -1,22 +1,30 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
1
|
+
module WonkoTheSane
|
2
|
+
module Util
|
3
|
+
class TaskStack
|
4
|
+
attr_reader :queue
|
5
|
+
|
6
|
+
def initialize
|
7
|
+
@queue = []
|
8
|
+
end
|
9
|
+
|
10
|
+
def push(task)
|
11
|
+
@queue.push task
|
12
|
+
end
|
13
|
+
def push_defered(task)
|
14
|
+
@queue.unshift task
|
15
|
+
end
|
16
|
+
def pop
|
17
|
+
task = @queue.pop
|
18
|
+
task.call
|
19
|
+
end
|
20
|
+
def pop_all
|
21
|
+
pop until @queue.empty?
|
22
|
+
end
|
23
|
+
def in_background(&block)
|
24
|
+
thread = Thread.new &block
|
25
|
+
pop_all
|
26
|
+
thread.join.value
|
27
|
+
end
|
28
|
+
end
|
21
29
|
end
|
22
30
|
end
|
@@ -1,111 +1,107 @@
|
|
1
|
-
|
2
|
-
|
1
|
+
module WonkoTheSane
|
2
|
+
module Util
|
3
|
+
class VersionParser
|
4
|
+
private
|
3
5
|
|
4
|
-
|
6
|
+
class << self; attr_accessor :cache; end
|
7
|
+
self.cache = {}
|
5
8
|
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
end
|
15
|
-
|
16
|
-
result = {
|
17
|
-
appendix: appendix,
|
18
|
-
sections: sections
|
19
|
-
}
|
20
|
-
self.cache[string] = result
|
21
|
-
return result
|
22
|
-
end
|
9
|
+
def self.parse(string)
|
10
|
+
return self.cache[string] if self.cache.has_key? string
|
11
|
+
appendix = string.scan(/\-.*$/).first
|
12
|
+
sections = string.sub(/\-.*$/, '').split '.'
|
13
|
+
sections.map! do |sec|
|
14
|
+
test = Integer sec rescue nil
|
15
|
+
test || sec
|
16
|
+
end
|
23
17
|
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
[0, digits]
|
32
|
-
when 'b'
|
33
|
-
[1, digits]
|
34
|
-
when 'beta'
|
35
|
-
[1, digits]
|
36
|
-
when 'rc'
|
37
|
-
[2, digits]
|
38
|
-
when 'pre'
|
39
|
-
[2, digits]
|
40
|
-
end
|
41
|
-
ret || [-1, digits]
|
42
|
-
end
|
18
|
+
result = {
|
19
|
+
appendix: appendix,
|
20
|
+
sections: sections
|
21
|
+
}
|
22
|
+
self.cache[string] = result
|
23
|
+
return result
|
24
|
+
end
|
43
25
|
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
26
|
+
def self.appendix_values(appendix)
|
27
|
+
str = appendix.scan /[a-zA-Z]*/
|
28
|
+
digits = appendix.scan(/\d*/).join.to_i
|
29
|
+
ret = case str.find { |s| !s.blank? }
|
30
|
+
when 'a'
|
31
|
+
[0, digits]
|
32
|
+
when 'alpha'
|
33
|
+
[0, digits]
|
34
|
+
when 'b'
|
35
|
+
[1, digits]
|
36
|
+
when 'beta'
|
37
|
+
[1, digits]
|
38
|
+
when 'rc'
|
39
|
+
[2, digits]
|
40
|
+
when 'pre'
|
41
|
+
[2, digits]
|
42
|
+
end
|
43
|
+
ret || [-1, digits]
|
44
|
+
end
|
53
45
|
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
val2 = par2[:sections].length > index ? par2[:sections][index] : 0
|
63
|
-
if val1.is_a? Integer && val2.is_a?(Integer)
|
64
|
-
ret = VersionParser.compare_values val1, val2
|
65
|
-
elsif val1.is_a? Integer
|
66
|
-
ret = VersionParser.compare_values val1.to_s, val2
|
67
|
-
elsif val2.is_a? Integer
|
68
|
-
ret = VersionParser.compare_values val1, val2.to_s
|
69
|
-
else
|
70
|
-
ret = VersionParser.compare_values val1.to_s, val2.to_s
|
46
|
+
def self.compare_values(first, second)
|
47
|
+
if first < second
|
48
|
+
-1
|
49
|
+
elsif first > second
|
50
|
+
1
|
51
|
+
else
|
52
|
+
0
|
53
|
+
end
|
71
54
|
end
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
ret =
|
55
|
+
|
56
|
+
public
|
57
|
+
def self.compare(string1, string2)
|
58
|
+
par1 = VersionParser.parse string1
|
59
|
+
par2 = VersionParser.parse string2
|
60
|
+
size = [par1[:sections].length, par2[:sections].length].max
|
61
|
+
ret = 0
|
62
|
+
size.times do |index|
|
63
|
+
val1 = par1[:sections].length > index ? par1[:sections][index] : 0
|
64
|
+
val2 = par2[:sections].length > index ? par2[:sections][index] : 0
|
65
|
+
ret = VersionParser.compare_values val1.to_i, val2.to_i
|
66
|
+
break unless ret == 0
|
67
|
+
end
|
79
68
|
if ret == 0
|
80
|
-
|
69
|
+
if par1[:appendix] && par2[:appendix]
|
70
|
+
appendix1 = VersionParser.appendix_values par1[:appendix]
|
71
|
+
appendix2 = VersionParser.appendix_values par2[:appendix]
|
72
|
+
ret = VersionParser.compare_values appendix1[0], appendix2[0]
|
73
|
+
if ret == 0
|
74
|
+
ret = VersionParser.compare_values appendix1[1], appendix2[1]
|
75
|
+
end
|
76
|
+
elsif par1[:appendix]
|
77
|
+
ret = -1
|
78
|
+
elsif par2[:appendix]
|
79
|
+
ret = 1
|
80
|
+
end
|
81
81
|
end
|
82
|
-
|
83
|
-
ret = -1
|
84
|
-
elsif par2[:appendix]
|
85
|
-
ret = 1
|
82
|
+
return ret
|
86
83
|
end
|
87
|
-
end
|
88
|
-
return ret
|
89
|
-
end
|
90
84
|
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
85
|
+
def self.less?(string1, string2)
|
86
|
+
VersionParser.compare(string1, string2) == -1
|
87
|
+
end
|
88
|
+
def self.greater?(string1, string2)
|
89
|
+
VersionParser.compare(string1, string2) == 1
|
90
|
+
end
|
91
|
+
def self.equal?(string1, string2)
|
92
|
+
VersionParser.compare(string1, string2) == 0
|
93
|
+
end
|
94
|
+
def self.less_or_equal?(string1, string2)
|
95
|
+
ret = VersionParser.compare string1, string2
|
96
|
+
ret == 0 or ret == -1
|
97
|
+
end
|
98
|
+
def self.greater_or_equal?(string1, string2)
|
99
|
+
ret = VersionParser.compare string1, string2
|
100
|
+
ret == 0 or ret == 1
|
101
|
+
end
|
102
|
+
def self.not_equal?(string1, string2)
|
103
|
+
VersionParser.compare(string1, string2) != 0
|
104
|
+
end
|
105
|
+
end
|
110
106
|
end
|
111
107
|
end
|
@@ -26,11 +26,10 @@ class VanillaLegacyVersionList < BaseVersionList
|
|
26
26
|
file.client.downloads = [ main_lib ]
|
27
27
|
|
28
28
|
file.client.folders['minecraft/screenshots'] = ['general.screenshots']
|
29
|
-
file.client.folders['minecraft/resourcepackks'] = ['mc.resourcepacks'] if file.time >= 1372430921
|
30
29
|
file.client.folders['minecraft/texturepacks'] = ['mc.texturepacks'] if file.time < 1372430921
|
31
30
|
file.client.folders['minecraft/saves'] = ['mc.saves.anvil'] if file.time >= 1330552800
|
32
|
-
file.client.folders['minecraft/saves'] = ['mc.saves.region'] if file.time >= 1298325600
|
33
|
-
file.client.folders['minecraft/saves'] = ['mc.saves.infdev'] if file.time >= 1291327200
|
31
|
+
file.client.folders['minecraft/saves'] = ['mc.saves.region'] if file.time >= 1298325600 && file.time < 1330552800
|
32
|
+
file.client.folders['minecraft/saves'] = ['mc.saves.infdev'] if file.time >= 1291327200 && file.time < 1298325600
|
34
33
|
file.client.traits.delete 'texturepacks' if file.client.traits
|
35
34
|
file.client.traits.delete 'no-resourcepacks' if file.client.traits
|
36
35
|
|
@@ -19,8 +19,8 @@ class Download
|
|
19
19
|
size: @size,
|
20
20
|
sha256: @sha256
|
21
21
|
}
|
22
|
-
obj[:rules] = @rules.map
|
23
|
-
|
22
|
+
obj[:rules] = @rules.map { |rule| rule.to_json } unless @rules.blank?
|
23
|
+
obj
|
24
24
|
end
|
25
25
|
|
26
26
|
def from_json(json)
|
@@ -100,7 +100,7 @@ class VersionLibrary < Download
|
|
100
100
|
def to_json
|
101
101
|
obj = super
|
102
102
|
obj[:name] = @name
|
103
|
-
obj[:@maven_base_url] = @maven_base_url
|
103
|
+
obj[:@maven_base_url] = @maven_base_url unless @maven_base_url.blank?
|
104
104
|
|
105
105
|
unless @url
|
106
106
|
obj.delete :url
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: wonko_the_sane
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- 02JanDal
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2015-10-
|
13
|
+
date: 2015-10-04 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: bundler
|
@@ -375,7 +375,6 @@ files:
|
|
375
375
|
- lib/wonko_the_sane/rules.rb
|
376
376
|
- lib/wonko_the_sane/timestamps.rb
|
377
377
|
- lib/wonko_the_sane/tools/update_nem.rb
|
378
|
-
- lib/wonko_the_sane/util.rb
|
379
378
|
- lib/wonko_the_sane/util/benchmark.rb
|
380
379
|
- lib/wonko_the_sane/util/configuration.rb
|
381
380
|
- lib/wonko_the_sane/util/deep_storage_cache.rb
|
data/lib/wonko_the_sane/util.rb
DELETED
@@ -1,17 +0,0 @@
|
|
1
|
-
module Util
|
2
|
-
def self.deep_map_keys(val, &block)
|
3
|
-
Util.deep_map_hash val do |k, v|
|
4
|
-
[yield(k), v]
|
5
|
-
end
|
6
|
-
end
|
7
|
-
|
8
|
-
def self.deep_map(val, &block)
|
9
|
-
if val.is_a? Array
|
10
|
-
val.map { |item| deep_map_hash item, &block }
|
11
|
-
elsif val.is_a? Hash
|
12
|
-
Hash[val.map { |k, v| yield k, deep_map_hash(v, &block) }]
|
13
|
-
else
|
14
|
-
yield nil, val
|
15
|
-
end
|
16
|
-
end
|
17
|
-
end
|