rakali 0.1.0 → 0.1.2

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
  SHA1:
3
- metadata.gz: f100f7c3e9f272f29ae6d04f4d6bfd6c08503e01
4
- data.tar.gz: 6b910f09126fc3fb6208c304d77f230b6ce6e7fd
3
+ metadata.gz: fbcaba4904aa189e1f6d70fb4b4c1f988c1d79bc
4
+ data.tar.gz: 2d606db038c01b720c0842efaa821f90ca0893a5
5
5
  SHA512:
6
- metadata.gz: 7e29cc1e99f2bd1e4980369da3f7c4766fec28df424092a4639ab767a82df89274de9f371cb7f6908167a97ef255f75e4739094b1ebc7eb5b6bb04d3f2a879e7
7
- data.tar.gz: f0072b709f8462dbc88e4e430f10484b26a552d23c9204516a56e96e8aaf1ed91e226002988f11b6e2909a2941b29b1712a1883f109e62bb8592fbf3b22b0a51
6
+ metadata.gz: a81348d6aedbc7680d92e752d2eb594265d401def51cb9d810f17f8fa2b7f52ccb0d1e2e3531123ea7e4a161831aaf1343a5f120263b7c5912b20c5fc4936277
7
+ data.tar.gz: 75cff22509e12081aab80da77f6a72b77ffe4bb10e017795a6a960fb0de473584093fa925f8dce997067f096911b74a04a3fef6b3d14351c7cf71531afd91ccb
data/.gitignore CHANGED
@@ -1,8 +1,6 @@
1
1
  pkg/*
2
2
  *.gem
3
3
  .bundle
4
- *.html
5
- *.epub
6
- *.jats
7
4
  spec/fixtures/*.html
8
5
  spec/fixtures/*.docx
6
+ spec/fixtures/*.epub
@@ -1,6 +1,11 @@
1
1
  from:
2
2
  folder: examples
3
- format: md
3
+ format: docx
4
4
  to:
5
- format: epub
6
- merge: true
5
+ format: html
6
+ merge: false
7
+ options:
8
+ latex-engine: xelatex
9
+ variables:
10
+ mainfont: 'Minion Pro'
11
+ sansfont: 'Myriad Pro'
@@ -1,17 +1,14 @@
1
1
  language: haskell
2
-
3
2
  rvm:
4
- - 1.9.3
5
- - 2.1.2
6
-
3
+ - 1.9.3
4
+ - 2.1.2
7
5
  install:
8
- - travis_retry cabal install pandoc pandoc-citeproc
9
- - travis_retry bundle install
10
-
6
+ - travis_retry cabal install pandoc pandoc-citeproc
7
+ - travis_retry bundle install
11
8
  script:
12
- - bundle exec rake
13
- - bundle exec rakali convert .rakali.yml
14
-
9
+ - bundle exec rake
10
+ - bundle exec rakali convert .rakali.yml
11
+ - bundle exec rake repo:push
15
12
  deploy:
16
13
  provider: rubygems
17
14
  api_key:
@@ -20,3 +17,8 @@ deploy:
20
17
  on:
21
18
  tags: true
22
19
  repo: rakali/rakali.rb
20
+ env:
21
+ global:
22
+ - secure: hO+7d+PxnOAk0tLbJOSisF6aKzGjll6E3TsaMuZHoBAA93WCvpZgYmn5VyJy1eRCobxqeP/7xIfiCHBMzHNtr7BC4wHMWx+z6tE/M3osTwQVVsg8Cdviq4LU/XvgXjk4dI8Owsk2aEC/Dw2uRm3XBmvnpMwrj3QoNjunCUeXwo4=
23
+ - secure: JCEDpRmeSeR3nqJg3659mXafpjyvHG5jdg5Uk54zdb/jQfDoHX7qHO5bPG0IJTAKx+vnVWpcs6JMC6ADocymaMxv195Acu9Ch3IEjcYBwdZFoqbBC7d5ZgmhloAVrWBAWgT9zoOj7ppiO3U2iUuj/vHOL57Nnf/DCkW4oxB6ykU=
24
+ - secure: MLmk4mLBqOK8rDbYaT+IZnP0IoxLueCWTGwoNpyx2HdcUIny2235iCmJGE66FY0/ULFsQ3WmFuB5OWgRGkj1bvYAOFiucWotZzDnsUrWyGcH+ZL4xBaZuP9qEFedtB7r1Dv9nrBn6CuhLi1l+BJwk01PpPVq0UPWXxTQ8f9wbhI=
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- rakali (0.1.0)
4
+ rakali (0.1.2)
5
5
  colorator (~> 0.1)
6
6
  json-schema (~> 2.2)
7
7
  safe_yaml (~> 1.0)
@@ -17,6 +17,8 @@ GEM
17
17
  builder (3.2.2)
18
18
  childprocess (0.5.3)
19
19
  ffi (~> 1.0, >= 1.0.11)
20
+ codeclimate-test-reporter (0.3.0)
21
+ simplecov (>= 0.7.1, < 1.0.0)
20
22
  colorator (0.1)
21
23
  cucumber (1.3.16)
22
24
  builder (>= 2.1.2)
@@ -41,6 +43,10 @@ GEM
41
43
  diff-lcs (>= 1.1.3, < 2.0)
42
44
  rspec-mocks (2.99.2)
43
45
  safe_yaml (1.0.3)
46
+ simplecov (0.7.1)
47
+ multi_json (~> 1.0)
48
+ simplecov-html (~> 0.7.1)
49
+ simplecov-html (0.7.1)
44
50
  thor (0.19.1)
45
51
 
46
52
  PLATFORMS
@@ -48,6 +54,7 @@ PLATFORMS
48
54
 
49
55
  DEPENDENCIES
50
56
  aruba (~> 0)
57
+ codeclimate-test-reporter (~> 0)
51
58
  cucumber (~> 1.3)
52
59
  rakali!
53
60
  rake (~> 0)
data/README.md CHANGED
@@ -4,6 +4,7 @@ rakali.rb
4
4
  [![Build Status](https://travis-ci.org/rakali/rakali.rb.svg)](https://travis-ci.org/rakali/rakali.rb)
5
5
  [![Gem Version](https://badge.fury.io/rb/rakali.svg)](http://badge.fury.io/rb/rakali)
6
6
  [![Code Climate](https://codeclimate.com/github/rakali/rakali.rb.png)](https://codeclimate.com/github/rakali/rakali.rb)
7
+ [![Test Coverage](https://codeclimate.com/github/rakali/rakali.rb/badges/coverage.svg)](https://codeclimate.com/github/rakali/rakali.rb)
7
8
 
8
9
  Rakali is a wrapper for the [Pandoc](http://johnmacfarlane.net/pandoc/) document converter with the following features:
9
10
 
@@ -40,21 +41,16 @@ strict: false
40
41
  merge: false
41
42
  ```
42
43
 
43
- The only required key for the input yaml file is `from` `folder`, and you can override any key in the default file.
44
+ The only required key for the input yaml file is `from` `folder` (missing in the default file), and you can override any key in the default file.
44
45
 
45
46
  * **schema**: JSON schema used for validation. Use `your_folder/schema.json` for a custom schema, or use one of the built-in schemata (see [pandoc-schemata](https://github.com/rakali/pandoc-schemata) for a list.)
46
47
  * **citations**: include `-f citeproc-pandoc` for citation formatting
47
48
  * **strict**: abort conversion on validation errors
48
49
  * **merge**: merge all input files into a single file
49
50
 
50
- To integrate rakali into a continuous integration environment such as [Travis CI](https://travis-ci.org), add a configuration file (e.g. `.rakali.yml`) into the root folder of your repo and include the following line in your `.travis.yml` file:
51
+ Validation against **JSON Schema** also works directly with Pandoc, generate a JSON representation of the internal Pandoc document format (abstract syntax tree or AST) with `pandoc -o file.json`, and use a JSON Schema file for validation. If possible, please contribute your schema files to the [pandoc-schemata](https://github.com/rakali/pandoc-schemata).
51
52
 
52
- ```
53
- language: haskell
54
- script:
55
- - gem install rakali
56
- - rakali convert .rakali.yml
57
- ```
53
+ To integrate rakali into a continuous integration environment such as [Travis CI](https://travis-ci.org), add a configuration file (e.g. `.rakali.yml`) into the root folder of your repo, install Pandoc and the rakali gem and run `rakali convert .rakali.yml`. Look at `.travis.yml`, `.rakali.yml` and the `examples` folder in this repo for a working example.
58
54
 
59
55
  ## Feedback
60
56
 
data/Rakefile CHANGED
@@ -6,5 +6,24 @@ require 'rspec/core/rake_task'
6
6
  Bundler::GemHelper.install_tasks
7
7
  RSpec::Core::RakeTask.new('spec')
8
8
 
9
+ namespace :repo do
10
+ desc "push files generated with rakali to remote"
11
+ task :push do
12
+
13
+ # Configure git if this is run in Travis CI
14
+ if ENV["TRAVIS"]
15
+ sh "git config --global user.name '#{ENV['GIT_NAME']}'"
16
+ sh "git config --global user.email '#{ENV['GIT_EMAIL']}'"
17
+ sh "git config --global push.default simple"
18
+ end
19
+
20
+ # Commit and push to github
21
+ sh "git add --all ."
22
+ sh "git commit -m 'Committing converted files.'"
23
+ sh "git push https://${GH_TOKEN}@github.com/rakali/rakali.rb master --quiet"
24
+ puts "Pushed converted files to repo"
25
+ end
26
+ end
27
+
9
28
  # default task is running rspec tests
10
29
  task :default => :spec
Binary file
Binary file
@@ -10,7 +10,8 @@ module Rakali
10
10
  'schema' => 'default.json',
11
11
  'citations' => false,
12
12
  'strict' => false,
13
- 'merge' => false
13
+ 'merge' => false,
14
+ 'options' => {}
14
15
  }
15
16
 
16
17
  attr_accessor :config, :documents, :errors
@@ -3,7 +3,7 @@
3
3
  module Rakali
4
4
  class Document
5
5
 
6
- attr_accessor :config, :source, :destination, :content, :schema, :errors, :to_folder
6
+ attr_accessor :config, :source, :destination, :content, :schema, :errors, :options, :variables, :to_folder
7
7
 
8
8
  def initialize(document, config)
9
9
  begin
@@ -26,11 +26,19 @@ module Rakali
26
26
  @destination = @source.sub(/\.#{@from_format}$/, ".#{@to_format}")
27
27
  end
28
28
 
29
+ # add pandoc options from config
30
+ options = @config.fetch('options') || {}
31
+ @options = options.map { |k,v| "--#{k}=#{v}" }.join(" ")
32
+
33
+ # add pandoc variables from config
34
+ variables = @config.fetch('variables', nil) || {}
35
+ @variables = variables.map { |k,v| "--variable #{k}='#{v}'" }.join(" ")
36
+
29
37
  # use citeproc-pandoc if citations flag is set
30
- bibliography = @config.fetch('citations') ? "-f citeproc-pandoc" : ""
38
+ bibliography = @config.fetch('citations') ? "-f citeproc-pandoc " : ""
31
39
 
32
40
  # convert source document into JSON version of native AST
33
- @content = convert(nil, @from_folder, "#{@source} #{bibliography}-t json")
41
+ @content = convert(nil, @from_folder, "#{@source} #{bibliography}-t json #{@options} #{@variables}")
34
42
 
35
43
  # read in JSON schema, use included schemata folder if no folder is given
36
44
  @schema = scheme
@@ -39,7 +47,7 @@ module Rakali
39
47
  @errors = validate
40
48
 
41
49
  # convert to destination document from JSON version of native AST
42
- @output = convert(@content, @to_folder, "-f json #{bibliography}-o #{@destination}")
50
+ @output = convert(@content, @to_folder, "-f json #{bibliography}-o #{@destination} #{@options} #{@variables}")
43
51
  Rakali.logger.abort_with "Fatal:", "Writing file #{@destination} failed" unless created?
44
52
 
45
53
  if @errors.empty?
@@ -67,7 +75,10 @@ module Rakali
67
75
  end
68
76
 
69
77
  # abort with log message if non-zero exit_status
70
- Rakali.logger.abort_with "Fatal:", "#{captured_stderr}." unless exit_status.success?
78
+ unless exit_status.success?
79
+ Rakali.logger.error "Pandoc Args:", "#{args}."
80
+ Rakali.logger.abort_with "Fatal:", "#{captured_stderr}."
81
+ end
71
82
 
72
83
  # otherwise return stdout
73
84
  captured_stdout
@@ -1,3 +1,3 @@
1
1
  module Rakali
2
- VERSION = "0.1.0"
2
+ VERSION = "0.1.2"
3
3
  end
@@ -22,6 +22,7 @@ Gem::Specification.new do |s|
22
22
  s.add_development_dependency "rspec", '~> 2.6'
23
23
  s.add_development_dependency "cucumber", '~> 1.3'
24
24
  s.add_development_dependency "aruba", '~> 0'
25
+ s.add_development_dependency "codeclimate-test-reporter", '~> 0'
25
26
 
26
27
  s.files = `git ls-files`.split($/)
27
28
  s.executables = ["rakali"]
@@ -1,3 +1,6 @@
1
+ require "codeclimate-test-reporter"
2
+ CodeClimate::TestReporter.start
3
+
1
4
  require 'bundler/setup'
2
5
  Bundler.setup
3
6
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rakali
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Martin Fenner
@@ -122,6 +122,20 @@ dependencies:
122
122
  - - "~>"
123
123
  - !ruby/object:Gem::Version
124
124
  version: '0'
125
+ - !ruby/object:Gem::Dependency
126
+ name: codeclimate-test-reporter
127
+ requirement: !ruby/object:Gem::Requirement
128
+ requirements:
129
+ - - "~>"
130
+ - !ruby/object:Gem::Version
131
+ version: '0'
132
+ type: :development
133
+ prerelease: false
134
+ version_requirements: !ruby/object:Gem::Requirement
135
+ requirements:
136
+ - - "~>"
137
+ - !ruby/object:Gem::Version
138
+ version: '0'
125
139
  description: A Pandoc command-line wrapper written in Ruby.
126
140
  email: mf@martinfenner.org
127
141
  executables:
@@ -143,7 +157,9 @@ files:
143
157
  - examples/2014-07-24-dont-reinvent-the-wheel.md
144
158
  - examples/2014-08-06-what-is-doi.md
145
159
  - examples/fenner_2011.docx
160
+ - examples/fenner_2011.epub
146
161
  - examples/fenner_2013.docx
162
+ - examples/fenner_2013.epub
147
163
  - filters/caps.rb
148
164
  - filters/default.rb
149
165
  - lib/rakali.rb