vimgolf-finder 0.1.4 → 0.1.8
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/README.md +18 -2
- data/lib/vimgolf_finder/challenge.rb +2 -2
- data/lib/vimgolf_finder/cli.rb +34 -2
- data/lib/vimgolf_finder/parser.rb +3 -3
- data/lib/vimgolf_finder/version.rb +1 -1
- metadata +6 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: ecdf37d25dccd847f35afad840a47dc22c2f6cc149cddbc06613e6ac089e55a5
|
4
|
+
data.tar.gz: 19d602c1423e6c8f78f609d3981ecbed0cabcec5691f449261ac0a8b6c1977c7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8b9edd0609ab95167e65c79481df886d6478d534abbd05d0ba954f8a1d9f1bd3c1a2f12265fbb80fac8e694bbcfb94f5080400d7f0d7b48ac85c0a11b14f520c
|
7
|
+
data.tar.gz: 64dadc65b6e7588265c914acf241803a3132fc81862107f1cbcfd933d5cdbe8bc6d9f1b5fff287ba827bb81d962eefb9c8384ddb86e9d47595ff980378ea4100
|
data/README.md
CHANGED
@@ -7,7 +7,7 @@ Simple VimGolf challenge finder. It just toy project for me! :smile:
|
|
7
7
|
[![asciicast](https://asciinema.org/a/1whcqi8pjldxi767iiknqxeil.png)](https://asciinema.org/a/1whcqi8pjldxi767iiknqxeil)
|
8
8
|
|
9
9
|
## Installation
|
10
|
-
|
10
|
+
Paste this at a terminal prompt:
|
11
11
|
```
|
12
12
|
$ gem install vimgolf-finder
|
13
13
|
```
|
@@ -18,6 +18,7 @@ Commands:
|
|
18
18
|
vimgolf-finder help [COMMAND] # Describe available commands or one specific command
|
19
19
|
vimgolf-finder list # Show VimGolf challenges
|
20
20
|
vimgolf-finder random # Pick one at random from VimGolf challenges
|
21
|
+
vimgolf-finder solves # Show solved VimGolf challenges
|
21
22
|
```
|
22
23
|
|
23
24
|
### List 🔎
|
@@ -98,7 +99,22 @@ Do you want to play? (y/n) y
|
|
98
99
|
|
99
100
|
Thanks for playing!
|
100
101
|
Solves? (y/n) n
|
101
|
-
|
102
|
+
```
|
103
|
+
|
104
|
+
### Solves 🔎
|
105
|
+
Show solved VimGolf challenges
|
106
|
+
```
|
107
|
+
$ vimgolf-finder solves
|
108
|
+
1. Simple, Practical, and Common - 7953 entries (55b18bbea9c2c30d04000001) [✓]
|
109
|
+
Choose challenge number. 1
|
110
|
+
|
111
|
+
Open your web browser? (y/n) y
|
112
|
+
Do you want to play? (y/n) y
|
113
|
+
|
114
|
+
# Playing VimGolf...
|
115
|
+
|
116
|
+
Thanks for playing!
|
117
|
+
Solves? (y/n) y
|
102
118
|
```
|
103
119
|
|
104
120
|
## TODO
|
@@ -6,7 +6,7 @@ module VimGolfFinder
|
|
6
6
|
|
7
7
|
def print(index = 1)
|
8
8
|
if self.solved?
|
9
|
-
VimGolfFinder.ui.log "#{index}. \e[37m#{self.title}\e[0m - #{self.entries} entries (\e[33m#{self.id}\e[0m) [\u2713]"
|
9
|
+
VimGolfFinder.ui.log "#{index}. \e[37m#{self.title}\e[0m - #{self.entries} entries (\e[33m#{self.id}\e[0m) \e[32m[\u2713]\e[0m"
|
10
10
|
else
|
11
11
|
VimGolfFinder.ui.log "#{index}. \e[37m#{self.title}\e[0m - #{self.entries} entries (\e[33m#{self.id}\e[0m)"
|
12
12
|
end
|
@@ -51,7 +51,7 @@ module VimGolfFinder
|
|
51
51
|
File.new(path, File::CREAT|File::TRUNC|File::RDWR, 0644)
|
52
52
|
end
|
53
53
|
|
54
|
-
File.open(path, 'a') { |file| file.write(id) }
|
54
|
+
File.open(path, 'a') { |file| file.write("#{id}\n") }
|
55
55
|
end
|
56
56
|
end
|
57
57
|
end
|
data/lib/vimgolf_finder/cli.rb
CHANGED
@@ -54,7 +54,7 @@ module VimGolfFinder
|
|
54
54
|
|
55
55
|
number = VimGolfFinder.ui.ask 'Choose challenge number.'
|
56
56
|
number = number.to_i
|
57
|
-
if number.instance_of?
|
57
|
+
if number.instance_of? Integer
|
58
58
|
if number < 1 or number > limit
|
59
59
|
VimGolfFinder.ui.error 'Invalid number'
|
60
60
|
return
|
@@ -77,6 +77,35 @@ module VimGolfFinder
|
|
77
77
|
play(id)
|
78
78
|
end
|
79
79
|
|
80
|
+
desc 'solves', 'Show solved VimGolf challenges'
|
81
|
+
def solves
|
82
|
+
challenges = VimGolfFinder.parser.fetch_challenges
|
83
|
+
|
84
|
+
solved_challenges = []
|
85
|
+
challenges.each do |challenge|
|
86
|
+
if challenge.solved?
|
87
|
+
solved_challenges << challenge
|
88
|
+
end
|
89
|
+
end
|
90
|
+
|
91
|
+
solved_challenges.each_with_index do |challenge, index|
|
92
|
+
challenge.print(index+1)
|
93
|
+
end
|
94
|
+
|
95
|
+
number = VimGolfFinder.ui.ask 'Choose challenge number.'
|
96
|
+
number = number.to_i
|
97
|
+
if number.instance_of? Integer
|
98
|
+
if number < 1 or number > solved_challenges.count
|
99
|
+
VimGolfFinder.ui.error 'Invalid number'
|
100
|
+
return
|
101
|
+
end
|
102
|
+
|
103
|
+
id = challenges[number-1].id
|
104
|
+
print_challenge(id)
|
105
|
+
play(id)
|
106
|
+
end
|
107
|
+
end
|
108
|
+
|
80
109
|
private
|
81
110
|
def print_challenge(id)
|
82
111
|
VimGolfFinder.ui.log ''
|
@@ -95,7 +124,10 @@ module VimGolfFinder
|
|
95
124
|
result = VimGolfFinder.ui.ask 'Do you want to play? (y/n)'
|
96
125
|
|
97
126
|
if result.eql?('y') || result.eql?('yes')
|
98
|
-
system("vimgolf put #{id}")
|
127
|
+
if system("vimgolf put #{id}") == nil
|
128
|
+
VimGolfFinder.ui.error 'You need to install vimgolf. e.g. `gem install vimgolf`.'
|
129
|
+
return
|
130
|
+
end
|
99
131
|
|
100
132
|
solves = VimGolfFinder.ui.ask 'Solves? (y/n)'
|
101
133
|
|
@@ -5,7 +5,7 @@ module VimGolfFinder
|
|
5
5
|
def fetch_challenges
|
6
6
|
challenges = []
|
7
7
|
|
8
|
-
doc = Nokogiri::HTML(open(BASE_URL))
|
8
|
+
doc = Nokogiri::HTML(URI.open(BASE_URL))
|
9
9
|
doc.css('.grid_7 > div').each do |div|
|
10
10
|
challengeDOM = div.at_css('h5.challenge')
|
11
11
|
aTAG = challengeDOM.at_css('a')
|
@@ -22,7 +22,7 @@ module VimGolfFinder
|
|
22
22
|
def get_challenge(id)
|
23
23
|
challenge = VimGolfFinder::Challenge.new
|
24
24
|
|
25
|
-
doc = Nokogiri::HTML(open("#{BASE_URL}/challenges/#{id}", 'Accept' => 'text/html'))
|
25
|
+
doc = Nokogiri::HTML(URI.open("#{BASE_URL}/challenges/#{id}", 'Accept' => 'text/html'))
|
26
26
|
|
27
27
|
doc.css('.grid_7:not(#about)').each do |dom|
|
28
28
|
challenge.id = id
|
@@ -30,7 +30,7 @@ module VimGolfFinder
|
|
30
30
|
challenge.description = dom.at_css('p').content
|
31
31
|
challenge.start_file = dom.at_css('.prettyprint').content
|
32
32
|
challenge.end_file = dom.css('.prettyprint')[1].content
|
33
|
-
challenge.view_diff = dom.at_css('pre
|
33
|
+
challenge.view_diff = dom.at_css('pre#diff').content
|
34
34
|
end
|
35
35
|
|
36
36
|
challenge
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: vimgolf-finder
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.8
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Lee Sun-Hyoup
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2021-11-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: nokogiri
|
@@ -123,7 +123,7 @@ homepage: https://github.com/kciter/vimgolf-finder
|
|
123
123
|
licenses:
|
124
124
|
- MIT
|
125
125
|
metadata: {}
|
126
|
-
post_install_message:
|
126
|
+
post_install_message:
|
127
127
|
rdoc_options: []
|
128
128
|
require_paths:
|
129
129
|
- lib
|
@@ -138,9 +138,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
138
138
|
- !ruby/object:Gem::Version
|
139
139
|
version: '0'
|
140
140
|
requirements: []
|
141
|
-
|
142
|
-
|
143
|
-
signing_key:
|
141
|
+
rubygems_version: 3.1.2
|
142
|
+
signing_key:
|
144
143
|
specification_version: 4
|
145
144
|
summary: VimGolf challenge finder.
|
146
145
|
test_files: []
|