thinreports-template-cli 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 440a9f031f9ab0ef9d6f6fdf45c7a35f438b8055
4
+ data.tar.gz: 02cfb1280f33ddda03105ccb5cd0edb7c188c775
5
+ SHA512:
6
+ metadata.gz: e3c8b00c2f9cadc1991ad7ba6342532b564d44111dcd0be57504bc045e6d48e6934fe057bb8f19b84344ac787020d469423798682d2448dde80a6fe7e6f1cb66
7
+ data.tar.gz: 7fb5f9bc4faa843204604393c77fde2f5e5dbf627c27b86d125092bf873bdd362cb9e2f49a4288e881555dd98194d44f41c3eaba6d823626bd30e560c8fee770
data/.gitignore ADDED
@@ -0,0 +1,9 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
data/.travis.yml ADDED
@@ -0,0 +1,5 @@
1
+ sudo: false
2
+ language: ruby
3
+ rvm:
4
+ - 2.3.1
5
+ before_install: gem install bundler -v 1.12.5
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in thinreports-template-cli.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2016 Masayuki Higashino
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,46 @@
1
+ # Thinreports::Template::Cli
2
+
3
+ ## Installation
4
+
5
+ Add this line to your application's Gemfile:
6
+
7
+ ```ruby
8
+ gem 'thinreports-template-cli'
9
+ ```
10
+
11
+ And then execute:
12
+
13
+ $ bundle
14
+
15
+ Or install it yourself as:
16
+
17
+ $ gem install thinreports-template-cli
18
+
19
+ ## Usage
20
+
21
+ ```bash
22
+ $ thinreports-template-cli info --layout=~/template.tlf
23
+ $ thinreports-template-cli init --layout=~/template.tlf > config.yml
24
+ $ cat ~/config.yml
25
+ ---
26
+ name: Taro Tottori
27
+ item: Toripy Plush Toy
28
+ price: 2980
29
+ $ thinreports-template-cli generate --layout=~/template.tlf --config=~/config.yml > example.pdf
30
+ $ thinreports-template-cli generate --layout=~/template.tlf --config=~/config.yml | lpr -P ApeosPort_V_C3375__aa_bb_cc_
31
+ ```
32
+
33
+ ## Development
34
+
35
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake test` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
36
+
37
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
38
+
39
+ ## Contributing
40
+
41
+ Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/thinreports-template-cli.
42
+
43
+
44
+ ## License
45
+
46
+ The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
data/Rakefile ADDED
@@ -0,0 +1,10 @@
1
+ require 'bundler/gem_tasks'
2
+ require 'rake/testtask'
3
+
4
+ Rake::TestTask.new(:test) do |t|
5
+ t.libs << 'test'
6
+ t.libs << 'lib'
7
+ t.test_files = FileList['test/**/*_test.rb']
8
+ end
9
+
10
+ task :default => :test
data/bin/console ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "thinreports/template/cli"
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ # (If you use this, don't forget to add pry to your Gemfile!)
10
+ # require "pry"
11
+ # Pry.start
12
+
13
+ require "irb"
14
+ IRB.start
data/bin/setup ADDED
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,5 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'thinreports/template/cli'
4
+
5
+ Thinreports::Template::CLI::Commands.start(ARGV)
@@ -0,0 +1,37 @@
1
+ require 'thor'
2
+ require 'thinreports/template/cli/executor'
3
+
4
+ module Thinreports; module Template; module CLI; class Commands < Thor
5
+
6
+ desc 'generate', 'Generate a PDF file from .tlf to stdout'
7
+ option :layout, required:true
8
+ option :config
9
+ def generate
10
+ print Thinreports::Template::CLI::Executor.new(get_report, get_config).generate
11
+ end
12
+
13
+ desc 'info', 'Display information for .tlf'
14
+ option :layout, required:true
15
+ option :config
16
+ def info
17
+ print Thinreports::Template::CLI::Executor.new(get_report, get_config).info
18
+ end
19
+
20
+ desc 'init', 'Create config file for .tlf'
21
+ option :layout, required:true
22
+ def init
23
+ print Thinreports::Template::CLI::Executor.new(get_report).init
24
+ end
25
+
26
+ no_commands {
27
+
28
+ def get_report
29
+ return Thinreports::Report.new(layout:File.expand_path(options.layout))
30
+ end
31
+
32
+ def get_config
33
+ options.config && YAML.load_file(File.expand_path(options.config)) || {}
34
+ end
35
+
36
+ }
37
+ end; end; end; end
@@ -0,0 +1,52 @@
1
+ require 'thinreports'
2
+ require 'yaml'
3
+ require 'wareki'
4
+ require 'kosi'
5
+
6
+ module Thinreports; module Template; module CLI; class Executor
7
+
8
+ def initialize(report, config=nil)
9
+ @report = report
10
+ @config = config
11
+ end
12
+
13
+ def generate
14
+ @report.start_new_page
15
+ @report.default_layout.format.shapes.values.each do |shape|
16
+ case shape.type
17
+ when Thinreports::Core::Shape::TextBlock::TYPE_NAME
18
+ if shape.has_format? && shape.format_type == 'datetime'
19
+ @config[shape.id] ||= Date.today
20
+ end
21
+ else
22
+ end
23
+ end
24
+ @report.page.values(@config)
25
+ @report.generate
26
+ end
27
+
28
+ def info
29
+ kosi = Kosi::Table.new({
30
+ align: Kosi::Align::TYPE::LEFT,
31
+ header: %w(b:id b:type b:display? bf:value tb:has_format? tb:format_type)
32
+ })
33
+ return kosi.render(@report.default_layout.format.shapes.values.map { |s|
34
+ record = [s.id, s.type, s.display?, s.value]
35
+ case s.type
36
+ when Thinreports::Core::Shape::TextBlock::TYPE_NAME
37
+ record += [s.has_format?, s.format_type]
38
+ else
39
+ record += [nil, nil]
40
+ end
41
+ })
42
+ end
43
+
44
+ def init
45
+ @config = {}
46
+ @report.default_layout.format.shapes.values.map do |shape|
47
+ @config[shape.id] = shape.value
48
+ end
49
+ YAML.dump(@config)
50
+ end
51
+
52
+ end; end; end; end
@@ -0,0 +1,3 @@
1
+ module Thinreports; module Template; module CLI
2
+ VERSION = '0.1.0'
3
+ end; end; end
@@ -0,0 +1,3 @@
1
+ require 'thinreports/template/cli/version'
2
+ require 'thinreports/template/cli/commands'
3
+ require 'thinreports/template/cli/executor'
@@ -0,0 +1,31 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'thinreports/template/cli/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = 'thinreports-template-cli'
8
+ spec.version = Thinreports::Template::CLI::VERSION
9
+ spec.authors = ['mh61503891']
10
+ spec.email = ['msyk@hgsn.info']
11
+
12
+ spec.summary = %q{A command line tool to generate a PDF file from YAML config file and .tlf}
13
+ spec.description = %q{A command line tool to generate a PDF file from YAML config file and .tlf}
14
+ spec.homepage = 'https://github.com/mh61503891/thinreports-template-cli'
15
+ spec.license = 'MIT'
16
+
17
+ spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
18
+ spec.bindir = 'exe'
19
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
20
+ spec.require_paths = ['lib']
21
+
22
+ spec.add_dependency 'thinreports', '0.9.1'
23
+ spec.add_dependency 'thor', '0.19.1'
24
+ spec.add_dependency 'wareki', '0.1.2'
25
+ spec.add_dependency 'kosi', '1.0.0'
26
+ spec.add_development_dependency 'bundler', '~> 1.12'
27
+ spec.add_development_dependency 'rake', '~> 10.0'
28
+ spec.add_development_dependency 'minitest', '~> 5.0'
29
+ spec.add_development_dependency 'awesome_print', '~> 1.7.0'
30
+ spec.add_development_dependency 'pry', '~> 0.10.4'
31
+ end
metadata ADDED
@@ -0,0 +1,186 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: thinreports-template-cli
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - mh61503891
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2016-09-19 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: thinreports
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - '='
18
+ - !ruby/object:Gem::Version
19
+ version: 0.9.1
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - '='
25
+ - !ruby/object:Gem::Version
26
+ version: 0.9.1
27
+ - !ruby/object:Gem::Dependency
28
+ name: thor
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - '='
32
+ - !ruby/object:Gem::Version
33
+ version: 0.19.1
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - '='
39
+ - !ruby/object:Gem::Version
40
+ version: 0.19.1
41
+ - !ruby/object:Gem::Dependency
42
+ name: wareki
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - '='
46
+ - !ruby/object:Gem::Version
47
+ version: 0.1.2
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - '='
53
+ - !ruby/object:Gem::Version
54
+ version: 0.1.2
55
+ - !ruby/object:Gem::Dependency
56
+ name: kosi
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - '='
60
+ - !ruby/object:Gem::Version
61
+ version: 1.0.0
62
+ type: :runtime
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - '='
67
+ - !ruby/object:Gem::Version
68
+ version: 1.0.0
69
+ - !ruby/object:Gem::Dependency
70
+ name: bundler
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: '1.12'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: '1.12'
83
+ - !ruby/object:Gem::Dependency
84
+ name: rake
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - "~>"
88
+ - !ruby/object:Gem::Version
89
+ version: '10.0'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - "~>"
95
+ - !ruby/object:Gem::Version
96
+ version: '10.0'
97
+ - !ruby/object:Gem::Dependency
98
+ name: minitest
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - "~>"
102
+ - !ruby/object:Gem::Version
103
+ version: '5.0'
104
+ type: :development
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - "~>"
109
+ - !ruby/object:Gem::Version
110
+ version: '5.0'
111
+ - !ruby/object:Gem::Dependency
112
+ name: awesome_print
113
+ requirement: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - "~>"
116
+ - !ruby/object:Gem::Version
117
+ version: 1.7.0
118
+ type: :development
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - "~>"
123
+ - !ruby/object:Gem::Version
124
+ version: 1.7.0
125
+ - !ruby/object:Gem::Dependency
126
+ name: pry
127
+ requirement: !ruby/object:Gem::Requirement
128
+ requirements:
129
+ - - "~>"
130
+ - !ruby/object:Gem::Version
131
+ version: 0.10.4
132
+ type: :development
133
+ prerelease: false
134
+ version_requirements: !ruby/object:Gem::Requirement
135
+ requirements:
136
+ - - "~>"
137
+ - !ruby/object:Gem::Version
138
+ version: 0.10.4
139
+ description: A command line tool to generate a PDF file from YAML config file and
140
+ .tlf
141
+ email:
142
+ - msyk@hgsn.info
143
+ executables:
144
+ - thinreports-template-cli
145
+ extensions: []
146
+ extra_rdoc_files: []
147
+ files:
148
+ - ".gitignore"
149
+ - ".travis.yml"
150
+ - Gemfile
151
+ - LICENSE.txt
152
+ - README.md
153
+ - Rakefile
154
+ - bin/console
155
+ - bin/setup
156
+ - exe/thinreports-template-cli
157
+ - lib/thinreports/template/cli.rb
158
+ - lib/thinreports/template/cli/commands.rb
159
+ - lib/thinreports/template/cli/executor.rb
160
+ - lib/thinreports/template/cli/version.rb
161
+ - thinreports-template-cli.gemspec
162
+ homepage: https://github.com/mh61503891/thinreports-template-cli
163
+ licenses:
164
+ - MIT
165
+ metadata: {}
166
+ post_install_message:
167
+ rdoc_options: []
168
+ require_paths:
169
+ - lib
170
+ required_ruby_version: !ruby/object:Gem::Requirement
171
+ requirements:
172
+ - - ">="
173
+ - !ruby/object:Gem::Version
174
+ version: '0'
175
+ required_rubygems_version: !ruby/object:Gem::Requirement
176
+ requirements:
177
+ - - ">="
178
+ - !ruby/object:Gem::Version
179
+ version: '0'
180
+ requirements: []
181
+ rubyforge_project:
182
+ rubygems_version: 2.6.6
183
+ signing_key:
184
+ specification_version: 4
185
+ summary: A command line tool to generate a PDF file from YAML config file and .tlf
186
+ test_files: []