bookfile 0.1.2 → 0.1.3
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.
- checksums.yaml +4 -4
- data/Manifest.txt +2 -0
- data/lib/bookfile/builder.rb +6 -0
- data/lib/bookfile/database/database.rb +33 -0
- data/lib/bookfile/version.rb +1 -1
- data/test/bookfile/football.rb +93 -0
- data/test/test_football.rb +29 -0
- metadata +5 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c81694a303dcd835d8789dce463ec4a639e6d512
|
4
|
+
data.tar.gz: dbefc7253f83fbfcfecaad2a8b1c200e1151e001
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f3ae2203cec27d8afc9c768d1fba699771e98f50ed87b08b36b15e627b8d72bcc96d60f9f02187ad5e104907c7b0bc1175b1b3ca52c9bf6fe9829ed8d30b91c4
|
7
|
+
data.tar.gz: 80f11909f3b6de0848bfbd42779c453ac6334bbae57cbb67314e2bcd65d88e0dd9909469543a7cb5fc437733741ce933af7a52fef9c729e33a4f489c2df26402
|
data/Manifest.txt
CHANGED
@@ -13,8 +13,10 @@ lib/bookfile/helpers/misc.rb
|
|
13
13
|
lib/bookfile/package/package.rb
|
14
14
|
lib/bookfile/version.rb
|
15
15
|
test/bookfile/beer.rb
|
16
|
+
test/bookfile/football.rb
|
16
17
|
test/bookfile/world.rb
|
17
18
|
test/helper.rb
|
18
19
|
test/test_beer.rb
|
20
|
+
test/test_football.rb
|
19
21
|
test/test_world.rb
|
20
22
|
test/test_world_templates.rb
|
data/lib/bookfile/builder.rb
CHANGED
@@ -32,6 +32,7 @@ class Builder
|
|
32
32
|
@bookfile.packages << BookPackage.new( name, opts )
|
33
33
|
end
|
34
34
|
|
35
|
+
###########################
|
35
36
|
## database options
|
36
37
|
def world( opts={} )
|
37
38
|
puts "world opts: #{opts.inspect}"
|
@@ -44,6 +45,11 @@ class Builder
|
|
44
45
|
@bookfile.databases << BeerDef.new( opts )
|
45
46
|
end
|
46
47
|
|
48
|
+
def football( opts={} )
|
49
|
+
puts "football opts: #{opts.inspect}"
|
50
|
+
@bookfile.databases << FootballDef.new( opts )
|
51
|
+
end
|
52
|
+
|
47
53
|
|
48
54
|
|
49
55
|
def book( opts={}, &block )
|
@@ -86,4 +86,37 @@ class BeerDef < Database ## change to BeerDatabase or DatabaseBeer - why, why
|
|
86
86
|
end # class BeerDef
|
87
87
|
|
88
88
|
|
89
|
+
class FootballDef < Database ## change to FootballDatabase or DatabaseFootball - why, why not???
|
90
|
+
def initialize( db_config ) ## check - if it works by default (no initialze specfied)
|
91
|
+
super
|
92
|
+
end
|
93
|
+
|
94
|
+
def prepare ## change to require - why, why not??
|
95
|
+
puts "setup football: #{@db_config.inspect}"
|
96
|
+
|
97
|
+
res = require 'sportdb/models'
|
98
|
+
|
99
|
+
## also add to xxxx ???
|
100
|
+
## (possible to include as globals ???? how - Object.send :include ???) or
|
101
|
+
## Module.send :include ??
|
102
|
+
|
103
|
+
if res == false
|
104
|
+
## find a better check - check for constants defined??? if not define???
|
105
|
+
## or use constant_missing handler???
|
106
|
+
puts " todo/fix: SportDb::Models already included ??"
|
107
|
+
end
|
108
|
+
|
109
|
+
## for now always include
|
110
|
+
puts " include SportDb::Models"
|
111
|
+
|
112
|
+
### check/fix: include as globals/top-level!!! how? possible???
|
113
|
+
Builder.send :include, SportDb::Models
|
114
|
+
PageCtx.send :include, SportDb::Models
|
115
|
+
HybookHelper.send :include, SportDb::Models ## constants not accesible (include in module too)
|
116
|
+
|
117
|
+
|
118
|
+
end # method prepare
|
119
|
+
end # class FootballDef
|
120
|
+
|
121
|
+
|
89
122
|
end # module Bookfile
|
data/lib/bookfile/version.rb
CHANGED
@@ -0,0 +1,93 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
package 'book-templates/football'
|
4
|
+
|
5
|
+
|
6
|
+
football adapter: 'sqlite3', database: './football.db'
|
7
|
+
|
8
|
+
|
9
|
+
|
10
|
+
book do |b|
|
11
|
+
|
12
|
+
opts = {}
|
13
|
+
|
14
|
+
### generate table of contents (toc)
|
15
|
+
|
16
|
+
b.page( 'index', title: 'Contents',
|
17
|
+
id: 'index' ) do |page|
|
18
|
+
page.render_cover( opts )
|
19
|
+
page.render_about( opts )
|
20
|
+
page.render_toc( opts )
|
21
|
+
end
|
22
|
+
|
23
|
+
|
24
|
+
# note: use same order as table of contents
|
25
|
+
event_count = 0
|
26
|
+
League.order(:id).each do |league|
|
27
|
+
next if league.events.count == 0
|
28
|
+
|
29
|
+
league.events.each do |event|
|
30
|
+
puts " build event page [#{event_count+1}] #{event.key} #{event.title}..."
|
31
|
+
|
32
|
+
key = event.key.gsub( '/', '_' )
|
33
|
+
b.page( "events/#{key}", title: "#{event.title}",
|
34
|
+
id: "#{key}" ) do |page|
|
35
|
+
page.render_event( event, opts )
|
36
|
+
end
|
37
|
+
## b.divider() ## -- todo: add for inline version
|
38
|
+
event_count += 1
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
## ### generate events index
|
43
|
+
## b.page( 'events', title: 'Events',
|
44
|
+
## id: 'events' ) do |page|
|
45
|
+
## page.render_events( opts )
|
46
|
+
## end
|
47
|
+
|
48
|
+
|
49
|
+
# note: use same order as table of contents
|
50
|
+
country_count = 0
|
51
|
+
Continent.order(:id).each do |continent|
|
52
|
+
continent.countries.order(:name).each do |country|
|
53
|
+
next if country.teams.count == 0 # skip country w/o teams
|
54
|
+
|
55
|
+
puts " build country page [#{country_count+1}] #{country.key} #{country.title}..."
|
56
|
+
|
57
|
+
path = country.to_path
|
58
|
+
puts " path=#{path}"
|
59
|
+
b.page( "teams/#{path}", title: "#{country.title} (#{country.code})",
|
60
|
+
id: "#{country.key}" ) do |page|
|
61
|
+
page.render_country( country, opts )
|
62
|
+
end
|
63
|
+
|
64
|
+
country_count += 1
|
65
|
+
end
|
66
|
+
end
|
67
|
+
|
68
|
+
|
69
|
+
b.page( 'stadiums', title: 'Stadiums',
|
70
|
+
id: 'stadiums' ) do |page|
|
71
|
+
page.render_grounds( opts )
|
72
|
+
end
|
73
|
+
|
74
|
+
|
75
|
+
### generate national teams a-z index
|
76
|
+
b.page( 'national-teams', title: 'National Teams A-Z Index',
|
77
|
+
id: 'national-teams' ) do |page|
|
78
|
+
page.render_national_teams_idx( opts )
|
79
|
+
end
|
80
|
+
|
81
|
+
### generate teams a-z index
|
82
|
+
b.page( 'clubs', title: 'Clubs A-Z Index',
|
83
|
+
id: 'clubs' ) do |page|
|
84
|
+
page.render_clubs_idx( opts )
|
85
|
+
end
|
86
|
+
|
87
|
+
b.page( 'back', title: 'Back',
|
88
|
+
id: 'back' ) do |page|
|
89
|
+
page.render_back( opts )
|
90
|
+
end
|
91
|
+
|
92
|
+
end # block book
|
93
|
+
|
@@ -0,0 +1,29 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
###
|
4
|
+
# to run use
|
5
|
+
# ruby -I ./lib -I ./test test/test_football.rb
|
6
|
+
|
7
|
+
|
8
|
+
require 'helper'
|
9
|
+
|
10
|
+
class TestFootball < MiniTest::Test
|
11
|
+
|
12
|
+
def test_football
|
13
|
+
book_templates_unzip_dir = './tmp/book-football'
|
14
|
+
|
15
|
+
bookfile = Bookfile::Bookfile.load_file( './test/bookfile/football.rb' )
|
16
|
+
|
17
|
+
bookfile.download # download book packages (templates n scripts)
|
18
|
+
bookfile.unzip( book_templates_unzip_dir )
|
19
|
+
|
20
|
+
bookfile.prepare( book_templates_unzip_dir )
|
21
|
+
bookfile.connect
|
22
|
+
|
23
|
+
bookfile.build( book_templates_unzip_dir )
|
24
|
+
|
25
|
+
assert true # if we get here - test success
|
26
|
+
end
|
27
|
+
|
28
|
+
end # class TestFootball
|
29
|
+
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: bookfile
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.3
|
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-03-
|
11
|
+
date: 2015-03-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: props
|
@@ -147,9 +147,11 @@ files:
|
|
147
147
|
- lib/bookfile/package/package.rb
|
148
148
|
- lib/bookfile/version.rb
|
149
149
|
- test/bookfile/beer.rb
|
150
|
+
- test/bookfile/football.rb
|
150
151
|
- test/bookfile/world.rb
|
151
152
|
- test/helper.rb
|
152
153
|
- test/test_beer.rb
|
154
|
+
- test/test_football.rb
|
153
155
|
- test/test_world.rb
|
154
156
|
- test/test_world_templates.rb
|
155
157
|
homepage: https://github.com/hybook/bookfile
|
@@ -179,6 +181,7 @@ signing_key:
|
|
179
181
|
specification_version: 4
|
180
182
|
summary: bookfile - builder for books
|
181
183
|
test_files:
|
184
|
+
- test/test_football.rb
|
182
185
|
- test/test_beer.rb
|
183
186
|
- test/test_world.rb
|
184
187
|
- test/test_world_templates.rb
|