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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: f027e70e0d98f2951621db12a217b98cb0d56977c71b6d4d66bfa2453c73efce
4
- data.tar.gz: 0dc7986c1a54e6a40081e33d72a45a33e895c5e9ac46a98b1eccd9b0549b85b7
3
+ metadata.gz: c2f63d161679d00d7087f193e6af9ccc319ed43f11ed7ad9e07ebab6264f5151
4
+ data.tar.gz: bbfe3a3be06ca63c15c47362d325e014d701873947160f4d958a7bbcbdb49ff1
5
5
  SHA512:
6
- metadata.gz: 1bcd53eece0e48c05329fe905c3cec2a8d03efb84040633f1a5c61170d7c5c71e044d966a01b1715615c7883622b13281c3f40b8e536e383b53e3185107e44a5
7
- data.tar.gz: f247a7e80372795deb178e90ac41ca87344a51cc50b4d728d34808aacbbfd27a4677517fa954ce36bebcc4c3847c48c529fdb009db9680d40dcd782fcde8a043
6
+ metadata.gz: 8614e224659fdbb202e00c5b23a9c8597498c451e089f9c2e24d37e2211388ddaacf9aef4a4ae594e30f4620ad329433e90ea4726195b1a39ae90730793c8b02
7
+ data.tar.gz: 5f1f538b2704cc95785c5a1bf197ad110a9d0585649c77cd6b4a327db3eed2f5b39a19beca717a66df2dcd6dbf4aa25ecf685d91a598f1627769e235de79ae69
@@ -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
@@ -1,5 +1,5 @@
1
1
  class DCMX
2
- def self.hello name
2
+ def self.hello(name)
3
3
  "Hello, #{name}!"
4
4
  end
5
5
  end
@@ -0,0 +1,3 @@
1
+ ---
2
+ en:
3
+ no_file: file not found
@@ -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.1
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-06 00:00:00.000000000 Z
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