hybook 0.1.2 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Manifest.txt +7 -0
- data/Rakefile +3 -1
- data/lib/hybook.rb +17 -19
- data/lib/hybook/helpers/markdown.rb +40 -0
- data/lib/hybook/helpers/misc.rb +16 -0
- data/lib/hybook/press/beer.rb +45 -0
- data/lib/hybook/press/config.rb +35 -0
- data/lib/hybook/press/football.rb +40 -0
- data/lib/hybook/press/press.rb +192 -0
- data/lib/hybook/press/world.rb +45 -0
- data/lib/hybook/std/album.rb +4 -4
- data/lib/hybook/type/album.rb +2 -2
- data/lib/hybook/type/picture.rb +2 -2
- data/lib/hybook/type/section.rb +2 -2
- data/lib/hybook/version.rb +19 -3
- data/test/helper.rb +1 -10
- data/test/test_basics.rb +5 -5
- metadata +37 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9b878421b3474bc82e8586c68f84d4c34adaf5e2
|
4
|
+
data.tar.gz: de54ebb90f480d931d0fb35ad258c153bbd5a242
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1bb70427653c97cdf8713b007dd361dae41fd1263ac7541bbfa4ff7d38765fa0bc7608cee5c356ace22acb2e93ccdf389a0449c235803943ee209102ae14868e
|
7
|
+
data.tar.gz: 05ecd1f22fd8fb07bb1af99e7848fed44a3355f31f3068cb38dbe28d0486dfa42197d4365d30f5344c06d9657782dc113e7b6d0ab05a93b14a106097643d7c51
|
data/Manifest.txt
CHANGED
@@ -5,6 +5,13 @@ Rakefile
|
|
5
5
|
lib/hybook.rb
|
6
6
|
lib/hybook/builder/album.rb
|
7
7
|
lib/hybook/builder/book.rb
|
8
|
+
lib/hybook/helpers/markdown.rb
|
9
|
+
lib/hybook/helpers/misc.rb
|
10
|
+
lib/hybook/press/beer.rb
|
11
|
+
lib/hybook/press/config.rb
|
12
|
+
lib/hybook/press/football.rb
|
13
|
+
lib/hybook/press/press.rb
|
14
|
+
lib/hybook/press/world.rb
|
8
15
|
lib/hybook/std/album.rb
|
9
16
|
lib/hybook/type/album.rb
|
10
17
|
lib/hybook/type/picture.rb
|
data/Rakefile
CHANGED
@@ -3,7 +3,7 @@ require './lib/hybook/version.rb'
|
|
3
3
|
|
4
4
|
Hoe.spec 'hybook' do
|
5
5
|
|
6
|
-
self.version =
|
6
|
+
self.version = Hybook::VERSION
|
7
7
|
|
8
8
|
self.summary = 'hybook - hypertext book generator'
|
9
9
|
self.description = summary
|
@@ -24,6 +24,8 @@ Hoe.spec 'hybook' do
|
|
24
24
|
['logutils'], # logging
|
25
25
|
['textutils'], # e.g. >= 0.6 && <= 1.0 ## will include logutils, props
|
26
26
|
['markdown'], # markdown helper (e.g. link_to etc.)
|
27
|
+
['bookfile'], ## used by (book)press
|
28
|
+
['datafile'], ## used by (book)press
|
27
29
|
|
28
30
|
## 3rd party
|
29
31
|
['gli'],
|
data/lib/hybook.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
1
3
|
|
2
4
|
############
|
3
5
|
# stdlibs
|
@@ -11,7 +13,7 @@ require 'pp'
|
|
11
13
|
require 'textutils'
|
12
14
|
|
13
15
|
|
14
|
-
|
16
|
+
#####################
|
15
17
|
# our own code
|
16
18
|
|
17
19
|
require 'hybook/version' # let it always go first
|
@@ -24,6 +26,8 @@ require 'hybook/type/section'
|
|
24
26
|
# builtin std helpers, renderers n builders
|
25
27
|
|
26
28
|
require 'hybook/std/album'
|
29
|
+
require 'hybook/helpers/markdown'
|
30
|
+
require 'hybook/helpers/misc'
|
27
31
|
|
28
32
|
## builders
|
29
33
|
|
@@ -34,26 +38,20 @@ require 'hybook/builder/album'
|
|
34
38
|
|
35
39
|
require 'hybook/writer/jekyll'
|
36
40
|
|
41
|
+
## (book)press
|
42
|
+
require 'hybook/press/press'
|
43
|
+
require 'hybook/press/config'
|
44
|
+
require 'hybook/press/world'
|
45
|
+
require 'hybook/press/football'
|
46
|
+
require 'hybook/press/beer'
|
37
47
|
|
38
48
|
|
39
|
-
module HyBook
|
40
|
-
|
41
|
-
def self.banner
|
42
|
-
"hybook #{VERSION} on Ruby #{RUBY_VERSION} (#{RUBY_RELEASE_DATE}) [#{RUBY_PLATFORM}]"
|
43
|
-
end
|
44
|
-
|
45
|
-
def self.root
|
46
|
-
"#{File.expand_path( File.dirname(File.dirname(__FILE__)) )}"
|
47
|
-
end
|
48
|
-
|
49
|
-
def self.templates_path
|
50
|
-
"#{root}/templates"
|
51
|
-
end
|
52
|
-
|
53
|
-
end # module HyBook
|
54
49
|
|
55
50
|
|
56
|
-
puts HyBook.banner # say hello
|
57
|
-
puts "[hybook] root: #{HyBook.root}"
|
58
|
-
puts "[hybook] templates_path: #{HyBook.templates_path}"
|
59
51
|
|
52
|
+
# say hello
|
53
|
+
if $DEBUG || (defined?($RUBYLIBS_DEBUG) && $RUBYLIBS_DEBUG)
|
54
|
+
puts Hybook.banner
|
55
|
+
puts "[hybook] root: #{Hybook.root}"
|
56
|
+
puts "[hybook] templates_path: #{Hybook.templates_path}"
|
57
|
+
end
|
@@ -0,0 +1,40 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
|
4
|
+
###
|
5
|
+
## todo: change to Hybook::MarkdownHelper -- why, why not????
|
6
|
+
|
7
|
+
|
8
|
+
module HybookHelper
|
9
|
+
|
10
|
+
###########################
|
11
|
+
# markdown helpers
|
12
|
+
|
13
|
+
###
|
14
|
+
# fix: move to Markdown gem
|
15
|
+
# add to new module
|
16
|
+
# MarkdownHelper or Markdown::Helper ???
|
17
|
+
|
18
|
+
|
19
|
+
def link_to( title, link )
|
20
|
+
"[#{title}](#{link})"
|
21
|
+
end
|
22
|
+
|
23
|
+
|
24
|
+
def columns_begin( opts={} )
|
25
|
+
# note: will add columns2 or columns3 etc. depending on columns option passed in
|
26
|
+
|
27
|
+
## note: default was 2 (columns) for world.db, 300 (px) for beer.db
|
28
|
+
columns = opts[:columns] || 300
|
29
|
+
|
30
|
+
"\n<div class='columns#{columns}' markdown='1'>\n\n"
|
31
|
+
end
|
32
|
+
|
33
|
+
def columns_end
|
34
|
+
"\n</div>\n\n"
|
35
|
+
end
|
36
|
+
|
37
|
+
### todo: check if we can use columns simply w/ yield for body ??
|
38
|
+
|
39
|
+
|
40
|
+
end # module HybookHelper
|
@@ -0,0 +1,16 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
###
|
4
|
+
## todo: change to Hybook::NumberHelper - why? why not??
|
5
|
+
|
6
|
+
module HybookHelper
|
7
|
+
|
8
|
+
### todo:
|
9
|
+
## add to textutils ?? why? why not??
|
10
|
+
def number_with_delimiter( num )
|
11
|
+
delimiter = '.'
|
12
|
+
num.to_s.reverse.gsub( /(\d{3})(?=\d)/, "\\1#{delimiter}").reverse
|
13
|
+
end
|
14
|
+
|
15
|
+
|
16
|
+
end # module HybookHelper
|
@@ -0,0 +1,45 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
module Hybook
|
4
|
+
|
5
|
+
class BeerConfig < Config
|
6
|
+
|
7
|
+
def initialize( hash ) super; end
|
8
|
+
|
9
|
+
def collection() 'beer'; end
|
10
|
+
|
11
|
+
############
|
12
|
+
# Bookfile
|
13
|
+
# -- remote
|
14
|
+
def bookfile_url()
|
15
|
+
## note: for now always return beer.rb
|
16
|
+
## use setup/layout-specific bookfiles?? allow selection of package,how?? why,why not??
|
17
|
+
"http://github.com/book-templates/bookfile/raw/master/beer.rb"
|
18
|
+
end
|
19
|
+
|
20
|
+
########
|
21
|
+
# Datafile
|
22
|
+
# -- remote
|
23
|
+
def datafile_url() "http://github.com/openbeer/datafile/raw/master/#{setup}.rb"; end
|
24
|
+
|
25
|
+
#######
|
26
|
+
# Database
|
27
|
+
def db_path() "#{build_dir}/#{collection}/#{setup}/#{collection}.db"; end
|
28
|
+
def create_db!() BeerDb.create_all; end
|
29
|
+
|
30
|
+
####
|
31
|
+
# Book Templates
|
32
|
+
## rename to book_dir ?? why, why not? - split zip into book_dir and book_templates_dir why? why not?
|
33
|
+
def book_templates_unzip_dir() "#{build_dir}/#{collection}/#{setup}/book"; end
|
34
|
+
|
35
|
+
end # class BeerConfig
|
36
|
+
|
37
|
+
|
38
|
+
class BookPress
|
39
|
+
def self.create_beer_book_for( setup, opts={} )
|
40
|
+
config = BeerConfig.new( setup: setup )
|
41
|
+
BookPress.new( config )
|
42
|
+
end
|
43
|
+
end # class BookPress
|
44
|
+
|
45
|
+
end # module Hybook
|
@@ -0,0 +1,35 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
module Hybook
|
4
|
+
|
5
|
+
class Config
|
6
|
+
|
7
|
+
def initialize( hash )
|
8
|
+
@hash = hash
|
9
|
+
|
10
|
+
### add source_url e.g. https://github.com ?? - why, why not???
|
11
|
+
|
12
|
+
@build_dir = hash[:build_dir] || './build' ## note: defaults to ./build
|
13
|
+
@setup = hash[:setup]
|
14
|
+
end
|
15
|
+
|
16
|
+
def build_dir() @build_dir; end
|
17
|
+
def setup() @setup; end ## e.g. at, franken, worldcup, etc.
|
18
|
+
|
19
|
+
######
|
20
|
+
# Datafile
|
21
|
+
# -- local
|
22
|
+
def datafile_dir() "#{build_dir}/#{collection}/#{setup}"; end
|
23
|
+
def datafile_path() "#{datafile_dir}/Datafile"; end
|
24
|
+
|
25
|
+
######
|
26
|
+
# Bookfile -- allow multiple (more than one) bookfiles - how? why, why not???
|
27
|
+
# -- local
|
28
|
+
#
|
29
|
+
# todo: move bookfile_dir to unzip dir (e.g. move Bookfile into /book) - why, why not???
|
30
|
+
def bookfile_dir() "#{build_dir}/#{collection}/#{setup}"; end
|
31
|
+
def bookfile_path() "#{bookfile_dir}/Bookfile"; end
|
32
|
+
end
|
33
|
+
|
34
|
+
end # module Hybook
|
35
|
+
|
@@ -0,0 +1,40 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
module Hybook
|
4
|
+
|
5
|
+
class FootballConfig < Config
|
6
|
+
|
7
|
+
def initialize( hash ) super; end
|
8
|
+
|
9
|
+
def collection() 'football'; end
|
10
|
+
|
11
|
+
########
|
12
|
+
# Datafile
|
13
|
+
# -- remote
|
14
|
+
def datafile_url() "http://github.com/openfootball/datafile/raw/master/#{setup}.rb"; end
|
15
|
+
|
16
|
+
#######
|
17
|
+
# Database
|
18
|
+
def db_path() "#{build_dir}/#{collection}/#{setup}/#{collection}.db"; end
|
19
|
+
|
20
|
+
def create_db!()
|
21
|
+
SportDb.create_all
|
22
|
+
SportDb.read_builtin ## note: load built-in datasets (e.g. seasons etc.)
|
23
|
+
end
|
24
|
+
|
25
|
+
####
|
26
|
+
# Book Templates
|
27
|
+
## rename to book_dir ?? why, why not? - split zip into book_dir and book_templates_dir why? why not?
|
28
|
+
def book_templates_unzip_dir() "#{build_dir}/#{collection}/#{setup}/book"; end
|
29
|
+
|
30
|
+
end # class FootballConfig
|
31
|
+
|
32
|
+
|
33
|
+
class BookPress
|
34
|
+
def self.create_football_book_for( setup, opts={} )
|
35
|
+
config = FootballConfig.new( setup: setup )
|
36
|
+
BookPress.new( config )
|
37
|
+
end
|
38
|
+
end # class BookPress
|
39
|
+
|
40
|
+
end # module Hybook
|
@@ -0,0 +1,192 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
module Hybook
|
4
|
+
|
5
|
+
##
|
6
|
+
# todo: change/rename class to Press from BookPress - why, why not??
|
7
|
+
|
8
|
+
class BookPress
|
9
|
+
|
10
|
+
def initialize( config )
|
11
|
+
@config = config
|
12
|
+
end
|
13
|
+
|
14
|
+
|
15
|
+
def dl_datasets
|
16
|
+
## fetch Datafile
|
17
|
+
datafile_dir = @config.datafile_dir
|
18
|
+
datafile_path = @config.datafile_path
|
19
|
+
|
20
|
+
## check if folders exists? if not create folder in path
|
21
|
+
FileUtils.mkdir_p( datafile_dir ) unless Dir.exists?( datafile_dir )
|
22
|
+
|
23
|
+
## note: lets use http:// instead of https:// for now - lets us use person proxy (NOT working w/ https for now)
|
24
|
+
src = @config.datafile_url
|
25
|
+
## dest will be something like './Datafile'
|
26
|
+
|
27
|
+
fetch_datafile( src, datafile_path )
|
28
|
+
|
29
|
+
datafile = Datafile::Datafile.load_file( datafile_path )
|
30
|
+
datafile.dump ## for debugging
|
31
|
+
datafile.download ## datafile step 1 - download all datasets/zips
|
32
|
+
end
|
33
|
+
|
34
|
+
|
35
|
+
def dl_book_templates
|
36
|
+
## fetch Bookfile
|
37
|
+
bookfile_dir = @config.bookfile_dir
|
38
|
+
bookfile_path = @config.bookfile_path
|
39
|
+
|
40
|
+
## check if folders exists? if not create folder in path
|
41
|
+
FileUtils.mkdir_p( bookfile_dir ) unless Dir.exists?( bookfile_dir )
|
42
|
+
|
43
|
+
## note: lets use http:// instead of https:// for now - lets us use person proxy (NOT working w/ https for now)
|
44
|
+
src = @config.bookfile_url
|
45
|
+
## dest will be something like './Bookfile'
|
46
|
+
|
47
|
+
fetch_bookfile( src, bookfile_path )
|
48
|
+
|
49
|
+
|
50
|
+
bookfile = Bookfile::Bookfile.load_file( bookfile_path )
|
51
|
+
|
52
|
+
bookfile.dump ## for debugging
|
53
|
+
bookfile.download ## bookfile step 1 - download all packages/zips (defaults to ./tmp)
|
54
|
+
|
55
|
+
## todo/check: already checked in unzip if folder exists???
|
56
|
+
dest_unzip = @config.book_templates_unzip_dir
|
57
|
+
FileUtils.mkdir_p( dest_unzip ) unless Dir.exists?( dest_unzip )
|
58
|
+
|
59
|
+
bookfile.unzip( dest_unzip ) ## bookfile step 2 - unzip book templates
|
60
|
+
end
|
61
|
+
|
62
|
+
|
63
|
+
def connect
|
64
|
+
db_path = @config.db_path
|
65
|
+
|
66
|
+
db_config = {
|
67
|
+
adapter: 'sqlite3',
|
68
|
+
database: db_path
|
69
|
+
}
|
70
|
+
|
71
|
+
pp db_config
|
72
|
+
ActiveRecord::Base.establish_connection( db_config )
|
73
|
+
|
74
|
+
c = ActiveRecord::Base.connection
|
75
|
+
|
76
|
+
## try to speed up sqlite
|
77
|
+
## see http://www.sqlite.org/pragma.html
|
78
|
+
c.execute( 'PRAGMA synchronous=OFF;' )
|
79
|
+
c.execute( 'PRAGMA journal_mode=OFF;' )
|
80
|
+
## c.execute( 'PRAGMA journal_mode=MEMORY;' )
|
81
|
+
c.execute( 'PRAGMA temp_store=MEMORY;' )
|
82
|
+
end
|
83
|
+
|
84
|
+
|
85
|
+
def build_db
|
86
|
+
## clean; remove db if exits
|
87
|
+
|
88
|
+
db_path = @config.db_path
|
89
|
+
FileUtils.rm( db_path ) if File.exists?( db_path )
|
90
|
+
|
91
|
+
connect()
|
92
|
+
@config.create_db!
|
93
|
+
|
94
|
+
datafile_path = @config.datafile_path
|
95
|
+
pp datafile_path
|
96
|
+
|
97
|
+
|
98
|
+
### hack/quick fix for at,de - "standalone quick test": todo
|
99
|
+
## - find something better
|
100
|
+
if datafile_path.end_with?( 'at.rb' ) ||
|
101
|
+
datafile_path.end_with?( '/at/Datafile' )
|
102
|
+
## standalone austria for debugging add country
|
103
|
+
WorldDb::Model::Country.create!( key: 'at',
|
104
|
+
name: 'Austria',
|
105
|
+
code: 'AUT',
|
106
|
+
pop: 0,
|
107
|
+
area: 0 )
|
108
|
+
elsif datafile_path.end_with?( 'de.rb' ) ||
|
109
|
+
datafile_path.end_with?( '/de/Datafile' )
|
110
|
+
WorldDb::Model::Country.create!( key: 'de',
|
111
|
+
name: 'Germany',
|
112
|
+
code: 'GER',
|
113
|
+
pop: 0,
|
114
|
+
area: 0 )
|
115
|
+
else
|
116
|
+
# no special case; continue
|
117
|
+
puts "[debug] - no special world archive case w/ start script; continue"
|
118
|
+
end
|
119
|
+
|
120
|
+
|
121
|
+
datafile = Datafile::Datafile.load_file( datafile_path )
|
122
|
+
datafile.dump ## for debugging
|
123
|
+
|
124
|
+
logger = LogUtils::Logger.root
|
125
|
+
logger.level = :debug
|
126
|
+
|
127
|
+
datafile.read ## datafile step 2 - read all datasets
|
128
|
+
end
|
129
|
+
|
130
|
+
|
131
|
+
def build_book
|
132
|
+
connect()
|
133
|
+
|
134
|
+
bookfile_path = @config.bookfile_path
|
135
|
+
|
136
|
+
bookfile = Bookfile::Bookfile.load_file( bookfile_path )
|
137
|
+
bookfile.dump ## for debugging
|
138
|
+
|
139
|
+
### fix:
|
140
|
+
### assume WorldDb::Models already included ??
|
141
|
+
## - for now always include on prepare
|
142
|
+
bookfile.prepare( @config.book_templates_unzip_dir )
|
143
|
+
|
144
|
+
puts " contintents: #{WorldDb::Model::Continent.count}" ## for debugging
|
145
|
+
|
146
|
+
bookfile.build( @config.book_templates_unzip_dir )
|
147
|
+
|
148
|
+
puts 'Done.'
|
149
|
+
end
|
150
|
+
|
151
|
+
|
152
|
+
def run_jekyll
|
153
|
+
# change cwd folder
|
154
|
+
cwd = FileUtils.pwd
|
155
|
+
puts "cwd (before): #{cwd}"
|
156
|
+
FileUtils.cd( @config.book_templates_unzip_dir )
|
157
|
+
puts "cwd (after): #{cwd}"
|
158
|
+
|
159
|
+
## use `cd #{book_dir}; jekyll build` -- why, why not???
|
160
|
+
puts `jekyll build`
|
161
|
+
|
162
|
+
# restore cwd folder
|
163
|
+
FileUtils.cd( cwd )
|
164
|
+
end
|
165
|
+
|
166
|
+
|
167
|
+
def build
|
168
|
+
## all-in-one; do everything; complete all steps
|
169
|
+
dl_datasets
|
170
|
+
dl_book_templates
|
171
|
+
|
172
|
+
build_db
|
173
|
+
build_book
|
174
|
+
run_jekyll
|
175
|
+
end
|
176
|
+
|
177
|
+
|
178
|
+
private
|
179
|
+
|
180
|
+
def fetch_datafile( src, dest )
|
181
|
+
worker = Fetcher::Worker.new
|
182
|
+
worker.copy( src, dest )
|
183
|
+
end
|
184
|
+
|
185
|
+
def fetch_bookfile( src, dest )
|
186
|
+
worker = Fetcher::Worker.new
|
187
|
+
worker.copy( src, dest )
|
188
|
+
end
|
189
|
+
|
190
|
+
end # class BookPress
|
191
|
+
|
192
|
+
end # module Hybook
|
@@ -0,0 +1,45 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
module Hybook
|
4
|
+
|
5
|
+
class WorldConfig < Config
|
6
|
+
|
7
|
+
def initialize( hash ) super; end
|
8
|
+
|
9
|
+
def collection() 'world'; end
|
10
|
+
|
11
|
+
############
|
12
|
+
# Bookfile
|
13
|
+
# -- remote
|
14
|
+
def bookfile_url()
|
15
|
+
## note: for now always return world.rb
|
16
|
+
## use country specific bookfiles ?? allow selection of package,how?? why,why not??
|
17
|
+
"https://github.com/book-templates/bookfile/raw/master/world.rb"
|
18
|
+
end
|
19
|
+
|
20
|
+
########
|
21
|
+
# Datafile
|
22
|
+
# -- remote
|
23
|
+
def datafile_url() "https://github.com/openmundi/datafile/raw/master/#{setup}.rb"; end
|
24
|
+
|
25
|
+
#######
|
26
|
+
# Database
|
27
|
+
def db_path() "#{build_dir}/#{collection}/#{setup}/#{collection}.db"; end
|
28
|
+
def create_db!() WorldDb.create_all; end
|
29
|
+
|
30
|
+
|
31
|
+
######################
|
32
|
+
## rename to book_dir ?? why, why not? - split zip into book_dir and book_templates_dir why? why not?
|
33
|
+
def book_templates_unzip_dir() "#{build_dir}/#{collection}/#{setup}/book"; end
|
34
|
+
|
35
|
+
end # class WorldConfig
|
36
|
+
|
37
|
+
|
38
|
+
class BookPress
|
39
|
+
def self.create_world_book_for( setup, opts={} )
|
40
|
+
config = WorldConfig.new( setup: setup )
|
41
|
+
BookPress.new( config )
|
42
|
+
end
|
43
|
+
end # class BookPress
|
44
|
+
|
45
|
+
end # module Hybook
|
data/lib/hybook/std/album.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# encoding: utf-8
|
2
2
|
|
3
|
-
module
|
3
|
+
module Hybook
|
4
4
|
module AlbumHelper
|
5
5
|
|
6
6
|
def render_pictures( pics, opts )
|
@@ -49,13 +49,13 @@ module HyBook
|
|
49
49
|
## TODO/FIX:
|
50
50
|
## use TextUtils::PageTemplate.read( path ).render( binding ) - one line
|
51
51
|
|
52
|
-
tmpl = File.read_utf8( "#{
|
52
|
+
tmpl = File.read_utf8( "#{Hybook.templates_path}/album.md" )
|
53
53
|
TextUtils::PageTemplate.new( tmpl ).render( binding )
|
54
54
|
end
|
55
55
|
|
56
56
|
end # module AblumHelper
|
57
57
|
|
58
58
|
|
59
|
-
# make helpers available as class methods for now e.g.
|
59
|
+
# make helpers available as class methods for now e.g. Hybook.render_album etc.
|
60
60
|
extend AlbumHelper
|
61
|
-
end # module
|
61
|
+
end # module Hybook
|
data/lib/hybook/type/album.rb
CHANGED
data/lib/hybook/type/picture.rb
CHANGED
data/lib/hybook/type/section.rb
CHANGED
data/lib/hybook/version.rb
CHANGED
@@ -1,8 +1,24 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
|
4
|
+
module Hybook
|
5
|
+
VERSION = '0.2.0'
|
6
|
+
|
7
|
+
def self.banner
|
8
|
+
"hybook #{VERSION} on Ruby #{RUBY_VERSION} (#{RUBY_RELEASE_DATE}) [#{RUBY_PLATFORM}]"
|
9
|
+
end
|
10
|
+
|
11
|
+
def self.root
|
12
|
+
"#{File.expand_path( File.dirname(File.dirname(File.dirname(__FILE__))) )}"
|
13
|
+
end
|
14
|
+
|
15
|
+
def self.templates_path
|
16
|
+
"#{root}/templates"
|
17
|
+
end
|
1
18
|
|
2
|
-
module HyBook
|
3
|
-
VERSION = '0.1.2'
|
4
19
|
end
|
5
20
|
|
6
21
|
## add module alias
|
7
22
|
|
8
|
-
|
23
|
+
HyBook = Hybook
|
24
|
+
|
data/test/helper.rb
CHANGED
@@ -2,18 +2,9 @@
|
|
2
2
|
|
3
3
|
## minitest setup
|
4
4
|
|
5
|
-
# require 'minitest/unit'
|
6
5
|
require 'minitest/autorun'
|
7
6
|
|
8
|
-
# include MiniTest::Unit # lets us use TestCase instead of MiniTest::Unit::TestCase
|
9
|
-
|
10
|
-
|
11
|
-
# ruby stdlibs
|
12
|
-
|
13
|
-
require 'json'
|
14
|
-
require 'uri'
|
15
|
-
require 'pp'
|
16
|
-
|
17
7
|
|
8
|
+
### our own code
|
18
9
|
require 'hybook'
|
19
10
|
|
data/test/test_basics.rb
CHANGED
@@ -3,14 +3,14 @@
|
|
3
3
|
|
4
4
|
require 'helper'
|
5
5
|
|
6
|
-
class TestBasics
|
6
|
+
class TestBasics < MiniTest::Test
|
7
7
|
|
8
8
|
def test_banner
|
9
9
|
|
10
|
-
banner = "hybook #{
|
11
|
-
|
12
|
-
assert_equal banner,
|
13
|
-
assert_equal banner,
|
10
|
+
banner = "hybook #{Hybook::VERSION} on Ruby #{RUBY_VERSION} (#{RUBY_RELEASE_DATE}) [#{RUBY_PLATFORM}]"
|
11
|
+
|
12
|
+
assert_equal banner, Hybook.banner
|
13
|
+
assert_equal banner, HyBook.banner ## check module alias
|
14
14
|
|
15
15
|
end
|
16
16
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: hybook
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Gerald Bauer
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-04-01 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: props
|
@@ -66,6 +66,34 @@ dependencies:
|
|
66
66
|
- - ">="
|
67
67
|
- !ruby/object:Gem::Version
|
68
68
|
version: '0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: bookfile
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ">="
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
76
|
+
type: :runtime
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - ">="
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: datafile
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - ">="
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '0'
|
90
|
+
type: :runtime
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - ">="
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '0'
|
69
97
|
- !ruby/object:Gem::Dependency
|
70
98
|
name: gli
|
71
99
|
requirement: !ruby/object:Gem::Requirement
|
@@ -140,6 +168,13 @@ files:
|
|
140
168
|
- lib/hybook.rb
|
141
169
|
- lib/hybook/builder/album.rb
|
142
170
|
- lib/hybook/builder/book.rb
|
171
|
+
- lib/hybook/helpers/markdown.rb
|
172
|
+
- lib/hybook/helpers/misc.rb
|
173
|
+
- lib/hybook/press/beer.rb
|
174
|
+
- lib/hybook/press/config.rb
|
175
|
+
- lib/hybook/press/football.rb
|
176
|
+
- lib/hybook/press/press.rb
|
177
|
+
- lib/hybook/press/world.rb
|
143
178
|
- lib/hybook/std/album.rb
|
144
179
|
- lib/hybook/type/album.rb
|
145
180
|
- lib/hybook/type/picture.rb
|