hatenikki 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +8 -0
- data/Gemfile +6 -0
- data/Gemfile.lock +27 -0
- data/README.md +36 -0
- data/Rakefile +2 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/exe/hatenikki +7 -0
- data/hatenikki.gemspec +28 -0
- data/lib/hatenikki.rb +10 -0
- data/lib/hatenikki/cli.rb +78 -0
- data/lib/hatenikki/version.rb +3 -0
- metadata +71 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: cacdb6cc13cdf2bd49abfbde46eadca78dea4f120e2cad6aee5405f99b6435f7
|
4
|
+
data.tar.gz: 3880daf589a4a138c51520f239330a7123e4525c788c66b97544f2cde3eaa48c
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 23cc9288162253c267ac89a1be1f60e182bd178f3ac0a638be346cd2651e358ff551fc1dce3caadb1295df37691bd007186d50e69e037d7334c0cc6c1d455202
|
7
|
+
data.tar.gz: 6ed78af41822b0ab243191f528cd1104e2f017fc1d464f4eadce8221beb21d06a3cd35ebd6a3b0ffebc1ee544b289d98114690f397f1b4cc89e1dd678fcb42b0
|
data/.gitignore
ADDED
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,27 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
hatenikki (0.1.0)
|
5
|
+
hatenablog
|
6
|
+
|
7
|
+
GEM
|
8
|
+
remote: https://rubygems.org/
|
9
|
+
specs:
|
10
|
+
hatenablog (0.6.0)
|
11
|
+
nokogiri
|
12
|
+
oauth
|
13
|
+
mini_portile2 (2.4.0)
|
14
|
+
nokogiri (1.10.7)
|
15
|
+
mini_portile2 (~> 2.4.0)
|
16
|
+
oauth (0.5.4)
|
17
|
+
rake (12.3.3)
|
18
|
+
|
19
|
+
PLATFORMS
|
20
|
+
ruby
|
21
|
+
|
22
|
+
DEPENDENCIES
|
23
|
+
hatenikki!
|
24
|
+
rake (~> 12.0)
|
25
|
+
|
26
|
+
BUNDLED WITH
|
27
|
+
2.1.1
|
data/README.md
ADDED
@@ -0,0 +1,36 @@
|
|
1
|
+
# Hatenikki
|
2
|
+
|
3
|
+
Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/hatenikki`. To experiment with that code, run `bin/console` for an interactive prompt.
|
4
|
+
|
5
|
+
TODO: Delete this and the text above, and describe your gem
|
6
|
+
|
7
|
+
## Installation
|
8
|
+
|
9
|
+
Add this line to your application's Gemfile:
|
10
|
+
|
11
|
+
```ruby
|
12
|
+
gem 'hatenikki'
|
13
|
+
```
|
14
|
+
|
15
|
+
And then execute:
|
16
|
+
|
17
|
+
$ bundle install
|
18
|
+
|
19
|
+
Or install it yourself as:
|
20
|
+
|
21
|
+
$ gem install hatenikki
|
22
|
+
|
23
|
+
## Usage
|
24
|
+
|
25
|
+
TODO: Write usage instructions here
|
26
|
+
|
27
|
+
## Development
|
28
|
+
|
29
|
+
After checking out the repo, run `bin/setup` to install dependencies. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
30
|
+
|
31
|
+
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).
|
32
|
+
|
33
|
+
## Contributing
|
34
|
+
|
35
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/pocke/hatenikki.
|
36
|
+
|
data/Rakefile
ADDED
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "hatenikki"
|
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(__FILE__)
|
data/bin/setup
ADDED
data/exe/hatenikki
ADDED
data/hatenikki.gemspec
ADDED
@@ -0,0 +1,28 @@
|
|
1
|
+
require_relative 'lib/hatenikki/version'
|
2
|
+
|
3
|
+
Gem::Specification.new do |spec|
|
4
|
+
spec.name = "hatenikki"
|
5
|
+
spec.version = Hatenikki::VERSION
|
6
|
+
spec.authors = ["Masataka Pocke Kuwabara"]
|
7
|
+
spec.email = ["kuwabara@pocke.me"]
|
8
|
+
|
9
|
+
spec.summary = %q{Write nikki every day!}
|
10
|
+
spec.description = %q{Write nikki every day!}
|
11
|
+
spec.homepage = "https://github.com/pocke/hatenikki"
|
12
|
+
spec.required_ruby_version = Gem::Requirement.new(">= 2.3.0")
|
13
|
+
|
14
|
+
spec.metadata["homepage_uri"] = spec.homepage
|
15
|
+
spec.metadata["source_code_uri"] = spec.homepage
|
16
|
+
# spec.metadata["changelog_uri"] = "TODO: Put your gem's CHANGELOG.md URL here."
|
17
|
+
|
18
|
+
# Specify which files should be added to the gem when it is released.
|
19
|
+
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
|
20
|
+
spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
|
21
|
+
`git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
22
|
+
end
|
23
|
+
spec.bindir = "exe"
|
24
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
25
|
+
spec.require_paths = ["lib"]
|
26
|
+
|
27
|
+
spec.add_runtime_dependency 'hatenablog'
|
28
|
+
end
|
data/lib/hatenikki.rb
ADDED
@@ -0,0 +1,78 @@
|
|
1
|
+
module Hatenikki
|
2
|
+
class CLI
|
3
|
+
CONFIG_DIR = Pathname(File.expand_path("~/.config/hatenikki"))
|
4
|
+
HATENABLOG_CONFIG_PATH = CONFIG_DIR / 'hatenablog.yaml'
|
5
|
+
|
6
|
+
def initialize(argv)
|
7
|
+
@argv = argv
|
8
|
+
end
|
9
|
+
|
10
|
+
def run
|
11
|
+
case subcommand
|
12
|
+
when 'load', 'save', 'publish'
|
13
|
+
__send__ subcommand
|
14
|
+
else
|
15
|
+
raise "Unknown subcommand: #{subcommand}"
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
# Load today's diary.
|
20
|
+
private def load
|
21
|
+
if entry = todays_entry
|
22
|
+
puts entry.content
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
# Save today's diary as draft
|
27
|
+
private def save
|
28
|
+
content = STDIN.read
|
29
|
+
categories = []
|
30
|
+
|
31
|
+
if entry = todays_entry
|
32
|
+
client.update_entry(
|
33
|
+
entry.id,
|
34
|
+
today,
|
35
|
+
content,
|
36
|
+
categories,
|
37
|
+
entry.draft,
|
38
|
+
)
|
39
|
+
else
|
40
|
+
client.post_entry(
|
41
|
+
today,
|
42
|
+
content,
|
43
|
+
categories,
|
44
|
+
'yes', # draft
|
45
|
+
)
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
# Publish drafts except today's
|
50
|
+
private def publish
|
51
|
+
client.entries.each do |e|
|
52
|
+
next unless e.draft?
|
53
|
+
next if e.title == today
|
54
|
+
|
55
|
+
draft = 'no'
|
56
|
+
client.update_entry(e.id, e.title, e.content, e.categories, draft)
|
57
|
+
puts "#{e.title} has been published."
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
61
|
+
private def client
|
62
|
+
@client ||= Hatenablog::Client.create(HATENABLOG_CONFIG_PATH)
|
63
|
+
end
|
64
|
+
|
65
|
+
private def subcommand
|
66
|
+
@argv[0]
|
67
|
+
end
|
68
|
+
|
69
|
+
private def todays_entry
|
70
|
+
client.entries.find{|entry| entry.title == today }
|
71
|
+
end
|
72
|
+
|
73
|
+
private def today
|
74
|
+
# TODO: configurable the offset
|
75
|
+
@today ||= (Time.now - 4 * 60 * 60).strftime('%Y-%m-%d')
|
76
|
+
end
|
77
|
+
end
|
78
|
+
end
|
metadata
ADDED
@@ -0,0 +1,71 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: hatenikki
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Masataka Pocke Kuwabara
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2019-12-20 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: hatenablog
|
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: Write nikki every day!
|
28
|
+
email:
|
29
|
+
- kuwabara@pocke.me
|
30
|
+
executables:
|
31
|
+
- hatenikki
|
32
|
+
extensions: []
|
33
|
+
extra_rdoc_files: []
|
34
|
+
files:
|
35
|
+
- ".gitignore"
|
36
|
+
- Gemfile
|
37
|
+
- Gemfile.lock
|
38
|
+
- README.md
|
39
|
+
- Rakefile
|
40
|
+
- bin/console
|
41
|
+
- bin/setup
|
42
|
+
- exe/hatenikki
|
43
|
+
- hatenikki.gemspec
|
44
|
+
- lib/hatenikki.rb
|
45
|
+
- lib/hatenikki/cli.rb
|
46
|
+
- lib/hatenikki/version.rb
|
47
|
+
homepage: https://github.com/pocke/hatenikki
|
48
|
+
licenses: []
|
49
|
+
metadata:
|
50
|
+
homepage_uri: https://github.com/pocke/hatenikki
|
51
|
+
source_code_uri: https://github.com/pocke/hatenikki
|
52
|
+
post_install_message:
|
53
|
+
rdoc_options: []
|
54
|
+
require_paths:
|
55
|
+
- lib
|
56
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
57
|
+
requirements:
|
58
|
+
- - ">="
|
59
|
+
- !ruby/object:Gem::Version
|
60
|
+
version: 2.3.0
|
61
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
62
|
+
requirements:
|
63
|
+
- - ">="
|
64
|
+
- !ruby/object:Gem::Version
|
65
|
+
version: '0'
|
66
|
+
requirements: []
|
67
|
+
rubygems_version: 3.1.1
|
68
|
+
signing_key:
|
69
|
+
specification_version: 4
|
70
|
+
summary: Write nikki every day!
|
71
|
+
test_files: []
|