qotd 1.2.2.1 → 1.3.0

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 4874967bbddcfc0553e466a4220a2a112b01ab92
4
- data.tar.gz: 44f30615771cc29120b0a47833645ae38744656e
3
+ metadata.gz: c40d0d024d6c68946cd406f607b65b164dc4f2eb
4
+ data.tar.gz: 8414433fc8c7fa005102f17720f6d845263183ae
5
5
  SHA512:
6
- metadata.gz: 5755d95adf3857c9eea548d458c329d003bd12bec2281892a590a7afc203f5fe8d149d179476133fcdee6503600addb0cb7a97b91e6d9ab973dddb359d3d8a15
7
- data.tar.gz: 63910de535476b06b6eb896743be8d176b15f6a894ca9856b05140dc99d479d8a1fc51df918f09af6d9da89a4614e923f1a0bfcd63153e3f1acce93d09a98570
6
+ metadata.gz: 18a44e856fd71155511ead40c13b02b529ace81e18e22a2248131eb4c6bef744e3569d00c70f1b2dcf4aa1d7dbf736267279afe846fd2c92f10ab08a8a61cce4
7
+ data.tar.gz: 5740ad365ff336f57bc78598b7fc7e25f58f2ec3c7c7316b99da90b4b24573bbc18fb49df484e68f5a5825c6a7000a087f88aaf7ac5194be63624d4c84a28dbd
data/README.md CHANGED
@@ -14,7 +14,9 @@ the quotes in it numbers over 3000 lines!
14
14
 
15
15
  ## Todo
16
16
 
17
- - Publish on `rubygems.org`.
17
+ - Make a method that returns a quotes array.
18
+ - Make a method that returns the same formatted array as before.
19
+ - Test each of them.
18
20
 
19
21
  ## Installation
20
22
 
data/bin/qotd CHANGED
@@ -7,9 +7,16 @@ require 'qotd'
7
7
 
8
8
  puts "Quote of the Day:"
9
9
 
10
+ quote = []
10
11
  if ARGV.first
11
- Qotd.format_quote(ARGV.first)
12
+ quote = Format.format_quote(ARGV.first)
12
13
  else
13
- Qotd.format_quote(Qotd.quote)
14
+ quote = Format.format_quote(Qotd.quote)
14
15
  end
15
16
 
17
+ last = quote.length - 1
18
+
19
+ print quote[0]
20
+ puts quote[(1...last)]
21
+ print quote[last]
22
+
data/lib/format.rb CHANGED
@@ -1,3 +1,5 @@
1
+ require_relative "qotd"
2
+
1
3
  module Format
2
4
 
3
5
  def self.space(str, spaces = 1)
@@ -21,21 +23,38 @@ module Format
21
23
  return padding
22
24
  end
23
25
 
26
+ def self.to_array(quote)
27
+ quote.split(/\n/)
28
+ end
29
+
30
+ def self.format_quote(quote)
31
+ message = self.padding(quote, 2) # => Add padding to the quote.
32
+ space = ' ' * 80 # => Filler to highlight.
33
+
34
+ [
35
+ Qotd.color,
36
+ space,
37
+ message,
38
+ space,
39
+ Qotd.clear,
40
+ ]
41
+ end
42
+
24
43
  def self.padding(str, spaces = 1)
25
- lines = str.split(/\n/)
44
+ qarray = self.to_array(str)
26
45
 
27
- if lines.length > 1
46
+ if qarray.length > 1
28
47
  pstr = ""
29
- last = lines.length - 1
48
+ last = qarray.length - 1
30
49
 
31
50
  (0...last).each do |line|
32
- text = self.space(lines[line], spaces)
51
+ text = self.space(qarray[line], spaces)
33
52
  filler = self.to_80(text)
34
53
 
35
54
  pstr << text << filler << "\n"
36
55
  end
37
56
 
38
- text = self.space(lines[last], spaces)
57
+ text = self.space(qarray[last], spaces)
39
58
  pstr << text << self.to_80(text)
40
59
 
41
60
  return pstr
data/lib/qotd.rb CHANGED
@@ -28,18 +28,5 @@ module Qotd
28
28
  "\033[0m" # => Reset to normal.
29
29
  end
30
30
 
31
- def self.format_quote(quote)
32
- message = Format.padding(quote, 2) # => Add padding to the quote.
33
- space = ' ' * 80 # => Filler to highlight.
34
-
35
- print self.color
36
- puts space
37
-
38
- puts message
39
-
40
- puts space
41
- print self.clear
42
- end
43
-
44
31
  end
45
32
 
data/lib/qotd/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Qotd
2
- VERSION = "1.2.2.1"
2
+ VERSION = "1.3.0"
3
3
  end
data/spec/format_spec.rb CHANGED
@@ -18,6 +18,14 @@ describe "Format" do
18
18
  Format.space(str, 2).should == " Hello World! "
19
19
  end
20
20
 
21
+ it "should return an array of a quote" do
22
+ Format.to_array(str).should == [str]
23
+ end
24
+
25
+ it "should return an array of lines in a multi_line quote" do
26
+ Format.to_array(multi_line_str).should == multi_line_str.split(/\n/)
27
+ end
28
+
21
29
  it "should add spaces and padding to a multi-line string" do
22
30
  expected = "%s%s%s" % [
23
31
  " Foo " << Format.to_80(" Foo ") << "\n",
data/spec/qotd_spec.rb CHANGED
@@ -5,7 +5,8 @@ require "rspec"
5
5
  describe "Qotd" do
6
6
 
7
7
  it "should return the quotes file" do
8
- file = File.read(File.join(File.dirname(File.dirname(__FILE__)), "lib/quotes/quotes.txt"))
8
+ dir = File.dirname(File.dirname(__FILE__))
9
+ file = File.read(File.join(dir, "lib/quotes/quotes.txt"))
9
10
  Qotd.quote_file.should == file
10
11
  end
11
12
 
@@ -37,7 +38,7 @@ describe "Qotd" do
37
38
  space = ' ' * 80 # => Filler to highlight.
38
39
  message = Format.padding(quote, 2) # => Add padding to the quote.
39
40
 
40
- expected = "%s%s%s%s%s" % [
41
+ expected = [
41
42
  Qotd.color,
42
43
  space,
43
44
  message,
@@ -45,7 +46,7 @@ describe "Qotd" do
45
46
  Qotd.clear,
46
47
  ]
47
48
 
48
- Qotd.format_quote(quote).should == expected
49
+ Format.format_quote(quote).should == expected
49
50
  end
50
51
 
51
52
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: qotd
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.2.1
4
+ version: 1.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - jfjhh
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-04-07 00:00:00.000000000 Z
11
+ date: 2014-04-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler