pick_and_roll 0.1 → 0.9
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/lib/pick_and_roll.rb +24 -13
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f7892a2ef90c07b149b2f958ed57d0c4f5bfa04a
|
4
|
+
data.tar.gz: dfd28b34fdd449f3e58f35d62c4f8c264c2faba5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8b455ae0d0c4e6063be872831dc0d19f2fce4228e13350d2507840aab923d533afbd45574127c25745684b39a81d82874925e2be4da5843aa7bbcef3a0610518
|
7
|
+
data.tar.gz: 6efc0feb7fe303f63890890c3d0855c2f2ef5880ed0c8d97b7d146bd4fe75f00d3a3201400a14b7c7d03142511b6d697d5f4d49de7d6bd4a3d58ce5ded0da13d
|
data/lib/pick_and_roll.rb
CHANGED
@@ -7,13 +7,15 @@ class PickAndRoll
|
|
7
7
|
PARCONFIG_FILE_NAME = '.parconfig'
|
8
8
|
|
9
9
|
def initialize(config_path = '')
|
10
|
+
@parconfig = read_configuration
|
10
11
|
@config_file = config_path.to_s
|
11
12
|
end
|
12
13
|
|
13
14
|
def pick
|
14
|
-
|
15
|
-
|
16
|
-
|
15
|
+
master_config_name = @parconfig.has_key?('config') ? @parconfig['config'] : MASTER_CONFIG
|
16
|
+
if File.exist?(master_config_name)
|
17
|
+
@config = JSON.parse(File.read(master_config_name))
|
18
|
+
puts "pick config: #{master_config_name}"
|
17
19
|
else
|
18
20
|
@config = Hash.new
|
19
21
|
end
|
@@ -21,11 +23,18 @@ class PickAndRoll
|
|
21
23
|
if @config_file.strip.empty? == false && File.exists?("#{@config_file}.json")
|
22
24
|
@config.deep_merge!(JSON.parse(File.read("#{@config_file}.json")))
|
23
25
|
puts "pick config: #{@config_file}.json"
|
24
|
-
|
25
|
-
|
26
|
-
|
26
|
+
else
|
27
|
+
custom_config = "#{ENV["COMPUTERNAME"]}.json"
|
28
|
+
if @parconfig.has_key?('customDir')
|
29
|
+
custom_config = File.join(@parconfig['customDir'], custom_config)
|
30
|
+
end
|
31
|
+
if File.exist?(custom_config)
|
32
|
+
@config.deep_merge!(JSON.parse(File.read(custom_config)))
|
33
|
+
puts "pick config: #{custom_config}"
|
34
|
+
end
|
27
35
|
end
|
28
36
|
|
37
|
+
|
29
38
|
if @config.empty?
|
30
39
|
printf 'Please set configuration path or create config.json file'
|
31
40
|
exit
|
@@ -33,7 +42,7 @@ class PickAndRoll
|
|
33
42
|
end
|
34
43
|
|
35
44
|
def roll
|
36
|
-
file_patterns =
|
45
|
+
file_patterns = get_file_patterns()
|
37
46
|
|
38
47
|
file_patterns.each {|file_pattern|
|
39
48
|
Dir.glob("**/#{file_pattern}"){ |file_name|
|
@@ -47,15 +56,17 @@ class PickAndRoll
|
|
47
56
|
}
|
48
57
|
end
|
49
58
|
|
50
|
-
def
|
51
|
-
|
59
|
+
def get_file_patterns
|
60
|
+
@parconfig.has_key?('files') ? @parconfig['files'] : Array.new
|
61
|
+
end
|
62
|
+
|
63
|
+
def read_configuration
|
64
|
+
result = Hash.new
|
52
65
|
if File.exist?(PARCONFIG_FILE_NAME)
|
53
|
-
File.
|
54
|
-
file_patterns.push(line.strip)
|
55
|
-
}
|
66
|
+
result = JSON.parse(File.read(PARCONFIG_FILE_NAME))
|
56
67
|
end
|
57
68
|
|
58
|
-
|
69
|
+
result
|
59
70
|
end
|
60
71
|
|
61
72
|
def find_config_value(key)
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: pick_and_roll
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: '0.
|
4
|
+
version: '0.9'
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Dima Salakhov
|
@@ -17,7 +17,7 @@ extensions: []
|
|
17
17
|
extra_rdoc_files: []
|
18
18
|
files:
|
19
19
|
- lib/pick_and_roll.rb
|
20
|
-
homepage:
|
20
|
+
homepage: https://rubygems.org/gems/pick_and_roll
|
21
21
|
licenses:
|
22
22
|
- MIT
|
23
23
|
metadata: {}
|