kaimono 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/.gitignore +11 -0
- data/Gemfile +9 -0
- data/LICENSE.txt +21 -0
- data/README.md +43 -0
- data/Rakefile +13 -0
- data/bin/console +15 -0
- data/bin/setup +6 -0
- data/exe/kaimono +5 -0
- data/img/kaimono.png +0 -0
- data/kaimono.gemspec +28 -0
- data/kaimono.html +25 -0
- data/kaimono.yml +9 -0
- data/lib/kaimono/command.rb +28 -0
- data/lib/kaimono/options.rb +72 -0
- data/lib/kaimono/version.rb +5 -0
- data/lib/kaimono.rb +29 -0
- metadata +75 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: d15f19ae47b5a40c63a58774fab652b99ec37e1694a3232fdbba7c2908af53a7
|
4
|
+
data.tar.gz: e0d134ea501720e64b31759f64652c5f449db6d2efba46eb777729541d3526b3
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: e17226116bd94ac3819f207556db01cc662b85b8f14f82453172f5414279b30eb4024d2c214695c5e0472d24e7894d259f35696b3135cc2fa0fe2ec6388b395d
|
7
|
+
data.tar.gz: ec58c963766640efd30ebf86b1383f8a1a64f313167a0fdc4139cdfa56c38e9bd843b1df893bc35db433b7cf51faeb0c054de0aa97fe962d108bc0daa9e73552
|
data/.gitignore
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2022 icm7216
|
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,43 @@
|
|
1
|
+
# Kaimono
|
2
|
+
|
3
|
+
The kaimono command generates a shopping list with checkboxes from a shopping list in YAML format.
|
4
|
+
|
5
|
+
# Install
|
6
|
+
|
7
|
+
```
|
8
|
+
gem install kaimono
|
9
|
+
```
|
10
|
+
|
11
|
+
# Usage
|
12
|
+
|
13
|
+
```
|
14
|
+
kaimono <YAML format file>
|
15
|
+
```
|
16
|
+
|
17
|
+
for example
|
18
|
+
```
|
19
|
+
kaimono kaimono.yml
|
20
|
+
```
|
21
|
+
|
22
|
+
`kaimono.yml`
|
23
|
+
```
|
24
|
+
mylist1:
|
25
|
+
- bread 1
|
26
|
+
- milk 1
|
27
|
+
- banana 1
|
28
|
+
|
29
|
+
mylist2:
|
30
|
+
- bread 2
|
31
|
+
- milk 2
|
32
|
+
- banana2
|
33
|
+
|
34
|
+
```
|
35
|
+
|
36
|
+
kaimono command generates `kaimono.html`.
|
37
|
+
|
38
|
+
<img src="./img/kaimono.png" width="50%">
|
39
|
+
|
40
|
+
|
41
|
+
# License
|
42
|
+
|
43
|
+
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
data/Rakefile
ADDED
@@ -0,0 +1,13 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "bundler/gem_tasks"
|
4
|
+
require "rake/testtask"
|
5
|
+
|
6
|
+
Rake::TestTask.new(:test) do |t|
|
7
|
+
t.libs << "test"
|
8
|
+
t.libs << "lib"
|
9
|
+
t.test_files = FileList["test/**/*_test.rb"]
|
10
|
+
t.options = "-v"
|
11
|
+
end
|
12
|
+
|
13
|
+
task default: :test
|
data/bin/console
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
require "bundler/setup"
|
5
|
+
require "kaimono"
|
6
|
+
|
7
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
8
|
+
# with your gem easier. You can also use a different console, if you like.
|
9
|
+
|
10
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
11
|
+
# require "pry"
|
12
|
+
# Pry.start
|
13
|
+
|
14
|
+
require "irb"
|
15
|
+
IRB.start(__FILE__)
|
data/bin/setup
ADDED
data/exe/kaimono
ADDED
data/img/kaimono.png
ADDED
Binary file
|
data/kaimono.gemspec
ADDED
@@ -0,0 +1,28 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative "lib/kaimono/version"
|
4
|
+
|
5
|
+
Gem::Specification.new do |spec|
|
6
|
+
spec.name = "kaimono"
|
7
|
+
spec.version = Kaimono::VERSION
|
8
|
+
spec.authors = ["icm7216"]
|
9
|
+
spec.email = ["icm7216d@gmail.com"]
|
10
|
+
|
11
|
+
spec.summary = "Ruby Shopping List"
|
12
|
+
spec.description = "Create your Shopping List. The kaimono command generates a shopping list with checkboxes from a shopping list in YAML format."
|
13
|
+
spec.homepage = "https://github.com/icm7216/kaimono"
|
14
|
+
spec.license = "MIT"
|
15
|
+
spec.required_ruby_version = Gem::Requirement.new(">= 2.7.0")
|
16
|
+
|
17
|
+
# Specify which files should be added to the gem when it is released.
|
18
|
+
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
|
19
|
+
spec.files = Dir.chdir(File.expand_path(__dir__)) do
|
20
|
+
`git ls-files -z`.split("\x0").reject { |f| f.match(%r{\A(?:test|spec|features)/}) }
|
21
|
+
end
|
22
|
+
spec.bindir = "exe"
|
23
|
+
spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) }
|
24
|
+
spec.require_paths = ["lib"]
|
25
|
+
|
26
|
+
spec.add_runtime_dependency "haml"
|
27
|
+
|
28
|
+
end
|
data/kaimono.html
ADDED
@@ -0,0 +1,25 @@
|
|
1
|
+
<!DOCTYPE html>
|
2
|
+
<html lang='ja'>
|
3
|
+
<head>
|
4
|
+
<meta charset='utf-8'>
|
5
|
+
<title>Shopping List</title>
|
6
|
+
</head>
|
7
|
+
<body>
|
8
|
+
<fieldset>
|
9
|
+
<legend>mylist1</legend>
|
10
|
+
<div id='content'>
|
11
|
+
<p><label><input type='checkbox'>bread 1</input></label></p>
|
12
|
+
<p><label><input type='checkbox'>milk 1</input></label></p>
|
13
|
+
<p><label><input type='checkbox'>banana 1</input></label></p>
|
14
|
+
</div>
|
15
|
+
</fieldset>
|
16
|
+
<fieldset>
|
17
|
+
<legend>mylist2</legend>
|
18
|
+
<div id='content'>
|
19
|
+
<p><label><input type='checkbox'>bread 2</input></label></p>
|
20
|
+
<p><label><input type='checkbox'>milk 2</input></label></p>
|
21
|
+
<p><label><input type='checkbox'>banana2</input></label></p>
|
22
|
+
</div>
|
23
|
+
</fieldset>
|
24
|
+
</body>
|
25
|
+
</html>
|
data/kaimono.yml
ADDED
@@ -0,0 +1,28 @@
|
|
1
|
+
module Kaimono
|
2
|
+
class Command
|
3
|
+
attr_reader :opts
|
4
|
+
|
5
|
+
def self.run(argv)
|
6
|
+
new(argv).execute
|
7
|
+
end
|
8
|
+
|
9
|
+
def initialize(argv)
|
10
|
+
@argv = argv
|
11
|
+
@kaimono_list = Kaimono::Options.new
|
12
|
+
@options = @kaimono_list.parse(@argv)
|
13
|
+
end
|
14
|
+
|
15
|
+
def output_html
|
16
|
+
html_file = @kaimono_list.filename + ".html"
|
17
|
+
File.open(html_file, "w") do |w|
|
18
|
+
w.puts @kaimono_list.to_html
|
19
|
+
end
|
20
|
+
puts "output HTML => #{html_file}"
|
21
|
+
end
|
22
|
+
|
23
|
+
def execute
|
24
|
+
puts @kaimono_list.to_s
|
25
|
+
output_html
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
@@ -0,0 +1,72 @@
|
|
1
|
+
module Kaimono
|
2
|
+
class Options
|
3
|
+
def initialize
|
4
|
+
@options = {}
|
5
|
+
@config = {}
|
6
|
+
end
|
7
|
+
|
8
|
+
def hash_key_to_sym(h)
|
9
|
+
Hash[h.map{|k, v| [k.to_s.to_sym, v]}]
|
10
|
+
end
|
11
|
+
|
12
|
+
def get_tasklist
|
13
|
+
@options[:task] = hash_key_to_sym(@config)
|
14
|
+
end
|
15
|
+
|
16
|
+
def load_config(file)
|
17
|
+
@config = YAML.load(File.read(file))
|
18
|
+
get_tasklist
|
19
|
+
end
|
20
|
+
|
21
|
+
def filename
|
22
|
+
@options[:filename].to_s
|
23
|
+
end
|
24
|
+
|
25
|
+
def to_s
|
26
|
+
str = []
|
27
|
+
str << "---------- file name ----------"
|
28
|
+
str << @options[:filename].to_s
|
29
|
+
|
30
|
+
@options[:task].each do |k,v|
|
31
|
+
str << "------------------------------"
|
32
|
+
str << "task name: #{k.to_s}"
|
33
|
+
str << "------------------------------"
|
34
|
+
str << "item:"
|
35
|
+
v.each {|item| str << item.to_s}
|
36
|
+
end
|
37
|
+
str
|
38
|
+
end
|
39
|
+
|
40
|
+
def to_html
|
41
|
+
haml = Haml::Template.new {Kaimono::HTML_TEMPLATE}
|
42
|
+
html = haml.render(Object.new, {task: @options[:task]})
|
43
|
+
html
|
44
|
+
end
|
45
|
+
|
46
|
+
def usage_message
|
47
|
+
puts "The kaimono command generates HTML file from YAML-formatted Shopping List."
|
48
|
+
puts
|
49
|
+
puts "Usage: kaimono <YAML format file>"
|
50
|
+
puts
|
51
|
+
puts "version: #{Kaimono::VERSION}"
|
52
|
+
end
|
53
|
+
|
54
|
+
def parse(argv)
|
55
|
+
if argv.empty? || (argv.size > 1) || File.extname(argv.first) != ".yml"
|
56
|
+
usage_message
|
57
|
+
exit
|
58
|
+
end
|
59
|
+
|
60
|
+
if File.exist?(argv.first)
|
61
|
+
yaml_file = argv.first
|
62
|
+
@options[:filename] = File.basename(yaml_file, ".yml")
|
63
|
+
load_config(yaml_file)
|
64
|
+
else
|
65
|
+
puts "file not exist => #{argv.first}"
|
66
|
+
exit
|
67
|
+
end
|
68
|
+
|
69
|
+
@options
|
70
|
+
end
|
71
|
+
end
|
72
|
+
end
|
data/lib/kaimono.rb
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
require "optparse"
|
3
|
+
require "yaml"
|
4
|
+
require "haml"
|
5
|
+
|
6
|
+
require_relative "kaimono/command"
|
7
|
+
require_relative "kaimono/options"
|
8
|
+
require_relative "kaimono/version"
|
9
|
+
|
10
|
+
module Kaimono
|
11
|
+
|
12
|
+
HTML_TEMPLATE = <<EOS
|
13
|
+
!!!
|
14
|
+
%html{lang: "ja"}
|
15
|
+
%head
|
16
|
+
%meta{charset: "utf-8"}
|
17
|
+
%title Shopping List
|
18
|
+
%body
|
19
|
+
-task.each do |shop, items|
|
20
|
+
%fieldset
|
21
|
+
%legend= shop
|
22
|
+
#content
|
23
|
+
-items.each do |item|
|
24
|
+
%p<
|
25
|
+
%label<
|
26
|
+
%input{type: "checkbox"}= item
|
27
|
+
EOS
|
28
|
+
|
29
|
+
end
|
metadata
ADDED
@@ -0,0 +1,75 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: kaimono
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- icm7216
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2022-12-02 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: haml
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
27
|
+
description: Create your Shopping List. The kaimono command generates a shopping list
|
28
|
+
with checkboxes from a shopping list in YAML format.
|
29
|
+
email:
|
30
|
+
- icm7216d@gmail.com
|
31
|
+
executables:
|
32
|
+
- kaimono
|
33
|
+
extensions: []
|
34
|
+
extra_rdoc_files: []
|
35
|
+
files:
|
36
|
+
- ".gitignore"
|
37
|
+
- Gemfile
|
38
|
+
- LICENSE.txt
|
39
|
+
- README.md
|
40
|
+
- Rakefile
|
41
|
+
- bin/console
|
42
|
+
- bin/setup
|
43
|
+
- exe/kaimono
|
44
|
+
- img/kaimono.png
|
45
|
+
- kaimono.gemspec
|
46
|
+
- kaimono.html
|
47
|
+
- kaimono.yml
|
48
|
+
- lib/kaimono.rb
|
49
|
+
- lib/kaimono/command.rb
|
50
|
+
- lib/kaimono/options.rb
|
51
|
+
- lib/kaimono/version.rb
|
52
|
+
homepage: https://github.com/icm7216/kaimono
|
53
|
+
licenses:
|
54
|
+
- MIT
|
55
|
+
metadata: {}
|
56
|
+
post_install_message:
|
57
|
+
rdoc_options: []
|
58
|
+
require_paths:
|
59
|
+
- lib
|
60
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
61
|
+
requirements:
|
62
|
+
- - ">="
|
63
|
+
- !ruby/object:Gem::Version
|
64
|
+
version: 2.7.0
|
65
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
66
|
+
requirements:
|
67
|
+
- - ">="
|
68
|
+
- !ruby/object:Gem::Version
|
69
|
+
version: '0'
|
70
|
+
requirements: []
|
71
|
+
rubygems_version: 3.3.7
|
72
|
+
signing_key:
|
73
|
+
specification_version: 4
|
74
|
+
summary: Ruby Shopping List
|
75
|
+
test_files: []
|