jank 0.1.1 → 0.1.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: a3e278250ebc32f5c970ec7f2f4ae840d8706237
4
- data.tar.gz: 7da75b202884aa2ab651ff9a139fd9560ef27862
3
+ metadata.gz: 37759091c326beb11e7deaa86dfa71e40f579e01
4
+ data.tar.gz: bd84b8681b031c2eb3f4a828c811dd0acd16159b
5
5
  SHA512:
6
- metadata.gz: 97f5a4017776d8de5677aa2b3ad92daeb165b48f416afdbaf4bd17385508fafb7812ea87480d000b013c5750e2552430e47b973507359c4650a4423e41b668f7
7
- data.tar.gz: 0d5066f0f73ecc0887ea0b9f4a58a755caa0d89992a687f123de9a2b587a062643cd5828d1312b556f6f4387305a90198e5a1e0dc250d1e6f9719a6b0d7940b4
6
+ metadata.gz: eb5a6145b23e9f61b50d603df813f0e56f31d6c65ee410be7ed5d3c009fb301ac776b9891487b73f13da287d326be1215e1247a5dee90efb9fb8bad7049fccab
7
+ data.tar.gz: 62fedca00dd8892439d5fd672b1ee37cc5472703f82f204b200d1ec189df9f78a6dc26787d4b80bfd7c6a213925ce0d43de198d9710a17a8342eefaeb3278986
data/lib/base.rb CHANGED
@@ -3,4 +3,4 @@ require_relative '../lib/debug'
3
3
  require_relative '../lib/executor'
4
4
  require_relative '../lib/janker'
5
5
 
6
- Jank.debug_log("#{$0} #{ARGV.inspect}")
6
+ Jank.debug_log("\n#{$0} #{ARGV.inspect}")
data/lib/config.rb CHANGED
@@ -72,8 +72,6 @@ module Jank
72
72
  else
73
73
  @env['GOPATH'] = (@janked_gopaths + @gopaths).uniq.join(':')
74
74
  end
75
-
76
- Jank.debug_log("GOPATH = #{@env['GOPATH']}")
77
75
  end
78
76
 
79
77
  private
data/lib/executor.rb CHANGED
@@ -6,35 +6,33 @@ module Jank
6
6
  @config = c
7
7
  end
8
8
 
9
- def apply_package(args)
10
- return args if @config.package == nil
11
-
12
- new_args = Array.new
13
- package_applied = false
9
+ def execute(cmd, args)
10
+ if @config.janked
11
+ Dir.chdir(@config.janked_gopath) do
12
+ janked_args = Array.new
13
+ args.each do |a|
14
+ if a.start_with? @config.janked_local_path
15
+ janked_args << a.sub(@config.janked_local_path, @config.janked_gopath)
16
+ else
17
+ janked_args << a
18
+ end
19
+ end
14
20
 
15
- args.each do |a|
16
- case a
17
- when /^\./
18
- package_applied = true
19
- new_args << a.gsub(/^\./, @config.package)
20
- when /\//
21
- package_applied = true
22
- new_args << a
23
- when /\.go$/
24
- package_applied = true
25
- new_args << a
26
- else
27
- new_args << a
21
+ Jank.debug_log("🚀 #{@config.janked_gopath}> #{cmd} #{janked_args.inspect}")
22
+ run(cmd, janked_args)
28
23
  end
24
+ else
25
+ Jank.debug_log("🚀 #{cmd} #{args.inspect}")
26
+ run(cmd, args)
29
27
  end
30
-
31
- new_args << @config.package if !package_applied
32
- new_args
33
28
  end
34
29
 
35
- def execute(cmd, args)
36
- Jank.debug_log("🚀 #{cmd} #{args.inspect}")
37
- Kernel.exec(@config.env, cmd, *args)
30
+ def run(cmd, args)
31
+ IO.popen(@config.env, [cmd, *args]) do |pipe|
32
+ while line = pipe.gets
33
+ puts line
34
+ end
35
+ end
38
36
  end
39
37
  end
40
- end
38
+ end
data/lib/go_command.rb CHANGED
@@ -2,42 +2,42 @@ require_relative 'command'
2
2
 
3
3
  module Jank
4
4
  class GoCommand < Command
5
- def run_go
6
- @janker.link
5
+ def go
7
6
  @exec.go(@args)
8
7
  end
9
8
 
10
- def run_go_with_janked_package
9
+ def go_sync
11
10
  @janker.link
12
- @exec.go( @exec.apply_package(@args) )
11
+ @exec.go(@args)
12
+ @janker.sync_results
13
13
  end
14
14
 
15
15
  def build_command
16
- run_go_with_janked_package
16
+ go_sync
17
17
  end
18
18
 
19
19
  def clean_command
20
- run_go_with_janked_package
20
+ go_sync
21
21
  end
22
22
 
23
23
  def env_command
24
- run_go
24
+ go
25
25
  end
26
26
 
27
27
  def fix_command
28
- run_go_with_janked_package
28
+ go_sync
29
29
  end
30
30
 
31
31
  def fmt_command
32
- run_go_with_janked_package
32
+ go_sync
33
33
  end
34
34
 
35
35
  def help
36
- run_go
36
+ go
37
37
  end
38
38
 
39
39
  def generate_command
40
- run_go_with_janked_package
40
+ go_sync
41
41
  end
42
42
 
43
43
  def get_command
@@ -45,20 +45,19 @@ module Jank
45
45
  end
46
46
 
47
47
  def install_command
48
- run_go_with_janked_package
48
+ go_sync
49
49
  end
50
50
 
51
51
  def list_command
52
- @janker.link
53
- run_go_with_janked_package
52
+ go_sync
54
53
  end
55
54
 
56
55
  def run_command
57
- run_go
56
+ go_sync
58
57
  end
59
58
 
60
59
  def test_command
61
- run_go_with_janked_package
60
+ go_sync
62
61
  end
63
62
 
64
63
  def tool_command
@@ -66,11 +65,11 @@ module Jank
66
65
  end
67
66
 
68
67
  def version_command
69
- run_go
68
+ go
70
69
  end
71
70
 
72
71
  def vet_command
73
- run_go_with_janked_package
72
+ go_sync
74
73
  end
75
74
  end
76
75
  end
@@ -7,7 +7,7 @@ module Jank
7
7
 
8
8
  @gocode = ENV['JANK_GOCODE'] || `which gocode`.chomp
9
9
  if @gocode.empty?
10
- puts "gocode is not installed. See https://github.com/nsf/gocode"
10
+ STDERR.puts "gocode is not installed. See https://github.com/nsf/gocode"
11
11
  exit(1)
12
12
  end
13
13
  end
@@ -15,6 +15,7 @@ module Jank
15
15
  def dispatch
16
16
  @janker.link
17
17
  @exec.execute(@gocode, @args)
18
+ @janker.sync_results
18
19
  end
19
20
  end
20
21
  end
data/lib/godoc_command.rb CHANGED
@@ -7,7 +7,7 @@ module Jank
7
7
 
8
8
  @godoc = ENV['JANK_GODOC'] || `which godoc`.chomp
9
9
  if @godoc.empty?
10
- puts "gocode is not installed. Run:\n go get code.google.com/p/go.tools/cmd/godoc"
10
+ STDERR.puts "gocode is not installed. Run:\n go get code.google.com/p/go.tools/cmd/godoc"
11
11
  exit(1)
12
12
  end
13
13
  end
@@ -15,6 +15,7 @@ module Jank
15
15
  def dispatch
16
16
  @janker.link
17
17
  @exec.execute(@godoc, @args)
18
+ @janker.sync_results
18
19
  end
19
20
  end
20
21
  end
data/lib/gofmt_command.rb CHANGED
@@ -7,7 +7,7 @@ module Jank
7
7
 
8
8
  @gofmt = ENV['JANK_GOFMT'] || `which gofmt`.chomp
9
9
  if @gofmt.empty?
10
- puts "gofmt is not installed. See: https://golang.org/cmd/gofmt/"
10
+ STDERR.puts "gofmt is not installed. See: https://golang.org/cmd/gofmt/"
11
11
  exit(1)
12
12
  end
13
13
  end
@@ -15,6 +15,7 @@ module Jank
15
15
  def dispatch
16
16
  @janker.link
17
17
  @exec.execute(@gofmt, @args)
18
+ @janker.sync_results
18
19
  end
19
20
  end
20
21
  end
@@ -7,7 +7,7 @@ module Jank
7
7
 
8
8
  @goimports = ENV['JANK_GOIMPORTS'] || `which goimports`.chomp
9
9
  if @goimports.empty?
10
- puts "goimports is not installed. See http://godoc.org/golang.org/x/tools/cmd/goimports"
10
+ STDERR.puts "goimports is not installed. See http://godoc.org/golang.org/x/tools/cmd/goimports"
11
11
  exit(1)
12
12
  end
13
13
  end
@@ -15,6 +15,7 @@ module Jank
15
15
  def dispatch
16
16
  @janker.link
17
17
  @exec.execute(@goimports, @args)
18
+ @janker.sync_results
18
19
  end
19
20
  end
20
- end
21
+ end
@@ -7,15 +7,15 @@ module Jank
7
7
 
8
8
  @golint = ENV['JANK_GOLINT'] || `which golint`.chomp
9
9
  if @golint.empty?
10
- puts "golint is not installed. See https://github.com/golang/lint"
10
+ STDERR.puts "golint is not installed. See https://github.com/golang/lint"
11
11
  exit(1)
12
12
  end
13
13
  end
14
14
 
15
15
  def dispatch
16
- @args = @exec.apply_package(@args)
17
16
  @janker.link
18
17
  @exec.execute(@golint, @args)
18
+ @janker.sync_results
19
19
  end
20
20
  end
21
- end
21
+ end
data/lib/jank_command.rb CHANGED
@@ -24,15 +24,14 @@ module Jank
24
24
  end
25
25
 
26
26
  def package_command
27
- @janker.sync_packages
28
-
29
27
  if ARGV[1] == '-r' || ARGV[1] == '--reverse'
30
28
  package = ARGV[2]
31
29
  if package == nil
32
- puts package_help_text
30
+ STDERR.puts puts package_help_text
33
31
  exit(1)
34
32
  end
35
33
 
34
+ @janker.sync_packages
36
35
  puts @janker.location_of_package(package)
37
36
  exit
38
37
  end
@@ -43,6 +42,7 @@ module Jank
43
42
  exit
44
43
  end
45
44
 
45
+ @janker.sync_packages
46
46
  puts @janker.package_for_location path
47
47
  end
48
48
 
data/lib/janker.rb CHANGED
@@ -113,13 +113,19 @@ module Jank
113
113
  end
114
114
  end
115
115
 
116
+ def sync_results()
117
+ return if !@config.janked
118
+ rsync(@config.janked_gopath, @config.janked_local_path)
119
+ end
120
+
116
121
  def rsync(src, dest)
117
122
  return if src == dest
118
123
 
119
- exclude = %w{JANKED .bzr .bzringore .hg .hgignore .git .gitignore .nfs}
124
+ exclude = %w{.jank JANKED .bzr .bzringore .hg .hgignore .git .gitignore .nfs}
120
125
  opts = "--delete"
121
126
  exclude.each {|e| opts += " --exclude #{e}"}
122
127
 
128
+ Jank.debug_log("🚀 rsync -az #{opts} \"#{src}/\" \"#{dest}\"")
123
129
  `rsync -az #{opts} "#{src}/" "#{dest}"`
124
130
  end
125
131
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jank
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Fred McCann
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-05-18 00:00:00.000000000 Z
11
+ date: 2015-05-19 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: Jank is a suite of scripts that wrap the go command and a collection
14
14
  of utility commands for go programming. Jank will rewrite the gopath dynamically