rate_theme 0.0.4 → 0.0.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/rate_theme.rb +7 -7
- data/lib/rate_theme/monitor.rb +44 -22
- data/lib/rate_theme/version.rb +1 -1
- data/rate_theme.gemspec +0 -2
- data/test/test_helper.rb +7 -5
- data/test/test_monitor.rb +6 -2
- metadata +3 -31
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3ec40c5d2fe724dfd79a20b18f86899bd8d9eea4
|
4
|
+
data.tar.gz: 0fd9e03645277e0dd5329c722c02c8d0a65c2a16
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 64141a53c1a02dc62d3572599f71519fa7ed68c6efa602bf019fd0fa52564125e6c1ec3a00882f708196919d99e477c96577721a1e9a67fc14bc3fd8d945fbf8
|
7
|
+
data.tar.gz: 93dac488882f6acac76c9fe075566ea2a73141fedfd1382180c88ecfd364d586164e11382cf5753b8380aee4f3a11699d1cb5b67180ec234eb71676fc8b38de0
|
data/lib/rate_theme.rb
CHANGED
@@ -36,13 +36,13 @@ require "rate_theme/ask"
|
|
36
36
|
@div.call
|
37
37
|
rating.receive_answer
|
38
38
|
@div.call
|
39
|
-
|
39
|
+
|
40
40
|
logger = RateTheme::Logger.new name: name.input, rating: rating.input
|
41
41
|
logger.action
|
42
42
|
end
|
43
43
|
elsif ask.input == '2'
|
44
44
|
chosen = RateTheme::Lister.new
|
45
|
-
if chosen.
|
45
|
+
if chosen.find_file
|
46
46
|
@best = chosen.best_theme
|
47
47
|
puts @best.colorize(:red) + " Is your highest rated!"
|
48
48
|
@div.call
|
@@ -51,7 +51,7 @@ require "rate_theme/ask"
|
|
51
51
|
puts "1. Change theme to highest rated?"
|
52
52
|
puts "2. Choose specific theme?"
|
53
53
|
@div.call
|
54
|
-
change_theme = RateTheme::Ask.new question: "choose theme?"
|
54
|
+
change_theme = RateTheme::Ask.new question: "choose theme?"
|
55
55
|
change_theme.receive_answer
|
56
56
|
|
57
57
|
@div.call
|
@@ -60,15 +60,15 @@ require "rate_theme/ask"
|
|
60
60
|
change = RateTheme::Changer.new @best
|
61
61
|
@status.call("done")
|
62
62
|
|
63
|
-
change.
|
63
|
+
change.find_file
|
64
64
|
elsif change_theme.input == '2'
|
65
65
|
specific_theme = RateTheme::Ask.new question: "Type in the specific theme"
|
66
66
|
puts specific_theme.question
|
67
67
|
specific_theme.receive_answer
|
68
68
|
unless specific_theme.input == ''
|
69
|
-
change = RateTheme::Changer.new specific_theme.input
|
69
|
+
change = RateTheme::Changer.new specific_theme.input
|
70
70
|
@status.call("done")
|
71
|
-
change.
|
71
|
+
change.find_file
|
72
72
|
@div.call
|
73
73
|
puts "open a new window for changes to show!".colorize(:green)
|
74
74
|
end
|
@@ -82,5 +82,5 @@ require "rate_theme/ask"
|
|
82
82
|
elsif ask.input == '3'
|
83
83
|
@status.call("done")
|
84
84
|
random = RateTheme::Changer.new 'random'
|
85
|
-
random.
|
85
|
+
random.find_file
|
86
86
|
end
|
data/lib/rate_theme/monitor.rb
CHANGED
@@ -59,34 +59,43 @@ module RateTheme
|
|
59
59
|
end
|
60
60
|
|
61
61
|
class Changer
|
62
|
-
|
63
|
-
attr_reader :theme
|
62
|
+
attr_accessor :file
|
63
|
+
attr_reader :theme
|
64
64
|
def initialize(theme)
|
65
65
|
@theme = theme
|
66
66
|
@file = Dir.home + "/.zshrc"
|
67
|
-
@
|
67
|
+
@personal_defualt = Dir.home + "/code/configs/.zshrc"
|
68
|
+
@user_location = ''
|
68
69
|
end
|
69
70
|
|
70
|
-
def
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
71
|
+
def file?
|
72
|
+
File.exist?(self.file) ? true : false
|
73
|
+
end
|
74
|
+
|
75
|
+
def self.find_theme_config lines
|
76
|
+
tmp = 0
|
77
|
+
lines.each { |l| tmp = l if l =~ /ZSH_THEME/ }
|
78
|
+
tmp == 0 ? false : tmp
|
79
|
+
end
|
80
|
+
|
81
|
+
def rewrite_config lines
|
82
|
+
File.open(self.file, 'w') do |f|
|
83
|
+
lines.each {|l| f << l}
|
84
|
+
end
|
85
|
+
end
|
86
|
+
|
87
|
+
def find_file
|
88
|
+
if self.file?
|
89
|
+
Success.p_found_file self.file
|
90
|
+
config_file = File.open(self.file, 'a+')
|
91
|
+
all_lines = config_file.readlines
|
92
|
+
config_file.close
|
93
|
+
config_line = Changer.find_theme_config all_lines
|
94
|
+
index = all_lines.index(config_line)
|
95
|
+
all_lines[index.to_i] = "ZSH_THEME=" + "'" + "#{@theme}" + "'"
|
96
|
+
self.rewrite_config all_lines
|
87
97
|
else
|
88
|
-
|
89
|
-
puts "Please enter the path of your .zshrc file '/../../'"
|
98
|
+
Error.missing_file
|
90
99
|
input = gets.chomp
|
91
100
|
unless input == ''
|
92
101
|
self.file = input
|
@@ -94,5 +103,18 @@ module RateTheme
|
|
94
103
|
end
|
95
104
|
end
|
96
105
|
end
|
106
|
+
|
107
|
+
class Error
|
108
|
+
def self.p_missing_file
|
109
|
+
puts "We can't find your file".colorize(:red)
|
110
|
+
puts "Please enter the path of your .zshrc file '/../../'"
|
111
|
+
end
|
112
|
+
end
|
113
|
+
|
114
|
+
class Success
|
115
|
+
def self.p_found_file file
|
116
|
+
puts "File found in #{file}".colorize(:green)
|
117
|
+
end
|
118
|
+
end
|
97
119
|
end
|
98
120
|
end
|
data/lib/rate_theme/version.rb
CHANGED
data/rate_theme.gemspec
CHANGED
@@ -22,7 +22,5 @@ Gem::Specification.new do |spec|
|
|
22
22
|
spec.add_development_dependency "bundler", "~> 1.5"
|
23
23
|
spec.add_development_dependency "rake"
|
24
24
|
spec.add_development_dependency "minitest"
|
25
|
-
spec.add_development_dependency "ZenTest"
|
26
|
-
spec.add_development_dependency "autotest-fsevent"
|
27
25
|
spec.add_runtime_dependency "colorize"
|
28
26
|
end
|
data/test/test_helper.rb
CHANGED
@@ -1,13 +1,15 @@
|
|
1
1
|
gems = %w[rate_theme/ask
|
2
2
|
rate_theme/monitor
|
3
|
+
rate_theme/version
|
3
4
|
minitest/autorun
|
5
|
+
minitest/focus
|
4
6
|
minitest/pride
|
5
7
|
minitest/unit]
|
8
|
+
|
6
9
|
gems.each {|gem| require "#{gem}"}
|
7
10
|
|
8
|
-
|
9
|
-
it "must be defined" do
|
10
|
-
RateTheme::VERSION.wont_be_nil
|
11
|
-
end
|
12
|
-
end
|
11
|
+
include RateTheme
|
13
12
|
|
13
|
+
def test_the_version_constant_truly_exist
|
14
|
+
assert RateTheme::Version
|
15
|
+
end
|
data/test/test_monitor.rb
CHANGED
@@ -18,12 +18,16 @@ module RateTheme
|
|
18
18
|
lister = Lister.new
|
19
19
|
assert_instance_of RateTheme::Lister, lister
|
20
20
|
end
|
21
|
-
|
21
|
+
|
22
22
|
end
|
23
23
|
|
24
24
|
class TestChanger < Minitest::Test
|
25
25
|
def setup
|
26
26
|
@changer = RateTheme::Changer.new "minimal"
|
27
|
-
end
|
27
|
+
end
|
28
|
+
|
29
|
+
def test_if_no_file_is_found_it_allows_you_to_enter_a_new_path
|
30
|
+
@changer.find_file
|
31
|
+
end
|
28
32
|
end
|
29
33
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rate_theme
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- hayduke19us
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2015-04-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -52,34 +52,6 @@ dependencies:
|
|
52
52
|
- - ">="
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: '0'
|
55
|
-
- !ruby/object:Gem::Dependency
|
56
|
-
name: ZenTest
|
57
|
-
requirement: !ruby/object:Gem::Requirement
|
58
|
-
requirements:
|
59
|
-
- - ">="
|
60
|
-
- !ruby/object:Gem::Version
|
61
|
-
version: '0'
|
62
|
-
type: :development
|
63
|
-
prerelease: false
|
64
|
-
version_requirements: !ruby/object:Gem::Requirement
|
65
|
-
requirements:
|
66
|
-
- - ">="
|
67
|
-
- !ruby/object:Gem::Version
|
68
|
-
version: '0'
|
69
|
-
- !ruby/object:Gem::Dependency
|
70
|
-
name: autotest-fsevent
|
71
|
-
requirement: !ruby/object:Gem::Requirement
|
72
|
-
requirements:
|
73
|
-
- - ">="
|
74
|
-
- !ruby/object:Gem::Version
|
75
|
-
version: '0'
|
76
|
-
type: :development
|
77
|
-
prerelease: false
|
78
|
-
version_requirements: !ruby/object:Gem::Requirement
|
79
|
-
requirements:
|
80
|
-
- - ">="
|
81
|
-
- !ruby/object:Gem::Version
|
82
|
-
version: '0'
|
83
55
|
- !ruby/object:Gem::Dependency
|
84
56
|
name: colorize
|
85
57
|
requirement: !ruby/object:Gem::Requirement
|
@@ -138,7 +110,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
138
110
|
version: '0'
|
139
111
|
requirements: []
|
140
112
|
rubyforge_project:
|
141
|
-
rubygems_version: 2.
|
113
|
+
rubygems_version: 2.4.6
|
142
114
|
signing_key:
|
143
115
|
specification_version: 4
|
144
116
|
summary: rate your zsh themes and keep track of favorites
|