repotube 0.1.0 → 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/exe/repotube +19 -12
- data/lib/repotube.rb +31 -7
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: dfe47d60ab1d4645acfa7dcb74ce52b516ff2b54285d7df19c6c287d26057bd7
|
4
|
+
data.tar.gz: ff9dced1eedc5dac81c6260b045e4032e2c11e368abac27486f13279ddb84deb
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6cf569736f58df4bdaf919db36843a1e27dac2d54a0dcc27ebcb87eddc4fc4c8b9eb2f4dfb795facfd46a4e3607147567a2bbf39f8b2b8937274f06d38ccdad2
|
7
|
+
data.tar.gz: 6dd779e90ca2d1f05f888e6ebf072f8bfa95774ce3a5055ba2c98c05d7057ed248ad5a3e761e5a79bd39417337df78234f707af2a12741e5d92a330849a0d6e8
|
data/exe/repotube
CHANGED
@@ -10,21 +10,28 @@ Mercenary.program(:repotube) do |p|
|
|
10
10
|
p.version RepoTube::VERSION
|
11
11
|
p.description "YouTube time-marked URLs from Git commit timestamps"
|
12
12
|
p.syntax "repotube [options] <youtube short URL>"
|
13
|
-
p.option "start", "-s SECONDS", 'Set the timestamp for the first commit; defaults to 0'
|
14
|
-
p.option "offset", "-o SECONDS", "Set the offset, from the start of the video, for the first commit;\n defaults to 0"
|
15
|
-
p.option "first", "-f HASH", "Set the hash of the first commit in the video"
|
16
|
-
p.option "last", "-l HASH", "Set the hash of the last commit in the video"
|
13
|
+
p.option "start", "-s SECONDS", "--start SECONDS", 'Set the timestamp for the first commit; defaults to 0'
|
14
|
+
p.option "offset", "-o SECONDS", "--offset SECONDS", "Set the offset, from the start of the video, for the first commit;\n defaults to 0"
|
15
|
+
p.option "first", "-f HASH", "--first HASH", "Set the hash of the first commit in the video"
|
16
|
+
p.option "last", "-l HASH", "--last HASH", "Set the hash of the last commit in the video"
|
17
|
+
p.option "remote", "-r USERNAME/REPO", "--remote USERNAME/REPO", "Set the remote repo path on GitHub; auto-detected if repo has a remote"
|
18
|
+
p.option "readme", "-d FILENAME", "--readme FILENAME", "Set the README file name; defaults to README.md"
|
19
|
+
p.option "noreadme", "-n", "--no-readme", "Disable generating the README.md file"
|
17
20
|
|
18
21
|
p.action do |args, options|
|
19
|
-
|
20
|
-
|
21
|
-
puts "At least we're in a Git repo"
|
22
|
-
thing.process_commits
|
23
|
-
puts thing.commits
|
24
|
-
thing.output_index
|
25
|
-
else
|
26
|
-
puts "Not a Git repo!"
|
22
|
+
if args.empty?
|
23
|
+
puts "A YouTube URL is required"
|
27
24
|
abort
|
25
|
+
else
|
26
|
+
rt = RepoTube::Program.new(args,options)
|
27
|
+
if rt.is_repo?
|
28
|
+
rt.process_commits
|
29
|
+
rt.output_index
|
30
|
+
rt.output_readme
|
31
|
+
else
|
32
|
+
puts "Not a Git repo!"
|
33
|
+
abort
|
34
|
+
end
|
28
35
|
end
|
29
36
|
end
|
30
37
|
|
data/lib/repotube.rb
CHANGED
@@ -3,10 +3,9 @@
|
|
3
3
|
require 'pathname'
|
4
4
|
|
5
5
|
module RepoTube
|
6
|
-
VERSION = "0.
|
6
|
+
VERSION = "0.2.0"
|
7
7
|
|
8
8
|
class Program
|
9
|
-
#COMMITS = `git log #{RANGE} --date=unix --format=tformat:"%at|%h|%s" --reverse`
|
10
9
|
|
11
10
|
attr_reader :git_path, :url, :start, :offset, :first, :last, :commits
|
12
11
|
|
@@ -18,7 +17,9 @@ module RepoTube
|
|
18
17
|
@offset = set_value(options['offset'].to_i, 0)
|
19
18
|
@first = set_value(options['first'], "")
|
20
19
|
@last = set_value(options['last'], "HEAD")
|
21
|
-
|
20
|
+
@remote = set_value(options['remote'], discover_remote)
|
21
|
+
@readme = set_value(options['readme'],"README.md")
|
22
|
+
@noreadme = options['noreadme']
|
22
23
|
@commits = log_commits
|
23
24
|
|
24
25
|
end
|
@@ -28,20 +29,23 @@ module RepoTube
|
|
28
29
|
end
|
29
30
|
|
30
31
|
def log_commits
|
31
|
-
# TODO: include the range
|
32
32
|
if !@first.empty?
|
33
33
|
range = "#{@first}~1..#{@last}"
|
34
34
|
else
|
35
35
|
range = ""
|
36
36
|
end
|
37
37
|
if is_repo?
|
38
|
-
`git log #{range} --date=unix --format=tformat:"%at|%
|
38
|
+
`git log #{range} --date=unix --format=tformat:"%at|%H|%s" --reverse`
|
39
39
|
else
|
40
40
|
puts "Oops. repotube must be run in a Git repository"
|
41
41
|
abort
|
42
42
|
end
|
43
43
|
end
|
44
44
|
|
45
|
+
def discover_remote
|
46
|
+
`git remote -v`.split("\n")[0].match(/:(.+).git+/)[1]
|
47
|
+
end
|
48
|
+
|
45
49
|
def set_value(custom,default)
|
46
50
|
if custom.to_s.empty?
|
47
51
|
custom = default
|
@@ -74,10 +78,30 @@ module RepoTube
|
|
74
78
|
end
|
75
79
|
|
76
80
|
def output_index
|
77
|
-
puts "
|
81
|
+
puts "\nYouTube-Friendly Index by Commit"
|
82
|
+
puts "(cut and paste into the YouTube description box):\n\n"
|
83
|
+
@commits.each do |commit|
|
84
|
+
puts "#{Time.at(commit[:offset]).utc.strftime("%H:%M:%S")} #{commit[:cs]}"
|
85
|
+
end
|
86
|
+
puts "\n"
|
87
|
+
end
|
88
|
+
|
89
|
+
def output_markdown
|
90
|
+
markdown = "## [YouTube Video](#{@url}) Indexes by Commit\n"
|
78
91
|
@commits.each do |commit|
|
79
|
-
|
92
|
+
markdown += "* [#{commit[:cs]}](https://github.com/#{@remote}/commit/#{commit[:ch]}) [[Video](#{@url}?t=#{commit[:offset]})]\n"
|
93
|
+
end
|
94
|
+
markdown
|
95
|
+
end
|
96
|
+
|
97
|
+
def output_readme
|
98
|
+
# NB: Append mode will create a file if it doesn't exist
|
99
|
+
if @noreadme.nil?
|
100
|
+
File.open(@readme,'a') do |file|
|
101
|
+
file.write(output_markdown)
|
102
|
+
end
|
80
103
|
end
|
104
|
+
|
81
105
|
end
|
82
106
|
|
83
107
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: repotube
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Karl Stolley
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-05-
|
11
|
+
date: 2020-05-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: mercenary
|