Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Fix more bugs related to mi3

  • Loading branch information...
commit 9fb9c7c56f433125892a08f8a7e3bbc63c1114bc 1 parent ff859d1
@dcu dcu authored
View
1  Gemfile
@@ -12,5 +12,6 @@ group :development do
gem "rspec", "~> 2.3.0"
gem "yard", "~> 0.6.0"
gem "jeweler", "~> 1.6.0"
+ gem 'pry'
end
View
32 Gemfile.lock
@@ -1,15 +1,15 @@
GEM
remote: http://rubygems.org/
specs:
- activemodel (3.2.5)
- activesupport (= 3.2.5)
+ activemodel (3.2.7)
+ activesupport (= 3.2.7)
builder (~> 3.0.0)
- activesupport (3.2.5)
+ activesupport (3.2.7)
i18n (~> 0.6)
multi_json (~> 1.0)
- addressable (2.2.8)
- bson (1.6.2)
+ addressable (2.3.2)
builder (3.0.0)
+ coderay (1.0.7)
diff-lcs (1.1.3)
git (1.2.5)
haml (3.1.6)
@@ -18,15 +18,21 @@ GEM
bundler (~> 1.0)
git (>= 1.2.5)
rake
- launchy (2.1.0)
- addressable (~> 2.2.6)
- mongo (1.6.2)
- bson (~> 1.6.2)
- mongoid (2.4.10)
+ launchy (2.1.1)
+ addressable (~> 2.3)
+ method_source (0.8)
+ mongoid (3.0.3)
activemodel (~> 3.1)
- mongo (~> 1.3)
+ moped (~> 1.1)
+ origin (~> 1.0)
tzinfo (~> 0.3.22)
+ moped (1.2.0)
multi_json (1.3.6)
+ origin (1.0.4)
+ pry (0.9.10)
+ coderay (~> 1.0.5)
+ method_source (~> 0.8)
+ slop (~> 3.3.1)
rack (1.4.1)
rack-protection (1.2.0)
rack
@@ -39,13 +45,14 @@ GEM
rspec-expectations (2.3.0)
diff-lcs (~> 1.1.2)
rspec-mocks (2.3.0)
- sass (3.1.19)
+ sass (3.1.20)
shotgun (0.9)
rack (>= 1.0)
sinatra (1.3.2)
rack (~> 1.3, >= 1.3.6)
rack-protection (~> 1.2)
tilt (~> 1.3, >= 1.3.3)
+ slop (3.3.2)
tilt (1.3.3)
tzinfo (0.3.33)
yard (0.6.8)
@@ -58,6 +65,7 @@ DEPENDENCIES
jeweler (~> 1.6.0)
launchy
mongoid
+ pry
rack (>= 1.0.0)
rspec (~> 2.3.0)
sass
View
20 lib/bug_hunter.rb
@@ -1,21 +1,23 @@
require 'rubygems'
+require 'bundler/setup'
$:.unshift File.expand_path("..", __FILE__)
+Bundler.require
+
require 'json'
require 'benchmark'
require 'sinatra'
require 'haml'
require 'sass'
-require 'mongo'
-require 'bson'
require 'mongoid'
require 'net/http'
require 'uri'
require 'cgi'
require 'benchmark'
+require 'pry'
require 'bug_hunter/config'
require 'bug_hunter/middleware'
@@ -64,31 +66,31 @@ def self.push_list(name, row)
end
def self.increment_counter(name, value)
- BugHunter::CounterWidget.collection.update({:name => name}, {:$inc => {:value => value}}, {:multi => true})
+ BugHunter::CounterWidget.collection.find({:name => name}).update_all({:$inc => {:value => value}})
end
def self.set_counter(name, value)
- BugHunter::CounterWidget.collection.update({:name => name}, {:$set => {:value => value}}, {:multi => true})
+ BugHunter::CounterWidget.collection.find({:name => name}).update_all({:$set => {:value => value}})
end
def self.connect
begin
return if !Mongoid.sessions.empty? || Mongoid.session(:default)
- rescue Mongoid::Errors::InvalidDatabase, TypeError
+ rescue Mongoid::Errors::InvalidDatabase, Mongoid::Errors::NoSessionConfig, TypeError
# let it pass to configure the database
end
- ENV["RACK_ENV"] ||= ENV["RAILS_ENV"]
+ ENV["RACK_ENV"] ||= ENV["RAILS_ENV"] || 'development'
if !ENV["RACK_ENV"]
raise ArgumentError, "please define the env var RACK_ENV"
end
if File.exist?("/etc/mongoid.yml")
- Mongoid.load("/etc/mongoid.yml")
+ Mongoid.load("/etc/mongoid.yml", ENV['RACK_ENV'])
elsif File.exist?("config/mongoid.yml")
- Mongoid.load!("config/mongoid.yml")
+ Mongoid.load!("config/mongoid.yml", ENV['RACK_ENV'])
elsif File.exist?("mongoid.yml")
- Mongoid.load!("mongoid.yml")
+ Mongoid.load!("mongoid.yml", ENV['RACK_ENV'])
else
raise ArgumentError, "/etc/mongoid.yml, ./config/mongoid.yml or ./mongoid.yml were not found"
end
View
4 lib/bug_hunter/app.rb
@@ -3,6 +3,8 @@ class App < Sinatra::Base
include BugHunter::UiHelper
include BugHunter::RoutesHelper
+ use BugHunter::Middleware # NOTE: uncomment this line for development purposes
+
def initialize(*args)
BugHunter.connect
super(*args)
@@ -18,8 +20,6 @@ def self.setup_application!
def self.reload!
end
-# use BugHunter::Middleware # NOTE: uncomment this line for development purposes
-
use BugHunter::DashboardApp
helpers do
View
9 lib/bug_hunter/middleware.rb
@@ -16,7 +16,6 @@ def call(env)
end
rescue StandardError, LoadError, SyntaxError => e
register_error(env, e)
-
raise e
end
@@ -27,9 +26,11 @@ def register_error(env, e)
error = BugHunter::Error.build_from(env, e)
if !error.valid? && !error.errors[:uniqueness].empty?
- BugHunter::Error.collection.update(error.unique_error_selector,
- {:$inc => {:times => 1}, :$set => {:updated_at => Time.now.utc}},
- {:multi => true})
+ BugHunter::Error.collection.find(error.unique_error_selector).
+ update_all({
+ :$inc => {:times => 1},
+ :$set => {:updated_at => Time.now.utc}
+ })
else
error.save!
end
View
2  lib/bug_hunter/models/list_widget.rb
@@ -5,7 +5,7 @@ class ListWidget < BugHunter::Widget
field :data, :type => Array, :default => []
def self.add_row(name, row)
- self.collection.update({:name => name}, {:$push => {:data => row}}, {:multi => true})
+ self.collection.find({:name => name}).update_all({:$push => {:data => row}})
end
def find_data
View
2  lib/bug_hunter/models/table_widget.rb
@@ -6,7 +6,7 @@ class TableWidget < BugHunter::Widget
field :data, :type => Array, :default => []
def self.add_row(name, *row)
- BugHunter::TableWidget.collection.update({:name => name}, {:$push => {:data => row}}, {:multi => true})
+ BugHunter::TableWidget.collection.find({:name => name}).update_all({:$push => {:data => row}})
end
def find_data
Please sign in to comment.
Something went wrong with that request. Please try again.