hatenikki 0.1.1 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +2 -2
- data/README.md +14 -4
- data/lib/hatenikki/cli.rb +20 -3
- data/lib/hatenikki/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: bbf08a23ddaf07118a72899ce748dd39f98bf053ceabee43180ac08c3569bf82
|
4
|
+
data.tar.gz: 6cad9f81f2af8cbd3b6686baf212ccb8ec63f92479958ff9a7c48b86d012ee51
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 663dab3d0d8f2153b43a6a53dc128e8f1ca25adf32613cd29d21949c5a24ff855ada9ddf572e81ab780901a0ebcd2ec400265aaf4d5e5b08a488a32eccb4b364
|
7
|
+
data.tar.gz: 76274c3f7f810b27dad12f20220d7de18fb0693e5ef3ad253ae08a7e9b0e75f79f08f93d22e776aaa4d1c611d851ad567941742d75aef92017ecc9b57903fcac
|
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
hatenikki (0.
|
4
|
+
hatenikki (0.2.0)
|
5
5
|
hatenablog
|
6
6
|
|
7
7
|
GEM
|
@@ -11,7 +11,7 @@ GEM
|
|
11
11
|
nokogiri
|
12
12
|
oauth
|
13
13
|
mini_portile2 (2.4.0)
|
14
|
-
nokogiri (1.10.
|
14
|
+
nokogiri (1.10.9)
|
15
15
|
mini_portile2 (~> 2.4.0)
|
16
16
|
oauth (0.5.4)
|
17
17
|
rake (12.3.3)
|
data/README.md
CHANGED
@@ -1,8 +1,6 @@
|
|
1
1
|
# Hatenikki
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
TODO: Delete this and the text above, and describe your gem
|
3
|
+
Write diary every day with Hatena blog.
|
6
4
|
|
7
5
|
## Installation
|
8
6
|
|
@@ -22,7 +20,19 @@ Or install it yourself as:
|
|
22
20
|
|
23
21
|
## Usage
|
24
22
|
|
25
|
-
|
23
|
+
```
|
24
|
+
# Print the today's article to STDOUT
|
25
|
+
$ hatenikki load
|
26
|
+
|
27
|
+
# Save the today's article from STDIN
|
28
|
+
$ hatenikki save
|
29
|
+
|
30
|
+
# Publish draft articles except today's one
|
31
|
+
$ hatenikki publish
|
32
|
+
```
|
33
|
+
|
34
|
+
* For more information (in Japanese): https://pocke.hatenablog.com/entry/2020/01/18/191652
|
35
|
+
* Related project: https://github.com/pocke/hatenikki.vim
|
26
36
|
|
27
37
|
## Development
|
28
38
|
|
data/lib/hatenikki/cli.rb
CHANGED
@@ -19,6 +19,9 @@ module Hatenikki
|
|
19
19
|
# Load today's diary.
|
20
20
|
private def load
|
21
21
|
if entry = todays_entry
|
22
|
+
if match = entry.title.match(/ - (?<subtitle>.+)/)
|
23
|
+
puts "title: #{match[:subtitle]}"
|
24
|
+
end
|
22
25
|
puts entry.content
|
23
26
|
end
|
24
27
|
end
|
@@ -28,17 +31,19 @@ module Hatenikki
|
|
28
31
|
content = STDIN.read
|
29
32
|
categories = []
|
30
33
|
|
34
|
+
title, content = title_and_content(content)
|
35
|
+
|
31
36
|
if entry = todays_entry
|
32
37
|
client.update_entry(
|
33
38
|
entry.id,
|
34
|
-
|
39
|
+
title,
|
35
40
|
content,
|
36
41
|
categories,
|
37
42
|
entry.draft,
|
38
43
|
)
|
39
44
|
else
|
40
45
|
client.post_entry(
|
41
|
-
|
46
|
+
title,
|
42
47
|
content,
|
43
48
|
categories,
|
44
49
|
'yes', # draft
|
@@ -46,6 +51,14 @@ module Hatenikki
|
|
46
51
|
end
|
47
52
|
end
|
48
53
|
|
54
|
+
private def title_and_content(content)
|
55
|
+
if match = content.match(/\Atitle: (?<subtitle>.+)/)
|
56
|
+
["#{today} - #{match[:subtitle]}", content.sub(/.+\n/, '')]
|
57
|
+
else
|
58
|
+
[today, content]
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
49
62
|
# Publish drafts except today's
|
50
63
|
private def publish
|
51
64
|
client.entries.each do |e|
|
@@ -66,8 +79,12 @@ module Hatenikki
|
|
66
79
|
@argv[0]
|
67
80
|
end
|
68
81
|
|
82
|
+
private def todays_entry?(entry)
|
83
|
+
entry.title.match?(/\A#{Regexp.escape(today)}\b/)
|
84
|
+
end
|
85
|
+
|
69
86
|
private def todays_entry
|
70
|
-
client.entries.find{|entry| entry
|
87
|
+
client.entries.find{|entry| todays_entry?(entry) }
|
71
88
|
end
|
72
89
|
|
73
90
|
private def today
|
data/lib/hatenikki/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: hatenikki
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Masataka Pocke Kuwabara
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-
|
11
|
+
date: 2020-07-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: hatenablog
|
@@ -66,7 +66,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
66
66
|
- !ruby/object:Gem::Version
|
67
67
|
version: '0'
|
68
68
|
requirements: []
|
69
|
-
rubygems_version: 3.
|
69
|
+
rubygems_version: 3.2.0.pre1
|
70
70
|
signing_key:
|
71
71
|
specification_version: 4
|
72
72
|
summary: Write nikki every day!
|