txtbook 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.autotest +23 -0
- data/.gitignore +1 -0
- data/README.txt +50 -0
- data/Rakefile +21 -0
- data/VERSION +1 -0
- data/bin/txtbook +5 -0
- data/lib/txtbook.rb +51 -0
- data/lib/txtbook/new_book_template/Rakefile +11 -0
- data/lib/txtbook/new_book_template/answers/README.txt +1 -0
- data/lib/txtbook/new_book_template/exercises/README.txt +1 -0
- data/lib/txtbook/new_book_template/slides/sample.key/Contents/PkgInfo +1 -0
- data/lib/txtbook/new_book_template/slides/sample.key/QuickLook/Thumbnail.jpg +0 -0
- data/lib/txtbook/new_book_template/slides/sample.key/index.apxl.gz +0 -0
- data/lib/txtbook/new_book_template/slides/sample.key/thumbs/st0.tiff +0 -0
- data/lib/txtbook/new_book_template/slides/sample.key/thumbs/st1.tiff +0 -0
- data/lib/txtbook/new_book_template/slides/sample.key/thumbs/st2.tiff +0 -0
- data/lib/txtbook/new_book_template/slides/sample.key/thumbs/st3.tiff +0 -0
- data/lib/txtbook/new_book_template/snippets/java/Sample.java +7 -0
- data/spec/txtbook_spec.rb +85 -0
- data/spec_helper.rb +4 -0
- metadata +74 -0
data/.autotest
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
# -*- ruby -*-
|
2
|
+
|
3
|
+
require 'autotest/restart'
|
4
|
+
|
5
|
+
# Autotest.add_hook :initialize do |at|
|
6
|
+
# at.extra_files << "../some/external/dependency.rb"
|
7
|
+
#
|
8
|
+
# at.libs << ":../some/external"
|
9
|
+
#
|
10
|
+
# at.add_exception 'vendor'
|
11
|
+
#
|
12
|
+
# at.add_mapping(/dependency.rb/) do |f, _|
|
13
|
+
# at.files_matching(/test_.*rb$/)
|
14
|
+
# end
|
15
|
+
#
|
16
|
+
# %w(TestA TestB).each do |klass|
|
17
|
+
# at.extra_class_map[klass] = "test/test_misc.rb"
|
18
|
+
# end
|
19
|
+
# end
|
20
|
+
|
21
|
+
# Autotest.add_hook :run_command do |at|
|
22
|
+
# system "rake build"
|
23
|
+
# end
|
data/.gitignore
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
pkg
|
data/README.txt
ADDED
@@ -0,0 +1,50 @@
|
|
1
|
+
= txtbook
|
2
|
+
|
3
|
+
http://github.com/bjrady/txtbook/tree/master
|
4
|
+
|
5
|
+
== DESCRIPTION:
|
6
|
+
|
7
|
+
A presentation and training class generation and packaging tool based on rake
|
8
|
+
|
9
|
+
== FEATURES/PROBLEMS:
|
10
|
+
|
11
|
+
* Basic templating of keynote '08 files is currently supported
|
12
|
+
|
13
|
+
== SYNOPSIS:
|
14
|
+
|
15
|
+
txtbook myNewPresentation
|
16
|
+
cd myNewPresentation
|
17
|
+
rake
|
18
|
+
|
19
|
+
== REQUIREMENTS:
|
20
|
+
|
21
|
+
* Ruby 1.8 or later
|
22
|
+
|
23
|
+
== INSTALL:
|
24
|
+
|
25
|
+
* sudo gem install txtbook
|
26
|
+
|
27
|
+
== LICENSE:
|
28
|
+
|
29
|
+
(The MIT License)
|
30
|
+
|
31
|
+
Copyright (c) 2009 Ben Rady
|
32
|
+
|
33
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
34
|
+
a copy of this software and associated documentation files (the
|
35
|
+
'Software'), to deal in the Software without restriction, including
|
36
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
37
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
38
|
+
permit persons to whom the Software is furnished to do so, subject to
|
39
|
+
the following conditions:
|
40
|
+
|
41
|
+
The above copyright notice and this permission notice shall be
|
42
|
+
included in all copies or substantial portions of the Software.
|
43
|
+
|
44
|
+
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
|
45
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
46
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
47
|
+
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
48
|
+
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
49
|
+
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
50
|
+
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/Rakefile
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
# -*- ruby -*-
|
2
|
+
|
3
|
+
require 'rubygems'
|
4
|
+
require 'hoe'
|
5
|
+
|
6
|
+
begin
|
7
|
+
require 'jeweler'
|
8
|
+
Jeweler::Tasks.new do |gemspec|
|
9
|
+
gemspec.name = "txtbook"
|
10
|
+
gemspec.summary = "Code templating for Keynote"
|
11
|
+
gemspec.description = "Allows you to insert code snippets into keynote file to create training classes or technical presentations"
|
12
|
+
gemspec.email = "benrady@gmail.com"
|
13
|
+
gemspec.homepage = "http://github.com/bjrady/txtbook"
|
14
|
+
gemspec.authors = ["Ben Rady"]
|
15
|
+
end
|
16
|
+
Jeweler::GemcutterTasks.new
|
17
|
+
rescue LoadError
|
18
|
+
puts "Jeweler not available. Install it with: sudo gem install technicalpickles-jeweler -s http://gems.github.com"
|
19
|
+
end
|
20
|
+
|
21
|
+
# vim: syntax=ruby
|
data/VERSION
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
0.1.0
|
data/bin/txtbook
ADDED
data/lib/txtbook.rb
ADDED
@@ -0,0 +1,51 @@
|
|
1
|
+
require 'fileutils'
|
2
|
+
|
3
|
+
module TxtBook
|
4
|
+
class Factory
|
5
|
+
def self.create(cmd_line_args)
|
6
|
+
textbook_root = cmd_line_args[0]
|
7
|
+
# DEBT Move to member var
|
8
|
+
template = File.join(File.dirname(__FILE__), 'txtbook', 'new_book_template')
|
9
|
+
FileUtils.cp_r(template, textbook_root)
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
class KeynoteBuilder
|
14
|
+
attr_accessor :snippets, :keynote_content, :work_dir
|
15
|
+
|
16
|
+
def initialize(book_dir)
|
17
|
+
@textbook = File.expand_path(book_dir)
|
18
|
+
@work_dir = File.join(@textbook, "work")
|
19
|
+
end
|
20
|
+
|
21
|
+
def unbind
|
22
|
+
FileUtils.mkdir_p @work_dir
|
23
|
+
Dir[File.join(@textbook, "slides/*.key")].each do |prez|
|
24
|
+
FileUtils.cp_r(prez, @work_dir)
|
25
|
+
|
26
|
+
# DEBT Untested
|
27
|
+
gunzip(File.join(@work_dir, File.basename(prez), "index.apxl.gz"))
|
28
|
+
|
29
|
+
@keynote_content = IO.read(File.join(@work_dir, File.basename(prez), "index.apxl"))
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
def press
|
34
|
+
@keynote_content.scan(/\$\{(.+?)\}/).each do |template|
|
35
|
+
@keynote_content.gsub!("${#{template}}", IO.read("snippets/#{template}"))
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
def rebind
|
40
|
+
Dir[File.join(@work_dir, "*.key")].each do |prez|
|
41
|
+
File.open(File.join(@work_dir, prez, "index.apxl"), "w+") do |file|
|
42
|
+
file.write @keynote_content
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
def gunzip(filename)
|
48
|
+
Kernel.system("gunzip --force #{filename}")
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
@@ -0,0 +1 @@
|
|
1
|
+
solutions to the exercises go here
|
@@ -0,0 +1 @@
|
|
1
|
+
exercises for instructors, students or audience members go here
|
@@ -0,0 +1 @@
|
|
1
|
+
????????
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
@@ -0,0 +1,85 @@
|
|
1
|
+
require File.join(File.dirname(__FILE__), '..', 'spec_helper')
|
2
|
+
require 'ftools'
|
3
|
+
require 'fileutils'
|
4
|
+
|
5
|
+
#Inspiration:
|
6
|
+
# http://github.com/skippy/s3_rake_tasks/tree/master
|
7
|
+
# http://github.com/smtlaissezfaire/smt_rake_tasks/blob/a8137b860a6fa113a8ffcdb827012aaca9b62087/git.rb
|
8
|
+
|
9
|
+
module TxtBook
|
10
|
+
describe Factory do
|
11
|
+
it "can create a new TextBook" do
|
12
|
+
template = './spec/../lib/txtbook/new_book_template'
|
13
|
+
FileUtils.should_receive(:cp_r).with(template, 'new-book').ordered
|
14
|
+
Factory.create(['new-book'])
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
describe KeynoteBuilder do
|
19
|
+
before(:each) do
|
20
|
+
Factory.create(['temp-book'])
|
21
|
+
@builder = KeynoteBuilder.new('temp-book')
|
22
|
+
end
|
23
|
+
|
24
|
+
it "should copy the keynote08 template to a working directory" do
|
25
|
+
FileUtils.should_receive(:cp_r).with(full_path_to_textbook("slides/sample.key"),
|
26
|
+
full_path_to_textbook("work")).ordered
|
27
|
+
IO.should_receive(:read).ordered
|
28
|
+
|
29
|
+
@builder.unbind
|
30
|
+
end
|
31
|
+
|
32
|
+
it "should unbind keynote09 files"
|
33
|
+
|
34
|
+
it "should unbind keynote08 files" do
|
35
|
+
IO.stub!(:read).with(full_path_to_keynote("index.apxl")).and_return("${java/Sample.java}")
|
36
|
+
zipped_content = full_path_to_keynote("index.apxl.gz")
|
37
|
+
Kernel.should_receive(:system).with("gunzip --force #{zipped_content}")
|
38
|
+
|
39
|
+
@builder.unbind
|
40
|
+
|
41
|
+
@builder.keynote_content.should == "${java/Sample.java}"
|
42
|
+
end
|
43
|
+
|
44
|
+
it "should insert code snippets into keynote content" do
|
45
|
+
@builder.keynote_content = "${java/JavaSample.java}"
|
46
|
+
IO.stub!(:read).with("snippets/java/JavaSample.java").and_return("public class JavaSample")
|
47
|
+
|
48
|
+
@builder.press
|
49
|
+
|
50
|
+
@builder.keynote_content.should include("public class JavaSample")
|
51
|
+
end
|
52
|
+
|
53
|
+
it "should replace multiple code snippet templates in keynote content" do
|
54
|
+
@builder.keynote_content = "${java/Snippet1.java} other stuff ${java/Snippet2.java}"
|
55
|
+
IO.should_receive(:read).with("snippets/java/Snippet1.java").and_return("Snippet1")
|
56
|
+
IO.should_receive(:read).with("snippets/java/Snippet2.java").and_return("Snippet2")
|
57
|
+
|
58
|
+
@builder.press
|
59
|
+
|
60
|
+
@builder.keynote_content.should include("Snippet1 other stuff Snippet2")
|
61
|
+
end
|
62
|
+
|
63
|
+
it "should repack the new keynote content" do
|
64
|
+
@builder.keynote_content = "My Fake Java"
|
65
|
+
Dir.should_receive(:[]).with("#{@builder.work_dir}/*.key").and_return(['prez.key'])
|
66
|
+
file = mock(File)
|
67
|
+
file.should_receive(:write).with("My Fake Java")
|
68
|
+
File.should_receive(:open).with(full_path_to_textbook("work/prez.key/index.apxl"), "w+").and_yield(file)
|
69
|
+
|
70
|
+
@builder.rebind
|
71
|
+
end
|
72
|
+
|
73
|
+
def full_path_to_textbook(filepath)
|
74
|
+
File.expand_path(File.dirname(__FILE__) + "/../temp-book/#{filepath}")
|
75
|
+
end
|
76
|
+
|
77
|
+
def full_path_to_keynote(filename)
|
78
|
+
full_path_to_textbook("work/sample.key/#{filename}")
|
79
|
+
end
|
80
|
+
|
81
|
+
after(:each) do
|
82
|
+
FileUtils.rm_rf('temp-book')
|
83
|
+
end
|
84
|
+
end
|
85
|
+
end
|
data/spec_helper.rb
ADDED
metadata
ADDED
@@ -0,0 +1,74 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: txtbook
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Ben Rady
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
|
12
|
+
date: 2009-10-21 00:00:00 -05:00
|
13
|
+
default_executable: txtbook
|
14
|
+
dependencies: []
|
15
|
+
|
16
|
+
description: Allows you to insert code snippets into keynote file to create training classes or technical presentations
|
17
|
+
email: benrady@gmail.com
|
18
|
+
executables:
|
19
|
+
- txtbook
|
20
|
+
extensions: []
|
21
|
+
|
22
|
+
extra_rdoc_files:
|
23
|
+
- README.txt
|
24
|
+
files:
|
25
|
+
- .autotest
|
26
|
+
- .gitignore
|
27
|
+
- README.txt
|
28
|
+
- Rakefile
|
29
|
+
- VERSION
|
30
|
+
- bin/txtbook
|
31
|
+
- lib/txtbook.rb
|
32
|
+
- lib/txtbook/new_book_template/Rakefile
|
33
|
+
- lib/txtbook/new_book_template/answers/README.txt
|
34
|
+
- lib/txtbook/new_book_template/exercises/README.txt
|
35
|
+
- lib/txtbook/new_book_template/slides/sample.key/Contents/PkgInfo
|
36
|
+
- lib/txtbook/new_book_template/slides/sample.key/QuickLook/Thumbnail.jpg
|
37
|
+
- lib/txtbook/new_book_template/slides/sample.key/index.apxl.gz
|
38
|
+
- lib/txtbook/new_book_template/slides/sample.key/thumbs/st0.tiff
|
39
|
+
- lib/txtbook/new_book_template/slides/sample.key/thumbs/st1.tiff
|
40
|
+
- lib/txtbook/new_book_template/slides/sample.key/thumbs/st2.tiff
|
41
|
+
- lib/txtbook/new_book_template/slides/sample.key/thumbs/st3.tiff
|
42
|
+
- lib/txtbook/new_book_template/snippets/java/Sample.java
|
43
|
+
- spec/txtbook_spec.rb
|
44
|
+
- spec_helper.rb
|
45
|
+
has_rdoc: true
|
46
|
+
homepage: http://github.com/bjrady/txtbook
|
47
|
+
licenses: []
|
48
|
+
|
49
|
+
post_install_message:
|
50
|
+
rdoc_options:
|
51
|
+
- --charset=UTF-8
|
52
|
+
require_paths:
|
53
|
+
- lib
|
54
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
55
|
+
requirements:
|
56
|
+
- - ">="
|
57
|
+
- !ruby/object:Gem::Version
|
58
|
+
version: "0"
|
59
|
+
version:
|
60
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
61
|
+
requirements:
|
62
|
+
- - ">="
|
63
|
+
- !ruby/object:Gem::Version
|
64
|
+
version: "0"
|
65
|
+
version:
|
66
|
+
requirements: []
|
67
|
+
|
68
|
+
rubyforge_project:
|
69
|
+
rubygems_version: 1.3.5
|
70
|
+
signing_key:
|
71
|
+
specification_version: 3
|
72
|
+
summary: Code templating for Keynote
|
73
|
+
test_files:
|
74
|
+
- spec/txtbook_spec.rb
|