rate_theme 0.0.3

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 ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 99e01e4b71eff6d5572c0f2ead9420d9e276f05c
4
+ data.tar.gz: 079f5b8e0551f721d1c614bdb5414ca195e9326e
5
+ SHA512:
6
+ metadata.gz: a48680ed50d4b1bef3c5e788cb63639d0b17f63198aed56fdaa6db41893a421728b7af456e20e4ca7644413489563df045cece17efa51e40426e57c9d78e3fb4
7
+ data.tar.gz: 29c35b035aa2853dff1564ce69558702f9f2a7d3762262991a7c882fe2b77b36120206ad8e6e78106d6f89332ef0c007d7630a174bc3ecc5b0dd195cf205e1b6
data/.gitignore ADDED
@@ -0,0 +1,17 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
data/Gemfile ADDED
@@ -0,0 +1,5 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in rate_theme.gemspec
4
+
5
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2014 hayduke19us
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,29 @@
1
+ # RateTheme
2
+
3
+ TODO: Write a gem description
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ gem 'rate_theme'
10
+
11
+ And then execute:
12
+
13
+ $ bundle
14
+
15
+ Or install it yourself as:
16
+
17
+ $ gem install rate_theme
18
+
19
+ ## Usage
20
+
21
+ TODO: Write usage instructions here
22
+
23
+ ## Contributing
24
+
25
+ 1. Fork it ( http://github.com/<my-github-username>/rate_theme/fork )
26
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
27
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
28
+ 4. Push to the branch (`git push origin my-new-feature`)
29
+ 5. Create new Pull Request
data/Rakefile ADDED
@@ -0,0 +1,9 @@
1
+ require "bundler/gem_tasks"
2
+ require "rake/testtask"
3
+
4
+ Rake::TestTask.new do |t|
5
+ t.libs << "test"
6
+ t.pattern = "test/test_*"
7
+ end
8
+
9
+ task default: :test
data/bin/rate_theme ADDED
@@ -0,0 +1,2 @@
1
+ #!/usr/bin/env ruby
2
+ require 'rate_theme'
@@ -0,0 +1,17 @@
1
+ module RateTheme
2
+ class Ask
3
+ attr_accessor :question, :input
4
+ def initialize(args)
5
+ @question = args.fetch(:question, nil)
6
+ @input = args.fetch(:input, nil)
7
+ end
8
+
9
+ def receive_answer test=nil
10
+ self.input = test || gets.chomp.strip
11
+ end
12
+ end
13
+ end
14
+
15
+
16
+
17
+
@@ -0,0 +1,98 @@
1
+ module RateTheme
2
+ class Logger
3
+ attr_reader :name, :rating
4
+ def initialize(args)
5
+ @name = args.fetch(:name)
6
+ @rating = args.fetch(:rating)
7
+ @file = "themes.yml"
8
+ end
9
+
10
+ def file_virgin
11
+ File.open(@file, 'w') do |f|
12
+ f.puts({self.name => self.rating.to_i}.to_yaml)
13
+ f.close
14
+ end
15
+ end
16
+
17
+ def file_exist
18
+ data = YAML.load_file(@file)
19
+ data[self.name] = self.rating.to_i
20
+ File.open(@file, 'w+') {|f| YAML.dump(data, f)}
21
+ end
22
+
23
+ def action
24
+ unless File.exists?(@file)
25
+ self.file_virgin
26
+ else
27
+ self.file_exist
28
+ end
29
+ end
30
+ end
31
+
32
+ class Lister
33
+ attr_accessor :best_theme, :sorted, :data
34
+ attr_reader :file
35
+ def initialize
36
+ @file = "themes.yml"
37
+ @data = nil
38
+ @best_theme = nil
39
+ @sorted = nil
40
+ end
41
+
42
+ def file_search
43
+ if File.exist?(@file)
44
+ self.data = YAML.load_file(@file)
45
+ true
46
+ end
47
+ end
48
+
49
+ def best_theme
50
+ @sorted = @data.sort_by {|k, v| v}
51
+ reversed = sorted.reverse
52
+ theme = reversed.first
53
+ self.best_theme = theme.first.dup
54
+ end
55
+
56
+ def all
57
+ self.sorted.reverse.each {|k,v| puts "#{k}: #{v}"}
58
+ end
59
+ end
60
+
61
+ class Changer
62
+ attr_writer :file
63
+ attr_reader :theme, :file
64
+ def initialize(theme)
65
+ @theme = theme
66
+ @file = Dir.home + "/.zshrc"
67
+ @user_location = nil
68
+ end
69
+
70
+ def file_search
71
+ if File.exist?(@file)
72
+ puts "File found in #{@file}".colorize(:green)
73
+ rc = File.open(@file, 'a+')
74
+ all = rc.readlines
75
+ all.each do |line|
76
+ if line =~ /ZSH_THEME=/
77
+ @tmp = line
78
+ end
79
+ end
80
+ index = all.index(@tmp).to_i
81
+ all[index] = "ZSH_THEME=" + "'" + "#{@theme}" + "'"
82
+ File.open(@file, 'w') do |file|
83
+ all.each do |a|
84
+ file.puts a
85
+ end
86
+ end
87
+ else
88
+ puts "We can't find your file".colorize(:red)
89
+ puts "Please enter the path of your .zshrc file '/../../'"
90
+ input = gets.chomp
91
+ unless input == ''
92
+ self.file = input
93
+ self.file_search
94
+ end
95
+ end
96
+ end
97
+ end
98
+ end
@@ -0,0 +1,3 @@
1
+ module RateTheme
2
+ VERSION = "0.0.3"
3
+ end
data/lib/rate_theme.rb ADDED
@@ -0,0 +1,84 @@
1
+ $: << File.expand_path('../rate_theme.rb', __FILE__)
2
+ require "colorize"
3
+ require "yaml"
4
+ require "rate_theme/version"
5
+ require "rate_theme/monitor"
6
+ require "rate_theme/ask"
7
+
8
+
9
+ @div = lambda{ puts "=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-".colorize(:blue)}
10
+ @status = lambda{|str| 20.times do |t|
11
+ sleep(1.0/24)
12
+ print ".".colorize(:green)
13
+ end
14
+ str}
15
+
16
+
17
+ @div.call
18
+ puts "1. Rate theme."
19
+ puts "2. List all rated themes and change theme."
20
+ puts "3. Change theme to random."
21
+ @div.call
22
+
23
+ ask = RateTheme::Ask.new expected: 1
24
+ ask.receive_answer
25
+ @div.call
26
+
27
+ if ask.input == '1'
28
+ name = RateTheme::Ask.new question: "Theme name?"
29
+ puts name.question
30
+ @div.call
31
+ name.receive_answer
32
+ @div.call
33
+ rating = RateTheme::Ask.new question: "Theme rating? (1-10)"
34
+ puts rating.question
35
+ @div.call
36
+ rating.receive_answer
37
+ @div.call
38
+
39
+ logger = RateTheme::Logger.new name: name.input, rating: rating.input
40
+ logger.action
41
+ elsif ask.input == '2'
42
+ chosen = RateTheme::Lister.new
43
+ if chosen.file_search
44
+ @best = chosen.best_theme
45
+ puts @best.colorize(:red) + " Is your highest rated!"
46
+ @div.call
47
+ chosen.all
48
+ @div.call
49
+ puts "1. Change theme to highest rated?"
50
+ puts "2. Choose specific theme?"
51
+ @div.call
52
+ change_theme = RateTheme::Ask.new question: "choose theme?"
53
+ change_theme.receive_answer
54
+
55
+ @div.call
56
+
57
+ if change_theme.input == '1'
58
+ change = RateTheme::Changer.new @best
59
+ @status.call("done")
60
+
61
+ change.file_search
62
+ elsif change_theme.input == '2'
63
+ specific_theme = RateTheme::Ask.new question: "Type in the specific theme"
64
+ puts specific_theme.question
65
+ specific_theme.receive_answer
66
+ unless specific_theme.input == ''
67
+ change = RateTheme::Changer.new specific_theme.input
68
+ @status.call("done")
69
+ change.file_search
70
+ @div.call
71
+ puts "open a new window for changes to show!".colorize(:green)
72
+ end
73
+ else
74
+ puts "choice must be 1 or 2"
75
+ end
76
+ else
77
+ puts "No rated themes!"
78
+ @div.call
79
+ end
80
+ elsif ask.input == '3'
81
+ @status.call("done")
82
+ random = RateTheme::Changer.new 'random'
83
+ random.file_search
84
+ end
data/rate_theme ADDED
File without changes
@@ -0,0 +1,28 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'rate_theme/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "rate_theme"
8
+ spec.version = RateTheme::VERSION
9
+ spec.authors = ["hayduke19us"]
10
+ spec.email = ["hayduke19us@gmail.com"]
11
+ spec.summary = %q{rate your zsh themes and keep track of favorites}
12
+ spec.description = %q{Start with random in your zshrc file.
13
+ Log your favorite themes with 'rate_theme' and dynamically change
14
+ your current theme to the highest rated.}
15
+ spec.homepage = ""
16
+ spec.license = "MIT"
17
+ spec.files = `git ls-files`.split($/)
18
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
19
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
20
+ spec.require_paths = ["lib"]
21
+
22
+ spec.add_development_dependency "bundler", "~> 1.5"
23
+ spec.add_development_dependency "rake"
24
+ spec.add_development_dependency "minitest"
25
+ spec.add_development_dependency "ZenTest"
26
+ spec.add_development_dependency "autotest-fsevent"
27
+ spec.add_runtime_dependency "colorize"
28
+ end
data/test/test_ask.rb ADDED
@@ -0,0 +1,20 @@
1
+ require 'test_helper'
2
+
3
+ module RateTheme
4
+ class TestAsk < Minitest::Test
5
+ def setup
6
+ @ask = RateTheme::Ask.new question: "how are you"
7
+ end
8
+
9
+ def test_Ask_class_question_is_writable
10
+ assert_equal @ask.question, "how are you"
11
+ @ask.question = "whats your name"
12
+ assert_equal @ask.question, "whats your name"
13
+ end
14
+
15
+ def test_receive_answer_changes_input
16
+ @ask.receive_answer "favorite color"
17
+ assert_equal @ask.input, "favorite color"
18
+ end
19
+ end
20
+ end
@@ -0,0 +1,13 @@
1
+ gems = %w[rate_theme/ask
2
+ rate_theme/monitor
3
+ minitest/autorun
4
+ minitest/pride
5
+ minitest/unit]
6
+ gems.each {|gem| require "#{gem}"}
7
+
8
+ describe RateTheme do
9
+ it "must be defined" do
10
+ RateTheme::VERSION.wont_be_nil
11
+ end
12
+ end
13
+
@@ -0,0 +1,29 @@
1
+ require 'test_helper'
2
+ require 'yaml'
3
+ require 'colorize'
4
+
5
+ module RateTheme
6
+ class TestLogger < Minitest::Test
7
+ def setup
8
+ @logger = RateTheme::Logger.new name: "minimal", rating: 5
9
+ end
10
+
11
+ def test_logger_valid
12
+ assert_instance_of RateTheme::Logger, @logger
13
+ end
14
+ end
15
+
16
+ class TestLister < Minitest::Test
17
+ def test_lister_valid
18
+ lister = Lister.new
19
+ assert_instance_of RateTheme::Lister, lister
20
+ end
21
+
22
+ end
23
+
24
+ class TestChanger < Minitest::Test
25
+ def setup
26
+ @changer = RateTheme::Changer.new "minimal"
27
+ end
28
+ end
29
+ end
data/test/themes.yml ADDED
File without changes
metadata ADDED
@@ -0,0 +1,150 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: rate_theme
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.3
5
+ platform: ruby
6
+ authors:
7
+ - hayduke19us
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-01-15 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.5'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.5'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: minitest
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
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
+ - !ruby/object:Gem::Dependency
84
+ name: colorize
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - ">="
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
90
+ type: :runtime
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - ">="
95
+ - !ruby/object:Gem::Version
96
+ version: '0'
97
+ description: "Start with random in your zshrc file. \n Log your favorite themes with
98
+ 'rate_theme' and dynamically change\n your current theme to the highest rated."
99
+ email:
100
+ - hayduke19us@gmail.com
101
+ executables:
102
+ - rate_theme
103
+ extensions: []
104
+ extra_rdoc_files: []
105
+ files:
106
+ - ".gitignore"
107
+ - Gemfile
108
+ - LICENSE.txt
109
+ - README.md
110
+ - Rakefile
111
+ - bin/rate_theme
112
+ - lib/rate_theme.rb
113
+ - lib/rate_theme/ask.rb
114
+ - lib/rate_theme/monitor.rb
115
+ - lib/rate_theme/version.rb
116
+ - rate_theme
117
+ - rate_theme.gemspec
118
+ - test/test_ask.rb
119
+ - test/test_helper.rb
120
+ - test/test_monitor.rb
121
+ - test/themes.yml
122
+ homepage: ''
123
+ licenses:
124
+ - MIT
125
+ metadata: {}
126
+ post_install_message:
127
+ rdoc_options: []
128
+ require_paths:
129
+ - lib
130
+ required_ruby_version: !ruby/object:Gem::Requirement
131
+ requirements:
132
+ - - ">="
133
+ - !ruby/object:Gem::Version
134
+ version: '0'
135
+ required_rubygems_version: !ruby/object:Gem::Requirement
136
+ requirements:
137
+ - - ">="
138
+ - !ruby/object:Gem::Version
139
+ version: '0'
140
+ requirements: []
141
+ rubyforge_project:
142
+ rubygems_version: 2.1.11
143
+ signing_key:
144
+ specification_version: 4
145
+ summary: rate your zsh themes and keep track of favorites
146
+ test_files:
147
+ - test/test_ask.rb
148
+ - test/test_helper.rb
149
+ - test/test_monitor.rb
150
+ - test/themes.yml