cheepub 0.2.0 → 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 2a8208f7e95b12fbe291fa305052ab6845b86727ad9d6c32eeaebe4290946a64
4
- data.tar.gz: 2c38721ff77731851add0e51e952c69286995316cf86e726909b69b922e774cf
3
+ metadata.gz: cb88e2dae0bf74523ce1e187024db8e8e3ec3a332480461e020ca76af1ccef5e
4
+ data.tar.gz: d56c9785adfca375b8892f960e4be9c2f9b3f3fc222d6953e70e7471a55279a3
5
5
  SHA512:
6
- metadata.gz: 1495dad487da24e6a782966908b3d8228b249b71e23fdc66d818fe64c37cba241da061b5e4320debbabf0946a5b4e58352ff24da7304c95f24a0e80b2efe1252
7
- data.tar.gz: eb7146ec19ff947c938f291161f5d1459f51badf7e6c1140b759cadbd2738c0e4841e455f2d8e04325ca97408b5c824333b66cb1b5ead7504a9eaead3ab03bc8
6
+ metadata.gz: 05a9ec137505b9b7fe6ee3777500a96b0e9b9305e244b143406dba78ae24cb857f369e6f709b6b460dc216c5eccf2d125fb2fc4d95d468616d8bd0f29177bd13
7
+ data.tar.gz: e01f312ba85bc5c318689d74efcc3dec662bbe5c7979f331167d999e6417f5b8b1ad64384a12e3bfadae74ae6226514d23511dd23a7c0d115fccdc75694e0626
data/.travis.yml CHANGED
@@ -1,11 +1,19 @@
1
1
  sudo: false
2
2
  language: ruby
3
+ env:
4
+ global:
5
+ - CC_TEST_REPORTER_ID=787a2f89b15c637323c7340d65ec17e898ac44480706b4b4122ea040c2a88f1d
3
6
  rvm:
4
7
  - 2.4.1
5
8
  - 2.5.1
9
+ before_script:
10
+ - curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 > ./cc-test-reporter
11
+ - chmod +x ./cc-test-reporter
12
+ - ./cc-test-reporter before-build
6
13
  before_install:
7
14
  - gem install bundler -v 1.16.1
8
-
15
+ after_script:
16
+ - ./cc-test-reporter after-build --exit-code $TRAVIS_TEST_RESULT
9
17
  branches:
10
18
  only:
11
19
  - master
data/README.md CHANGED
@@ -1,8 +1,8 @@
1
1
  # Cheepub
2
2
 
3
- Cheepub is EPUB generator from Markdown.
3
+ [![Gem Version](https://badge.fury.io/rb/cheepub.svg)](https://badge.fury.io/rb/cheepub)[![Build Status](https://travis-ci.org/takahashim/cheepub.svg?branch=master)](https://travis-ci.org/takahashim/cheepub)
4
4
 
5
- Cheepub uses [Kramdown](https://github.com/gettalong/kramdown) and [Gepub](https://github.com/skoji/gepub).
5
+ Cheepub is EPUB generator from Markdown. When you have markdown file, you can generate EPUB3 file with just one command: `cheepub sample.md`.
6
6
 
7
7
  ## Installation
8
8
 
@@ -16,10 +16,6 @@ If you use the gem in your project, add this line to your application's Gemfile:
16
16
  gem 'cheepub'
17
17
  ```
18
18
 
19
- And then execute:
20
-
21
- $ bundle
22
-
23
19
  ## Usage
24
20
 
25
21
  You can add options `--title` and `--author`.
@@ -34,8 +30,46 @@ If you use front-matter section like Jekyll, you can execute without any options
34
30
  $ cheepub source.md
35
31
  ```
36
32
 
33
+ ### Options
34
+
35
+ * `-v, --version` print version
36
+ * `--author AUTOR` set author of the book
37
+ * `--title TITLE` set title of the book
38
+ * `--config CONFIG` set configuration file
39
+ * `-o, --out EPUBFILE` set output epub filename
40
+ * `-h, --help` print help
41
+
42
+
43
+ ## Markdown extensions
44
+
45
+ Cheepub uses [Kramdown](https://github.com/gettalong/kramdown) and [Gepub](https://github.com/skoji/gepub).
46
+ So you can use Kramdown extensions and some other extensions from [DenDenMarkdown](https://github.com/denshoch/DenDenMarkdown).
47
+
48
+ * newpage (separate files): ex. `===` or `------`.
49
+ * tate-chu-yoko (horizontal in vertical): ex. `^30^` or `!?`.
50
+ * footnote: ex. `[^1]` and `[^1]: some notes about it`.
51
+ * ruby: ex. `{some base text|some ruby text}`
52
+
53
+
54
+ ## Configuration
55
+
56
+ You can define configration with in front-matter or `--config` option.
57
+
58
+ ### Configuration items
59
+
60
+ * id: identifier
61
+ * title: title of the book
62
+ * author: author of the book
63
+ * date: publishing date
64
+ * lastModified: last modified date-time
65
+ * pageDirection: `ltr` or `rtl`
66
+
37
67
  ## History
38
68
 
69
+ ### 0.3.0
70
+
71
+ - add option `--out`
72
+
39
73
  ### 0.2.0
40
74
 
41
75
  - add option `--title`, `--author`, `--config`
data/doc/README_ja.md CHANGED
@@ -31,6 +31,17 @@ Cheepubはコマンドラインで使うことを想定しています。
31
31
  $ cheepub sample.md
32
32
  ```
33
33
 
34
+ ### コマンドラインオプション
35
+
36
+ * `--title 【タイトル】` タイトルを指定します。
37
+ * `--author 【著者名】` 著者名を指定します。
38
+ * `--config 【設定ファイル】` 後述のfront-matterに相当するYAMLファイルを別ファイルで与えた場合に使います。Markdownファイル内に設定を書きたくない人用です。
39
+ * `--out 【EPUBファイル名】 (または -o 【EPUBファイル名】)` 出力するEPUBファイル名を指定します。省略時はbook.epubになります。
40
+ * `--help` ヘルプを表示します。
41
+ * `--version` バージョンを表示します。
42
+
43
+ front-matterがない場合は`--title`と`--author`は必須です。
44
+
34
45
  ## CheepubのMarkdownについて
35
46
 
36
47
  基本方針は3つです。
data/lib/cheepub/cli.rb CHANGED
@@ -2,13 +2,14 @@ module Cheepub
2
2
  class CLI < Clamp::Command
3
3
  using Cheepub::ExtHash
4
4
 
5
- option ["-v", "--version"], :flag, "Show version" do
5
+ option ["-v", "--version"], :flag, "print version" do
6
6
  puts Cheepub::VERSION
7
7
  exit(0)
8
8
  end
9
- option ["--author"], "AUTOR", "author of the book"
10
- option ["--title"], "TITLE", "title of the book"
11
- option ["--config"], "CONFIG", "configuration file"
9
+ option ["--author"], "AUTOR", "set author of the book"
10
+ option ["--title"], "TITLE", "set title of the book"
11
+ option ["--config"], "CONFIG", "set configuration file"
12
+ option ["-o", "--out"], "EPUBFILE", "set output epub filename", attribute_name: :epubfile
12
13
 
13
14
  parameter "SRC", "source file"
14
15
 
@@ -19,6 +20,7 @@ module Cheepub
19
20
  end
20
21
  params[:author] = author if author
21
22
  params[:title] = title if title
23
+ params[:epubfile] = epubfile if epubfile
22
24
  gen = Cheepub::Generator.new(src, params)
23
25
  begin
24
26
  gen.execute
@@ -19,10 +19,33 @@ module Cheepub
19
19
 
20
20
  def execute
21
21
  params = @params.merge(@content.header)
22
+ check_params(params)
23
+ book = GEPUB::Book.new
24
+ apply_params(book, params)
25
+ epubfile = params[:epubfile] || "book.epub"
26
+ book.generate_epub(epubfile)
27
+ end
28
+
29
+ def parse_creator(book, creator)
30
+ if creator.kind_of? String
31
+ book.add_creator(creator)
32
+ else
33
+ creator.each do |role, name|
34
+ if !ROLES.include?(role)
35
+ raise Cheepub::Error, "invalid role: '#{role}' for creator '#{name}'."
36
+ end
37
+ book.add_creator(name, nil, role)
38
+ end
39
+ end
40
+ end
41
+
42
+ def check_params(params)
22
43
  if !params[:author] || !params[:title]
23
- raise Cheepub::Error, "author and title should be defined."
44
+ raise Cheepub::Error, "you must use `--author` and `--title`, or add front-matter in Markdown file."
24
45
  end
25
- book = GEPUB::Book.new
46
+ end
47
+
48
+ def apply_params(book, params)
26
49
  book.identifier = params[:id] || "urn:uuid:#{SecureRandom.uuid}"
27
50
  book.title = params[:title]
28
51
  if params[:creator]
@@ -48,21 +71,6 @@ module Cheepub
48
71
  item.add_content(StringIO.new(page))
49
72
  end
50
73
  end
51
- epubname = params[:epubname] || "book.epub"
52
- book.generate_epub(epubname)
53
- end
54
-
55
- def parse_creator(book, creator)
56
- if creator.kind_of? String
57
- book.add_creator(creator)
58
- else
59
- creator.each do |role, name|
60
- if !ROLES.include?(role)
61
- raise Cheepub::Error, "invalid role: '#{role}' for creator '#{name}'."
62
- end
63
- book.add_creator(name, nil, role)
64
- end
65
- end
66
74
  end
67
75
  end
68
76
  end
@@ -1,3 +1,3 @@
1
1
  module Cheepub
2
- VERSION = "0.2.0"
2
+ VERSION = "0.3.0"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cheepub
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - takahashim
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2018-05-05 00:00:00.000000000 Z
11
+ date: 2018-05-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: gepub