hybook 0.2.0 → 0.2.1

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 9b878421b3474bc82e8586c68f84d4c34adaf5e2
4
- data.tar.gz: de54ebb90f480d931d0fb35ad258c153bbd5a242
3
+ metadata.gz: 301a430a30a440fb3217c8011dfa1f7c90352cd4
4
+ data.tar.gz: 12553f08d6ecb02fb264d47ec90b828cf84921ff
5
5
  SHA512:
6
- metadata.gz: 1bb70427653c97cdf8713b007dd361dae41fd1263ac7541bbfa4ff7d38765fa0bc7608cee5c356ace22acb2e93ccdf389a0449c235803943ee209102ae14868e
7
- data.tar.gz: 05ecd1f22fd8fb07bb1af99e7848fed44a3355f31f3068cb38dbe28d0486dfa42197d4365d30f5344c06d9657782dc113e7b6d0ab05a93b14a106097643d7c51
6
+ metadata.gz: f44c4eb9cd80d7504e5e0126a24bcef2221f4c0f87f9ae9eb8b98a733df850dde6cc1240699119e0e1280031bad30d1ecdd384bf750a4e18617c51e3de350111
7
+ data.tar.gz: b530e216c90abfe6e336cb2d890d4c495487e8b8fdc50afdc74f634e352de12377436bcd626228ff52a55193d3274e152555885bbbff7ec0efea4d5ea61a27c4
@@ -7,11 +7,6 @@ lib/hybook/builder/album.rb
7
7
  lib/hybook/builder/book.rb
8
8
  lib/hybook/helpers/markdown.rb
9
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
15
10
  lib/hybook/std/album.rb
16
11
  lib/hybook/type/album.rb
17
12
  lib/hybook/type/picture.rb
data/Rakefile CHANGED
@@ -24,8 +24,6 @@ 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
29
27
 
30
28
  ## 3rd party
31
29
  ['gli'],
@@ -38,19 +38,11 @@ require 'hybook/builder/album'
38
38
 
39
39
  require 'hybook/writer/jekyll'
40
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'
47
-
48
-
49
41
 
50
42
 
51
43
 
52
44
  # say hello
53
- if $DEBUG || (defined?($RUBYLIBS_DEBUG) && $RUBYLIBS_DEBUG)
45
+ if defined?($RUBYLIBS_DEBUG) && $RUBYLIBS_DEBUG
54
46
  puts Hybook.banner
55
47
  puts "[hybook] root: #{Hybook.root}"
56
48
  puts "[hybook] templates_path: #{Hybook.templates_path}"
@@ -2,10 +2,10 @@
2
2
 
3
3
 
4
4
  module Hybook
5
- VERSION = '0.2.0'
5
+ VERSION = '0.2.1'
6
6
 
7
7
  def self.banner
8
- "hybook #{VERSION} on Ruby #{RUBY_VERSION} (#{RUBY_RELEASE_DATE}) [#{RUBY_PLATFORM}]"
8
+ "hybook/#{VERSION} on Ruby #{RUBY_VERSION} (#{RUBY_RELEASE_DATE}) [#{RUBY_PLATFORM}]"
9
9
  end
10
10
 
11
11
  def self.root
@@ -7,7 +7,7 @@ class TestBasics < MiniTest::Test
7
7
 
8
8
  def test_banner
9
9
 
10
- banner = "hybook #{Hybook::VERSION} on Ruby #{RUBY_VERSION} (#{RUBY_RELEASE_DATE}) [#{RUBY_PLATFORM}]"
10
+ banner = "hybook/#{Hybook::VERSION} on Ruby #{RUBY_VERSION} (#{RUBY_RELEASE_DATE}) [#{RUBY_PLATFORM}]"
11
11
 
12
12
  assert_equal banner, Hybook.banner
13
13
  assert_equal banner, HyBook.banner ## check module alias
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.2.0
4
+ version: 0.2.1
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-04-01 00:00:00.000000000 Z
11
+ date: 2015-04-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: props
@@ -66,34 +66,6 @@ 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'
97
69
  - !ruby/object:Gem::Dependency
98
70
  name: gli
99
71
  requirement: !ruby/object:Gem::Requirement
@@ -170,11 +142,6 @@ files:
170
142
  - lib/hybook/builder/book.rb
171
143
  - lib/hybook/helpers/markdown.rb
172
144
  - 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
178
145
  - lib/hybook/std/album.rb
179
146
  - lib/hybook/type/album.rb
180
147
  - lib/hybook/type/picture.rb
@@ -1,45 +0,0 @@
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
@@ -1,35 +0,0 @@
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
-
@@ -1,40 +0,0 @@
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
@@ -1,192 +0,0 @@
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
@@ -1,45 +0,0 @@
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