forked from soveran/nest
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Rakefile
40 lines (28 loc) · 967 Bytes
/
Rakefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
task :test do
require "cutest"
Cutest.run(Dir["test/nest*"])
end
task :default => :test
task :commands do
require "open-uri"
require "par"
require "json"
file = File.expand_path("lib/nest.rb", File.dirname(__FILE__))
path = "https://github.com/antirez/redis-doc/raw/master/commands.json"
commands = JSON.parse(open(path).read).select do |name, command|
# Skip all DEBUG commands
next if command["group"] == "server"
# If the command has no arguments, it doesn't operate on a key
next if command["arguments"].nil?
arg = command["arguments"].first
arg["type"] == "key" ||
Array(arg["name"]) == ["channel"]
end
commands = commands.keys.map { |key| key.downcase.to_sym }
commands.delete(:mget)
source = File.read(file).sub(/ METHODS = .+?\n\n/m) do
Par.new(" METHODS = #{commands.inspect}\n\n", p: 2)
end
File.open(file, "w") { |f| f.write source }
system "git diff --color-words #{file}"
end