termnote 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
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/.rvmrc ADDED
@@ -0,0 +1,48 @@
1
+ #!/usr/bin/env bash
2
+
3
+ # This is an RVM Project .rvmrc file, used to automatically load the ruby
4
+ # development environment upon cd'ing into the directory
5
+
6
+ # First we specify our desired <ruby>[@<gemset>], the @gemset name is optional,
7
+ # Only full ruby name is supported here, for short names use:
8
+ # echo "rvm use 1.9.3" > .rvmrc
9
+ environment_id="ruby-1.9.3-p286@termnote"
10
+
11
+ # Uncomment the following lines if you want to verify rvm version per project
12
+ # rvmrc_rvm_version="1.16.17 (stable)" # 1.10.1 seams as a safe start
13
+ # eval "$(echo ${rvm_version}.${rvmrc_rvm_version} | awk -F. '{print "[[ "$1*65536+$2*256+$3" -ge "$4*65536+$5*256+$6" ]]"}' )" || {
14
+ # echo "This .rvmrc file requires at least RVM ${rvmrc_rvm_version}, aborting loading."
15
+ # return 1
16
+ # }
17
+
18
+ # First we attempt to load the desired environment directly from the environment
19
+ # file. This is very fast and efficient compared to running through the entire
20
+ # CLI and selector. If you want feedback on which environment was used then
21
+ # insert the word 'use' after --create as this triggers verbose mode.
22
+ if [[ -d "${rvm_path:-$HOME/.rvm}/environments"
23
+ && -s "${rvm_path:-$HOME/.rvm}/environments/$environment_id" ]]
24
+ then
25
+ \. "${rvm_path:-$HOME/.rvm}/environments/$environment_id"
26
+ [[ -s "${rvm_path:-$HOME/.rvm}/hooks/after_use" ]] &&
27
+ \. "${rvm_path:-$HOME/.rvm}/hooks/after_use" || true
28
+ else
29
+ # If the environment file has not yet been created, use the RVM CLI to select.
30
+ rvm --create "$environment_id" || {
31
+ echo "Failed to create RVM environment '${environment_id}'."
32
+ return 1
33
+ }
34
+ fi
35
+
36
+ # If you use bundler, this might be useful to you:
37
+ # if [[ -s Gemfile ]] && {
38
+ # ! builtin command -v bundle >/dev/null ||
39
+ # builtin command -v bundle | GREP_OPTIONS= \grep $rvm_path/bin/bundle >/dev/null
40
+ # }
41
+ # then
42
+ # printf "%b" "The rubygem 'bundler' is not installed. Installing it now.\n"
43
+ # gem install bundler
44
+ # fi
45
+ # if [[ -s Gemfile ]] && builtin command -v bundle >/dev/null
46
+ # then
47
+ # bundle install | GREP_OPTIONS= \grep -vE '^Using|Your bundle is complete'
48
+ # fi
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in termnote.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2012 Kurtis Rainbolt-Greene
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,74 @@
1
+ TermNote
2
+ --------
3
+
4
+ TermNote is a program that allows you to write presentations either in Ruby:
5
+
6
+ ``` ruby
7
+ require 'termnote'
8
+
9
+ include TermNote
10
+
11
+ show.add chapter title: "Hello, World"
12
+ show.add code language: "Ruby", source: <<-SOURCE
13
+ puts "Hello, world!"
14
+ SOURCE
15
+ show.start
16
+ ```
17
+ Or via a `.yaml` file:
18
+
19
+ ``` yaml
20
+ ---
21
+ type: chapter
22
+ title: Hello, World
23
+ subtitle: By Kurtis
24
+ ---
25
+ type: code
26
+ source: |
27
+ puts "Hello, world!"
28
+ ```
29
+
30
+ and then with the `termnote` binary:
31
+
32
+ ``` shell
33
+ $ termnote someshow.yml
34
+ ```
35
+
36
+ Here's an example of the slides in use:
37
+
38
+ ![Chapter](https://raw.github.com/krainboltgreene/termnote/master/example/chapter.png)
39
+ ![Text](https://raw.github.com/krainboltgreene/termnote/master/example/text.png)
40
+ ![List](https://raw.github.com/krainboltgreene/termnote/master/example/list.png)
41
+ ![Code](https://raw.github.com/krainboltgreene/termnote/master/example/code.png)
42
+
43
+ You can then use **j** or **k** to navigate through the slides.
44
+
45
+ Installation
46
+ ============
47
+
48
+ Install it yourself via:
49
+
50
+ $ gem install termnote
51
+
52
+
53
+ Usage
54
+ =====
55
+
56
+ Usage is pretty simple, there are 4 types of slides:
57
+
58
+ * Chapter, a single `title` [optional: and `subtitle`]
59
+ * Text, a blob of text called `content` [optional: and `title`]
60
+ * List, a list of `items` [optional: and `title`]
61
+ * Code, a syntax highlighted blob called `source`
62
+
63
+ You can change the way things are printed out by overriding the classes for
64
+ your specific presentation, but only if you do things programatically.
65
+
66
+
67
+ Contributing
68
+ ============
69
+
70
+ 1. Fork it
71
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
72
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
73
+ 4. Push to the branch (`git push origin my-new-feature`)
74
+ 5. Create new Pull Request
data/Rakefile ADDED
@@ -0,0 +1,31 @@
1
+ #!/usr/bin/env ruby
2
+ require 'bundler/gem_tasks'
3
+ require 'rake/clean'
4
+ require 'rake/testtask'
5
+ require 'yard'
6
+
7
+ begin
8
+ Bundler.setup :default, :development
9
+ rescue Bundler::BundlerError => error
10
+ $stderr.puts error.message
11
+ $stderr.puts "Run `bundle install` to install missing gems"
12
+ exit error.status_code
13
+ end
14
+
15
+ Bundler::GemHelper.install_tasks
16
+
17
+ desc "Run all of the tests"
18
+ Rake::TestTask.new do |config|
19
+ config.libs << 'test'
20
+ config.pattern = 'test/**/*_test*'
21
+ config.verbose = true
22
+ config.warning = true
23
+ end
24
+
25
+ desc "Generate all of the docs"
26
+ YARD::Rake::YardocTask.new do |config|
27
+ config.files = Dir['lib/**/*.rb']
28
+ end
29
+
30
+ desc 'Default: run tests, and generate docs'
31
+ task :default => [ :test, :yard ]
data/bin/termnote ADDED
@@ -0,0 +1,12 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'termnote'
4
+ require 'termnote/loader'
5
+
6
+ include TermNote
7
+
8
+ file = File.read ARGV.first
9
+
10
+ TermNote::Loader.new(file).to_panes.each { |pane| show.add pane }
11
+
12
+ show.start
Binary file
data/example/code.png ADDED
Binary file
data/example/list.png ADDED
Binary file
Binary file
@@ -0,0 +1,33 @@
1
+ ---
2
+ type: chapter
3
+ title: How To Learn
4
+ subtitle: A Presentation By Kurtis
5
+ ---
6
+ type: text
7
+ title: Find Inspiration
8
+ content: |
9
+ Anyone who stops learning is old, whether
10
+ at twenty or eighty. Anyone who keeps
11
+ learning stays young. The greatest
12
+ thing in life is to keep your mind
13
+ young.
14
+
15
+ -- Henry Ford
16
+ ---
17
+ type: list
18
+ title: Materials
19
+ items:
20
+ - Paper
21
+ - Pencil
22
+ - Heart
23
+ ---
24
+ type: code
25
+ language: ruby
26
+ source: |
27
+ # Some random code here
28
+ puts 'Hello, world!'
29
+ name + nom
30
+ function(full)
31
+ class Foo < Far
32
+ :sum
33
+ end
data/example/text.png ADDED
Binary file
@@ -0,0 +1,25 @@
1
+ module TermNote
2
+ class Loader
3
+ attr_accessor :document
4
+
5
+ def initialize(file)
6
+ if YAML.parse(file)
7
+ @documents = YAML.load_stream(file)
8
+ else
9
+ raise "not a yaml file?"
10
+ end
11
+ end
12
+
13
+ def to_panes
14
+ @documents.map do |document|
15
+ type = document['type']
16
+ case type
17
+ when "chapter" then Pane::Chapter.new document
18
+ when "code" then Pane::Code.new document
19
+ when "list" then Pane::List.new document
20
+ when "text" then Pane::Text.new document
21
+ end
22
+ end
23
+ end
24
+ end
25
+ end
@@ -0,0 +1,36 @@
1
+ module TermNote
2
+ module Pane
3
+ class Chapter
4
+ include Pane
5
+
6
+ attr_accessor :title, :subtitle
7
+
8
+ def initialize(options)
9
+ @title = options[:title] || options['title']
10
+ @subtitle = options[:subtitle] || options['subtitle']
11
+ end
12
+
13
+ def rows
14
+ if subtitle
15
+ title_rows + subtitle_rows
16
+ else
17
+ title_rows
18
+ end
19
+ end
20
+
21
+ private
22
+
23
+ def title_rows
24
+ title.split('').each_slice(80).map do |row|
25
+ row.join.center(width).bold
26
+ end
27
+ end
28
+
29
+ def subtitle_rows
30
+ subtitle.split('').each_slice(80).map do |row|
31
+ row.join.center(width)
32
+ end
33
+ end
34
+ end
35
+ end
36
+ end
@@ -0,0 +1,24 @@
1
+ module TermNote
2
+ module Pane
3
+ class Code
4
+ include Pane
5
+
6
+ attr_accessor :source, :language
7
+
8
+ def initialize(options)
9
+ @source = options[:source] || options['source']
10
+ @language = options[:language] || options['language']
11
+ end
12
+
13
+ def rows
14
+ highlighted.split("\n")
15
+ end
16
+
17
+ private
18
+
19
+ def highlighted
20
+ Pygments.highlight source, formatter: 'terminal256', lexer: language
21
+ end
22
+ end
23
+ end
24
+ end
@@ -0,0 +1,22 @@
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
@@ -0,0 +1,20 @@
1
+ module TermNote
2
+ module Pane
3
+ class Text
4
+ include Pane
5
+
6
+ attr_accessor :title, :content
7
+
8
+ def initialize(options)
9
+ @title = options[:title] || options['title']
10
+ @content = options[:content] || options['content']
11
+ end
12
+
13
+ def rows
14
+ "#{title.center(width).bold}\n\n#{content}".split("\n").map do |row|
15
+ row.center(width)
16
+ end
17
+ end
18
+ end
19
+ end
20
+ end
@@ -0,0 +1,43 @@
1
+ require_relative 'pane/chapter'
2
+ require_relative 'pane/code'
3
+ require_relative 'pane/list'
4
+ require_relative 'pane/text'
5
+ module TermNote
6
+ module Pane
7
+ attr_accessor :show, :height, :width, :rows
8
+
9
+ def call(window_size)
10
+ window_height, window_width = window_size
11
+ @width = window_width - (window_width * 0.2)
12
+ @height = window_height / 2
13
+ clear
14
+ render
15
+ end
16
+
17
+ private
18
+
19
+ def clear
20
+ system("clear")
21
+ end
22
+
23
+ def render
24
+ puts space + formated_rows + space + footer
25
+ end
26
+
27
+ def gutter
28
+ " " * (width * 0.1)
29
+ end
30
+
31
+ def space
32
+ "\n" * (height - rows.size)
33
+ end
34
+
35
+ def footer
36
+ "[#{show.panes.index(self) + 1}/#{show.panes.size}]".bold
37
+ end
38
+
39
+ def formated_rows
40
+ rows.map { |row| gutter + row }.join("\n")
41
+ end
42
+ end
43
+ end
@@ -0,0 +1,46 @@
1
+ module TermNote
2
+ class Show
3
+ attr_accessor :panes
4
+
5
+ def initialize
6
+ @panes = []
7
+ end
8
+
9
+ def add(pane)
10
+ panes << pane
11
+ pane.show = self
12
+ end
13
+
14
+ def pane
15
+ @pane || panes.first
16
+ end
17
+
18
+ def position
19
+ panes.index pane
20
+ end
21
+
22
+ def start
23
+ active = true
24
+ while active
25
+ pane.call $stdout.winsize
26
+ case command
27
+ when "j" then forward
28
+ when "k" then backward
29
+ when "q" then active = false
30
+ end
31
+ end
32
+ end
33
+
34
+ def forward
35
+ @pane = panes[position + 1] || panes.first
36
+ end
37
+
38
+ def backward
39
+ @pane = panes[position - 1] || panes.last
40
+ end
41
+
42
+ def command
43
+ $stdin.getch
44
+ end
45
+ end
46
+ end
@@ -0,0 +1,3 @@
1
+ module TermNote
2
+ VERSION = "1.0.0"
3
+ end
data/lib/termnote.rb ADDED
@@ -0,0 +1,31 @@
1
+ require 'io/console'
2
+ require 'colored'
3
+ require 'pygments'
4
+ require 'yaml'
5
+ require_relative 'termnote/version'
6
+ require_relative 'termnote/pane'
7
+ require_relative 'termnote/show'
8
+ require_relative 'termnote/pane'
9
+
10
+ module TermNote
11
+ def show
12
+ @show ||= Show.new
13
+ end
14
+
15
+ def chapter(options)
16
+ Pane::Chapter.new options
17
+ end
18
+
19
+ def text(options)
20
+ Pane::Text.new options
21
+ end
22
+
23
+ def code(options)
24
+ Pane::Code.new options
25
+ end
26
+
27
+ def list(options)
28
+ Pane::List.new options
29
+ end
30
+ end
31
+
data/termnote.gemspec ADDED
@@ -0,0 +1,26 @@
1
+ # encoding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'termnote/version'
5
+
6
+ Gem::Specification.new do |gem|
7
+ gem.name = "termnote"
8
+ gem.version = TermNote::VERSION
9
+ gem.authors = ["Kurtis Rainbolt-Greene"]
10
+ gem.email = ["me@kurtisrainboltgreene.name"]
11
+ gem.summary = %q{A terminal based keynote presentation machine}
12
+ gem.description = gem.summary
13
+ gem.homepage = "http://krainboltgreene.github.com/termnote"
14
+
15
+ gem.files = `git ls-files`.split($/)
16
+ gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
17
+ gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
18
+ gem.require_paths = ["lib"]
19
+
20
+ gem.add_runtime_dependency 'colored', '~> 1.2'
21
+ gem.add_runtime_dependency 'pygments.rb', '~> 0.3'
22
+ gem.add_development_dependency 'yard'
23
+ gem.add_development_dependency 'kramdown'
24
+ # gem.add_runtime_dependency 'gemname', '~> 1.0'
25
+ # gem.add_development_dependency 'gemname', '~> 1.0'
26
+ end
metadata ADDED
@@ -0,0 +1,140 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: termnote
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.0
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Kurtis Rainbolt-Greene
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2012-11-13 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: colored
16
+ requirement: !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ~>
20
+ - !ruby/object:Gem::Version
21
+ version: '1.2'
22
+ type: :runtime
23
+ prerelease: false
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ~>
28
+ - !ruby/object:Gem::Version
29
+ version: '1.2'
30
+ - !ruby/object:Gem::Dependency
31
+ name: pygments.rb
32
+ requirement: !ruby/object:Gem::Requirement
33
+ none: false
34
+ requirements:
35
+ - - ~>
36
+ - !ruby/object:Gem::Version
37
+ version: '0.3'
38
+ type: :runtime
39
+ prerelease: false
40
+ version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ~>
44
+ - !ruby/object:Gem::Version
45
+ version: '0.3'
46
+ - !ruby/object:Gem::Dependency
47
+ name: yard
48
+ requirement: !ruby/object:Gem::Requirement
49
+ none: false
50
+ requirements:
51
+ - - ! '>='
52
+ - !ruby/object:Gem::Version
53
+ version: '0'
54
+ type: :development
55
+ prerelease: false
56
+ version_requirements: !ruby/object:Gem::Requirement
57
+ none: false
58
+ requirements:
59
+ - - ! '>='
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ - !ruby/object:Gem::Dependency
63
+ name: kramdown
64
+ requirement: !ruby/object:Gem::Requirement
65
+ none: false
66
+ requirements:
67
+ - - ! '>='
68
+ - !ruby/object:Gem::Version
69
+ version: '0'
70
+ type: :development
71
+ prerelease: false
72
+ version_requirements: !ruby/object:Gem::Requirement
73
+ none: false
74
+ requirements:
75
+ - - ! '>='
76
+ - !ruby/object:Gem::Version
77
+ version: '0'
78
+ description: A terminal based keynote presentation machine
79
+ email:
80
+ - me@kurtisrainboltgreene.name
81
+ executables:
82
+ - termnote
83
+ extensions: []
84
+ extra_rdoc_files: []
85
+ files:
86
+ - .gitignore
87
+ - .rvmrc
88
+ - Gemfile
89
+ - LICENSE.txt
90
+ - README.md
91
+ - Rakefile
92
+ - bin/termnote
93
+ - example/chapter.png
94
+ - example/code.png
95
+ - example/list.png
96
+ - example/running.png
97
+ - example/slideshow1.yaml
98
+ - example/text.png
99
+ - lib/termnote.rb
100
+ - lib/termnote/loader.rb
101
+ - lib/termnote/pane.rb
102
+ - lib/termnote/pane/chapter.rb
103
+ - lib/termnote/pane/code.rb
104
+ - lib/termnote/pane/list.rb
105
+ - lib/termnote/pane/text.rb
106
+ - lib/termnote/show.rb
107
+ - lib/termnote/version.rb
108
+ - termnote.gemspec
109
+ homepage: http://krainboltgreene.github.com/termnote
110
+ licenses: []
111
+ post_install_message:
112
+ rdoc_options: []
113
+ require_paths:
114
+ - lib
115
+ required_ruby_version: !ruby/object:Gem::Requirement
116
+ none: false
117
+ requirements:
118
+ - - ! '>='
119
+ - !ruby/object:Gem::Version
120
+ version: '0'
121
+ segments:
122
+ - 0
123
+ hash: 1621899467072845328
124
+ required_rubygems_version: !ruby/object:Gem::Requirement
125
+ none: false
126
+ requirements:
127
+ - - ! '>='
128
+ - !ruby/object:Gem::Version
129
+ version: '0'
130
+ segments:
131
+ - 0
132
+ hash: 1621899467072845328
133
+ requirements: []
134
+ rubyforge_project:
135
+ rubygems_version: 1.8.24
136
+ signing_key:
137
+ specification_version: 3
138
+ summary: A terminal based keynote presentation machine
139
+ test_files: []
140
+ has_rdoc: