nogizaka_blog 0.1.5 → 0.1.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +10 -0
- data/bin/console +14 -0
- data/bin/setup +7 -0
- data/{bin → exe}/nogizaka_blog +2 -0
- data/lib/nogizaka_blog/cli.rb +70 -0
- data/lib/nogizaka_blog/version.rb +1 -1
- data/lib/nogizaka_blog.rb +1 -0
- data/nogizaka_blog.gemspec +6 -5
- metadata +22 -9
- data/spec/nogizaka_blog_spec.rb +0 -25
- data/spec/spec_helper.rb +0 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: dbe76780e0a1b57facd3805cd814a8a91d1d56b5
|
4
|
+
data.tar.gz: f8049d999e5e9db88f72c152d65c43017fae4f96
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 216c2cb2dfaca1d741143c411721f4d7c19ec7a0cf9b22c1d2749a69d8b325569eee4b5775dd8cab236cf1588422650e2e993f51cf63946aa0c7f1165fbb68d2
|
7
|
+
data.tar.gz: d61b73c17698cfdc3cb748db91c10475547bc0830f511b09a4178ec5085f4022131a571016253feccf537089b68ba629ef79b5c9197edd113930074b95db53c6
|
data/README.md
CHANGED
@@ -54,6 +54,16 @@ end
|
|
54
54
|
gen_json
|
55
55
|
```
|
56
56
|
|
57
|
+
### CLI
|
58
|
+
|
59
|
+
Basic usage in Terminal
|
60
|
+
|
61
|
+
$ nogizaka_blog when YEARMONTH [--sort comment/article]
|
62
|
+
|
63
|
+
(e.g. September 2015)
|
64
|
+
|
65
|
+
$ nogizaka_blog when 201509
|
66
|
+
|
57
67
|
## Contributing
|
58
68
|
|
59
69
|
1. Fork it ( https://github.com/[my-github-username]/nogizaka_blog/fork )
|
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "nogizaka_blog"
|
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
|
data/bin/setup
ADDED
data/{bin → exe}/nogizaka_blog
RENAMED
@@ -0,0 +1,70 @@
|
|
1
|
+
require 'thor'
|
2
|
+
|
3
|
+
module NogizakaBlog
|
4
|
+
Thread.abort_on_exception = true
|
5
|
+
|
6
|
+
class CLI < Thor
|
7
|
+
GLYPHS = %w(| / - \\ | / - \\)
|
8
|
+
|
9
|
+
desc 'when YEARMONTH', 'Show the number of comments and articles'
|
10
|
+
method_option :sort, aliases: '-s', desc: 'set comment or article'
|
11
|
+
def when(yearmonth)
|
12
|
+
@nogi = Amazing.new(yearmonth)
|
13
|
+
print_header
|
14
|
+
spinner
|
15
|
+
case options[:sort]
|
16
|
+
when 'comment' then sort_by_comment
|
17
|
+
when 'article' then sort_by_article
|
18
|
+
else normal
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
private
|
23
|
+
|
24
|
+
def print_header
|
25
|
+
ym = @nogi.yearmonth
|
26
|
+
puts "#{ym[0..3]}/#{ym[4..5]}"
|
27
|
+
head = display_format('name', 'comment', 'article')
|
28
|
+
puts head
|
29
|
+
puts '-' * head.size
|
30
|
+
end
|
31
|
+
|
32
|
+
def spinner
|
33
|
+
Thread.new do
|
34
|
+
loop do
|
35
|
+
GLYPHS.each do |glyph|
|
36
|
+
print "processing.. #{glyph}\r"
|
37
|
+
sleep 0.15
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
def normal
|
44
|
+
@nogi.each do |name, comment, article|
|
45
|
+
puts display_format("#{name.to_kanji}", comment, article)
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
def sort_by_comment
|
50
|
+
@nogi.sort_by { |_, b, _| b }.reverse_each do |name, comment, article|
|
51
|
+
puts display_format("#{name.to_kanji}", comment, article)
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
def sort_by_article
|
56
|
+
@nogi.sort_by { |_, _, c| c }.reverse_each do |name, comment, article|
|
57
|
+
puts display_format("#{name.to_kanji}", comment, article)
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
61
|
+
def display_format(name, comment, article)
|
62
|
+
name_length = 10 - full_width_count(name)
|
63
|
+
[name.ljust(name_length), comment.to_s.rjust(7), article.to_s.rjust(7)].join(' | ')
|
64
|
+
end
|
65
|
+
|
66
|
+
def full_width_count(string)
|
67
|
+
string.each_char.count { |char| !(/[ -~。-゚]/.match(char)) }
|
68
|
+
end
|
69
|
+
end
|
70
|
+
end
|
data/lib/nogizaka_blog.rb
CHANGED
data/nogizaka_blog.gemspec
CHANGED
@@ -8,17 +8,18 @@ Gem::Specification.new do |spec|
|
|
8
8
|
spec.version = NogizakaBlog::VERSION
|
9
9
|
spec.authors = ['hachy']
|
10
10
|
spec.email = ['pekoett@gmail.com']
|
11
|
-
spec.summary = %
|
12
|
-
spec.description = %
|
11
|
+
spec.summary = %(Get the number of comments and articles per month from Nogizaka46's blog)
|
12
|
+
spec.description = %(Get the number of comments and articles per month from Nogizaka46's blog)
|
13
13
|
spec.homepage = 'https://github.com/hachy/nogizaka_blog'
|
14
14
|
spec.license = 'MIT'
|
15
15
|
|
16
|
-
spec.files = `git ls-files -z`.split("\x0")
|
17
|
-
spec.
|
18
|
-
spec.
|
16
|
+
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
17
|
+
spec.bindir = 'exe'
|
18
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
19
19
|
spec.require_paths = ['lib']
|
20
20
|
|
21
21
|
spec.add_dependency 'nokogiri'
|
22
|
+
spec.add_dependency 'thor'
|
22
23
|
spec.add_development_dependency 'bundler', '~> 1.6'
|
23
24
|
spec.add_development_dependency 'rake'
|
24
25
|
spec.add_development_dependency 'rspec'
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: nogizaka_blog
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- hachy
|
8
8
|
autorequire:
|
9
|
-
bindir:
|
9
|
+
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-09-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: nokogiri
|
@@ -24,6 +24,20 @@ dependencies:
|
|
24
24
|
- - ">="
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: thor
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
27
41
|
- !ruby/object:Gem::Dependency
|
28
42
|
name: bundler
|
29
43
|
requirement: !ruby/object:Gem::Requirement
|
@@ -80,15 +94,16 @@ files:
|
|
80
94
|
- LICENSE.txt
|
81
95
|
- README.md
|
82
96
|
- Rakefile
|
83
|
-
- bin/
|
97
|
+
- bin/console
|
98
|
+
- bin/setup
|
99
|
+
- exe/nogizaka_blog
|
84
100
|
- lib/nogizaka_blog.rb
|
85
101
|
- lib/nogizaka_blog/amazing.rb
|
102
|
+
- lib/nogizaka_blog/cli.rb
|
86
103
|
- lib/nogizaka_blog/core_ext.rb
|
87
104
|
- lib/nogizaka_blog/member.rb
|
88
105
|
- lib/nogizaka_blog/version.rb
|
89
106
|
- nogizaka_blog.gemspec
|
90
|
-
- spec/nogizaka_blog_spec.rb
|
91
|
-
- spec/spec_helper.rb
|
92
107
|
homepage: https://github.com/hachy/nogizaka_blog
|
93
108
|
licenses:
|
94
109
|
- MIT
|
@@ -113,6 +128,4 @@ rubygems_version: 2.4.5.1
|
|
113
128
|
signing_key:
|
114
129
|
specification_version: 4
|
115
130
|
summary: Get the number of comments and articles per month from Nogizaka46's blog
|
116
|
-
test_files:
|
117
|
-
- spec/nogizaka_blog_spec.rb
|
118
|
-
- spec/spec_helper.rb
|
131
|
+
test_files: []
|
data/spec/nogizaka_blog_spec.rb
DELETED
@@ -1,25 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe NogizakaBlog do
|
4
|
-
describe 'Instance' do
|
5
|
-
it do
|
6
|
-
nogi = NogizakaBlog::Amazing.new(201508)
|
7
|
-
expect(nogi).to be_a(Enumerable)
|
8
|
-
end
|
9
|
-
end
|
10
|
-
|
11
|
-
describe 'Extensions to String' do
|
12
|
-
it 'to_kanji' do
|
13
|
-
expect('manatsu.akimoto'.to_kanji).to eq('秋元真夏')
|
14
|
-
end
|
15
|
-
end
|
16
|
-
|
17
|
-
describe 'Extensions to Array' do
|
18
|
-
using NogizakaBlog::Extensions if RUBY_VERSION >= '2.1.0'
|
19
|
-
|
20
|
-
it 'sum' do
|
21
|
-
ary = %w(1 2 3 4 5)
|
22
|
-
expect(ary.sum).to eq(15)
|
23
|
-
end
|
24
|
-
end
|
25
|
-
end
|
data/spec/spec_helper.rb
DELETED