vimgolf 0.3.0 → 0.4.0

Sign up to get free protection for your applications and to get access to all the features.
data/lib/vimgolf/ui.rb CHANGED
@@ -1,7 +1,14 @@
1
+ require 'highline'
2
+
1
3
  module VimGolf
2
4
  class CLI
3
5
  class UI < Thor::Base.shell
4
6
 
7
+ def initialize
8
+ super
9
+ @hl = HighLine.new($stdin)
10
+ end
11
+
5
12
  def error(name, message = nil)
6
13
  begin
7
14
  orig_out, $stdout = $stdout, $stderr
@@ -43,22 +50,31 @@ module VimGolf
43
50
  end
44
51
  end
45
52
 
46
- def ask(message, password = false)
53
+ def ask_question(message, options = {})
47
54
  begin
48
- require 'highline'
49
- @hl ||= HighLine.new($stdin)
50
- if not $stdin.tty?
51
- @hl.ask(message)
52
- elsif password
53
- @hl.ask(message) {|q| q.echo = "*" }
54
- else
55
- @hl.ask(message) {|q| q.readline = true }
55
+ message = color_string(message, options[:type])
56
+ details = Proc.new do |q|
57
+ q.readline = !$stdin.tty?
56
58
  end
59
+ @hl.ask(message, options[:choices] || [], &details)
57
60
  rescue EOFError
58
61
  return ''
59
62
  end
60
63
  end
61
64
 
65
+ def color_string(str, type)
66
+ @hl.color(
67
+ str,
68
+ case type
69
+ when :info then :green
70
+ when :warn then :yellow
71
+ when :error then :red
72
+ when :debug then :cyan
73
+ else nil
74
+ end
75
+ )
76
+ end
77
+
62
78
  def print_envs(apps, default_env_name = nil, simple = false)
63
79
  if simple
64
80
  envs = apps.map{ |a| a.environments }
@@ -113,4 +129,4 @@ module VimGolf
113
129
 
114
130
  end
115
131
  end
116
- end
132
+ end
@@ -1,3 +1,3 @@
1
1
  module Vimgolf
2
- VERSION = "0.3.0"
2
+ VERSION = "0.4.0"
3
3
  end
@@ -0,0 +1,31 @@
1
+ require "helper"
2
+ require "tmpdir"
3
+ require "fileutils"
4
+
5
+ describe VimGolf::Challenge do
6
+
7
+ before :each do
8
+ @dir = Dir.mktmpdir("vimgolf_test_")
9
+ VimGolf::Challenge.path(@dir)
10
+ end
11
+
12
+ after :each do
13
+ FileUtils.remove_entry_secure(@dir)
14
+ end
15
+
16
+ it "should raise error on invalid challenge" do
17
+ lambda { VimGolf::Challenge.new('invalidID').download }.should raise_error
18
+ end
19
+
20
+ it "should return type of challenge on success" do
21
+ challenge = VimGolf::Challenge.new('4d1a1c36567bac34a9000002')
22
+ challenge.download
23
+ challenge.type.should == "rb"
24
+ end
25
+
26
+ it "should raise error on invalid upload id" do
27
+ lambda { VimGolf::Challenge.new('invalidID').upload }.should raise_error
28
+ end
29
+ end
30
+
31
+
data/spec/cli_spec.rb CHANGED
@@ -22,20 +22,4 @@ describe VimGolf do
22
22
  out.should include("launch")
23
23
  end
24
24
 
25
- describe "download / upload challenge" do
26
- let(:c) { VimGolf::CLI.new }
27
-
28
- it "should raise error on invalid challenge" do
29
- lambda { c.download('invalidID') }.should raise_error
30
- end
31
-
32
- it "should return type of challenge on success" do
33
- c.download('4d1a1c36567bac34a9000002').should == "rb"
34
- end
35
-
36
- it "should raise error on invalid upload id" do
37
- lambda { c.upload('invalidID') }.should raise_error
38
- end
39
- end
40
-
41
- end
25
+ end
data/spec/helper.rb CHANGED
@@ -2,7 +2,7 @@ require 'rubygems'
2
2
  require 'bundler/setup'
3
3
 
4
4
  require 'rspec'
5
- require 'lib/vimgolf'
5
+ require 'vimgolf'
6
6
 
7
7
  require 'stringio'
8
8
 
data/spec/keylog_spec.rb CHANGED
@@ -1,15 +1,16 @@
1
1
  require "helper"
2
2
 
3
+ include VimGolf
4
+
3
5
  describe VimGolf::Keylog do
4
- include VimGolf
5
6
 
6
7
  Dir['spec/fixtures/*'].each do |f|
7
8
  it "should parse #{f} logfile" do
8
- lambda { Keylog.convert(IO.read(f)) }.should_not raise_error
9
+ lambda { Keylog.new(IO.read(f)).convert }.should_not raise_error
9
10
  end
10
11
 
11
12
  it "should score #{f} logfile" do
12
- lambda { Keylog.score(IO.read(f)) }.should_not raise_error
13
+ lambda { Keylog.new(IO.read(f)).convert }.should_not raise_error
13
14
  end
14
15
  end
15
16
  end
data/vimgolf.gemspec CHANGED
@@ -14,10 +14,10 @@ Gem::Specification.new do |s|
14
14
 
15
15
  s.rubyforge_project = "vimgolf"
16
16
  s.add_dependency "thor", ">= 0.14.6"
17
- s.add_dependency "json"
18
17
  s.add_dependency "highline"
19
18
 
20
19
  s.add_development_dependency "rspec"
20
+ s.add_development_dependency "rake"
21
21
 
22
22
  s.files = `git ls-files`.split("\n")
23
23
  s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
@@ -26,11 +26,12 @@ Gem::Specification.new do |s|
26
26
 
27
27
  s.post_install_message = %{
28
28
  ------------------------------------------------------------------------------
29
- Thank you for installing vimgolf-#{Vimgolf::VERSION}.
29
+ Thank you for installing vimgolf-#{Vimgolf::VERSION}.
30
30
 
31
31
  0.1.3: custom vimgolf .vimrc file to help level the playing field
32
32
  0.2.0: proxy support, custom diffs + proper vimscript parser/scoring
33
33
  0.3.0: improve windows support, switch to YAML to remove c-ext dependency
34
+ 0.4.0: improved diff/retry CLI, emacs support: http://bit.ly/yHgOPF
34
35
 
35
36
  *NOTE*: please re-run "vimgolf setup" prior to playing!
36
37
 
metadata CHANGED
@@ -1,86 +1,68 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: vimgolf
3
- version: !ruby/object:Gem::Version
4
- prerelease: false
5
- segments:
6
- - 0
7
- - 3
8
- - 0
9
- version: 0.3.0
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.4.0
5
+ prerelease:
10
6
  platform: ruby
11
- authors:
7
+ authors:
12
8
  - Ilya Grigorik
13
9
  autorequire:
14
10
  bindir: bin
15
11
  cert_chain: []
16
-
17
- date: 2011-01-06 00:00:00 -05:00
18
- default_executable:
19
- dependencies:
20
- - !ruby/object:Gem::Dependency
12
+ date: 2012-03-17 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
21
15
  name: thor
22
- prerelease: false
23
- requirement: &id001 !ruby/object:Gem::Requirement
16
+ requirement: &2153464140 !ruby/object:Gem::Requirement
24
17
  none: false
25
- requirements:
26
- - - ">="
27
- - !ruby/object:Gem::Version
28
- segments:
29
- - 0
30
- - 14
31
- - 6
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
32
21
  version: 0.14.6
33
22
  type: :runtime
34
- version_requirements: *id001
35
- - !ruby/object:Gem::Dependency
36
- name: json
37
23
  prerelease: false
38
- requirement: &id002 !ruby/object:Gem::Requirement
39
- none: false
40
- requirements:
41
- - - ">="
42
- - !ruby/object:Gem::Version
43
- segments:
44
- - 0
45
- version: "0"
46
- type: :runtime
47
- version_requirements: *id002
48
- - !ruby/object:Gem::Dependency
24
+ version_requirements: *2153464140
25
+ - !ruby/object:Gem::Dependency
49
26
  name: highline
50
- prerelease: false
51
- requirement: &id003 !ruby/object:Gem::Requirement
27
+ requirement: &2153463680 !ruby/object:Gem::Requirement
52
28
  none: false
53
- requirements:
54
- - - ">="
55
- - !ruby/object:Gem::Version
56
- segments:
57
- - 0
58
- version: "0"
29
+ requirements:
30
+ - - ! '>='
31
+ - !ruby/object:Gem::Version
32
+ version: '0'
59
33
  type: :runtime
60
- version_requirements: *id003
61
- - !ruby/object:Gem::Dependency
34
+ prerelease: false
35
+ version_requirements: *2153463680
36
+ - !ruby/object:Gem::Dependency
62
37
  name: rspec
38
+ requirement: &2153463180 !ruby/object:Gem::Requirement
39
+ none: false
40
+ requirements:
41
+ - - ! '>='
42
+ - !ruby/object:Gem::Version
43
+ version: '0'
44
+ type: :development
63
45
  prerelease: false
64
- requirement: &id004 !ruby/object:Gem::Requirement
46
+ version_requirements: *2153463180
47
+ - !ruby/object:Gem::Dependency
48
+ name: rake
49
+ requirement: &2153462600 !ruby/object:Gem::Requirement
65
50
  none: false
66
- requirements:
67
- - - ">="
68
- - !ruby/object:Gem::Version
69
- segments:
70
- - 0
71
- version: "0"
51
+ requirements:
52
+ - - ! '>='
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
72
55
  type: :development
73
- version_requirements: *id004
56
+ prerelease: false
57
+ version_requirements: *2153462600
74
58
  description: CLI client for vimgolf.com
75
- email:
59
+ email:
76
60
  - ilya@igvita.com
77
- executables:
61
+ executables:
78
62
  - vimgolf
79
63
  extensions: []
80
-
81
64
  extra_rdoc_files: []
82
-
83
- files:
65
+ files:
84
66
  - .gitignore
85
67
  - .rspec
86
68
  - Gemfile
@@ -88,12 +70,17 @@ files:
88
70
  - README.md
89
71
  - Rakefile
90
72
  - bin/vimgolf
73
+ - emacs/README.md
74
+ - emacs/ROADMAP.md
75
+ - emacs/vimgolf.el
91
76
  - lib/vimgolf.rb
77
+ - lib/vimgolf/challenge.rb
92
78
  - lib/vimgolf/cli.rb
93
79
  - lib/vimgolf/config.rb
94
80
  - lib/vimgolf/keylog.rb
95
81
  - lib/vimgolf/ui.rb
96
82
  - lib/vimgolf/version.rb
83
+ - spec/challenge_spec.rb
97
84
  - spec/cli_spec.rb
98
85
  - spec/fixtures/4d19832d8ae121365c00000b.log
99
86
  - spec/fixtures/4d1a1c36567bac34a9000002.log
@@ -103,47 +90,55 @@ files:
103
90
  - spec/helper.rb
104
91
  - spec/keylog_spec.rb
105
92
  - vimgolf.gemspec
106
- has_rdoc: true
107
93
  homepage: http://github.com/igrigorik/vimgolf
108
94
  licenses: []
95
+ post_install_message: ! '
109
96
 
110
- post_install_message: "\n\
111
- ------------------------------------------------------------------------------\n\
112
- Thank you for installing vimgolf-0.3.0. \n\n\
113
- 0.1.3: custom vimgolf .vimrc file to help level the playing field\n\
114
- 0.2.0: proxy support, custom diffs + proper vimscript parser/scoring\n\
115
- 0.3.0: improve windows support, switch to YAML to remove c-ext dependency\n\n\
116
- *NOTE*: please re-run \"vimgolf setup\" prior to playing!\n\n\
117
- For more information, rules & updates: http://vimgolf.com/about\n\
118
- ------------------------------------------------------------------------------\n"
119
- rdoc_options: []
97
+ ------------------------------------------------------------------------------
120
98
 
121
- require_paths:
99
+ Thank you for installing vimgolf-0.4.0.
100
+
101
+
102
+ 0.1.3: custom vimgolf .vimrc file to help level the playing field
103
+
104
+ 0.2.0: proxy support, custom diffs + proper vimscript parser/scoring
105
+
106
+ 0.3.0: improve windows support, switch to YAML to remove c-ext dependency
107
+
108
+ 0.4.0: improved diff/retry CLI, emacs support: http://bit.ly/yHgOPF
109
+
110
+
111
+ *NOTE*: please re-run "vimgolf setup" prior to playing!
112
+
113
+
114
+ For more information, rules & updates: http://vimgolf.com/about
115
+
116
+ ------------------------------------------------------------------------------
117
+
118
+ '
119
+ rdoc_options: []
120
+ require_paths:
122
121
  - lib
123
- required_ruby_version: !ruby/object:Gem::Requirement
122
+ required_ruby_version: !ruby/object:Gem::Requirement
124
123
  none: false
125
- requirements:
126
- - - ">="
127
- - !ruby/object:Gem::Version
128
- segments:
129
- - 0
130
- version: "0"
131
- required_rubygems_version: !ruby/object:Gem::Requirement
124
+ requirements:
125
+ - - ! '>='
126
+ - !ruby/object:Gem::Version
127
+ version: '0'
128
+ required_rubygems_version: !ruby/object:Gem::Requirement
132
129
  none: false
133
- requirements:
134
- - - ">="
135
- - !ruby/object:Gem::Version
136
- segments:
137
- - 0
138
- version: "0"
130
+ requirements:
131
+ - - ! '>='
132
+ - !ruby/object:Gem::Version
133
+ version: '0'
139
134
  requirements: []
140
-
141
135
  rubyforge_project: vimgolf
142
- rubygems_version: 1.3.7
136
+ rubygems_version: 1.8.10
143
137
  signing_key:
144
138
  specification_version: 3
145
139
  summary: CLI client for vimgolf.com
146
- test_files:
140
+ test_files:
141
+ - spec/challenge_spec.rb
147
142
  - spec/cli_spec.rb
148
143
  - spec/fixtures/4d19832d8ae121365c00000b.log
149
144
  - spec/fixtures/4d1a1c36567bac34a9000002.log
@@ -152,3 +147,4 @@ test_files:
152
147
  - spec/fixtures/4d1a34ccfa85f32065000004.log
153
148
  - spec/helper.rb
154
149
  - spec/keylog_spec.rb
150
+ has_rdoc: