gondler 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: 104db9f5d810e796f3ce77bc3a211ee3695fe4a7
4
- data.tar.gz: 4f784eec12d4fda11ba01b0304cdfe82bc1c9873
3
+ metadata.gz: cf6dd93e80946971588d4d6d2fc4751b9faf7cae
4
+ data.tar.gz: bda78e6d42392e0710635fea48fc6ae50d5604e5
5
5
  SHA512:
6
- metadata.gz: 2ab040815ddd335b2d102729ba88f206c267ec80965cd2ec50e4d89ff14b0dec214ca54d96a81b87dc23cc1419065195c93825c1532602eead2d78194d1eca05
7
- data.tar.gz: 684b5ba4aaef84aa40ad8f5f876ddaabb1bfe9fe2a4c561fea63510ebe3c0b5df8fbe7668432d9ca4a5263048947d88e57fa765f00ef23f90444fd280299e9d2
6
+ metadata.gz: 2c79866d55195c7d14b1c8f1ba1cd5683ed971571c88a193482dade7792ca95e033398241d33c456758ebf3b8770719209486da9f721b31c19e74aaaccb7de60
7
+ data.tar.gz: a34d1ccea61c134b31d3147b11cc756a0bd6a2a742c8b378589015b0598709650229ac67f7991b8cea3b0a8c20c171063ec5562028b69316e0909f787203b999
data/lib/gondler/cli.rb CHANGED
@@ -1,5 +1,4 @@
1
1
  require 'thor'
2
- require 'readline'
3
2
  require 'pathname'
4
3
  require 'gondler'
5
4
 
@@ -15,11 +14,13 @@ module Gondler
15
14
  end
16
15
 
17
16
  desc 'install', 'Install the dependecies specified in your Gomfile'
18
- method_option :without, :type => :array, :default => []
17
+ method_option :without, :type => :array, :default => nil
19
18
  def install
20
- gomfile.packages.each do |package|
21
- puts "Install #{package}"
22
- package.resolve
19
+ Gondler.without(options[:without] || []) do
20
+ gomfile.packages.each do |package|
21
+ puts "Install #{package}"
22
+ package.resolve
23
+ end
23
24
  end
24
25
  rescue Gondler::Package::InstallError => e
25
26
  puts e.message
@@ -28,12 +29,17 @@ module Gondler
28
29
 
29
30
  desc 'build', 'Build with dependencies specified in your Gomfile'
30
31
  def build(*args)
31
- invoke :exec, %w(go build) + args
32
+ invoke :go, %w(build) + args
32
33
  end
33
34
 
34
35
  desc 'test', 'Test with dependencies specified in your Gomfile'
35
36
  def test(*args)
36
- invoke :exec, %w(go test) + args
37
+ invoke :go, %w(test) + args
38
+ end
39
+
40
+ desc 'go', 'Execute go command in the context of Gondler'
41
+ def go(*args)
42
+ invoke :exec, %w(go) + args
37
43
  end
38
44
 
39
45
  desc 'exec', 'Execute a command in the context of Gondler'
@@ -49,24 +55,20 @@ module Gondler
49
55
  end
50
56
 
51
57
  desc 'list', 'Show all of the dependencies in the current bundle'
52
- method_option :without, :type => :array, :default => []
58
+ method_option :without, :type => :array, :default => nil
53
59
  def list
54
- Gondler.withouts = options[:without]
55
-
56
- puts 'Packages included by the gondler:'
57
- gomfile.packages.each do |package|
58
- puts " * #{package}"
60
+ Gondler.without(options[:without] || []) do
61
+ puts 'Packages included by the gondler:'
62
+ gomfile.packages.each do |package|
63
+ puts " * #{package}"
64
+ end
59
65
  end
60
66
  end
61
67
 
62
68
  desc 'repl', 'REPL in the context of Gondler'
63
69
  def repl
64
- buf = Readline.readline('> ', true)
65
- while buf
66
- Kernel.system(buf)
67
-
68
- buf = Readline.readline('> ', true)
69
- end
70
+ require 'gondler/repl'
71
+ Gondler::REPL.run
70
72
  end
71
73
 
72
74
  desc 'version', 'Print Gondler version'
@@ -75,8 +77,8 @@ module Gondler
75
77
  end
76
78
 
77
79
  desc 'env', 'Print Gondler environments'
78
- def env
79
- system('go env')
80
+ def env(*args)
81
+ invoke :go, %w(env) + args
80
82
  end
81
83
 
82
84
  private
@@ -45,7 +45,7 @@ module Gondler
45
45
  def installable?
46
46
  (
47
47
  (os.nil? || os.include?(Gondler.env.os)) &&
48
- (group.empty? || (Gondler.withouts & group).empty?)
48
+ (group.empty? || (Gondler.without & group).empty?)
49
49
  )
50
50
  end
51
51
 
@@ -0,0 +1,35 @@
1
+ require 'readline'
2
+ require 'gondler'
3
+
4
+ class Gondler::REPL
5
+ def self.run
6
+ new.run
7
+ end
8
+
9
+ def initialize
10
+ end
11
+
12
+ def run
13
+ while (buf = Readline.readline("> ", true))
14
+ execute(buf)
15
+ end
16
+ end
17
+
18
+ def execute(line)
19
+ cmd = line.match(/\A\w+/).to_s
20
+
21
+ if builtin.include?(cmd)
22
+ Gondler::CLI.start(line.split(/\s+/))
23
+ else
24
+ system(line)
25
+ end
26
+ end
27
+
28
+ def builtin
29
+ @builtin ||= builtin_commands.keys + ['help']
30
+ end
31
+
32
+ def builtin_commands
33
+ @builtin_commands ||= Gondler::CLI.commands
34
+ end
35
+ end
@@ -1,3 +1,3 @@
1
1
  module Gondler
2
- VERSION = '0.1.1'
2
+ VERSION = '0.1.2'
3
3
  end
data/lib/gondler.rb CHANGED
@@ -6,12 +6,13 @@ require 'gondler/gomfile'
6
6
 
7
7
  module Gondler
8
8
  class << self
9
- def withouts
10
- @withouts || []
11
- end
12
-
13
- def withouts=(withouts)
14
- @withouts = withouts.map(&:strip)
9
+ def without(_without = nil)
10
+ if block_given?
11
+ _without, @without = without, _without
12
+ yield
13
+ @without = _without
14
+ end
15
+ @without || []
15
16
  end
16
17
 
17
18
  def env
@@ -51,8 +51,7 @@ describe Gondler::Package do
51
51
  end
52
52
 
53
53
  context 'when development without' do
54
- before { Gondler.withouts = %w(development) }
55
- after { Gondler.withouts = [] }
54
+ around {|e| Gondler.without(%w(development)) { e.run } }
56
55
 
57
56
  let(:options) { { :group => 'development' } }
58
57
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gondler
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
  - Sho Kusano
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-10-13 00:00:00.000000000 Z
11
+ date: 2013-10-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake
@@ -61,6 +61,7 @@ files:
61
61
  - lib/gondler/env.rb
62
62
  - lib/gondler/gomfile.rb
63
63
  - lib/gondler/package.rb
64
+ - lib/gondler/repl.rb
64
65
  - lib/gondler/version.rb
65
66
  - spec/gondler/env_spec.rb
66
67
  - spec/gondler/gomfile_spec.rb