vimgolf 0.4.1 → 0.4.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,3 @@
1
+ [submodule "emacs/util/espuds"]
2
+ path = emacs/util/espuds
3
+ url = https://github.com/rejeep/espuds
@@ -0,0 +1,24 @@
1
+ Feature: VimGolf Browser
2
+ In order to browse and select VimGolf entries
3
+ As a user
4
+ I want to use the VimGolf browser
5
+
6
+ Scenario: Press TAB on entry to view description
7
+ Given I open the vimgolf browser
8
+ Then I should not see "Continuing from the last challenge"
9
+ When I press "TAB"
10
+ Then I should see "Continuing from the last challenge"
11
+ When I press "TAB"
12
+ Then I should not see "Continuing from the last challenge"
13
+
14
+ Scenario: Move through the browse list
15
+ Given I open the vimgolf browser
16
+ Then the cursor should be before "Compl"
17
+ When I press "n"
18
+ Then the cursor should be before "Make "
19
+ When I press "n"
20
+ Then the cursor should be before "Conve"
21
+ When I press "p"
22
+ Then the cursor should be before "Make "
23
+ When I press "p"
24
+ Then the cursor should be before "Compl"
@@ -0,0 +1,53 @@
1
+ ;; This file contains your project specific step definitions. All
2
+ ;; files in this directory whose names end with "-steps.el" will be
3
+ ;; loaded automatically by Ecukes.
4
+
5
+ (Given "^I open the vimgolf browser$"
6
+ (lambda ()
7
+ (setq *vimgolf-browse-list*
8
+ '(("50128129201f450002000027"
9
+ "Complete the circuit grid!"
10
+ "Continuing from the last challenge, add additional rows to the grid. Change each of the names from 'A1'...'A10' to 'B1'...'B10', 'C1'...'C10', etc, and for each new row add 0.7 to the X values in the (X Y) at the end of each line. ")
11
+ ("50127eba201f450002000024"
12
+ "Make the circuit grid!"
13
+ "Copy this command for a circuit layout program to create 10 total smd commands. Increment the number in quotes to name each pad, and add 0.7 to each of the (X Y) coordinates at the end of each line.")
14
+ ("500855e60599d90002000073"
15
+ "Convert pandoc unordered list to a numbered list"
16
+ "I know it's possible to use #. in pandoc to auto-generate numbered lists, but then it's not easy to tell how many items there are when reading it in Markdown. How fast can you make the switch?")
17
+ ("4fe62f8a8b2f800001000043"
18
+ "Cleanining up 80 column concatenated text"
19
+ "1. Put the whole query on one line, remove the concatenation operators
20
+ ("4d1b4ac3c58eaa2a8a0005c2"
21
+ "Ruby 1.9 compat"
22
+ "Remember when Ruby supported `when <expr> :`? Well, it doesn't in 1.9, so let's make sure we use `then`, without ruining our lovely new hash syntax!")
23
+ ))
24
+ (vimgolf-browse)))
25
+
26
+ (When "^I show the description$"
27
+ (lambda ()
28
+ (vimgolf-show-description)))
29
+
30
+ (Given "^I have \"\\(.+\\)\"$"
31
+ (lambda (something)
32
+ ;; Do something
33
+ ))
34
+
35
+ (When "^I have \"\\(.+\\)\"$"
36
+ (lambda (something)
37
+ ;; Do something
38
+ ))
39
+
40
+ (Then "^I should have \"\\(.+\\)\"$"
41
+ (lambda (something)
42
+ ;; Do something
43
+ ))
44
+
45
+ (And "^I have \"\\(.+\\)\"$"
46
+ (lambda (something)
47
+ ;; Do something
48
+ ))
49
+
50
+ (But "^I should not have \"\\(.+\\)\"$"
51
+ (lambda (something)
52
+ ;; Do something
53
+ ))
@@ -0,0 +1,37 @@
1
+ ;; This is an example of how you could set up this file. This setup
2
+ ;; requires a directory called util in the project root and that the
3
+ ;; util directory contains the testing tools ert and espuds.
4
+
5
+ (let* ((features-directory
6
+ (file-name-directory
7
+ (directory-file-name (file-name-directory load-file-name))))
8
+ (project-directory
9
+ (file-name-directory
10
+ (directory-file-name features-directory))))
11
+ (setq emacs-root-path project-directory)
12
+ (setq emacs-util-path (expand-file-name "util" emacs-root-path)))
13
+
14
+ (add-to-list 'load-path emacs-root-path)
15
+ (add-to-list 'load-path (expand-file-name "espuds" emacs-util-path))
16
+ (add-to-list 'load-path (expand-file-name "ert" emacs-util-path))
17
+
18
+ (require 'vimgolf)
19
+ (require 'espuds)
20
+ (require 'ert)
21
+
22
+
23
+ (Setup
24
+ ;; Before anything has run
25
+ )
26
+
27
+ (Before
28
+ ;; Before each scenario is run
29
+ )
30
+
31
+ (After
32
+ ;; After each scenario is run
33
+ )
34
+
35
+ (Teardown
36
+ ;; After when everything has been run
37
+ )
@@ -0,0 +1,45 @@
1
+ * VimGolf TODO
2
+
3
+ ** Game Excersizes
4
+
5
+ ** Browser
6
+ *** DONE Handle/fix character encoding
7
+ CLOSED: [2012-07-28 Sat 23:07]
8
+ :LOGBOOK:
9
+ - State "DONE" from "TODO" [2012-07-28 Sat 23:07] \\
10
+ Added a utility function to handling &lt, &gt, &amp, and &quot.
11
+ :END:
12
+ Things like < and >, etc.
13
+ *** DONE Fix line endings
14
+ CLOSED: [2012-07-28 Sat 22:51]
15
+ :LOGBOOK:
16
+ - State "DONE" from "TODO" [2012-07-28 Sat 22:51] \\
17
+ Added a function to replace ^M with some replacement (default space).
18
+ Currently only running this function on entry descriptions.
19
+ :END:
20
+ Need to convert ^M characters
21
+ *** DONE Add/fix line wrapping
22
+ CLOSED: [2012-07-28 Sat 22:04]
23
+ :LOGBOOK:
24
+ - State "DONE" from "TODO" [2012-07-28 Sat 22:04]
25
+ :END:
26
+ Can't assume that everyone's emacs will be set the same. Should really set a
27
+ particular fill-column and enforce it.
28
+ *** DONE Truncate long titles
29
+ CLOSED: [2012-07-28 Sat 22:21]
30
+ :LOGBOOK:
31
+ - State "DONE" from "IN PROGRESS" [2012-07-28 Sat 22:21]
32
+ - State "IN PROGRESS" from "TODO" [2012-07-28 Sat 22:09]
33
+ :END:
34
+ Use ellipses to truncate titles that would normally be longer than the
35
+ fill-column width.
36
+ *** DONE When first loading (via url-retrieve), list isn't showing after the call
37
+ CLOSED: [2012-07-28 Sat 23:11]
38
+ :LOGBOOK:
39
+ - State "DONE" from "TODO" [2012-07-28 Sat 23:11] \\
40
+ The list insertion was happening outside of the async callback. Now it happens
41
+ during the callback (if url-retrieve is used) and during the browse function
42
+ itself (if not).
43
+ :END:
44
+ I'm not sure if the call back isn't working or what. Manually refreshing
45
+ will display the list.
@@ -1,11 +1,10 @@
1
1
  ;;; vimgolf.el --- VimGolf interface for the One True Editor
2
-
3
2
  ;; Copyright (C) never, by no one
4
3
 
5
4
  ;;; Author: Tim Visher <tim.visher@gmail.com>
6
5
  ;;; Maintainer: Tim Visher <tim.visher@gmail.com>
7
6
  ;;; Created: 2011-11-02
8
- ;;; Version: 0.9.2
7
+ ;;; Version: 0.9.3
9
8
  ;;; Keywords: games vimgolf vim
10
9
 
11
10
  ;; This file is not part of GNU Emacs
@@ -123,7 +122,8 @@ with `C-c C-v` prefixes to help in playing VimGolf.
123
122
  universal-argument
124
123
  universal-argument-other-key
125
124
  universal-argument-minus
126
- universal-argument-more))
125
+ universal-argument-more
126
+ isearch-other-meta-char))
127
127
  (string-prefix-p "vimgolf-" (symbol-name this-command)))))
128
128
 
129
129
  (defun vimgolf-capturable-dangling-keystroke-p ()
@@ -152,6 +152,10 @@ unknown key sequence was entered).")
152
152
  (defun vimgolf-capture-dangling-keystroke ()
153
153
  (vimgolf-maybe-capture-keystroke 'vimgolf-capturable-dangling-keystroke-p))
154
154
 
155
+ (defun vimgolf-get-keystrokes-as-string (&optional separator)
156
+ (unless separator (setq separator " "))
157
+ (mapconcat 'key-description (mapcar 'car vimgolf-keystrokes) separator))
158
+
155
159
  (defun vimgolf-refresh-keystroke-log ()
156
160
  "Refresh the contents of the keystrokes log buffer."
157
161
  (let ((deactivate-mark nil))
@@ -160,7 +164,7 @@ unknown key sequence was entered).")
160
164
  (erase-buffer)
161
165
  (insert (format "Challenge ID: %s\n%s\n\n" vimgolf-challenge (vimgolf-challenge-url vimgolf-challenge))
162
166
  (format "Keystrokes (%d):\n\n" (vimgolf-count-keystrokes))
163
- (mapconcat 'key-description (mapcar 'car vimgolf-keystrokes) " ")
167
+ (vimgolf-get-keystrokes-as-string)
164
168
  "\n\nFull command log:\n\n")
165
169
  (when vimgolf-keystrokes
166
170
  (let* ((descrs-and-commands
@@ -328,12 +332,149 @@ unknown key sequence was entered).")
328
332
 
329
333
  (vimgolf-continue))))
330
334
 
335
+ (defvar *vimgolf-browse-list* nil
336
+ "Holds a list of parsed VimGolf challenges.")
337
+
338
+ (defun vimgolf-browse (&optional force-pull)
339
+ (interactive)
340
+ (if (or (eq *vimgolf-browse-list* nil)
341
+ force-pull)
342
+ (url-retrieve vimgolf-host 'vimgolf-parse-browse-html)
343
+ (vimgolf-browse-list)
344
+ (vimgolf-browse-next)))
345
+
346
+ (defun vimgolf-browse-refresh ()
347
+ (interactive)
348
+ (vimgolf-browse t))
349
+
350
+ (defun vimgolf-replace-control-m (string &optional replace)
351
+ (replace-regexp-in-string "
352
+
353
+ (defun vimgolf-parse-html-entites (string)
354
+ (replace-regexp-in-string
355
+ "&lt;" "<"
356
+ (replace-regexp-in-string
357
+ "&gt;" ">"
358
+ (replace-regexp-in-string
359
+ "&amp;" "&"
360
+ (replace-regexp-in-string
361
+ "&quot" "\""
362
+ string)))))
363
+
364
+ (defun vimgolf-parse-browse-html (status)
365
+ (with-current-buffer (current-buffer)
366
+ (let ((html (vimgolf-parse-html-entites
367
+ (replace-regexp-in-string "\n" "" (buffer-string))))
368
+ (start 0))
369
+ (setq *vimgolf-browse-list* nil)
370
+ (while
371
+ (string-match
372
+ "<a href=\"/challenges/\\([a-zA-Z0-9]+\\)\">\\(.*?\\)</a>.*?<p>\\(.*?\\)</p>"
373
+ html)
374
+ (add-to-list '*vimgolf-browse-list*
375
+ (cons (match-string 1 html)
376
+ (list (match-string 2 html)
377
+ (vimgolf-replace-control-m
378
+ (match-string 3 html))))
379
+ t)
380
+ (setq html (substring html (match-end 0))))
381
+ *vimgolf-browse-list*))
382
+ (vimgolf-browse-list)
383
+ (vimgolf-browse-next))
384
+
385
+ (defun vimgolf-browse-list ()
386
+ (let ((browse-buffer (get-buffer-create "*VimGolf Browse*")))
387
+ (switch-to-buffer browse-buffer)
388
+ (setq buffer-read-only nil)
389
+ (kill-region (point-min) (point-max))
390
+ (insert "VimGolf Challenges")
391
+ (newline 2)
392
+ (dolist (challenge *vimgolf-browse-list*)
393
+ (let ((title (substring (cadr challenge)
394
+ 0
395
+ (min (length (cadr challenge))
396
+ (- fill-column 3))))
397
+ (description (car (cdr (cdr challenge))))
398
+ (challenge-id (car challenge)))
399
+ (when (< (length title) (length (cadr challenge)))
400
+ (setq title (concat title "...")))
401
+ (insert-text-button title
402
+ 'action 'vimgolf-browse-select
403
+ 'follow-link t
404
+ 'challenge-id challenge-id
405
+ 'help-echo description))
406
+ (newline)))
407
+ (beginning-of-buffer)
408
+ (vimgolf-browse-mode))
409
+
410
+ (defun vimgolf-browse-select (arg)
411
+ (let ((challenge-id (get-text-property (point) 'challenge-id)))
412
+ (vimgolf challenge-id)))
413
+
414
+ (defun vimgolf-message-title ()
415
+ (let ((challenge-id (get-text-property (point) 'challenge-id)))
416
+ (when challenge-id
417
+ (message (cadr (assoc challenge-id *vimgolf-browse-list*))))))
418
+
419
+ (defun vimgolf-browse-next ()
420
+ (interactive)
421
+ (goto-char (next-single-property-change (point) 'challenge-id))
422
+ (unless (get-text-property (point) 'challenge-id)
423
+ (goto-char (next-single-property-change (point) 'challenge-id)))
424
+ (vimgolf-message-title))
425
+
426
+ (defun vimgolf-browse-previous ()
427
+ (interactive)
428
+ (goto-char (previous-single-property-change (point) 'challenge-id))
429
+ (unless (get-text-property (point) 'challenge-id)
430
+ (goto-char (previous-single-property-change (point) 'challenge-id)))
431
+ (vimgolf-message-title))
432
+
433
+ (defun vimgolf-show-description ()
434
+ (interactive)
435
+ (let ((challenge-id (get-text-property (point) 'challenge-id)))
436
+ (save-excursion
437
+ (setq buffer-read-only nil)
438
+ (if (text-property-any (point-min) (point-max) 'challenge-description challenge-id)
439
+ (progn
440
+ (beginning-of-buffer)
441
+ (while (not (eq (get-text-property (point) 'challenge-description) challenge-id))
442
+ (goto-char (next-single-property-change (point) 'challenge-description)))
443
+ (let ((start (point)))
444
+ (goto-char (next-single-property-change (point) 'challenge-description))
445
+ (delete-region start (point))
446
+ (delete-blank-lines)
447
+ (delete-blank-lines)))
448
+ (end-of-line)
449
+ (newline 3)
450
+ (forward-line -1)
451
+ (let ((start (point)))
452
+ (insert " " (car (cddr (assoc challenge-id *vimgolf-browse-list*))))
453
+ (fill-region start (point))
454
+ (add-text-properties start (point) `(challenge-description ,challenge-id))))
455
+ (setq buffer-read-only t))))
456
+
331
457
  ;;;###autoload
332
458
  (defun vimgolf (challenge-id)
333
459
  "Open a VimGolf Challenge"
334
460
  (interactive (list (read-from-minibuffer "Challenge ID: " nil nil nil 'vimgolf-challenge-history)))
335
461
  (url-retrieve (vimgolf-challenge-url challenge-id) 'vimgolf-setup `(,challenge-id)))
336
462
 
463
+ (defvar vimgolf-browse-mode-map (make-sparse-keymap)
464
+ "Keymap for vimgolf-mode.")
465
+
466
+ (define-derived-mode vimgolf-browse-mode special-mode "vimgolf browse"
467
+ "A major mode for completing vimgolf challenges.
468
+
469
+ \\{vimgolf-browse-mode-map}"
470
+ (define-key vimgolf-browse-mode-map (kbd "TAB") 'vimgolf-show-description)
471
+ (define-key vimgolf-browse-mode-map "g" 'vimgolf-browse-refresh)
472
+ (define-key vimgolf-browse-mode-map "n" 'vimgolf-browse-next)
473
+ (define-key vimgolf-browse-mode-map "p" 'vimgolf-browse-previous)
474
+ )
475
+
476
+ (put 'vimgolf-mode 'mode-class 'special)
477
+
337
478
  (provide 'vimgolf)
338
479
 
339
480
  ;;; Local Variables:
@@ -1,5 +1,7 @@
1
1
  require 'highline'
2
2
 
3
+ HighLine.track_eof = false
4
+
3
5
  module VimGolf
4
6
  class CLI
5
7
  class UI < Thor::Base.shell
@@ -58,7 +60,9 @@ module VimGolf
58
60
  end
59
61
  @hl.ask(message, options[:choices] || [], &details)
60
62
  rescue EOFError
61
- return ''
63
+ # be sure to exit, don't loop
64
+ error "Argh! Forced quit due to EOF error. Please report this problem so we can fix it!"
65
+ return :quit
62
66
  end
63
67
  end
64
68
 
@@ -1,3 +1,3 @@
1
1
  module Vimgolf
2
- VERSION = "0.4.1"
2
+ VERSION = "0.4.2"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: vimgolf
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.1
4
+ version: 0.4.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-03-17 00:00:00.000000000 Z
12
+ date: 2012-09-19 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: thor
16
- requirement: &2157019460 !ruby/object:Gem::Requirement
16
+ requirement: !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
@@ -21,10 +21,15 @@ dependencies:
21
21
  version: 0.14.6
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *2157019460
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ! '>='
28
+ - !ruby/object:Gem::Version
29
+ version: 0.14.6
25
30
  - !ruby/object:Gem::Dependency
26
31
  name: highline
27
- requirement: &2157018980 !ruby/object:Gem::Requirement
32
+ requirement: !ruby/object:Gem::Requirement
28
33
  none: false
29
34
  requirements:
30
35
  - - ! '>='
@@ -32,10 +37,15 @@ dependencies:
32
37
  version: '0'
33
38
  type: :runtime
34
39
  prerelease: false
35
- version_requirements: *2157018980
40
+ version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ! '>='
44
+ - !ruby/object:Gem::Version
45
+ version: '0'
36
46
  - !ruby/object:Gem::Dependency
37
47
  name: rspec
38
- requirement: &2157018480 !ruby/object:Gem::Requirement
48
+ requirement: !ruby/object:Gem::Requirement
39
49
  none: false
40
50
  requirements:
41
51
  - - ! '>='
@@ -43,10 +53,15 @@ dependencies:
43
53
  version: '0'
44
54
  type: :development
45
55
  prerelease: false
46
- version_requirements: *2157018480
56
+ version_requirements: !ruby/object:Gem::Requirement
57
+ none: false
58
+ requirements:
59
+ - - ! '>='
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
47
62
  - !ruby/object:Gem::Dependency
48
63
  name: rake
49
- requirement: &2157017900 !ruby/object:Gem::Requirement
64
+ requirement: !ruby/object:Gem::Requirement
50
65
  none: false
51
66
  requirements:
52
67
  - - ! '>='
@@ -54,7 +69,12 @@ dependencies:
54
69
  version: '0'
55
70
  type: :development
56
71
  prerelease: false
57
- version_requirements: *2157017900
72
+ version_requirements: !ruby/object:Gem::Requirement
73
+ none: false
74
+ requirements:
75
+ - - ! '>='
76
+ - !ruby/object:Gem::Version
77
+ version: '0'
58
78
  description: CLI client for vimgolf.com
59
79
  email:
60
80
  - ilya@igvita.com
@@ -64,6 +84,7 @@ extensions: []
64
84
  extra_rdoc_files: []
65
85
  files:
66
86
  - .gitignore
87
+ - .gitmodules
67
88
  - .rspec
68
89
  - Gemfile
69
90
  - Gemfile.lock
@@ -72,6 +93,10 @@ files:
72
93
  - bin/vimgolf
73
94
  - emacs/README.md
74
95
  - emacs/ROADMAP.md
96
+ - emacs/features/emacs.feature
97
+ - emacs/features/step-definitions/emacs-steps.el
98
+ - emacs/features/support/env.el
99
+ - emacs/todo.org
75
100
  - emacs/vimgolf.el
76
101
  - lib/vimgolf.rb
77
102
  - lib/vimgolf/challenge.rb
@@ -96,7 +121,7 @@ post_install_message: ! '
96
121
 
97
122
  ------------------------------------------------------------------------------
98
123
 
99
- Thank you for installing vimgolf-0.4.1.
124
+ Thank you for installing vimgolf-0.4.2.
100
125
 
101
126
 
102
127
  0.1.3: custom vimgolf .vimrc file to help level the playing field
@@ -133,7 +158,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
133
158
  version: '0'
134
159
  requirements: []
135
160
  rubyforge_project: vimgolf
136
- rubygems_version: 1.8.10
161
+ rubygems_version: 1.8.24
137
162
  signing_key:
138
163
  specification_version: 3
139
164
  summary: CLI client for vimgolf.com