関数を直接継承するのではなく、クラス変数、そして関数のパラメータ となる関数を継承する・させることで、設計思想や、インターフェースを残しながら、 大きく拡張することが可能になる。
以下に自身のvalueを出力する3つの例を示す。
- 直に継承してオーバーライドする場合(拡張性小)
- 直接、to_valuesがオーバーライドされる
.ace_editor{position:relative;overflow:hidden;font-family:'Microsoft Yahei','Menlo','Ubuntu Mono','Consolas','source-code-pro',monospace;font-size:12px;line-height:normal;color:black;-ms-user-select:none;-moz-user-select:none;-webkit-user-select:none;user-select:none} | |
.ace_scroller{position:absolute;overflow:hidden;top:0;bottom:0;background-color:inherit} | |
.ace_content{position:absolute;-moz-box-sizing:border-box;-webkit-box-sizing:border-box;box-sizing:border-box;cursor:text} | |
.ace_dragging,.ace_dragging *{cursor:move !important} | |
.ace_dragging .ace_scroller:before{position:absolute;top:0;left:0;right:0;bottom:0;content:'';background:rgba(250,250,250,0.01);z-index:1000} | |
.ace_dragging.ace_dark .ace_scroller:before{background:rgba(0,0,0,0.01)} | |
.ace_selecting,.ace_selecting *{cursor:text !important} | |
.ace_gutter{position:absolute;overflow:hidden;width:auto;top:0;bottom:0;left:0;cursor:default;z-index:4} | |
.ace_gutter-active-line{position:absolute;left:0;right:0} | |
.ace_scroller.ace_scroll-left{box-shadow:17px 0 16px -1 |
これまでEmbulkのPluginをいくつか書かせてもらってきましたが、初期の頃はテスト用のAPIが整備されていなくて後回しにしてきました。 この記事は、そろそろ書かねばという気持ちになり、奮闘した時のメモです。良かったら参考にしてくだい。
embulk -J-Dio.netty.leakDetectionLevel=advanced run config.yml -b embulk-bundle | |
... | |
2016-02-02 23:25:14.309 +0900 [ERROR] (task-0311): LEAK: ByteBuf.release() was not called before it's garbage-collected. | |
Recent access records: 0 | |
Created at: | |
io.netty.util.ResourceLeakDetector.open(ResourceLeakDetector.java:163) | |
io.netty.buffer.AbstractByteBufAllocator.toLeakAwareBuffer(AbstractByteBufAllocator.java:42) | |
io.netty.buffer.PooledByteBufAllocator.newHeapBuffer(PooledByteBufAllocator.java:228) | |
io.netty.buffer.AbstractByteBufAllocator.heapBuffer(AbstractByteBufAllocator.java:136) | |
io.netty.buffer.AbstractByteBufAllocator.heapBuffer(AbstractByteBufAllocator.java:127) |
in: | |
type: s3 | |
access_key_id: "{{ env.AWS_ACCESS_KEY_ID }}" | |
secret_access_key: "{{ env.AWS_SECRET_ACCESS_KEY }}" | |
bucket: "{{ env.S3_BUCKET }}" | |
path_prefix: "{{ env.INPUT_PREFIX }}" | |
decoders: | |
- type: gzip | |
parser: | |
type: csv |
[embulk-test] cat config.yml | |
in: | |
type: command | |
command: 'cat /Users/takahiro.nakayama/work/embulk-test/data/data*' | |
parser: | |
type: csv | |
columns: | |
- {name: t, type: string} | |
out: | |
type: file |
require 'embulk' | |
Embulk.setup | |
class MyError1 < ::Embulk::DataError; end | |
class MyError2 < ::Embulk::DataError; end | |
begin | |
raise MyError1.new("hoge") | |
rescue MyError2 => e |
# This configuration was generated by | |
# `rubocop --auto-gen-config` | |
# on 2016-01-24 14:28:14 +0900 using RuboCop version 0.36.0. | |
# The point is for the user to remove these configuration records | |
# one by one as the offenses are removed from the code base. | |
# Note that changes in the inspected code, or installation of new | |
# versions of RuboCop, may require this file to be generated again. | |
AllCops: | |
Exclude: |
optimist
is a simple option parser for golang which is inspired by minimist, Getopt::Casual.
The below code returns optimist.Args
that is the result of parsing arguments and structuring them.
plugins { | |
id "com.jfrog.bintray" version "1.1" | |
id "com.github.jruby-gradle.base" version "0.1.5" | |
id "java" | |
id "checkstyle" | |
} | |
import com.github.jrubygradle.JRubyExec | |
repositories { | |
mavenCentral() | |
jcenter() |