colorconfig 2.2.2 → 2.2.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: f8308a51603353511690ee54501c43b7d5b59634
4
- data.tar.gz: c011f9d8bb35bb65a515305ce50a067893871802
3
+ metadata.gz: 43a7742ca93ab1464260a1b0d68f4d00757b4ae5
4
+ data.tar.gz: 6b2a12fdae1fba1112c32da9eb388916af2c0acc
5
5
  SHA512:
6
- metadata.gz: c35a54cb707b07593e191fff2b73e11b128eb6ca26fd555be726297e536c88e46c7e5136c1de72289c42d893254349098c57840f3df97e909cc8cdadfba06935
7
- data.tar.gz: a2ca99faad01999e1d9840a7143cd778bd53e9ff0ccff038ff885097fac4180b7202d211fc75177611df04841ae55c0b072f7ffa5fb919714b73f28b2b40ed1f
6
+ metadata.gz: e33a5ab9307f39988bc110d195419cd3022aa3917954a908e354e75389e8ed02284c149f4617ac3a33a08b19ba69765dda179c2167cac2f3df395993a00e47ac
7
+ data.tar.gz: 0d38094af9964f14d274470bbf326980f7558a7277fd7ff6aacbf4e5e4fc830ec97a0310527d7581a379013c4d74bf5815e0e063830ded9fe7c5dc3439e9a697
data/bin/colorconfig CHANGED
@@ -7,65 +7,83 @@ require 'everyday-cli-utils'
7
7
  include EverydayCliUtils
8
8
  import :maputil, :ask
9
9
 
10
- config_files = {
11
- mvn2: '~/mvn2-colors.yaml',
12
- mvr: '~/mvr-colors.yaml',
10
+ Signal.trap('SIGINT') {
11
+ Process.waitall
12
+ puts
13
+ exit 1
13
14
  }
14
15
 
16
+ def check_has_config(name)
17
+ begin
18
+ require name
19
+ true
20
+ rescue LoadError => e
21
+ # puts e
22
+ # puts e.backtrace.join("\n")
23
+ false
24
+ end
25
+ end
26
+
27
+ config_files = {}
28
+ if check_has_config('mvn2')
29
+ config_files[:mvn2] = '~/mvn2-colors.yaml'
30
+ else
31
+ puts 'mvn2 gem not installed.'
32
+ end
33
+ if check_has_config('mvr')
34
+ config_files[:mvr] = '~/mvr-colors.yaml'
35
+ else
36
+ puts 'mvr gem not installed.'
37
+ end
38
+
15
39
  default_options = {
16
- mvn2: {
17
- time: {
18
- fg: :green,
19
- bg: :none,
20
- },
21
- percent: {
22
- fg: :purple,
23
- bg: :none,
24
- },
25
- average: {
26
- fg: :cyan,
27
- bg: :none,
28
- },
40
+ mvn2: {
41
+ time: {
42
+ fg: :green,
43
+ bg: :none
44
+ },
45
+ percent: {
46
+ fg: :purple,
47
+ bg: :none
48
+ },
49
+ average: {
50
+ fg: :cyan,
51
+ bg: :none
52
+ }
53
+ },
54
+ mvr: {
55
+ normal: {
56
+ fg: :none,
57
+ bg: :none
29
58
  },
30
- mvr: {
31
- normal: {
32
- fg: :none,
33
- bg: :none,
34
- },
35
- same: {
36
- fg: :black,
37
- bg: :white,
38
- },
39
- conflict: {
40
- fg: :white,
41
- bg: :red,
42
- },
59
+ same: {
60
+ fg: :black,
61
+ bg: :white
43
62
  },
63
+ conflict: {
64
+ fg: :white,
65
+ bg: :red
66
+ }
67
+ }
44
68
  }
45
69
 
46
70
  colors = [:black, :red, :green, :yellow, :blue, :purple, :cyan, :white, :none]
47
71
 
48
- while true
49
-
50
- Ask::ask('Which script do you want to configure colors for?', [:mvn2, :mvr, :Exit]) { |script|
51
- if script == :Exit
52
- exit(0)
53
- end
72
+ loop do
73
+ Ask.ask('Which script do you want to configure colors for?', Ask.hash_to_options(config_files, [:Exit])) { |script|
74
+ exit(0) if script == :Exit
54
75
 
55
76
  config_file = File.expand_path(config_files[script])
56
77
 
57
78
  options = Marshal.load(Marshal.dump(default_options[script]))
58
79
 
59
- if File.exist?(config_file)
60
- options = YAML::load_file(config_file)
61
- end
80
+ options = YAML.load_file(config_file) if File.exist?(config_file)
62
81
 
63
82
  brk = false
64
83
  until brk
65
- Ask::ask('Which config option do you want?', Ask::hash_to_options(options, [:Save, :'Up a level', :Exit])) { |opt|
66
- if opt == :Exit
67
- exit(0)
68
- elsif opt == :'Up a level'
84
+ Ask.ask('Which config option do you want?', Ask.hash_to_options(options, [:Save, :'Up a level', :Exit])) { |opt|
85
+ exit(0) if opt == :Exit
86
+ if opt == :'Up a level'
69
87
  brk = true
70
88
  elsif opt == :Save
71
89
  IO.write(config_file, options.to_yaml)
@@ -73,13 +91,12 @@ while true
73
91
  else
74
92
  brk2 = false
75
93
  until brk2
76
- Ask::ask("Configuring: #{opt.to_s}\nWhich color do you want to set?", Ask::hash_to_options(options[opt], [:'Up a level', :Exit])) { |which|
77
- if which == :Exit
78
- exit(0)
79
- elsif which == :'Up a level'
94
+ Ask.ask("Configuring: #{opt}\nWhich color do you want to set?", Ask.hash_to_options(options[opt], [:'Up a level', :Exit])) { |which|
95
+ exit(0) if which == :Exit
96
+ if which == :'Up a level'
80
97
  brk2 = true
81
98
  else
82
- Ask::ask("Configuring: #{opt.to_s} -> #{which.to_s} (currently: #{options[opt][which].to_s}) (default: #{default_options[script][opt][which].to_s})\nWhich color do you want?", colors + [:Default, :Cancel]) { |color|
99
+ Ask.ask("Configuring: #{opt} -> #{which} (currently: #{options[opt][which]}) (default: #{default_options[script][opt][which]})\nWhich color do you want?", colors + [:Default, :Cancel]) { |color|
83
100
  unless color == :Cancel
84
101
  options[opt][which] = (color == :Default) ? default_options[script][opt][which] : color
85
102
  end
@@ -1,3 +1,3 @@
1
1
  module Colorconfig
2
- VERSION = '2.2.2'
2
+ VERSION = '2.2.3'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: colorconfig
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.2.2
4
+ version: 2.2.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Eric Henderson
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-11-03 00:00:00.000000000 Z
11
+ date: 2015-08-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -111,8 +111,9 @@ required_rubygems_version: !ruby/object:Gem::Requirement
111
111
  version: '0'
112
112
  requirements: []
113
113
  rubyforge_project:
114
- rubygems_version: 2.4.2
114
+ rubygems_version: 2.4.6
115
115
  signing_key:
116
116
  specification_version: 4
117
117
  summary: color configuration
118
118
  test_files: []
119
+ has_rdoc: