dpu 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/README.md +45 -0
- data/Rakefile +8 -1
- data/lib/dpu/version.rb +1 -1
- data/lib/dpu.rb +14 -4
- metadata +20 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2a227af81f9d54fd250484a739d28f09747ec598f7fe33a1f416741c2633abf5
|
4
|
+
data.tar.gz: e014ffa050d17dfc4e34552ea4f07c1ae0a91fed55f026624d877f53eddc48d2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f76f79cac63a88a84a8e78f9b0d3245716f8c8834493c05daa85daa442b62c0fbe2095d17358f7a19239a380430df44fa4f9fce54bb0d09877a642cf93cf5ba8
|
7
|
+
data.tar.gz: e09c2e510d33b688852376d77fa1e81ebf812ecc4645223914234f7800780dd6ca2b914a343e3eceae049d76bb4680db442f647c718a6ddfdeb680dcd50f9d84
|
data/README.md
CHANGED
@@ -1,5 +1,9 @@
|
|
1
1
|
# dpu: determine permanent URI
|
2
2
|
|
3
|
+
[![License X11](https://img.shields.io/badge/license-X11-blue.svg)](https://raw.githubusercontent.com/nishidayuya/dpu/master/LICENSE.txt)
|
4
|
+
[![Gem Version](https://badge.fury.io/rb/dpu.svg)](https://rubygems.org/gems/dpu)
|
5
|
+
[![Build Status](https://github.com/nishidayuya/dpu/workflows/ubuntu/badge.svg)](https://github.com/nishidayuya/dpu/actions?query=workflow%3Aubuntu)
|
6
|
+
|
3
7
|
`dpu` command shows us permanent source-code URI.
|
4
8
|
|
5
9
|
```console
|
@@ -31,6 +35,47 @@ Get permanent source code URI with line range:
|
|
31
35
|
$ dpu path_to_code start_line_number end_line_number
|
32
36
|
```
|
33
37
|
|
38
|
+
### Emacs integration
|
39
|
+
|
40
|
+
Write following code to your `.emacs`, and evaluate it.
|
41
|
+
|
42
|
+
```emacs-lisp
|
43
|
+
(define-key global-map (kbd "C-x L")
|
44
|
+
(lambda ()
|
45
|
+
(interactive)
|
46
|
+
(message
|
47
|
+
(concat
|
48
|
+
"Copied: "
|
49
|
+
(kill-new
|
50
|
+
(s-chomp
|
51
|
+
(shell-command-to-string
|
52
|
+
(concat
|
53
|
+
"dpu "
|
54
|
+
buffer-file-name
|
55
|
+
" "
|
56
|
+
(number-to-string (line-number-at-pos (region-beginning)))
|
57
|
+
(if mark-active (concat " " (number-to-string (line-number-at-pos (region-end)))))
|
58
|
+
)
|
59
|
+
)))))))
|
60
|
+
```
|
61
|
+
|
62
|
+
Then type `C-x L` to copy permanent URI. `C-y` to paste it.
|
63
|
+
|
64
|
+
### Textbringer integration
|
65
|
+
|
66
|
+
```ruby
|
67
|
+
define_command(:copy_permanent_uri, doc: "Copy permanent URI") do
|
68
|
+
require "dpu"
|
69
|
+
b = Buffer.current
|
70
|
+
uri = Dpu.determine_permanent_uri(Pathname(b.file_name), b.current_line, nil)
|
71
|
+
KILL_RING.push(uri)
|
72
|
+
Clipboard.copy(uri) if CLIPBOARD_AVAILABLE
|
73
|
+
message("Copied: #{uri}")
|
74
|
+
end
|
75
|
+
|
76
|
+
GLOBAL_MAP.define_key("\C-xL", :copy_permanent_uri)
|
77
|
+
```
|
78
|
+
|
34
79
|
## Contributing
|
35
80
|
|
36
81
|
Bug reports and pull requests are welcome on GitHub at https://github.com/nishidayuya/dpu .
|
data/Rakefile
CHANGED
data/lib/dpu/version.rb
CHANGED
data/lib/dpu.rb
CHANGED
@@ -8,6 +8,14 @@ module Dpu
|
|
8
8
|
|
9
9
|
class << self
|
10
10
|
GITHUB_REPOSITORY_URI_TEMPLATE = "https://github.com/%{account_name}/%{repository_name}"
|
11
|
+
REMOTE_URL_PATTERN = [
|
12
|
+
%r{\Agit://github\.com/(?<account_name>[^/]+)/(?<repository_name>.+)(?=\.git)},
|
13
|
+
%r{\Ahttps?://github\.com/(?<account_name>[^/]+)/(?<repository_name>.+)(?=\.git)},
|
14
|
+
%r{\Agit@github\.com:(?<account_name>[^/]+)/(?<repository_name>.+)(?=\.git)},
|
15
|
+
%r{\Assh://git@github\.com/(?<account_name>[^/]+)/(?<repository_name>.+)(?=\.git)},
|
16
|
+
].then { |patterns|
|
17
|
+
Regexp.union(*patterns)
|
18
|
+
}
|
11
19
|
|
12
20
|
def determine_permanent_uri(path, start_line_number, end_line_number)
|
13
21
|
relative_path = determine_relative_path(path)
|
@@ -44,14 +52,16 @@ module Dpu
|
|
44
52
|
stdout = run_command("git remote get-url origin", chdir: path.dirname)
|
45
53
|
repository_http_or_ssh_url = stdout.chomp
|
46
54
|
|
47
|
-
md =
|
55
|
+
md = REMOTE_URL_PATTERN.match(repository_http_or_ssh_url)
|
48
56
|
if !md
|
49
57
|
return URI(repository_http_or_ssh_url)
|
50
58
|
end
|
51
59
|
|
52
|
-
|
53
|
-
|
54
|
-
|
60
|
+
url = GITHUB_REPOSITORY_URI_TEMPLATE % {
|
61
|
+
account_name: md[:account_name],
|
62
|
+
repository_name: md[:repository_name],
|
63
|
+
}
|
64
|
+
return URI(url)
|
55
65
|
end
|
56
66
|
|
57
67
|
def determine_commit_id(path)
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: dpu
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Yuya.Nishida.
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-
|
11
|
+
date: 2023-06-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: debug
|
@@ -24,7 +24,21 @@ dependencies:
|
|
24
24
|
- - ">="
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '0'
|
27
|
-
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: test-unit
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
description:
|
28
42
|
email:
|
29
43
|
- yuya@j96.org
|
30
44
|
executables:
|
@@ -46,7 +60,7 @@ licenses: []
|
|
46
60
|
metadata:
|
47
61
|
homepage_uri: https://github.com/nishidayuya/dpu
|
48
62
|
source_code_uri: https://github.com/nishidayuya/dpu
|
49
|
-
post_install_message:
|
63
|
+
post_install_message:
|
50
64
|
rdoc_options: []
|
51
65
|
require_paths:
|
52
66
|
- lib
|
@@ -62,7 +76,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
62
76
|
version: '0'
|
63
77
|
requirements: []
|
64
78
|
rubygems_version: 3.4.10
|
65
|
-
signing_key:
|
79
|
+
signing_key:
|
66
80
|
specification_version: 4
|
67
81
|
summary: determine permanent URI
|
68
82
|
test_files: []
|