embulk-formatter-html_table 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: fef61817c3f7eb09156b167bac186ff820ad3bbb
4
+ data.tar.gz: 62960e593192e3e6856e4ecfab9efdecbd04c81e
5
+ SHA512:
6
+ metadata.gz: 0ea5420005dab39574bcc7140c0bc49492ecd5bb0edf2d824ba2b17197d5cd98d91d9dc7a6d1f76743ef99d36ef9b2d4cb8a4f96e8fa3576dd9e4eb7ef291f50
7
+ data.tar.gz: 52eb6022873f317df32565e053e9c5c3199d5267d5b06b240fb372d6585f34de3e7bdb36ce0fc857fd6e66105d8c0279921f54ab72e28e92f2d5c7669be315dc
@@ -0,0 +1,67 @@
1
+ # Created by https://www.gitignore.io/api/osx,ruby
2
+
3
+ ### OSX ###
4
+ .DS_Store
5
+ .AppleDouble
6
+ .LSOverride
7
+
8
+ # Icon must end with two \r
9
+ Icon
10
+
11
+
12
+ # Thumbnails
13
+ ._*
14
+
15
+ # Files that might appear in the root of a volume
16
+ .DocumentRevisions-V100
17
+ .fseventsd
18
+ .Spotlight-V100
19
+ .TemporaryItems
20
+ .Trashes
21
+ .VolumeIcon.icns
22
+
23
+ # Directories potentially created on remote AFP share
24
+ .AppleDB
25
+ .AppleDesktop
26
+ Network Trash Folder
27
+ Temporary Items
28
+ .apdisk
29
+
30
+
31
+ ### Ruby ###
32
+ *.gem
33
+ *.rbc
34
+ /.config
35
+ /coverage/
36
+ /InstalledFiles
37
+ /pkg/
38
+ /spec/reports/
39
+ /spec/examples.txt
40
+ /test/tmp/
41
+ /test/version_tmp/
42
+ /tmp/
43
+
44
+ ## Specific to RubyMotion:
45
+ .dat*
46
+ .repl_history
47
+ build/
48
+
49
+ ## Documentation cache and generated files:
50
+ /.yardoc/
51
+ /_yardoc/
52
+ /doc/
53
+ /rdoc/
54
+
55
+ ## Environment normalization:
56
+ /.bundle/
57
+ /vendor/bundle
58
+ /lib/bundler/man/
59
+
60
+ # for a library or gem, you might want to ignore these files since the code is
61
+ # intended to run in multiple environments; otherwise, check them in:
62
+ Gemfile.lock
63
+ # .ruby-version
64
+ # .ruby-gemset
65
+
66
+ # unless supporting rvm < 1.11.0 or doing something fancy, ignore this:
67
+ .rvmrc
@@ -0,0 +1 @@
1
+ jruby-9.0.4.0
data/Gemfile ADDED
@@ -0,0 +1,2 @@
1
+ source 'https://rubygems.org/'
2
+ gemspec
@@ -0,0 +1,21 @@
1
+
2
+ MIT License
3
+
4
+ Permission is hereby granted, free of charge, to any person obtaining
5
+ a copy of this software and associated documentation files (the
6
+ "Software"), to deal in the Software without restriction, including
7
+ without limitation the rights to use, copy, modify, merge, publish,
8
+ distribute, sublicense, and/or sell copies of the Software, and to
9
+ permit persons to whom the Software is furnished to do so, subject to
10
+ the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be
13
+ included in all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
16
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
17
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
18
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
19
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
20
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
21
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,57 @@
1
+ # Html Table formatter plugin for Embulk
2
+
3
+ This plugin is formatter to html_table for Embulk
4
+
5
+ ## Overview
6
+
7
+ * **Plugin type**: formatter
8
+
9
+ ## Configuration
10
+
11
+ - **encoding**: encoding (string, default: `"UTF-8"`)
12
+ - **newline**: newline (string, default: `"LF"`)
13
+ - **to_br**: convert newline to `<BR>` (boolean, default: `true`)
14
+ - **timestamp_format**: timestamp to string format (string, default: `"%Y-%m-%d %H-%M-%S"`)
15
+
16
+ ## Example
17
+
18
+ Config:
19
+
20
+ ```yaml
21
+ out:
22
+ type: any output input plugin type
23
+ formatter:
24
+ type: html_table
25
+ encoding: "UTF-8"
26
+ newline: "LF"
27
+ to_br: true
28
+ timestamp_format: "%Y-%m-%d %H-%M-%S"
29
+ ```
30
+
31
+ Input:
32
+
33
+ ```
34
+ id,account,time,purchase,comment
35
+ 1,32864,2015-01-27 19:23:49,20150127,embulk
36
+ 2,14824,2015-01-27 19:01:23,20150127,embulk jruby
37
+ 3,27559,2015-01-28 02:20:02,20150128,"Embulk ""csv"" parser plugin"
38
+ 4,11270,2015-01-29 11:54:36,20150129,NULL
39
+ ```
40
+
41
+ Output:
42
+
43
+ ```
44
+ <table>
45
+ <tr><th>id</th><th>account</th><th>time</th><th>purchase</th><th>comment</th></tr>
46
+ <tr><td>1</td><td>32864</td><td>2015-01-27 19-23-49</td><td>2015-01-27 00-00-00</td><td>embulk</td></tr>
47
+ <tr><td>2</td><td>14824</td><td>2015-01-27 19-01-23</td><td>2015-01-27 00-00-00</td><td>embulk jruby</td></tr>
48
+ <tr><td>3</td><td>27559</td><td>2015-01-28 02-20-02</td><td>2015-01-28 00-00-00</td><td>Embulk "csv" parser plugin</td></tr>
49
+ <tr><td>4</td><td>11270</td><td>2015-01-29 11-54-36</td><td>2015-01-29 00-00-00</td><td>NULL</td></tr>
50
+ </table>
51
+ ```
52
+
53
+ ## Build
54
+
55
+ ```
56
+ $ rake
57
+ ```
@@ -0,0 +1,3 @@
1
+ require "bundler/gem_tasks"
2
+
3
+ task default: :build
@@ -0,0 +1,20 @@
1
+
2
+ Gem::Specification.new do |spec|
3
+ spec.name = "embulk-formatter-html_table"
4
+ spec.version = "0.1.0"
5
+ spec.authors = ["yuemori"]
6
+ spec.summary = "Html Table formatter plugin for Embulk"
7
+ spec.description = "Formats Html Table files for other file output plugins."
8
+ spec.email = ["yuemori@aiming-inc.com"]
9
+ spec.licenses = ["MIT"]
10
+ spec.homepage = "https://github.com/yuemori/embulk-formatter-html_table"
11
+
12
+ spec.files = `git ls-files`.split("\n") + Dir["classpath/*.jar"]
13
+ spec.test_files = spec.files.grep(%r{^(test|spec)/})
14
+ spec.require_paths = ["lib"]
15
+
16
+ spec.add_development_dependency 'embulk', ['>= 0.8.3']
17
+ spec.add_development_dependency 'bundler', ['>= 1.10.6']
18
+ spec.add_development_dependency 'rake', ['>= 10.0']
19
+ spec.add_development_dependency 'pry'
20
+ end
@@ -0,0 +1,80 @@
1
+ module Embulk
2
+ module Formatter
3
+ class HtmlTable < FormatterPlugin
4
+ Plugin.register_formatter("html_table", self)
5
+
6
+ NEWLINES = {
7
+ 'CRLF' => "\r\n",
8
+ 'LF' => "\n",
9
+ 'CR' => "\r",
10
+ 'NUL' => "\0"
11
+ }
12
+
13
+ def self.join_texts((*inits,last), opt = {})
14
+ delim = opt[:delimiter] || ', '
15
+ last_delim = opt[:last_delimiter] || ' or '
16
+ [inits.join(delim),last].join(last_delim)
17
+ end
18
+
19
+ def self.transaction(config, schema, &control)
20
+ task = {
21
+ 'encoding' => config.param('encoding', :string, default: 'UTF-8'),
22
+ 'newline' => config.param('newline', :string, default: 'LF'),
23
+ 'to_br' => config.param('to_br', :bool, default: true),
24
+ 'timestamp_format' => config.param('timestamp_format', :string, default: '%Y-%m-%d %H-%M-%S'),
25
+ }
26
+
27
+ yield(task)
28
+ end
29
+
30
+ def init
31
+ @header_print = true
32
+ @encoding = task['encoding'].upcase
33
+ @newline = NEWLINES[task['newline'].upcase]
34
+ @to_br = task['to_br']
35
+ @timestamp_format = task['timestamp_format']
36
+ @current_file = nil
37
+ @current_file_size = 0
38
+ end
39
+
40
+ def close
41
+ end
42
+
43
+ def add(page)
44
+ page.each do |record|
45
+ if @current_file == nil
46
+ @current_file = file_output.next_file
47
+ @current_file_size = 0
48
+ elsif @current_file_size > 32*1024
49
+ @current_file.write '</table>'.encode(@encoding)
50
+ @current_file = file_output.next_file
51
+ @current_file_size = 0
52
+ end
53
+
54
+ if @header_print
55
+ @current_file.write "<table>#{@newline}".encode(@encoding)
56
+ header = "<tr>#{page.schema.map(&:name).map { |name| "<th>#{name}</th>"}.join('')}</tr>#{@newline}"
57
+ @current_file.write header.encode(@encoding)
58
+ @header_print = false
59
+ end
60
+
61
+ row = "<tr>#{record.map { |col| format(col) }.join('')}</tr>#{@newline}"
62
+ @current_file.write row.encode(@encoding)
63
+ end
64
+ end
65
+
66
+ def format(column)
67
+ if @to_br
68
+ column = column.strftime(@timestamp_format) if column.is_a? Time
69
+ column = column.to_s.split(@newline).join('<BR>') if @to_br
70
+ end
71
+ "<td>#{column}</td>"
72
+ end
73
+
74
+ def finish
75
+ @current_file.write '</table>'.encode(@encoding)
76
+ file_output.finish
77
+ end
78
+ end
79
+ end
80
+ end
metadata ADDED
@@ -0,0 +1,108 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: embulk-formatter-html_table
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - yuemori
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2016-02-15 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: embulk
15
+ version_requirements: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: 0.8.3
20
+ requirement: !ruby/object:Gem::Requirement
21
+ requirements:
22
+ - - ">="
23
+ - !ruby/object:Gem::Version
24
+ version: 0.8.3
25
+ prerelease: false
26
+ type: :development
27
+ - !ruby/object:Gem::Dependency
28
+ name: bundler
29
+ version_requirements: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: 1.10.6
34
+ requirement: !ruby/object:Gem::Requirement
35
+ requirements:
36
+ - - ">="
37
+ - !ruby/object:Gem::Version
38
+ version: 1.10.6
39
+ prerelease: false
40
+ type: :development
41
+ - !ruby/object:Gem::Dependency
42
+ name: rake
43
+ version_requirements: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '10.0'
48
+ requirement: !ruby/object:Gem::Requirement
49
+ requirements:
50
+ - - ">="
51
+ - !ruby/object:Gem::Version
52
+ version: '10.0'
53
+ prerelease: false
54
+ type: :development
55
+ - !ruby/object:Gem::Dependency
56
+ name: pry
57
+ version_requirements: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ requirement: !ruby/object:Gem::Requirement
63
+ requirements:
64
+ - - ">="
65
+ - !ruby/object:Gem::Version
66
+ version: '0'
67
+ prerelease: false
68
+ type: :development
69
+ description: Formats Html Table files for other file output plugins.
70
+ email:
71
+ - yuemori@aiming-inc.com
72
+ executables: []
73
+ extensions: []
74
+ extra_rdoc_files: []
75
+ files:
76
+ - ".gitignore"
77
+ - ".ruby-version"
78
+ - Gemfile
79
+ - LICENSE.txt
80
+ - README.md
81
+ - Rakefile
82
+ - embulk-formatter-html_table.gemspec
83
+ - lib/embulk/formatter/html_table.rb
84
+ homepage: https://github.com/yuemori/embulk-formatter-html_table
85
+ licenses:
86
+ - MIT
87
+ metadata: {}
88
+ post_install_message:
89
+ rdoc_options: []
90
+ require_paths:
91
+ - lib
92
+ required_ruby_version: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - ">="
95
+ - !ruby/object:Gem::Version
96
+ version: '0'
97
+ required_rubygems_version: !ruby/object:Gem::Requirement
98
+ requirements:
99
+ - - ">="
100
+ - !ruby/object:Gem::Version
101
+ version: '0'
102
+ requirements: []
103
+ rubyforge_project:
104
+ rubygems_version: 2.4.8
105
+ signing_key:
106
+ specification_version: 4
107
+ summary: Html Table formatter plugin for Embulk
108
+ test_files: []