qotd 1.2.1

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.
data/qotd.gemspec ADDED
@@ -0,0 +1,24 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'qotd/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "qotd"
8
+ spec.version = Qotd::VERSION
9
+ spec.authors = ["jfjhh"]
10
+ spec.email = ["alex.striff1@gmail.com"]
11
+ spec.summary = "Displays a new quote on login to terminal."
12
+ spec.description = "Gets a random quote from a file and displays it to the standard output."
13
+ spec.homepage = "https://github.com/jfjhh/qotd"
14
+ spec.license = "MIT"
15
+
16
+ spec.files = `git ls-files -z`.split("\x0")
17
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
+ spec.require_paths = ["lib"]
20
+
21
+ spec.add_development_dependency "bundler", "~> 1.5"
22
+ spec.add_development_dependency "rake"
23
+ spec.add_development_dependency "rspec"
24
+ end
Binary file
@@ -0,0 +1,40 @@
1
+ require_relative "../lib/format.rb"
2
+ require "rspec"
3
+
4
+ describe "Format" do
5
+
6
+ str = "Hello World!"
7
+ multi_line_str = "Foo\nBar\nBaz"
8
+
9
+ it "should return spaces up until column 80" do
10
+ Format.to_80('X' * 10).should == ' ' * 70 # => 10 'X's + 70 spaces => 80
11
+ end
12
+
13
+ it "should add spaces to either end of string" do
14
+ Format.space(str).should == " Hello World! "
15
+ end
16
+
17
+ it "should add multiple spaces to either end of string" do
18
+ Format.space(str, 2).should == " Hello World! "
19
+ end
20
+
21
+ it "should add spaces and padding to a multi-line string" do
22
+ expected = "%s%s%s" % [
23
+ " Foo " << Format.to_80(" Foo ") << "\n",
24
+ " Bar " << Format.to_80(" Bar ") << "\n",
25
+ " Baz " << Format.to_80(" Baz ")
26
+ ]
27
+ Format.padding(multi_line_str).should == expected << Format.to_80(expected)
28
+ end
29
+
30
+ it "should add multiple spaces and padding to a multi-line string" do
31
+ expected = "%s%s%s" % [
32
+ " Foo " << Format.to_80(" Foo ") << "\n",
33
+ " Bar " << Format.to_80(" Bar ") << "\n",
34
+ " Baz " << Format.to_80(" Baz ")
35
+ ]
36
+ Format.padding(multi_line_str, 2).should == expected << Format.to_80(expected)
37
+ end
38
+
39
+ end
40
+
data/spec/qotd_spec.rb ADDED
@@ -0,0 +1,52 @@
1
+ require_relative "../lib/qotd"
2
+ require_relative "../lib/format"
3
+ require "rspec"
4
+
5
+ describe "Qotd" do
6
+
7
+ it "should return the quotes file" do
8
+ file = File.read(File.join(File.dirname(File.dirname(__FILE__)), "lib/quotes/quotes.txt"))
9
+ Qotd.quote_file.should == file
10
+ end
11
+
12
+ it "should return a quotes array" do
13
+ Qotd.quotes.should == Qotd.quote_file.split(/\n\n/)
14
+ end
15
+
16
+ it "should return a random index in quotes" do
17
+ index = Qotd.rand_index
18
+ length = Qotd.quotes.length
19
+ index.should <= length
20
+ index.should >= 0
21
+ end
22
+
23
+ it "should return a random quote" do
24
+ Qotd.quotes.should include Qotd.quote
25
+ end
26
+
27
+ it "should return a color code" do
28
+ Qotd.color.should == "\033[7m"
29
+ end
30
+
31
+ it "should return a clearing color code" do
32
+ Qotd.clear.should == "\033[0m"
33
+ end
34
+
35
+ it "should return a formatted quote" do
36
+ quote = "Hello World!"
37
+ space = ' ' * 80 # => Filler to highlight.
38
+ message = Format.padding(quote, 2) # => Add padding to the quote.
39
+
40
+ expected = "%s%s%s%s%s" % [
41
+ Qotd.color,
42
+ space,
43
+ message,
44
+ space,
45
+ Qotd.clear,
46
+ ]
47
+
48
+ Qotd.format_quote(quote).should == expected
49
+ end
50
+
51
+ end
52
+
metadata ADDED
@@ -0,0 +1,104 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: qotd
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.2.1
5
+ platform: ruby
6
+ authors:
7
+ - jfjhh
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-04-07 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: rspec
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
+ description: Gets a random quote from a file and displays it to the standard output.
56
+ email:
57
+ - alex.striff1@gmail.com
58
+ executables:
59
+ - qotd
60
+ extensions: []
61
+ extra_rdoc_files: []
62
+ files:
63
+ - .gitignore
64
+ - Gemfile
65
+ - LICENSE.txt
66
+ - README.md
67
+ - Rakefile
68
+ - bin/qotd
69
+ - lib/format.rb
70
+ - lib/qotd.rb
71
+ - lib/qotd/version.rb
72
+ - lib/quotes/quotes.txt
73
+ - qotd.gemspec
74
+ - screenshot/screenshot.png
75
+ - spec/format_spec.rb
76
+ - spec/qotd_spec.rb
77
+ homepage: https://github.com/jfjhh/qotd
78
+ licenses:
79
+ - MIT
80
+ metadata: {}
81
+ post_install_message:
82
+ rdoc_options: []
83
+ require_paths:
84
+ - lib
85
+ required_ruby_version: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - '>='
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
90
+ required_rubygems_version: !ruby/object:Gem::Requirement
91
+ requirements:
92
+ - - '>='
93
+ - !ruby/object:Gem::Version
94
+ version: '0'
95
+ requirements: []
96
+ rubyforge_project:
97
+ rubygems_version: 2.0.3
98
+ signing_key:
99
+ specification_version: 4
100
+ summary: Displays a new quote on login to terminal.
101
+ test_files:
102
+ - spec/format_spec.rb
103
+ - spec/qotd_spec.rb
104
+ has_rdoc: