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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
|
# File 'lib/formidable/commands.rb', line 5
def run(args)
if args[0] == "install" and api_key = args[1]
config = <<CONFIG
# Leave api_key blank to disable Formidable for a specific environment.
development:
api_key: #{api_key}
production:
api_key: #{api_key}
CONFIG
Dir.mkdir("config") unless File.exists?("config")
File.open(CONFIG_PATH, "w") {|f| f.write(config)}
puts "Created config file at #{CONFIG_PATH}."
elsif args[0] == "test"
begin
Config.load_file(CONFIG_PATH)
Config.thread = false
Formidable.track(
:form => "Test",
:errors => {:email => "is invalid"},
:values => {:email => "test@formidable"},
:attempt => 1,
:total_time => 10.1,
:times => {:username => 2.4, :email => 5.6}
)
Formidable.track(:form => "Test", :attempt => 2)
Formidable.track(
:form => "Test",
:errors => {:email => "is invalid", :username => "is already taken"},
:attempt => 1
)
Formidable.track(:form => "Test", :attempt => 2)
Formidable.track(:form => "Test", :attempt => 1)
Formidable.track(:form => "Test", :attempt => 1)
puts "Test successful! Login to http://www.getformidable.com to see it."
rescue Exception => e
puts "Test failed:\n #{e.message}"
end
else
help =<<HELP
Usage:
formidable install <api-key>
formidable test
HELP
puts help
end
end
|