fuzzake 0.0.1 → 0.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/Rakefile +13 -0
- data/lib/fuzzake.rb +2 -57
- data/lib/fuzzake/version.rb +1 -1
- data/lib/fuzzake_task.rake +56 -0
- metadata +3 -2
data/Rakefile
CHANGED
@@ -1,2 +1,15 @@
|
|
1
1
|
#!/usr/bin/env rake
|
2
|
+
|
2
3
|
require "bundler/gem_tasks"
|
4
|
+
require_relative 'lib/fuzzake.rb'
|
5
|
+
|
6
|
+
include Fuzzake
|
7
|
+
|
8
|
+
desc "Default will build the project"
|
9
|
+
task :default => "fuzzake:call"
|
10
|
+
|
11
|
+
|
12
|
+
desc "Dummy task to test fuzzake"
|
13
|
+
task :dummy do
|
14
|
+
puts "Dummy task executed!"
|
15
|
+
end
|
data/lib/fuzzake.rb
CHANGED
@@ -1,60 +1,5 @@
|
|
1
|
-
|
1
|
+
require_relative "fuzzake/version"
|
2
|
+
import File.expand_path "fuzzake_task.rake", "lib"
|
2
3
|
|
3
4
|
module Fuzzake
|
4
|
-
namespace :fuzzake do
|
5
|
-
desc "Task to give ask the user for a pattern name and then suggest the possible names. If the name is exactly fitting then the task will be executed."
|
6
|
-
task :call do
|
7
|
-
fuzzy_name = take_property_or_ask("task_pattern", "Write the full name or just a part of the task you want to call:")
|
8
|
-
fitting_tasks = []
|
9
|
-
Rake::Task.tasks.each do |t|
|
10
|
-
if t.name == fuzzy_name
|
11
|
-
return Rake::Task[fuzzy_name].execute
|
12
|
-
elsif t.name =~ Regexp.new(fuzzy_name)
|
13
|
-
fitting_tasks << t.name
|
14
|
-
end
|
15
|
-
end
|
16
|
-
if fitting_tasks.empty?
|
17
|
-
Rake::Task.tasks.each do |t|
|
18
|
-
unless t.name =~ /default/ || t.name =~ /fuzzy/
|
19
|
-
fitting_tasks << t.name
|
20
|
-
end
|
21
|
-
end
|
22
|
-
end
|
23
|
-
puts "There are the following tasks to execute:"
|
24
|
-
fitting_tasks.each_with_index do |task,index|
|
25
|
-
puts "#{index} for #{task}"
|
26
|
-
end
|
27
|
-
execution_task_index = ask("So what is the index of the task you want to call?")
|
28
|
-
Rake::Task[fitting_tasks[execution_task_index.to_i]].execute
|
29
|
-
end
|
30
|
-
|
31
|
-
task :fuzzake, :arg1 do |t, args|
|
32
|
-
Rake::Task["fuzzake:call"].execute("task_pattern" => args[:arg1])
|
33
|
-
end
|
34
|
-
|
35
|
-
def ask(message, default="")
|
36
|
-
unless default.empty?
|
37
|
-
message << " (type 'default' for #{default})"
|
38
|
-
end
|
39
|
-
print message
|
40
|
-
answer = STDIN.gets.chomp
|
41
|
-
if answer.strip.downcase == "default"
|
42
|
-
default
|
43
|
-
else
|
44
|
-
answer
|
45
|
-
end
|
46
|
-
end
|
47
|
-
|
48
|
-
def take_property_or_ask(property, question, default="")
|
49
|
-
if ENV[property].nil?
|
50
|
-
property_answer = ask(question, default)
|
51
|
-
if property_answer == "default"
|
52
|
-
property_answer = default
|
53
|
-
end
|
54
|
-
else
|
55
|
-
property_answer = ENV[property]
|
56
|
-
end
|
57
|
-
property_answer
|
58
|
-
end
|
59
|
-
end
|
60
5
|
end
|
data/lib/fuzzake/version.rb
CHANGED
@@ -0,0 +1,56 @@
|
|
1
|
+
namespace :fuzzake do
|
2
|
+
desc "Task to give ask the user for a pattern name and then suggest the possible names. If the name is exactly fitting then the task will be executed."
|
3
|
+
task :call do
|
4
|
+
fuzzy_name = take_property_or_ask("task_pattern", "Write the full name or just a part of the task you want to call:")
|
5
|
+
fitting_tasks = []
|
6
|
+
Rake::Task.tasks.each do |t|
|
7
|
+
if t.name == fuzzy_name
|
8
|
+
return Rake::Task[fuzzy_name].execute
|
9
|
+
elsif t.name =~ Regexp.new(fuzzy_name)
|
10
|
+
fitting_tasks << t.name
|
11
|
+
end
|
12
|
+
end
|
13
|
+
if fitting_tasks.empty?
|
14
|
+
Rake::Task.tasks.each do |t|
|
15
|
+
unless t.name =~ /default/ || t.name =~ /fuzzy/
|
16
|
+
fitting_tasks << t.name
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
puts "There are the following tasks to execute:"
|
21
|
+
fitting_tasks.each_with_index do |task,index|
|
22
|
+
puts "#{index} for #{task}"
|
23
|
+
end
|
24
|
+
execution_task_index = ask("So what is the index of the task you want to call?")
|
25
|
+
Rake::Task[fitting_tasks[execution_task_index.to_i]].execute
|
26
|
+
end
|
27
|
+
|
28
|
+
task :fuzzake, :arg1 do |t, args|
|
29
|
+
Rake::Task["fuzzake:call"].execute("task_pattern" => args[:arg1])
|
30
|
+
end
|
31
|
+
|
32
|
+
def ask(message, default="")
|
33
|
+
unless default.empty?
|
34
|
+
message << " (type 'default' for #{default})"
|
35
|
+
end
|
36
|
+
print message
|
37
|
+
answer = STDIN.gets.chomp
|
38
|
+
if answer.strip.downcase == "default"
|
39
|
+
default
|
40
|
+
else
|
41
|
+
answer
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
def take_property_or_ask(property, question, default="")
|
46
|
+
if ENV[property].nil?
|
47
|
+
property_answer = ask(question, default)
|
48
|
+
if property_answer == "default"
|
49
|
+
property_answer = default
|
50
|
+
end
|
51
|
+
else
|
52
|
+
property_answer = ENV[property]
|
53
|
+
end
|
54
|
+
property_answer
|
55
|
+
end
|
56
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: fuzzake
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-06-
|
12
|
+
date: 2012-06-30 00:00:00.000000000Z
|
13
13
|
dependencies: []
|
14
14
|
description: Fuzzake is a small library to integrate it with your rake file to be
|
15
15
|
able to run rake taks in a fuzzy way.
|
@@ -27,6 +27,7 @@ files:
|
|
27
27
|
- fuzzake.gemspec
|
28
28
|
- lib/fuzzake.rb
|
29
29
|
- lib/fuzzake/version.rb
|
30
|
+
- lib/fuzzake_task.rake
|
30
31
|
homepage: ''
|
31
32
|
licenses: []
|
32
33
|
post_install_message:
|