Skip to content

Commit

Permalink
more work on shell. this is gonna be so damn awesome #shell
Browse files Browse the repository at this point in the history
  • Loading branch information
Lennart Koopmann committed Jun 30, 2011
1 parent d0debad commit 3a692c7
Show file tree
Hide file tree
Showing 6 changed files with 57 additions and 59 deletions.
66 changes: 34 additions & 32 deletions Gemfile.lock
Expand Up @@ -3,38 +3,38 @@ GEM
specs:
SystemTimer (1.2.3)
abstract (1.0.0)
actionmailer (3.0.7)
actionpack (= 3.0.7)
mail (~> 2.2.15)
actionpack (3.0.7)
activemodel (= 3.0.7)
activesupport (= 3.0.7)
actionmailer (3.0.9)
actionpack (= 3.0.9)
mail (~> 2.2.19)
actionpack (3.0.9)
activemodel (= 3.0.9)
activesupport (= 3.0.9)
builder (~> 2.1.2)
erubis (~> 2.6.6)
i18n (~> 0.5.0)
rack (~> 1.2.1)
rack-mount (~> 0.6.14)
rack-test (~> 0.5.7)
tzinfo (~> 0.3.23)
activemodel (3.0.7)
activesupport (= 3.0.7)
activemodel (3.0.9)
activesupport (= 3.0.9)
builder (~> 2.1.2)
i18n (~> 0.5.0)
activerecord (3.0.7)
activemodel (= 3.0.7)
activesupport (= 3.0.7)
arel (~> 2.0.2)
activerecord (3.0.9)
activemodel (= 3.0.9)
activesupport (= 3.0.9)
arel (~> 2.0.10)
tzinfo (~> 0.3.23)
activeresource (3.0.7)
activemodel (= 3.0.7)
activesupport (= 3.0.7)
activesupport (3.0.7)
activeresource (3.0.9)
activemodel (= 3.0.9)
activesupport (= 3.0.9)
activesupport (3.0.9)
arel (2.0.10)
bson (1.3.1)
bson_ext (1.3.1)
builder (2.1.2)
chronic (0.3.0)
ci_reporter (1.6.4)
ci_reporter (1.6.5)
builder (>= 2.1.2)
daemon_controller (0.2.6)
database_cleaner (0.6.7)
Expand All @@ -49,7 +49,7 @@ GEM
activesupport
builder
i18n (0.5.0)
json (1.5.1)
json (1.5.3)
machinist (1.0.6)
machinist_mongo (1.2.0)
machinist (~> 1.0.6)
Expand All @@ -67,35 +67,37 @@ GEM
mongo (~> 1.3)
tzinfo (~> 0.3.22)
will_paginate (~> 3.0.pre)
newrelic_rpm (3.0.1)
newrelic_rpm (3.1.0)
passenger (3.0.7)
daemon_controller (>= 0.2.5)
fastthread (>= 1.0.1)
rack
rake (>= 0.8.1)
polyglot (0.3.1)
pony (1.2)
pony (1.3)
mail (> 2.0)
rack (1.2.3)
rack-mount (0.6.14)
rack (>= 1.0.0)
rack-test (0.5.7)
rack (>= 1.0)
rails (3.0.7)
actionmailer (= 3.0.7)
actionpack (= 3.0.7)
activerecord (= 3.0.7)
activeresource (= 3.0.7)
activesupport (= 3.0.7)
rails (3.0.9)
actionmailer (= 3.0.9)
actionpack (= 3.0.9)
activerecord (= 3.0.9)
activeresource (= 3.0.9)
activesupport (= 3.0.9)
bundler (~> 1.0)
railties (= 3.0.7)
railties (3.0.7)
actionpack (= 3.0.7)
activesupport (= 3.0.7)
railties (= 3.0.9)
railties (3.0.9)
actionpack (= 3.0.9)
activesupport (= 3.0.9)
rake (>= 0.8.7)
rdoc (~> 3.4)
thor (~> 0.14.4)
rake (0.8.7)
rpm_contrib (2.1.2)
rdoc (3.8)
rpm_contrib (2.1.3)
newrelic_rpm (>= 3.0.0)
shoulda (2.11.3)
shoulda-activemodel (0.0.2)
Expand All @@ -104,7 +106,7 @@ GEM
timecop (0.3.5)
treetop (1.4.9)
polyglot (>= 0.3.1)
tzinfo (0.3.27)
tzinfo (0.3.29)
will_paginate (3.0.pre2)

PLATFORMS
Expand Down
13 changes: 5 additions & 8 deletions app/controllers/analytics_controller.rb
Expand Up @@ -18,7 +18,11 @@ def shell

ms = sprintf("%#.2f", time*1000);

html_result = render_to_string(decide_result_partial(@result[:operation]), :layout => false)
if @result[:operation] == "find"
html_result = render_to_string("_find_result", :layout => false)
else
html_result = ""
end

render_success(ms, html_result, shell.operator, @result[:result])
rescue => e
Expand All @@ -27,13 +31,6 @@ def shell
end

private
def decide_result_partial(type)
case type
when "count" then return "_count_result"
when "find" then return "_find_result"
when "distinct" then return "_distinct_result"
end
end

def render_error(reason)
res = {
Expand Down
3 changes: 0 additions & 3 deletions app/views/analytics/_count_result.html.erb

This file was deleted.

13 changes: 0 additions & 13 deletions app/views/analytics/_distinct_result.html.erb

This file was deleted.

17 changes: 14 additions & 3 deletions public/javascripts/shell.js
Expand Up @@ -128,16 +128,27 @@ var Shell = new function() {

switch (res.op) {
case "count":
x += " - Count result: " + res.result
x += " - Count result: " + "<span class=\"shell-result-string\">" + res.result + "</span>";
break;
case "distinct":
x += " - Distinct result: " + res.result
x += " - Distinct result: " + "<span class=\"shell-result-string\">";
if (res.result.length == 0) {
x += "No matches.";
} else {
for (key in res.result) {
x += res.result[key] + ", ";
}
x = x.substring(0, x.length - 2); // Remove last comma and whitespace.
x += "</span>"
}
break;
}

output(x);

render_result_content(res);
if (res.op == "find") {
render_result_content(res);
}
} else {
output("Error: " + res.reason);
}
Expand Down
4 changes: 4 additions & 0 deletions public/stylesheets/shell.css
Expand Up @@ -42,3 +42,7 @@
position: relative;
top: -3px;
}

.shell-result-string {
color: #fd0c99;
}

0 comments on commit 3a692c7

Please sign in to comment.