dcmx 0.0.1 → 0.0.2
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 +4 -4
- data/bin/dcmx +64 -0
- data/lib/dcmx.rb +1 -1
- data/locales/en.yml +3 -0
- data/locales/ja.yml +5 -0
- metadata +7 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c2f63d161679d00d7087f193e6af9ccc319ed43f11ed7ad9e07ebab6264f5151
|
4
|
+
data.tar.gz: bbfe3a3be06ca63c15c47362d325e014d701873947160f4d958a7bbcbdb49ff1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8614e224659fdbb202e00c5b23a9c8597498c451e089f9c2e24d37e2211388ddaacf9aef4a4ae594e30f4620ad329433e90ea4726195b1a39ae90730793c8b02
|
7
|
+
data.tar.gz: 5f1f538b2704cc95785c5a1bf197ad110a9d0585649c77cd6b4a327db3eed2f5b39a19beca717a66df2dcd6dbf4aa25ecf685d91a598f1627769e235de79ae69
|
data/bin/dcmx
ADDED
@@ -0,0 +1,64 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# coding: utf-8
|
3
|
+
require "yaml"
|
4
|
+
require "i18n"
|
5
|
+
require "erb"
|
6
|
+
|
7
|
+
begin
|
8
|
+
settings = YAML.load_file("~/.config/dcmx/settings.yml")
|
9
|
+
rescue
|
10
|
+
settings = YAML.load(<<EOT
|
11
|
+
---
|
12
|
+
lang: ja
|
13
|
+
timezone: +9
|
14
|
+
EOT
|
15
|
+
)
|
16
|
+
end
|
17
|
+
|
18
|
+
I18n.load_path = Dir.glob(File.expand_path('../../locales/*', __FILE__))
|
19
|
+
I18n.locale = settings["lang"]
|
20
|
+
|
21
|
+
case ARGV[0]
|
22
|
+
when "create"
|
23
|
+
if ["-h", "--help", "help"].include? ARGV[1]
|
24
|
+
puts I18n.t("create_help")
|
25
|
+
return nil
|
26
|
+
end
|
27
|
+
|
28
|
+
if ARGV[1].nil? || ARGV[1] =~ /^-{1,2}/
|
29
|
+
puts I18n.t("create_null")
|
30
|
+
return nil
|
31
|
+
end
|
32
|
+
|
33
|
+
cons = ARGV[1..-1].each_cons(2)
|
34
|
+
title = ARGV[1]
|
35
|
+
from = cons.select { |fst, snd| fst =~ /^(--from)|(-f)/ }.last&.last || Time.now
|
36
|
+
by = cons.select { |fst, snd| fst =~ /^(--by)|(-b)/ }.last&.last || Time.now
|
37
|
+
input = cons.select { |fst, snd| fst =~ /^(--input)|(-i)/ }.last&.last
|
38
|
+
output = cons.select { |fst, snd| fst =~ /^(--output)|(-o)/ }.last&.last || `pwd`.chomp + "/_drafts"
|
39
|
+
|
40
|
+
loop.with_index(0) do |_, add|
|
41
|
+
that_time = from + 24 * 60 * 60 * add
|
42
|
+
lines = []
|
43
|
+
|
44
|
+
break if that_time > from
|
45
|
+
|
46
|
+
array = if input
|
47
|
+
then File.open(input, "r")
|
48
|
+
else ['---', 'title: <%= title %>(<%= that_time.strftime("%y-%m-%d") %>)', 'date: <%= that_time.strftime("%H:%M:%S %z") %>', '---']
|
49
|
+
end
|
50
|
+
|
51
|
+
array.each do |line|
|
52
|
+
lines << ERB.new(line.chomp).result(binding)
|
53
|
+
end
|
54
|
+
|
55
|
+
created_file = File.open("#{output}/#{that_time.strftime("%Y-%m-%d")}-#{ARGV[1]}.md", "w")
|
56
|
+
lines.each do |line|
|
57
|
+
created_file.puts(line)
|
58
|
+
end
|
59
|
+
created_file.close
|
60
|
+
end
|
61
|
+
when "help"
|
62
|
+
else
|
63
|
+
puts I18n.t("null_command")
|
64
|
+
end
|
data/lib/dcmx.rb
CHANGED
data/locales/en.yml
ADDED
data/locales/ja.yml
ADDED
@@ -0,0 +1,5 @@
|
|
1
|
+
ja:
|
2
|
+
file: ファイルが見つかりません
|
3
|
+
null_command: コマンドを入力しましょう
|
4
|
+
create_help: "このコマンドではマークダウン・ファイルをつくることができます\n\t$ dcmx create example \nまた以下の引数を指定することも可能です\n\t -f, --from\t 開始する日付を指定します\n\t -b, --by\t 終了する日付を指定します\n\t -i, --input\t テンプレートファイルを指定します\n\t -o, --output\t 出力先を指定します\n"
|
5
|
+
create_null: ファイル名は指名する必要があります
|
metadata
CHANGED
@@ -1,22 +1,26 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: dcmx
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- seahal
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-08-
|
11
|
+
date: 2018-08-07 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: The first Gem package for practice
|
14
14
|
email: shiiharagikenaa@gmail.com
|
15
|
-
executables:
|
15
|
+
executables:
|
16
|
+
- dcmx
|
16
17
|
extensions: []
|
17
18
|
extra_rdoc_files: []
|
18
19
|
files:
|
20
|
+
- bin/dcmx
|
19
21
|
- lib/dcmx.rb
|
22
|
+
- locales/en.yml
|
23
|
+
- locales/ja.yml
|
20
24
|
homepage: https://seahal.net
|
21
25
|
licenses:
|
22
26
|
- MIT
|