###前提・実現したいこと
Wercker CIで文書添削システムRedPenでの文書添削を自動化しようと考えています。
RedPenには添削のルールを既存のvalidatorを多種組み合わせてカスタマイズできるのですが、validatorをjavascriptで自作し、自身で新しい添削ルールを追加出来ます。(ローカルでは実装・機能している)
具体的には、redpenの設定ファイル(redpen-conf.xml)に validator = "Javascript"
で自作のjsファイルが機能するみたいなのですが、上手くいかないです。
###使っているツール
・docker
・github
・redpen(xmlファイルと.jsファイル)
・wercker
###redpen-conf.xml
<redpen-conf lang="ja" type="zenkaku2"> <validators> <validator name="JavaScript" > <property name="script-path" value="./js" /> </validator> </validators> </redpen-conf>
###jsファイル
function validateSentence(sentence) { // アルファベットを半角で表記するルール var terms = [ { 'expected':'[a-zA-Z]', 'pattern':['[a-zA-Z]'] } ]; var regex = new RegExp( terms[0]['pattern'], 'g'); // 形態素解析するかどうか if ( sentence.content.match(regex) ) { addError('全角のアルファベットが含まれています。半角に修正してください', sentence); } }
###wercker.yml
# This references a standard debian container from the # Docker Hub https://registry.hub.docker.com/_/debian/ # Read more about containers on our dev center # http://devcenter.wercker.com/docs/containers/index.html box: ユーザーネーム/ディレクトリ名 # You can also use services such as databases. Read more on our dev center: # http://devcenter.wercker.com/docs/services/index.html # services: # - postgres # http://devcenter.wercker.com/docs/services/postgresql.html # - mongodb # http://devcenter.wercker.com/docs/services/mongodb.html # This is the build pipeline. Pipelines are the core of wercker # Read more about pipelines on our dev center # http://devcenter.wercker.com/docs/pipelines/index.html build: # Steps make up the actions in your pipeline # Read more about steps on our dev center: # http://devcenter.wercker.com/docs/steps/index.html steps: - script: name: check code: | redpen -c ./redpen-conf.xml -f latex draft.tex
###補足情報
redpen-conf.xmlのvalidator = "Javascript"
で自作のjsファイルを呼ぶみたいです。
少し言うと、script-pathをどのように使えばいいのか理解していないのも現状ですが・・・(汗)
werckerの最後の行 redpen -c ./redpen-conf.xml -f latex draft.tex
で添削に使う設定ファイルと、draft.texを読み取るよう記述します。
###最後に
ローカルでは自作のjsファイルが機能しているのですが、サーバーだと上手くいきません。主にxmlファイルとwercker.ymlの最後の行を変更しては繰り返しをしています。
werckerに詳しい方、物知りな方の回答・ご協力よろしくおねがいしますm(_ _)m
###追記
[2017-12-07 17:32:01.023][WARN ] cc.redpen.validator.JavaScriptValidator - JavaScript validators directory is missing: cc.redpen.RedPenException: /.js is not under working directory (/pipeline/source), base (.), $REDPEN_HOME (/usr/local).
とwerckerが吐き出すようになりました。

回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2017/12/08 05:29
2017/12/11 15:43