bug_hunter 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,5 @@
1
+ lib/**/*.rb
2
+ bin/*
3
+ -
4
+ features/**/*.feature
5
+ LICENSE.txt
data/.rspec ADDED
@@ -0,0 +1 @@
1
+ --color
data/Gemfile ADDED
@@ -0,0 +1,17 @@
1
+ source "http://rubygems.org"
2
+
3
+ gem "rack", ">= 1.0.0"
4
+ gem 'sinatra', '~> 1.2.6'
5
+ gem 'haml'
6
+ gem 'sass'
7
+ gem 'launchy'
8
+ gem 'mongoid'
9
+
10
+ group :development do
11
+ gem "rspec", "~> 2.3.0"
12
+ gem "yard", "~> 0.6.0"
13
+ gem "bundler", "~> 1.0.0"
14
+ gem "jeweler", "~> 1.6.0"
15
+ gem "rcov", ">= 0"
16
+ end
17
+
@@ -0,0 +1,64 @@
1
+ GEM
2
+ remote: http://rubygems.org/
3
+ specs:
4
+ activemodel (3.0.7)
5
+ activesupport (= 3.0.7)
6
+ builder (~> 2.1.2)
7
+ i18n (~> 0.5.0)
8
+ activesupport (3.0.7)
9
+ bson (1.3.1)
10
+ builder (2.1.2)
11
+ configuration (1.2.0)
12
+ diff-lcs (1.1.2)
13
+ git (1.2.5)
14
+ haml (3.1.1)
15
+ i18n (0.5.0)
16
+ jeweler (1.6.0)
17
+ bundler (~> 1.0.0)
18
+ git (>= 1.2.5)
19
+ rake
20
+ launchy (0.4.0)
21
+ configuration (>= 0.0.5)
22
+ rake (>= 0.8.1)
23
+ mongo (1.3.1)
24
+ bson (>= 1.3.1)
25
+ mongoid (2.0.1)
26
+ activemodel (~> 3.0)
27
+ mongo (~> 1.3)
28
+ tzinfo (~> 0.3.22)
29
+ will_paginate (~> 3.0.pre)
30
+ rack (1.3.0)
31
+ rake (0.8.7)
32
+ rcov (0.9.9)
33
+ rspec (2.3.0)
34
+ rspec-core (~> 2.3.0)
35
+ rspec-expectations (~> 2.3.0)
36
+ rspec-mocks (~> 2.3.0)
37
+ rspec-core (2.3.1)
38
+ rspec-expectations (2.3.0)
39
+ diff-lcs (~> 1.1.2)
40
+ rspec-mocks (2.3.0)
41
+ sass (3.1.1)
42
+ sinatra (1.2.6)
43
+ rack (~> 1.1)
44
+ tilt (>= 1.2.2, < 2.0)
45
+ tilt (1.3.2)
46
+ tzinfo (0.3.27)
47
+ will_paginate (3.0.pre2)
48
+ yard (0.6.7)
49
+
50
+ PLATFORMS
51
+ ruby
52
+
53
+ DEPENDENCIES
54
+ bundler (~> 1.0.0)
55
+ haml
56
+ jeweler (~> 1.6.0)
57
+ launchy
58
+ mongoid
59
+ rack (>= 1.0.0)
60
+ rcov
61
+ rspec (~> 2.3.0)
62
+ sass
63
+ sinatra (~> 1.2.6)
64
+ yard (~> 0.6.0)
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2011 David A. Cuadrado
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,19 @@
1
+ = bug_hunter
2
+
3
+ Description goes here.
4
+
5
+ == Contributing to bug_hunter
6
+
7
+ * Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet
8
+ * Check out the issue tracker to make sure someone already hasn't requested it and/or contributed it
9
+ * Fork the project
10
+ * Start a feature/bugfix branch
11
+ * Commit and push until you are happy with your contribution
12
+ * Make sure to add tests for it. This is important so I don't break it in a future version unintentionally.
13
+ * Please try not to mess with the Rakefile, version, or history. If you want to have your own version, or is otherwise necessary, that is fine, but please isolate to its own commit so I can cherry-pick around it.
14
+
15
+ == Copyright
16
+
17
+ Copyright (c) 2011 David A. Cuadrado. See LICENSE.txt for
18
+ further details.
19
+
@@ -0,0 +1,42 @@
1
+ # encoding: utf-8
2
+
3
+ require 'rubygems'
4
+ require 'bundler'
5
+ begin
6
+ Bundler.setup(:default, :development)
7
+ rescue Bundler::BundlerError => e
8
+ $stderr.puts e.message
9
+ $stderr.puts "Run `bundle install` to install missing gems"
10
+ exit e.status_code
11
+ end
12
+ require 'rake'
13
+
14
+ require 'jeweler'
15
+ Jeweler::Tasks.new do |gem|
16
+ # gem is a Gem::Specification... see http://docs.rubygems.org/read/chapter/20 for more options
17
+ gem.name = "bug_hunter"
18
+ gem.homepage = "http://github.com/dcu/bug_hunter"
19
+ gem.license = "MIT"
20
+ gem.summary = %Q{sinatra app to manage exceptions}
21
+ gem.description = %Q{sinatra app to manage web app exceptions}
22
+ gem.email = "krawek@gmail.com"
23
+ gem.authors = ["David A. Cuadrado"]
24
+ # dependencies defined in Gemfile
25
+ end
26
+ Jeweler::RubygemsDotOrgTasks.new
27
+
28
+ require 'rspec/core'
29
+ require 'rspec/core/rake_task'
30
+ RSpec::Core::RakeTask.new(:spec) do |spec|
31
+ spec.pattern = FileList['spec/**/*_spec.rb']
32
+ end
33
+
34
+ RSpec::Core::RakeTask.new(:rcov) do |spec|
35
+ spec.pattern = 'spec/**/*_spec.rb'
36
+ spec.rcov = true
37
+ end
38
+
39
+ task :default => :spec
40
+
41
+ require 'yard'
42
+ YARD::Rake::YardocTask.new
data/VERSION ADDED
@@ -0,0 +1 @@
1
+ 0.0.1
@@ -0,0 +1,33 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ $:.unshift << File.expand_path("../../lib", __FILE__)
4
+
5
+ require 'bug_hunter'
6
+ require 'launchy'
7
+ require 'fileutils'
8
+
9
+ if ARGV[0] == "--install"
10
+ base_path = File.expand_path("../../", __FILE__)
11
+
12
+ if File.exist?("public/javascripts/") && File.exist?("public/stylesheets/")
13
+ FileUtils.cp_r("#{base_path}/public/javascripts/", "public/")
14
+ FileUtils.cp_r("#{base_path}/public/stylesheets/", "public/")
15
+ else
16
+ raise ArgumentError, "public/javascripts and public/stylesheets do not exist"
17
+ end
18
+
19
+
20
+ exit 0
21
+ end
22
+
23
+ Thread.start do
24
+ sleep 2.5
25
+ Launchy.open("http://localhost:9753")
26
+ end
27
+
28
+ Rack::Server.new(:Port => "9753",
29
+ :config => File.dirname(__FILE__)+"/../config.ru",
30
+ :AccessLog => [],
31
+ :pid => nil,
32
+ :Host => "0.0.0.0").start
33
+
@@ -0,0 +1,104 @@
1
+ # Generated by jeweler
2
+ # DO NOT EDIT THIS FILE DIRECTLY
3
+ # Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
4
+ # -*- encoding: utf-8 -*-
5
+
6
+ Gem::Specification.new do |s|
7
+ s.name = %q{bug_hunter}
8
+ s.version = "0.0.1"
9
+
10
+ s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
+ s.authors = ["David A. Cuadrado"]
12
+ s.date = %q{2011-05-28}
13
+ s.default_executable = %q{bug_hunter}
14
+ s.description = %q{sinatra app to manage web app exceptions}
15
+ s.email = %q{krawek@gmail.com}
16
+ s.executables = ["bug_hunter"]
17
+ s.extra_rdoc_files = [
18
+ "LICENSE.txt",
19
+ "README.rdoc"
20
+ ]
21
+ s.files = [
22
+ ".document",
23
+ ".rspec",
24
+ "Gemfile",
25
+ "LICENSE.txt",
26
+ "README.rdoc",
27
+ "Rakefile",
28
+ "bin/bug_hunter",
29
+ "config.ru",
30
+ "lib/bug_hunter.rb",
31
+ "lib/bug_hunter/app.rb",
32
+ "lib/bug_hunter/config.rb",
33
+ "lib/bug_hunter/middleware.rb",
34
+ "lib/bug_hunter/models.rb",
35
+ "lib/bug_hunter/routes_helper.rb",
36
+ "lib/bug_hunter/ui_helper.rb",
37
+ "lib/bug_hunter/views/errors/_error_info.haml",
38
+ "lib/bug_hunter/views/errors/assign.haml",
39
+ "lib/bug_hunter/views/errors/show.haml",
40
+ "lib/bug_hunter/views/index.haml",
41
+ "lib/bug_hunter/views/layout.haml",
42
+ "public/javascripts/bug_hunter.js",
43
+ "public/javascripts/jquery.mobile-1.0b1pre.min.js",
44
+ "public/stylesheets/highlight.css",
45
+ "public/stylesheets/images/ajax-loader.png",
46
+ "public/stylesheets/images/icon-search-black.png",
47
+ "public/stylesheets/images/icons-18-black.png",
48
+ "public/stylesheets/images/icons-18-white.png",
49
+ "public/stylesheets/images/icons-36-black.png",
50
+ "public/stylesheets/images/icons-36-white.png",
51
+ "public/stylesheets/jquery.mobile-1.0b1pre.min.css",
52
+ "spec/bug_hunter_spec.rb",
53
+ "spec/spec_helper.rb"
54
+ ]
55
+ s.homepage = %q{http://github.com/dcu/bug_hunter}
56
+ s.licenses = ["MIT"]
57
+ s.require_paths = ["lib"]
58
+ s.rubygems_version = %q{1.3.7}
59
+ s.summary = %q{sinatra app to manage exceptions}
60
+
61
+ if s.respond_to? :specification_version then
62
+ current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
63
+ s.specification_version = 3
64
+
65
+ if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
66
+ s.add_runtime_dependency(%q<rack>, [">= 1.0.0"])
67
+ s.add_runtime_dependency(%q<sinatra>, ["~> 1.2.6"])
68
+ s.add_runtime_dependency(%q<haml>, [">= 0"])
69
+ s.add_runtime_dependency(%q<sass>, [">= 0"])
70
+ s.add_runtime_dependency(%q<launchy>, [">= 0"])
71
+ s.add_runtime_dependency(%q<mongoid>, [">= 0"])
72
+ s.add_development_dependency(%q<rspec>, ["~> 2.3.0"])
73
+ s.add_development_dependency(%q<yard>, ["~> 0.6.0"])
74
+ s.add_development_dependency(%q<bundler>, ["~> 1.0.0"])
75
+ s.add_development_dependency(%q<jeweler>, ["~> 1.6.0"])
76
+ s.add_development_dependency(%q<rcov>, [">= 0"])
77
+ else
78
+ s.add_dependency(%q<rack>, [">= 1.0.0"])
79
+ s.add_dependency(%q<sinatra>, ["~> 1.2.6"])
80
+ s.add_dependency(%q<haml>, [">= 0"])
81
+ s.add_dependency(%q<sass>, [">= 0"])
82
+ s.add_dependency(%q<launchy>, [">= 0"])
83
+ s.add_dependency(%q<mongoid>, [">= 0"])
84
+ s.add_dependency(%q<rspec>, ["~> 2.3.0"])
85
+ s.add_dependency(%q<yard>, ["~> 0.6.0"])
86
+ s.add_dependency(%q<bundler>, ["~> 1.0.0"])
87
+ s.add_dependency(%q<jeweler>, ["~> 1.6.0"])
88
+ s.add_dependency(%q<rcov>, [">= 0"])
89
+ end
90
+ else
91
+ s.add_dependency(%q<rack>, [">= 1.0.0"])
92
+ s.add_dependency(%q<sinatra>, ["~> 1.2.6"])
93
+ s.add_dependency(%q<haml>, [">= 0"])
94
+ s.add_dependency(%q<sass>, [">= 0"])
95
+ s.add_dependency(%q<launchy>, [">= 0"])
96
+ s.add_dependency(%q<mongoid>, [">= 0"])
97
+ s.add_dependency(%q<rspec>, ["~> 2.3.0"])
98
+ s.add_dependency(%q<yard>, ["~> 0.6.0"])
99
+ s.add_dependency(%q<bundler>, ["~> 1.0.0"])
100
+ s.add_dependency(%q<jeweler>, ["~> 1.6.0"])
101
+ s.add_dependency(%q<rcov>, [">= 0"])
102
+ end
103
+ end
104
+
@@ -0,0 +1,5 @@
1
+ $:.unshift File.expand_path("../lib", __FILE__)
2
+ require 'bug_hunter'
3
+
4
+ run BugHunter.app
5
+
@@ -0,0 +1,50 @@
1
+ require 'rubygems'
2
+
3
+ $:.unshift File.expand_path("..", __FILE__)
4
+
5
+ require 'json'
6
+
7
+ require 'benchmark'
8
+ require 'sinatra'
9
+ require 'haml'
10
+ require 'sass'
11
+ require 'mongo'
12
+ require 'bson'
13
+ require 'mongoid'
14
+
15
+ require 'net/http'
16
+ require 'uri'
17
+ require 'cgi'
18
+
19
+ require 'bug_hunter/config'
20
+ require 'bug_hunter/middleware'
21
+ require 'bug_hunter/ui_helper'
22
+ require 'bug_hunter/routes_helper'
23
+ require 'bug_hunter/models'
24
+ require 'bug_hunter/app'
25
+
26
+ module BugHunter
27
+ def self.app
28
+ BugHunter::App
29
+ end
30
+
31
+ def self.connect
32
+ return unless Mongoid.config.databases.empty?
33
+
34
+ ENV["RACK_ENV"] ||= ENV["RAILS_ENV"]
35
+ if !ENV["RACK_ENV"]
36
+ raise ArgumentError, "please define the env var RACK_ENV"
37
+ end
38
+
39
+ if File.exist?("/etc/mongoid.yml")
40
+ Mongoid.load("/etc/mongoid.yml")
41
+ elsif File.exist?("config/mongoid.yml")
42
+ Mongoid.load!("config/mongoid.yml")
43
+ elsif File.exist?("mongoid.yml")
44
+ Mongoid.load!("mongoid.yml")
45
+ else
46
+ raise ArgumentError, "/etc/mongoid.yml, ./config/mongoid.yml or ./mongoid.yml were not found"
47
+ end
48
+ end
49
+ end
50
+
@@ -0,0 +1,108 @@
1
+ module BugHunter
2
+ class App < Sinatra::Base
3
+ include BugHunter::UiHelper
4
+ include BugHunter::RoutesHelper
5
+
6
+ if BugHunter.config["enable_auth"]
7
+ use Rack::Auth::Basic, "Restricted Area" do |username, password|
8
+ [username, password] == [BugHunter.config["username"], BugHunter.config["password"]]
9
+ end
10
+ end
11
+
12
+ def initialize(*args)
13
+ BugHunter.connect
14
+ super(*args)
15
+ end
16
+
17
+ #use BugHunter::Middleware
18
+
19
+ helpers do
20
+ include Rack::Utils
21
+ alias_method :h, :escape_html
22
+ end
23
+
24
+ set :public, File.expand_path("../../../public", __FILE__)
25
+ set :views, File.expand_path("../../../lib/bug_hunter/views", __FILE__)
26
+
27
+ before do
28
+ end
29
+
30
+ get "/" do
31
+ conds = {:resolved => false}
32
+ if params[:resolved] == "1"
33
+ conds[:resolved] = true
34
+ end
35
+
36
+ if params[:unassigned] == "1"
37
+ conds[:assignee] = nil
38
+ elsif params[:assignee]
39
+ conds[:assignee] = params[:assignee]
40
+ end
41
+
42
+ @errors = BugHunter::Error.minimal.where(conds).all
43
+ # paginate(:per_page => params[:per_page]||25, :page => params[:page])
44
+
45
+ haml :"index"
46
+ end
47
+
48
+ get "/errors/:id" do
49
+ @error = BugHunter::Error.find(params[:id])
50
+
51
+ haml :"errors/show"
52
+ end
53
+
54
+ post "/errors/:id/comment" do
55
+ @error = BugHunter::Error.minimal.find(params[:id])
56
+ @error.add_comment(params[:from], params[:message], request.ip)
57
+
58
+ redirect error_path(@error)
59
+ end
60
+
61
+ get "/errors/:id/resolve" do
62
+ @error = BugHunter::Error.minimal.find(params[:id])
63
+ @error.resolve!
64
+
65
+ redirect error_path(@error)
66
+ end
67
+
68
+ get "/errors/:id/assign" do
69
+ @error = BugHunter::Error.minimal.find(params[:id])
70
+
71
+ haml :"errors/assign"
72
+ end
73
+
74
+ get "/errors/:id/assign_to" do
75
+ @error = BugHunter::Error.minimal.find(params[:id])
76
+
77
+ @error.assignee = params[:member]
78
+ @error.save(:validate => false)
79
+
80
+ redirect error_path(@error)
81
+ end
82
+
83
+ post "/add_member" do
84
+ project = Project.instance
85
+ member = params[:name]
86
+ project.members << member if member && !member.empty?
87
+
88
+ if project.save
89
+ if params[:assign_to]
90
+ @error = BugHunter::Error.minimal.find(params[:assign_to])
91
+ @error.assignee = member
92
+ @error.save(:validate => false)
93
+ end
94
+ end
95
+
96
+ if @error
97
+ redirect error_path(@error)
98
+ else
99
+ redirect "/"
100
+ end
101
+ end
102
+
103
+ private
104
+ def error_not_found
105
+ status 404
106
+ end
107
+ end
108
+ end