obst 0.1.0 → 0.1.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/.gitignore +1 -0
- data/exe/obst +23 -0
- data/lib/obst/git_log.rb +14 -9
- data/lib/obst/version.rb +1 -1
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 43dc48712314838bb19c932cd61c53196acfba4d1850192048f0946ba8a2bf90
|
4
|
+
data.tar.gz: 7498633a8f52ad0c9651b9e1a7a17361ee3aca822594ea42d96ac9dede0b713a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: eea44c54b0be8db9911ce89a05a89df918a563ad1adfd266b24f28285b067a22f3923d5cb3003c1994e90a4d74047aa5a7440973a9f1864a7d5761bdb78098d6
|
7
|
+
data.tar.gz: ec792740ca69bf79d39ef1b12a2c66903c55f8e51dbbcd78c83c207bb600f036244c2ad7c21941b0af9ebae7f9fb3a28ae76dda4338eec07fe751c0c97fa8949
|
data/.gitignore
CHANGED
data/exe/obst
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "obst"
|
4
|
+
|
5
|
+
path = ARGV[0] || '.'
|
6
|
+
|
7
|
+
gitignore = File.join(path, '.gitignore')
|
8
|
+
File.open(gitignore, 'a+') do |f|
|
9
|
+
f.puts("# Obst\nobst.md") unless f.read =~ /# Obst/
|
10
|
+
end
|
11
|
+
|
12
|
+
buffer = []
|
13
|
+
Obst::GroupByDays.new(C: path, days: 1).take(7).each do |record|
|
14
|
+
buffer << "- #{record.time} (#{record.statuses.size})"
|
15
|
+
record.statuses.each_key do |name|
|
16
|
+
buffer << "\t- [[#{name}]]"
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
obst_md = File.join(path, 'obst.md')
|
21
|
+
File.open(obst_md, 'w') do |f|
|
22
|
+
f.puts(buffer.join("\n"))
|
23
|
+
end
|
data/lib/obst/git_log.rb
CHANGED
@@ -1,13 +1,16 @@
|
|
1
|
+
require "open3"
|
2
|
+
|
1
3
|
module Obst
|
2
4
|
class GitLog
|
3
5
|
def initialize(**opts)
|
4
|
-
|
5
|
-
@
|
6
|
-
@
|
6
|
+
path = opts[:C] || '.'
|
7
|
+
@cmd = ['git', '-C', path, 'log', '--name-status', '--pretty=format:%ad', "--date=format:'%Y-%m-%dT%H:%M:%S'"]
|
8
|
+
@cmd << '--after' << opts[:after] if opts[:after]
|
9
|
+
@cmd << '--before' << opts[:before] if opts[:before]
|
7
10
|
end
|
8
11
|
|
9
12
|
def to_s
|
10
|
-
|
13
|
+
`#{@cmd.join(' ')}`
|
11
14
|
end
|
12
15
|
|
13
16
|
class Commit
|
@@ -26,7 +29,6 @@ module Obst
|
|
26
29
|
AMD = /^[AMD]/
|
27
30
|
RENAME = /^R/
|
28
31
|
|
29
|
-
|
30
32
|
attr_reader :status, :name, :old_name
|
31
33
|
|
32
34
|
def initialize(line)
|
@@ -47,10 +49,13 @@ module Obst
|
|
47
49
|
def commits
|
48
50
|
Enumerator.new do |y|
|
49
51
|
batch = []
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
52
|
+
Open3.popen2(*@cmd) do |stdin, stdout, status_thread|
|
53
|
+
stdout.each_line do |line|
|
54
|
+
next batch << line unless line == EMPTY_LINE
|
55
|
+
y << Commit.new(batch)
|
56
|
+
batch.clear
|
57
|
+
end
|
58
|
+
raise 'fail to loop git log' unless status_thread.value.success?
|
54
59
|
end
|
55
60
|
y << Commit.new(batch)
|
56
61
|
end
|
data/lib/obst/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: obst
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- ken
|
@@ -13,7 +13,8 @@ dependencies: []
|
|
13
13
|
description:
|
14
14
|
email:
|
15
15
|
- block24block@gmail.com
|
16
|
-
executables:
|
16
|
+
executables:
|
17
|
+
- obst
|
17
18
|
extensions: []
|
18
19
|
extra_rdoc_files: []
|
19
20
|
files:
|
@@ -26,6 +27,7 @@ files:
|
|
26
27
|
- Rakefile
|
27
28
|
- bin/console
|
28
29
|
- bin/setup
|
30
|
+
- exe/obst
|
29
31
|
- lib/obst.rb
|
30
32
|
- lib/obst/git_log.rb
|
31
33
|
- lib/obst/group_by_days.rb
|