bookery 0.0.2 → 0.1.0

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.
Files changed (64) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +20 -8
  3. data/.travis.yml +5 -0
  4. data/{LICENSE.txt → LICENSE} +0 -0
  5. data/README.md +26 -11
  6. data/Rakefile +2 -1
  7. data/bookery.gemspec +18 -14
  8. data/docs/config.md +61 -0
  9. data/docs/contributing.md +47 -0
  10. data/docs/editing.md +82 -0
  11. data/docs/project.md +77 -0
  12. data/lib/bookery.rb +27 -4
  13. data/lib/bookery/book.rb +13 -15
  14. data/lib/bookery/cli.rb +29 -12
  15. data/lib/bookery/config.rb +42 -0
  16. data/lib/bookery/factories/chapter_factory.rb +35 -0
  17. data/lib/bookery/factories/publisher_factory.rb +13 -0
  18. data/lib/bookery/processors/include_processor.rb +17 -0
  19. data/lib/bookery/project.rb +75 -0
  20. data/lib/bookery/publishers/html_publisher.rb +68 -0
  21. data/lib/bookery/version.rb +1 -1
  22. data/{bin → libexec}/bookery +1 -4
  23. data/templates/basic/Gemfile.tt +2 -0
  24. data/templates/basic/assets/css/base.css +7 -0
  25. data/templates/basic/assets/css/layout.css +23 -0
  26. data/templates/basic/assets/css/modules/code-block.css +132 -0
  27. data/templates/{book/assets → basic/assets/includes}/.empty_directory +0 -0
  28. data/templates/basic/assets/style.css +3 -0
  29. data/templates/basic/assets/templates/template.html.erb +30 -0
  30. data/templates/basic/book/en/001-first-chapter/01-chapter-file.md +9 -0
  31. data/templates/basic/config.yml +14 -0
  32. data/test/bookery/book_test.rb +32 -9
  33. data/test/bookery/cli_test.rb +25 -14
  34. data/test/bookery/config_test.rb +26 -0
  35. data/test/bookery/factories/chapter_factory_test.rb +24 -0
  36. data/test/bookery/factories/publisher_factory_test.rb +16 -0
  37. data/test/bookery/processor/include_processor_test.rb +38 -0
  38. data/test/bookery/project_test.rb +37 -0
  39. data/test/bookery/publishers/html_publisher_test.rb +78 -0
  40. data/test/data/project/Gemfile.tt +2 -0
  41. data/{templates/book/book/.empty_directory → test/data/project/assets/images/cover.png} +0 -0
  42. data/test/data/project/assets/includes/ruby/chapter2.rb +3 -0
  43. data/test/data/project/assets/style.css +1 -0
  44. data/test/data/project/assets/templates/template.html.erb +15 -0
  45. data/test/data/project/book/en/001-first-chapter/01-chapter-file.md +9 -0
  46. data/test/data/project/book/en/002-second-chapter/01-chapter-file.md +7 -0
  47. data/test/data/project/book/en/002-second-chapter/02-second-chapter-file.md +1 -0
  48. data/{templates/book/book/en/.empty_directory → test/data/project/book/es/.git-keep} +0 -0
  49. data/test/data/project/config.yml +19 -0
  50. data/test/test_helper.rb +3 -46
  51. metadata +107 -79
  52. data/Gemfile.lock +0 -64
  53. data/Guardfile +0 -9
  54. data/lib/bookery/chapter.rb +0 -30
  55. data/templates/book/Gemfile +0 -2
  56. data/templates/book/README.md +0 -3
  57. data/templates/book/config.yml +0 -5
  58. data/templates/sample/Gemfile +0 -2
  59. data/templates/sample/README.md +0 -3
  60. data/templates/sample/book/en/01-introduction/01-intro-to-book.md +0 -0
  61. data/templates/sample/book/en/02-second-chapter/01-first-things-first.md +0 -1
  62. data/templates/sample/book/en/02-second-chapter/02-before_intro.md +0 -1
  63. data/templates/sample/config.yml +0 -5
  64. data/test/bookery/chapter_test.rb +0 -21
data/Guardfile DELETED
@@ -1,9 +0,0 @@
1
- # A sample Guardfile
2
- # More info at https://github.com/guard/guard#readme
3
-
4
- guard :minitest do
5
- # with Minitest::Unit
6
- watch(%r{^test/(.*)\/?(.*)_test\.rb})
7
- watch(%r{^lib/(.*/)?([^/]+)\.rb}) { |m| "test/#{m[1]}#{m[2]}_test.rb" }
8
- watch(%r{^test/test_helper\.rb}) { 'test' }
9
- end
@@ -1,30 +0,0 @@
1
- module Bookery
2
- class Chapter
3
- attr_reader :name
4
-
5
- def initialize(chapter_dir)
6
- @name = sanitize_name(chapter_dir)
7
- @dir = chapter_dir
8
- end
9
-
10
- def markup
11
- @markup ||= concatenate_files
12
- end
13
-
14
- private
15
-
16
- def sanitize_name(path)
17
- File.basename(path).sub(/\A\d+\s?-\s?/, '').titleize
18
- end
19
-
20
- def concatenate_files
21
- contents = ''
22
-
23
- Dir.glob(File.join(@dir, '**/*.md')) do |file|
24
- contents << File.read(file)
25
- end
26
-
27
- contents
28
- end
29
- end
30
- end
@@ -1,2 +0,0 @@
1
- source 'https://rubygems'
2
- gem 'redcarpet'
@@ -1,3 +0,0 @@
1
- # My Book
2
-
3
- This is the git repository for my book...
@@ -1,5 +0,0 @@
1
- book:
2
- authors:
3
- -
4
- name: 'your name'
5
- email: 'your email address'
@@ -1,2 +0,0 @@
1
- source 'https://rubygems'
2
- gem 'redcarpet'
@@ -1,3 +0,0 @@
1
- # My Book
2
-
3
- This is the git repository for my book...
@@ -1 +0,0 @@
1
- # The first file in chapter 2
@@ -1 +0,0 @@
1
- # The second file in chapter 2
@@ -1,5 +0,0 @@
1
- book:
2
- authors:
3
- -
4
- name: 'your name'
5
- email: 'your email address'
@@ -1,21 +0,0 @@
1
- require 'test_helper'
2
-
3
- class ChapterTest < AppTest
4
- def setup
5
- super
6
- @chapter = Bookery::Chapter.new('sandbox/book/en/02-second-chapter')
7
- end
8
-
9
- def test_name_is_sanitized
10
- assert_equal 'Second Chapter', @chapter.name
11
- end
12
-
13
- def test_markup_contains_all_files
14
- assert_match /# The first file in chapter 2/, @chapter.markup
15
- assert_match /# The second file in chapter 2/, @chapter.markup
16
- end
17
-
18
- def template_name
19
- 'sample'
20
- end
21
- end