shellout 0.3 → 0.4

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/CHANGES CHANGED
@@ -1,3 +1,12 @@
1
+ 2011-12-03: version 0.4
2
+
3
+ - Added a class for printing menus
4
+
5
+ - Changed the calendar to not use ansi escapes when printing multiple calendars
6
+
7
+ - Added shortcuts for creating menus, calendars, tables, and shadowboxes that
8
+ can be mixed in.
9
+
1
10
  2011-10-31: version 0.3
2
11
 
3
12
  - Added a class for printing calendars
data/README.md CHANGED
@@ -14,49 +14,43 @@ Install
14
14
  Usage
15
15
  -----
16
16
 
17
- ### Shadowboxes
17
+ require 'shellout'
18
+ include Shellout
18
19
 
20
+ ### Shadowboxes
19
21
 
20
- require 'shellout/shadowbox'
21
-
22
- Shellout::Shadowbox.new("Hello world").print
22
+ Shadowbox("Hello world").print
23
23
 
24
24
  # ┌──────────────────────────────────────────┐
25
25
  # │ Hello world │▒
26
26
  # └──────────────────────────────────────────┘▒
27
27
  # ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒
28
28
 
29
-
30
29
  ### Tables
31
30
 
32
- require 'shellout/table'
33
-
34
- Shellout::Table.new(headers: %w{Team Points},
35
- rows: [['Man City', 22],
36
- ['Man Utd', 20],
37
- ['Chelsea', 19],
38
- ['Newcastle', 16]]).print
31
+ Table(headers: %w{Team Points},
32
+ rows: [['Man City', 22],
33
+ ['Man Utd', 20],
34
+ ['Chelsea', 19],
35
+ ['Newcastle', 16]]).print
39
36
 
40
- # ┌───────────┬────────┐
41
- # │ Team │ Points │
42
- # ├───────────┼────────┤
43
- # │ Man City │ 22 │
44
- # │ Man Utd │ 20 │
45
- # │ Chelsea │ 19 │
46
- # │ Newcastle │ 16 │
47
- # └───────────┴────────┘
48
-
37
+ # ┌───────────┬────────┐
38
+ # │ Team │ Points │
39
+ # ├───────────┼────────┤
40
+ # │ Man City │ 22 │
41
+ # │ Man Utd │ 20 │
42
+ # │ Chelsea │ 19 │
43
+ # │ Newcastle │ 16 │
44
+ # └───────────┴────────┘
45
+
49
46
 
50
47
  ### Calendars
51
48
 
52
- require 'date'
53
- require 'shellout/calendar'
54
-
55
49
  today = Date.today # => "2011-10-31"
56
-
57
- Shellout::Calendar.new(today).print
58
50
 
59
- # October 2011
51
+ Calendar(today).print
52
+
53
+ # October 2011
60
54
  # Mo Tu We Th Fr Sa Su
61
55
  # 1 2
62
56
  # 3 4 5 6 7 8 9
@@ -65,11 +59,10 @@ Usage
65
59
  # 24 25 26 27 28 29 30
66
60
  # 31
67
61
 
68
- Shellout::Calendar.new(today.prev_month,
69
- today,
70
- today.next_month).print
71
-
72
- # September 2011 October 2011 November 2011
62
+ Calendar(today).print3
63
+
64
+ # 2011
65
+ # September October November
73
66
  # Mo Tu We Th Fr Sa Su Mo Tu We Th Fr Sa Su Mo Tu We Th Fr Sa Su
74
67
  # 1 2 3 4 1 2 1 2 3 4 5 6
75
68
  # 5 6 7 8 9 10 11 3 4 5 6 7 8 9 7 8 9 10 11 12 13
@@ -78,6 +71,37 @@ Usage
78
71
  # 26 27 28 29 30 24 25 26 27 28 29 30 28 29 30
79
72
  # 31
80
73
 
74
+
75
+ ### Menus
76
+
77
+ Menu([
78
+ "Do this",
79
+ "No, this",
80
+ "Or, maybe this",
81
+ "Forget it, this is the right choice",
82
+ "Amazing things will happen if you choose this",
83
+ "Ignore #5. Pick me!",
84
+ "I'm the obvious choice",
85
+ "There is no end to the awesomeness that will come from choosing this",
86
+ "Don't choose this",
87
+ "Or this",
88
+ "Things are getting worse",
89
+ "Might as well choose this one",
90
+ ]).print
91
+
92
+ # 1. Do this
93
+ # 2. No, this
94
+ # 3. Or, maybe this
95
+ # 4. Forget it, this is the right choice
96
+ # 5. Amazing things will happen if you choose this
97
+ # 6. Ignore #5. Pick me!
98
+ # 7. I'm the obvious choice
99
+ # 8. There is no end to the awesomeness that will come from choosing this
100
+ # 9. Don't choose this
101
+ # 10. Or this
102
+ # 11. Things are getting worse
103
+ # 12. Might as well choose this one
104
+
81
105
  Bugs
82
106
  ----
83
107
 
data/lib/shellout.rb CHANGED
@@ -1,4 +1,4 @@
1
- # -*- coding: utf-8 -*-
1
+ # encoding: utf-8
2
2
 
3
3
  # Unicode box drawing characters and block elements
4
4
  #
@@ -18,10 +18,33 @@
18
18
  # U+258x ▀ ▁ ▂ ▃ ▄ ▅ ▆ ▇ █ ▉ ▊ ▋ ▌ ▍ ▎ ▏
19
19
  # U+259x ▐ ░ ▒ ▓ ▔ ▕ ▖ ▗ ▘ ▙ ▚ ▛ ▜ ▝ ▞ ▟
20
20
 
21
+ require 'shellout/calendar'
22
+ require 'shellout/menu'
23
+ require 'shellout/shadowbox'
24
+ require 'shellout/table'
25
+
26
+ # You can mixin this module to get shortcuts to the various functionality
27
+ # provided by the classes below this namespace
21
28
  module Shellout
22
29
 
23
- autoload :Calendar, 'shellout/calendar'
24
- autoload :Shadowbox, 'shellout/shadowbox'
25
- autoload :Table, 'shellout/table'
30
+ # See doc for Shellout::Calendar.new
31
+ def Calendar(*whatever)
32
+ Shellout::Calendar.new(*whatever)
33
+ end
34
+
35
+ # See doc for Shellout::Shadowbox.new
36
+ def Shadowbox(*whatever)
37
+ Shellout::Shadowbox.new(*whatever)
38
+ end
39
+
40
+ # See doc for Shellout::Table.new
41
+ def Table(*whatever)
42
+ Shellout::Table.new(*whatever)
43
+ end
44
+
45
+ # See doc for Shellout::Menu.new
46
+ def Menu(*whatever)
47
+ Shellout::Menu.new(*whatever)
48
+ end
26
49
 
27
50
  end
@@ -1,94 +1,120 @@
1
+ require 'date'
2
+
1
3
  module Shellout
2
4
  class Calendar
3
5
 
4
- def initialize(*dates)
5
- @dates = dates
6
+ def initialize(date=Date.today)
7
+ @date = date
6
8
  @list_of_days = "Mo Tu We Th Fr Sa Su"
7
- reset
8
9
  end
9
10
 
10
11
  def print(out=$stdout)
11
- @out=out
12
- @dates.each do |d|
13
- print_calendar(d)
14
- unless d == @dates.last # FIXME
15
- @col += 24
16
- @out.print ansi_cursor_up(@lines) + ansi_cursor_right(@col)
17
- @lines = 1
18
- end
19
- end
20
- reset
21
- #puts
12
+ print_helper(out, Array(@date))
22
13
  end
23
-
24
- private
25
-
26
- def reset
27
- @lines = 1
28
- @col = 0
14
+
15
+ def print3(out=$stdout)
16
+ print_helper(out, [@date.prev_month, @date, @date.next_month])
29
17
  end
30
18
 
31
- def print_calendar(for_date)
32
- print_heading(for_date)
33
- print_dates(for_date)
19
+ private
20
+
21
+ def print_helper(out, dates)
22
+ print_headings(out, dates)
23
+ print_days(out, dates)
34
24
  end
35
25
 
36
- def print_heading(for_date)
37
- print_line("#{Date::MONTHNAMES[for_date.month]} #{for_date.year}".center(@list_of_days.length))
38
- print_line(@list_of_days)
26
+ def print_headings(out, dates)
27
+ print_heading_year(out, dates)
28
+ print_heading_months(out, dates)
29
+ print_heading_name_of_days(out, dates)
39
30
  end
40
-
41
- def print_dates(for_date)
42
- week = []
43
- days(for_date).each_with_index do |d, i|
44
- d = is_current_month?(for_date) && d == Date.today.day \
45
- ? ansi_reverse_color(d) : d
46
- week << "%2s" % d
47
- if end_of_week?(i)
48
- print_week(week)
49
- week = []
50
- end
31
+
32
+ def print_year_on_a_separate_line?(dates)
33
+ first_year = dates.first.year
34
+ same_year = dates.reduce(true) {|res, d| res && d.year == first_year}
35
+ same_year and dates.length > 1
36
+ end
37
+
38
+ def print_heading_year(out, dates)
39
+ if print_year_on_a_separate_line?(dates)
40
+ out.puts dates.first.year.to_s.center((@list_of_days.length + 2) * (dates.length) - 2)
51
41
  end
52
- print_week(week) unless week.empty?
53
- @out.puts
54
42
  end
55
43
 
56
- def print_week(week)
57
- print_line week.join(' ')
44
+ def print_heading_months(out, dates)
45
+ dates.each do |for_date|
46
+ head = Date::MONTHNAMES[for_date.month]
47
+ head += " #{for_date.year}" unless print_year_on_a_separate_line?(dates)
48
+ out.print head.center(@list_of_days.length)
49
+ out.print " "
50
+ end
51
+ out.puts
58
52
  end
59
-
60
- def end_of_week?(i)
61
- (i+1) % 7 == 0
53
+
54
+ def print_heading_name_of_days(out, dates)
55
+ dates.each do |for_date|
56
+ out.print @list_of_days
57
+ out.print " "
58
+ end
59
+ out.puts
60
+ end
61
+
62
+ def print_days(out, dates)
63
+ # FIXME: UGLY!!!
64
+ foo = dates.map do |for_date|
65
+ bar = days(for_date)
66
+ if is_current_month?(for_date)
67
+ bar.map! {|d| d == Date.today.day ? ansi_reverse_color(d) : d}
68
+ end
69
+ bar
70
+ end
71
+ i = 0
72
+ while true
73
+ num_done = 0
74
+ foo.each do |bar|
75
+ if i >= bar.length
76
+ num_done += 1
77
+ else
78
+ week = bar[i..i+6]
79
+ week = push_empty_strings_for_missing_week_days(week)
80
+ out.print week.map {|s| "%2s" % s}.join " "
81
+ out.print " "
82
+ end
83
+ end
84
+ break if num_done == foo.length
85
+ i += 7
86
+ out.puts
87
+ end
62
88
  end
63
89
 
64
90
  def is_current_month?(date)
65
91
  Date.today.month == date.month
66
92
  end
67
-
68
- def print_line(s="")
69
- @lines += 1
70
- @out.print s
71
- @out.print @col == 0 ? "\n" : ansi_cursor_down(1) + ansi_cursor_left(@list_of_days.length)
93
+
94
+ def days(for_date)
95
+ days = (1..last_day_of_month(for_date).day).to_a
96
+ unshift_empty_strings_for_missing_week(days, for_date)
97
+ end
98
+
99
+ def unshift_empty_strings_for_missing_week(days, date)
100
+ wday = (first_day_of_month(date).wday - 1) % 7
101
+ Array.new(wday, "") + days
72
102
  end
73
103
 
74
- def days(for_date)
75
- first_day_of_month = Date.new(for_date.year, for_date.month)
76
- days = (1..last_day_of_month(first_day_of_month).day).to_a
77
- wday = (first_day_of_month.wday - 1) % 7
78
- days.unshift(*Array.new(wday, ""))
79
- days
104
+ def push_empty_strings_for_missing_week_days(week)
105
+ week + Array.new(7 - week.length, "")
106
+ end
107
+
108
+ def first_day_of_month(date)
109
+ Date.new(date.year, date.month)
80
110
  end
81
111
 
82
- def last_day_of_month(first_day_of_month)
83
- first_day_of_month.next_month-1
112
+ def last_day_of_month(date)
113
+ first_day_of_month(date).next_month-1
84
114
  end
85
115
 
86
116
  def ansi_reverse_color(s); "\e[7m#{s}\e[0m"; end
87
117
 
88
- def ansi_cursor_up(n); "\e[#{n}A"; end
89
- def ansi_cursor_down(n); "\e[#{n}B"; end
90
- def ansi_cursor_left(n); "\e[#{n}D"; end
91
- def ansi_cursor_right(n); "\e[#{n}C"; end
92
118
 
93
119
  end
94
120
  end
@@ -0,0 +1,26 @@
1
+ module Shellout
2
+ class Menu
3
+
4
+ def initialize(items)
5
+ @items = items
6
+ end
7
+
8
+ def padding; 1; end
9
+
10
+ def print(out=$stdout)
11
+ format = menu_item_format
12
+ @items.each_with_index do |item, i|
13
+ out.printf format, i+1, item
14
+ end
15
+ end
16
+
17
+ private
18
+
19
+ def menu_item_format
20
+ return if @items.empty?
21
+ max_digits = Math.log10(@items.length).floor + padding
22
+ " %#{max_digits}d. %s\n"
23
+ end
24
+
25
+ end
26
+ end
@@ -1,3 +1,3 @@
1
1
  module Shellout
2
- VERSION = '0.3'
2
+ VERSION = '0.4'
3
3
  end
@@ -1,6 +1,6 @@
1
1
  require 'date'
2
2
  require 'stringio'
3
- require 'shellout/calendar'
3
+ require 'shellout'
4
4
 
5
5
  class Date
6
6
  def self.today
@@ -10,15 +10,34 @@ end
10
10
 
11
11
  describe Shellout::Calendar do
12
12
 
13
+ include Shellout
14
+
13
15
  before(:each) do
14
16
  @out = StringIO.new
15
17
  end
16
18
 
17
- describe 'when one date given' do
19
+ describe 'print' do
20
+
18
21
  it 'should print a calendar for the given month' do
19
- Shellout::Calendar.new(Date.new(2011, 10)).print(@out)
20
- @out.string.should == <<EOC
21
- October 2011
22
+ Calendar(Date.new(2011, 7)).print(@out)
23
+ res = @out.string.gsub(/\s+\n/, "\n")
24
+ res.should == <<EOC
25
+ July 2011
26
+ Mo Tu We Th Fr Sa Su
27
+ 1 2 3
28
+ 4 5 6 7 8 9 10
29
+ 11 12 13 14 15 16 17
30
+ 18 19 20 21 22 23 24
31
+ 25 26 27 28 29 30 31
32
+ EOC
33
+ end
34
+ end
35
+
36
+ it 'should print a calendar for this month when no date given' do
37
+ Calendar().print(@out)
38
+ res = @out.string.gsub(/\s+\n/, "\n")
39
+ res.should == <<EOC
40
+ October 2011
22
41
  Mo Tu We Th Fr Sa Su
23
42
  1 2
24
43
  3 4 5 6 7 8 9
@@ -26,35 +45,38 @@ Mo Tu We Th Fr Sa Su
26
45
  17 18 19 20 21 22 23
27
46
  24 25 26 27 28 29 \e[7m30\e[0m
28
47
  31
29
-
30
48
  EOC
31
49
  end
32
- end
33
50
 
34
- describe 'when three dates are given' do
35
- it 'should print all three calendars on one row' do
36
- Shellout::Calendar.new(Date.new(2011, 7), Date.new(2011, 8), Date.new(2011, 9)).print(@out)
37
- exp = <<EOC
38
- July 2011
39
- Mo Tu We Th Fr Sa Su
40
- 1 2 3
41
- 4 5 6 7 8 9 10
42
- 11 12 13 14 15 16 17
43
- 18 19 20 21 22 23 24
44
- 25 26 27 28 29 30 31
51
+ describe 'print3' do
52
+ it 'should print the months before, at given, and after. Year on a separate line' do
53
+ Calendar(Date.new(2011, 8)).print3(@out)
54
+ res = @out.string.gsub(/\s+\n/, "\n")
55
+ res.should == <<EOC
56
+ 2011
57
+ July August September
58
+ Mo Tu We Th Fr Sa Su Mo Tu We Th Fr Sa Su Mo Tu We Th Fr Sa Su
59
+ 1 2 3 1 2 3 4 5 6 7 1 2 3 4
60
+ 4 5 6 7 8 9 10 8 9 10 11 12 13 14 5 6 7 8 9 10 11
61
+ 11 12 13 14 15 16 17 15 16 17 18 19 20 21 12 13 14 15 16 17 18
62
+ 18 19 20 21 22 23 24 22 23 24 25 26 27 28 19 20 21 22 23 24 25
63
+ 25 26 27 28 29 30 31 29 30 31 26 27 28 29 30
64
+ EOC
65
+ end
45
66
 
46
- \e[8A\e[24C August 2011 \e[1B\e[20DMo Tu We Th Fr Sa Su\e[1B\e[20D 1 2 3 4 5 6 7\e[1B\e[20D 8 9 10 11 12 13 14\e[1B\e[20D15 16 17 18 19 20 21\e[1B\e[20D22 23 24 25 26 27 28\e[1B\e[20D29 30 31\e[1B\e[20D
47
- \e[8A\e[48C September 2011 \e[1B\e[20DMo Tu We Th Fr Sa Su\e[1B\e[20D 1 2 3 4\e[1B\e[20D 5 6 7 8 9 10 11\e[1B\e[20D12 13 14 15 16 17 18\e[1B\e[20D19 20 21 22 23 24 25\e[1B\e[20D26 27 28 29 30\e[1B\e[20D
67
+ it 'Should print year together with month names when not same year' do
68
+ Calendar(Date.new(2011, 12)).print3(@out)
69
+ res = @out.string.gsub(/\s+\n/, "\n")
70
+ res.should == <<EOC
71
+ November 2011 December 2011 January 2012
72
+ Mo Tu We Th Fr Sa Su Mo Tu We Th Fr Sa Su Mo Tu We Th Fr Sa Su
73
+ 1 2 3 4 5 6 1 2 3 4 1
74
+ 7 8 9 10 11 12 13 5 6 7 8 9 10 11 2 3 4 5 6 7 8
75
+ 14 15 16 17 18 19 20 12 13 14 15 16 17 18 9 10 11 12 13 14 15
76
+ 21 22 23 24 25 26 27 19 20 21 22 23 24 25 16 17 18 19 20 21 22
77
+ 28 29 30 26 27 28 29 30 31 23 24 25 26 27 28 29
78
+ 30 31
48
79
  EOC
49
- # July 2011 August 2011 September 2011
50
- # Mo Tu We Th Fr Sa Su Mo Tu We Th Fr Sa Su Mo Tu We Th Fr Sa Su
51
- # 1 2 3 1 2 3 4 5 6 7 1 2 3 4
52
- # 4 5 6 7 8 9 10 8 9 10 11 12 13 14 5 6 7 8 9 10 11
53
- # 11 12 13 14 15 16 17 15 16 17 18 19 20 21 12 13 14 15 16 17 18
54
- # 18 19 20 21 22 23 24 22 23 24 25 26 27 28 19 20 21 22 23 24 25
55
- # 25 26 27 28 29 30 31 29 30 31 26 27 28 29 30
56
- #
57
- @out.string.inspect.should == exp.inspect # using inspect to help debugging
58
80
  end
59
81
  end
60
82
  end
@@ -0,0 +1,43 @@
1
+ require 'stringio'
2
+ require 'shellout'
3
+
4
+ describe Shellout::Menu do
5
+
6
+ include Shellout
7
+
8
+ before(:each) do
9
+ @out = StringIO.new
10
+ end
11
+
12
+ it "should work for a basic example" do
13
+ Menu(%w(a b c)).print(@out)
14
+ @out.string.should == <<EOT
15
+ 1. a
16
+ 2. b
17
+ 3. c
18
+ EOT
19
+ end
20
+
21
+ it "should print nothing when no items are given" do
22
+ Menu([]).print(@out)
23
+ @out.string.should == ''
24
+ end
25
+
26
+ it "should right justify the menu item number" do
27
+ Menu(('a'..'j').to_a).print(@out)
28
+ @out.string.should == <<EOT
29
+ 1. a
30
+ 2. b
31
+ 3. c
32
+ 4. d
33
+ 5. e
34
+ 6. f
35
+ 7. g
36
+ 8. h
37
+ 9. i
38
+ 10. j
39
+ EOT
40
+ end
41
+
42
+
43
+ end
@@ -1,17 +1,19 @@
1
1
  # encoding: utf-8
2
2
 
3
3
  require 'stringio'
4
- require 'shellout/shadowbox'
4
+ require 'shellout'
5
5
 
6
6
  describe Shellout::Shadowbox do
7
7
 
8
+ include Shellout
9
+
8
10
  before(:each) do
9
11
  @out = StringIO.new
10
12
  end
11
13
 
12
14
  describe 'when title is empty' do
13
15
  it 'should print an empty box' do
14
- @box = Shellout::Shadowbox.new('')
16
+ @box = Shadowbox('')
15
17
  x = <<EOB
16
18
  ┌──────────────────────────────────────────┐
17
19
  │ │▒
@@ -25,7 +27,7 @@ EOB
25
27
 
26
28
  describe 'when a short title is given' do
27
29
  it 'should print a padded box with centered title' do
28
- @box = Shellout::Shadowbox.new('short')
30
+ @box = Shadowbox('short')
29
31
  x = <<EOB
30
32
  ┌──────────────────────────────────────────┐
31
33
  │ short │▒
@@ -39,7 +41,7 @@ EOB
39
41
 
40
42
  describe 'when a long title is given' do
41
43
  it 'should print a box that is big enough' do
42
- @box = Shellout::Shadowbox.new('a very extremely humongously large meaningless title')
44
+ @box = Shadowbox('a very extremely humongously large meaningless title')
43
45
  x = <<EOB
44
46
  ┌──────────────────────────────────────────────────────┐
45
47
  │ a very extremely humongously large meaningless title │▒
@@ -1,24 +1,26 @@
1
1
  # encoding: utf-8
2
2
 
3
3
  require 'stringio'
4
- require 'shellout/table'
4
+ require 'shellout'
5
5
 
6
6
  describe Shellout::Table do
7
7
 
8
+ include Shellout
9
+
8
10
  before(:each) do
9
11
  @out = StringIO.new
10
12
  end
11
13
 
12
14
  describe 'when no parameters' do
13
15
  it 'should not print anything' do
14
- Shellout::Table.new.print(@out)
16
+ Table().print(@out)
15
17
  @out.string.should == ''
16
18
  end
17
19
  end
18
20
 
19
- describe 'table with only a single data row' do
21
+ describe 'when table consists of only a single data row' do
20
22
  it 'should print a single row table' do
21
- Shellout::Table.new(rows: [%w{a b c}]).print(@out)
23
+ Table(rows: [%w{a b c}]).print(@out)
22
24
  @out.string.should == <<'EOT'
23
25
  ┌───┬───┬───┐
24
26
  │ a │ b │ c │
@@ -29,7 +31,7 @@ EOT
29
31
 
30
32
  describe 'when only given headers' do
31
33
  it 'should print headers and one empty row' do
32
- Shellout::Table.new(headers: %w{a b c}).print(@out)
34
+ Table(headers: %w{a b c}).print(@out)
33
35
  @out.string.should == <<'EOT'
34
36
  ┌───┬───┬───┐
35
37
  │ a │ b │ c │
@@ -41,7 +43,7 @@ EOT
41
43
 
42
44
  describe 'when all parameters are defined' do
43
45
  it 'should print a nice table' do
44
- Shellout::Table.new(headers: %w{a b c}, rows: [%w{d e f}, %w{g h i}], footers: %w{j k l}).print(@out)
46
+ Table(headers: %w{a b c}, rows: [%w{d e f}, %w{g h i}], footers: %w{j k l}).print(@out)
45
47
  @out.string.should == <<'EOT'
46
48
  ┌───┬───┬───┐
47
49
  │ a │ b │ c │
@@ -56,12 +58,12 @@ EOT
56
58
  end
57
59
 
58
60
  it 'should center headers' do
59
- Shellout::Table.new(headers: %w{a b c}, rows: [%w{123 456 789}]).print(@out)
61
+ Table(headers: %w{a b c}, rows: [%w{123 456 789}]).print(@out)
60
62
  @out.string.each_line.to_a[1].should == "│ a │ b │ c │\n"
61
63
  end
62
64
 
63
65
  it 'should_right_justify_numbers' do
64
- Shellout::Table.new(headers: %w{aaaa bb ccc}, rows: [%w{123 4 56}]).print(@out)
66
+ Table(headers: %w{aaaa bb ccc}, rows: [%w{123 4 56}]).print(@out)
65
67
  @out.string.should == <<'EOT'
66
68
  ┌──────┬────┬─────┐
67
69
  │ aaaa │ bb │ ccc │
@@ -72,7 +74,7 @@ EOT
72
74
  end
73
75
 
74
76
  it 'should handle an example with some "real" data' do
75
- Shellout::Table.new(
77
+ Table(
76
78
  headers: %w{project code hours price},
77
79
  rows: [%w{nice_project_1 a 7:30 100.00}, %w{nice_project_2 b 7:30 87.50}],
78
80
  footers: %w{Sum - 15:00 187.50},
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: shellout
3
3
  version: !ruby/object:Gem::Version
4
- version: '0.3'
4
+ version: '0.4'
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2011-10-31 00:00:00.000000000Z
12
+ date: 2011-12-03 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rspec
16
- requirement: &9770540 !ruby/object:Gem::Requirement
16
+ requirement: &70362130786780 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
@@ -21,10 +21,10 @@ dependencies:
21
21
  version: '0'
22
22
  type: :development
23
23
  prerelease: false
24
- version_requirements: *9770540
24
+ version_requirements: *70362130786780
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: guard
27
- requirement: &9770040 !ruby/object:Gem::Requirement
27
+ requirement: &70362130786200 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ! '>='
@@ -32,10 +32,10 @@ dependencies:
32
32
  version: '0'
33
33
  type: :development
34
34
  prerelease: false
35
- version_requirements: *9770040
35
+ version_requirements: *70362130786200
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: guard-rspec
38
- requirement: &9769360 !ruby/object:Gem::Requirement
38
+ requirement: &70362130784620 !ruby/object:Gem::Requirement
39
39
  none: false
40
40
  requirements:
41
41
  - - ! '>='
@@ -43,7 +43,29 @@ dependencies:
43
43
  version: '0'
44
44
  type: :development
45
45
  prerelease: false
46
- version_requirements: *9769360
46
+ version_requirements: *70362130784620
47
+ - !ruby/object:Gem::Dependency
48
+ name: rb-fsevent
49
+ requirement: &70362130784160 !ruby/object:Gem::Requirement
50
+ none: false
51
+ requirements:
52
+ - - ! '>='
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ type: :development
56
+ prerelease: false
57
+ version_requirements: *70362130784160
58
+ - !ruby/object:Gem::Dependency
59
+ name: growl_notify
60
+ requirement: &70362130783520 !ruby/object:Gem::Requirement
61
+ none: false
62
+ requirements:
63
+ - - ! '>='
64
+ - !ruby/object:Gem::Version
65
+ version: '0'
66
+ type: :development
67
+ prerelease: false
68
+ version_requirements: *70362130783520
47
69
  description: Contains classes for printing tables and boxes
48
70
  email:
49
71
  - kjellm@acm.org
@@ -59,14 +81,15 @@ files:
59
81
  - Rakefile
60
82
  - lib/shellout.rb
61
83
  - lib/shellout/calendar.rb
84
+ - lib/shellout/menu.rb
62
85
  - lib/shellout/shadowbox.rb
63
86
  - lib/shellout/table.rb
64
87
  - lib/shellout/version.rb
65
88
  - shellout.gemspec
66
89
  - spec/shellout/calendar_spec.rb
90
+ - spec/shellout/menu_spec.rb
67
91
  - spec/shellout/shadowbox_spec.rb
68
92
  - spec/shellout/table_spec.rb
69
- - spec/shellout_spec.rb
70
93
  homepage: https://github.com/kjellm/shellout
71
94
  licenses:
72
95
  - MIT
@@ -94,7 +117,6 @@ specification_version: 3
94
117
  summary: Tools for writing terminal interfaces
95
118
  test_files:
96
119
  - spec/shellout/calendar_spec.rb
120
+ - spec/shellout/menu_spec.rb
97
121
  - spec/shellout/shadowbox_spec.rb
98
122
  - spec/shellout/table_spec.rb
99
- - spec/shellout_spec.rb
100
- has_rdoc:
@@ -1,15 +0,0 @@
1
- # encoding: utf-8
2
-
3
- require 'shellout'
4
-
5
- describe Shellout do
6
-
7
- it 'should auto load shellout/shadowbox' do
8
- (Shellout.const_defined? :Shadowbox).should be_true
9
- end
10
-
11
- it 'should auto load shellout/table' do
12
- (Shellout.const_defined? :Table).should be_true
13
- end
14
-
15
- end