anything-gorepo 0.0.2 → 0.0.5
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/anything-gorepo.gemspec +1 -1
- data/bin/anything-gorepo +11 -6
- data/lib/anything-gorepo/version.rb +1 -1
- data/lib/anything-gorepo.rb +36 -3
- metadata +4 -5
- data/lib/anything-gorepo/finder.rb +0 -28
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0f785be26310765c4a249533ef3a0a66ea4159aa
|
4
|
+
data.tar.gz: 833b568c4c221ea7ab23abd0f1863b1e3b70c68a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c33da7e0f27cb852158380037079881c09b1660e30db5be5d5604ac4f6ab189e1c1decbaa4aa81f1f64cee9ef7b71d03724e72d9d870cda4a570b31f99fd7f46
|
7
|
+
data.tar.gz: 9fe227a9667f259ed57ac4f7f49bc40a01b266d72002570368bb9a0fcab5a923a52ee69cae3a8a7297086432e7e583ecc24e0c1c42cd2fab234289a98ed15461
|
data/anything-gorepo.gemspec
CHANGED
data/bin/anything-gorepo
CHANGED
@@ -13,11 +13,16 @@ end
|
|
13
13
|
|
14
14
|
require 'ruby-anything'
|
15
15
|
|
16
|
-
|
17
|
-
|
18
|
-
unless gopath
|
19
|
-
STDERR.puts e.message
|
20
|
-
exit 1
|
16
|
+
unless ENV['PATH'].split(':').any? { |path| File.exists?(File.join(path, 'go')) }
|
17
|
+
STDERR.puts 'go should be in $PATH'
|
21
18
|
end
|
22
19
|
|
23
|
-
|
20
|
+
goenv = `go env`.split("\n")
|
21
|
+
rgoroot = goenv.grep(/^GOROOT/).first
|
22
|
+
rgopath = goenv.grep(/^GOPATH/).first
|
23
|
+
|
24
|
+
find_paths = []
|
25
|
+
find_paths << File.join(rgoroot.gsub(/GOROOT="(.+)"/, '\1'), 'src', 'pkg') if rgoroot
|
26
|
+
find_paths << File.join(rgopath.gsub(/GOPATH="(.+)"/, '\1'), 'src') if rgopath
|
27
|
+
|
28
|
+
STDOUT.puts AnythingGorepo.find(find_paths)
|
data/lib/anything-gorepo.rb
CHANGED
@@ -1,8 +1,41 @@
|
|
1
1
|
require "anything-gorepo/version"
|
2
|
-
require "anything-gorepo/finder"
|
3
2
|
|
4
3
|
module AnythingGorepo
|
5
|
-
def self.find
|
6
|
-
|
4
|
+
def self.find paths
|
5
|
+
# key: package name
|
6
|
+
# value: package full path
|
7
|
+
pkgs = {}
|
8
|
+
|
9
|
+
paths.each do |path|
|
10
|
+
packages(path).map do |pkg|
|
11
|
+
pkgs[pkg.gsub(path + '/', '')] = pkg
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
pkgs[_anything_(pkgs.keys)]
|
16
|
+
end
|
17
|
+
|
18
|
+
def self.packages(src, stack = [])
|
19
|
+
directories(src).reduce([]) do |pkgs, p|
|
20
|
+
pkgs << File.join(src, p)
|
21
|
+
|
22
|
+
if directories(File.join(src, p)).empty?
|
23
|
+
pkgs
|
24
|
+
else
|
25
|
+
pkgs + packages(File.join(src, p))
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
private
|
31
|
+
|
32
|
+
def self.directories path
|
33
|
+
return [] if Dir.glob(File.join(path, "**/*.go")).empty?
|
34
|
+
|
35
|
+
Dir.entries(path).select do |filename|
|
36
|
+
File.directory?(File.join(path, filename))
|
37
|
+
end.select do |filename|
|
38
|
+
!filename.start_with?('.')
|
39
|
+
end
|
7
40
|
end
|
8
41
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: anything-gorepo
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Takatoshi Matsumoto
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2014-01-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -44,14 +44,14 @@ dependencies:
|
|
44
44
|
requirements:
|
45
45
|
- - '>='
|
46
46
|
- !ruby/object:Gem::Version
|
47
|
-
version: 0.0.
|
47
|
+
version: 0.0.5
|
48
48
|
type: :runtime
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
52
|
- - '>='
|
53
53
|
- !ruby/object:Gem::Version
|
54
|
-
version: 0.0.
|
54
|
+
version: 0.0.5
|
55
55
|
description: Find local go repositories in $GOPATH by anything interface.
|
56
56
|
email:
|
57
57
|
- toqoz403@gmail.com
|
@@ -68,7 +68,6 @@ files:
|
|
68
68
|
- anything-gorepo.gemspec
|
69
69
|
- bin/anything-gorepo
|
70
70
|
- lib/anything-gorepo.rb
|
71
|
-
- lib/anything-gorepo/finder.rb
|
72
71
|
- lib/anything-gorepo/version.rb
|
73
72
|
homepage: http://github.com/ToQoz/anything-gorepo
|
74
73
|
licenses:
|
@@ -1,28 +0,0 @@
|
|
1
|
-
module AnythingGorepo
|
2
|
-
class Finder
|
3
|
-
def initialize src
|
4
|
-
@repo_paths = []
|
5
|
-
directories(src).each do |host|
|
6
|
-
directories(File.join(src, host)).each do |user|
|
7
|
-
directories(File.join(src, host, user)).each do |repo|
|
8
|
-
@repo_paths << File.join(host, user, repo) # diplay without src
|
9
|
-
end
|
10
|
-
end
|
11
|
-
end
|
12
|
-
end
|
13
|
-
|
14
|
-
def find
|
15
|
-
_anything_(@repo_paths)
|
16
|
-
end
|
17
|
-
|
18
|
-
private
|
19
|
-
|
20
|
-
def directories path
|
21
|
-
Dir.entries(path).select do |filename|
|
22
|
-
File.directory?(File.join(path, filename))
|
23
|
-
end.select do |filename|
|
24
|
-
filename != '.' && filename != '..'
|
25
|
-
end
|
26
|
-
end
|
27
|
-
end
|
28
|
-
end
|