termnote 1.1.0 → 1.5.0

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -9,7 +9,7 @@ require 'termnote'
9
9
  include TermNote
10
10
 
11
11
  show.add chapter title: "Hello, World"
12
- show.add code language: "Ruby", source: <<-SOURCE
12
+ show.add code language: "ruby", source: <<-SOURCE
13
13
  puts "Hello, world!"
14
14
  SOURCE
15
15
  show.start
@@ -63,6 +63,36 @@ Usage is pretty simple, there are 4 types of slides:
63
63
  You can change the way things are printed out by overriding the classes for
64
64
  your specific presentation, but only if you do things programatically.
65
65
 
66
+ Ruby Usage Examples
67
+ =============
68
+
69
+ **Add a title slide**
70
+
71
+ ```ruby
72
+ show.add chapter title: "Title Slide"
73
+ ```
74
+
75
+ **Add a text slide**
76
+
77
+ ```ruby
78
+ show.add text title: "Content Title", content: "content blob"
79
+ ```
80
+
81
+ **Add a list slide**
82
+
83
+ ```ruby
84
+ show.add list title: "title", items: ["item 1", "item 2", "item 3"]
85
+ ```
86
+
87
+ **Add a slide with code**
88
+
89
+ ```ruby
90
+ show.add code langauge: "ruby", source: <<-SOURCE
91
+ def method
92
+ awesome = true
93
+ end
94
+ SOURCE
95
+ ```
66
96
 
67
97
  Contributing
68
98
  ============
@@ -14,12 +14,11 @@ content: |
14
14
 
15
15
  -- Henry Ford
16
16
  ---
17
- type: list
18
- title: Materials
19
- items:
20
- - Paper
21
- - Pencil
22
- - Heart
17
+ type: text
18
+ content: |
19
+ * Be assertive
20
+ * Don't let anyone down!
21
+ * Be yourself!
23
22
  ---
24
23
  type: console
25
24
  binary: irb
@@ -1,5 +1,5 @@
1
1
  require 'io/console'
2
- require 'colored'
2
+ require 'smart_colored/extend'
3
3
  require 'pygments'
4
4
  require 'yaml'
5
5
  require_relative 'termnote/version'
@@ -1,7 +1,7 @@
1
+ require_relative 'pane/helpers'
1
2
  require_relative 'pane/chapter'
2
- require_relative 'pane/code'
3
- require_relative 'pane/list'
4
3
  require_relative 'pane/text'
4
+ require_relative 'pane/code'
5
5
  require_relative 'pane/console'
6
6
 
7
7
  module TermNote
@@ -27,15 +27,24 @@ module TermNote
27
27
  end
28
28
 
29
29
  def space
30
- "\n" * (height / 2)
30
+ "\n" * (height / 2)
31
31
  end
32
32
 
33
33
  def formated_rows
34
- rows.map { |row| gutter + row }.join("\n")
34
+ @output ||= rows.map(&method(:guttered_row)).join("\n")
35
+ end
36
+
37
+ def guttered_row(row)
38
+ raise ArgumentError, "content was larger than screen" if gutter_width(row) < 0
39
+ gutter(row) + row
40
+ end
41
+
42
+ def gutter(row)
43
+ " " * gutter_width(row)
35
44
  end
36
45
 
37
- def gutter
38
- " " * (width / 10)
46
+ def gutter_width(row)
47
+ (width / 2.0).floor - (row.width / 2.0).ceil
39
48
  end
40
49
  end
41
50
  end
@@ -2,6 +2,7 @@ module TermNote
2
2
  module Pane
3
3
  class Chapter
4
4
  include Pane
5
+ include Helpers::Title
5
6
 
6
7
  attr_accessor :title, :subtitle
7
8
 
@@ -11,25 +12,17 @@ module TermNote
11
12
  end
12
13
 
13
14
  def rows
14
- if subtitle
15
- title_rows + subtitle_rows
16
- else
17
- title_rows
18
- end
15
+ subtitle ? title_row + subtitle_row : title_row
19
16
  end
20
17
 
21
18
  private
22
19
 
23
- def title_rows
24
- title.split('').each_slice(80).map do |row|
25
- row.join.center(width).bold
26
- end
20
+ def subtitle_row
21
+ wrapped_title(subtitle).map &method(:subtitle_row_format)
27
22
  end
28
23
 
29
- def subtitle_rows
30
- subtitle.split('').each_slice(80).map do |row|
31
- row.join.center(width)
32
- end
24
+ def subtitle_row_format(row)
25
+ row.join
33
26
  end
34
27
  end
35
28
  end
@@ -19,6 +19,15 @@ module TermNote
19
19
  def highlighted
20
20
  Pygments.highlight source, formatter: 'terminal256', lexer: language
21
21
  end
22
+
23
+ def gutter_width(row)
24
+ width * 0.25
25
+ end
26
+
27
+ def space
28
+ newlines = height > rows.size ? (height - rows.size) / 2 : 0
29
+ "\n" * newlines
30
+ end
22
31
  end
23
32
  end
24
33
  end
@@ -0,0 +1,10 @@
1
+ require_relative 'helpers/title'
2
+ require_relative 'helpers/content'
3
+
4
+ module TermNote
5
+ module Pane
6
+ module Helpers
7
+
8
+ end
9
+ end
10
+ end
@@ -0,0 +1,17 @@
1
+ module TermNote
2
+ module Pane
3
+ module Helpers
4
+ module Content
5
+ private
6
+
7
+ def content_row
8
+ wrapped_content(content)
9
+ end
10
+
11
+ def wrapped_content(content)
12
+ content.split("\n")
13
+ end
14
+ end
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,21 @@
1
+ module TermNote
2
+ module Pane
3
+ module Helpers
4
+ module Title
5
+ private
6
+
7
+ def title_row
8
+ wrapped_title(title).map &method(:title_row_format)
9
+ end
10
+
11
+ def title_row_format(row)
12
+ row.join.bold
13
+ end
14
+
15
+ def wrapped_title(title)
16
+ title.split('').each_slice(80)
17
+ end
18
+ end
19
+ end
20
+ end
21
+ end
@@ -2,6 +2,8 @@ module TermNote
2
2
  module Pane
3
3
  class Text
4
4
  include Pane
5
+ include Helpers::Title
6
+ include Helpers::Content
5
7
 
6
8
  attr_accessor :title, :content
7
9
 
@@ -10,10 +12,14 @@ module TermNote
10
12
  @content = options[:content] || options['content']
11
13
  end
12
14
 
15
+ private
16
+
13
17
  def rows
14
- "#{title.center(width).bold}\n\n#{content}".split("\n").map do |row|
15
- row.center(width)
16
- end
18
+ title ? title_row + content_row : content_row
19
+ end
20
+
21
+ def gutter_width(row)
22
+ width * 0.25
17
23
  end
18
24
  end
19
25
  end
@@ -3,7 +3,7 @@ module TermNote
3
3
  attr_accessor :panes
4
4
 
5
5
  def initialize
6
- @panes = []
6
+ @panes ||= []
7
7
  end
8
8
 
9
9
  def add(pane)
@@ -45,7 +45,7 @@ module TermNote
45
45
  end
46
46
 
47
47
  def header
48
- "[#{position}/#{total}] - #{panes.first.title}\n".bold
48
+ "[#{position + 1}/#{total}] - #{panes.first.title}\n".bold
49
49
  end
50
50
 
51
51
  private
@@ -1,3 +1,3 @@
1
1
  module TermNote
2
- VERSION = "1.1.0"
2
+ VERSION = "1.5.0"
3
3
  end
@@ -17,7 +17,7 @@ Gem::Specification.new do |gem|
17
17
  gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
18
18
  gem.require_paths = ["lib"]
19
19
 
20
- gem.add_runtime_dependency 'colored', '~> 1.2'
20
+ gem.add_runtime_dependency 'smart_colored', '~> 1.1'
21
21
  gem.add_runtime_dependency 'pygments.rb', '~> 0.3'
22
22
  gem.add_development_dependency 'yard'
23
23
  gem.add_development_dependency 'kramdown'
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: termnote
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.0
4
+ version: 1.5.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,16 +9,16 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-11-14 00:00:00.000000000 Z
12
+ date: 2012-11-15 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
- name: colored
15
+ name: smart_colored
16
16
  requirement: !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ~>
20
20
  - !ruby/object:Gem::Version
21
- version: '1.2'
21
+ version: '1.1'
22
22
  type: :runtime
23
23
  prerelease: false
24
24
  version_requirements: !ruby/object:Gem::Requirement
@@ -26,7 +26,7 @@ dependencies:
26
26
  requirements:
27
27
  - - ~>
28
28
  - !ruby/object:Gem::Version
29
- version: '1.2'
29
+ version: '1.1'
30
30
  - !ruby/object:Gem::Dependency
31
31
  name: pygments.rb
32
32
  requirement: !ruby/object:Gem::Requirement
@@ -92,7 +92,6 @@ files:
92
92
  - bin/termnote
93
93
  - example/chapter.png
94
94
  - example/code.png
95
- - example/list.png
96
95
  - example/running.png
97
96
  - example/slideshow1.yaml
98
97
  - example/text.png
@@ -102,7 +101,9 @@ files:
102
101
  - lib/termnote/pane/chapter.rb
103
102
  - lib/termnote/pane/code.rb
104
103
  - lib/termnote/pane/console.rb
105
- - lib/termnote/pane/list.rb
104
+ - lib/termnote/pane/helpers.rb
105
+ - lib/termnote/pane/helpers/content.rb
106
+ - lib/termnote/pane/helpers/title.rb
106
107
  - lib/termnote/pane/text.rb
107
108
  - lib/termnote/show.rb
108
109
  - lib/termnote/version.rb
@@ -121,7 +122,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
121
122
  version: '0'
122
123
  segments:
123
124
  - 0
124
- hash: 197848977520802502
125
+ hash: 1175875945885039062
125
126
  required_rubygems_version: !ruby/object:Gem::Requirement
126
127
  none: false
127
128
  requirements:
@@ -130,7 +131,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
130
131
  version: '0'
131
132
  segments:
132
133
  - 0
133
- hash: 197848977520802502
134
+ hash: 1175875945885039062
134
135
  requirements: []
135
136
  rubyforge_project:
136
137
  rubygems_version: 1.8.24
Binary file
@@ -1,22 +0,0 @@
1
- module TermNote
2
- module Pane
3
- class List
4
- include Pane
5
-
6
- attr_accessor :title, :items
7
-
8
- def initialize(options)
9
- @title = options[:title] || options['title']
10
- @items = options[:items] || options['items']
11
- end
12
-
13
- def rows
14
- items.map { |item| "* #{item}" }.unshift title.bold + "\n"
15
- end
16
-
17
- def gutter
18
- " " * (width * 0.5)
19
- end
20
- end
21
- end
22
- end