shelltoad 0.2.5 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- data/Changelog.textile +6 -0
- data/Gemfile +1 -5
- data/Gemfile.lock +8 -4
- data/Readme.textile +4 -2
- data/VERSION +1 -1
- data/lib/shelltoad/configuration.rb +36 -8
- data/lib/shelltoad/error.rb +97 -98
- data/shelltoad.gemspec +5 -8
- data/spec/assets/error.xml +1 -1
- data/spec/shelltoad_spec.rb +2 -18
- data/spec/spec_helper.rb +3 -2
- metadata +7 -21
data/Changelog.textile
CHANGED
data/Gemfile
CHANGED
@@ -1,11 +1,7 @@
|
|
1
1
|
source :gemcutter
|
2
2
|
|
3
3
|
gem "rake"
|
4
|
-
gem
|
5
|
-
# We use some hash extensions -
|
6
|
-
# #from_xml and #with_indifferent_access from activesupport
|
7
|
-
# By some unknown reason these extensions require i18n
|
8
|
-
gem "i18n"
|
4
|
+
gem "hoptoad-api"
|
9
5
|
|
10
6
|
group :development do
|
11
7
|
gem 'jeweler'
|
data/Gemfile.lock
CHANGED
@@ -1,11 +1,16 @@
|
|
1
1
|
GEM
|
2
2
|
remote: http://rubygems.org/
|
3
3
|
specs:
|
4
|
-
|
4
|
+
crack (0.1.8)
|
5
5
|
diff-lcs (1.1.2)
|
6
6
|
fakeweb (1.3.0)
|
7
7
|
git (1.2.5)
|
8
|
-
|
8
|
+
hashie (0.4.0)
|
9
|
+
hoptoad-api (2.3.0)
|
10
|
+
hashie (>= 0.2.0)
|
11
|
+
httparty (>= 0.5.2)
|
12
|
+
httparty (0.6.1)
|
13
|
+
crack (= 0.1.8)
|
9
14
|
jeweler (1.5.2)
|
10
15
|
bundler (~> 1.0.0)
|
11
16
|
git (>= 1.2.5)
|
@@ -25,9 +30,8 @@ PLATFORMS
|
|
25
30
|
ruby
|
26
31
|
|
27
32
|
DEPENDENCIES
|
28
|
-
activesupport
|
29
33
|
fakeweb
|
30
|
-
|
34
|
+
hoptoad-api
|
31
35
|
jeweler
|
32
36
|
mocha
|
33
37
|
rake
|
data/Readme.textile
CHANGED
@@ -6,8 +6,10 @@ h3. Configuration
|
|
6
6
|
|
7
7
|
Create <pre><code>.shelltoadrc</code></pre> file in your project directory
|
8
8
|
with the application name and access key:
|
9
|
-
<pre><code>
|
10
|
-
key: c285743ecbc285743ecbc285743ecbc285743ecb
|
9
|
+
<pre><code>account: myapp
|
10
|
+
key: c285743ecbc285743ecbc285743ecbc285743ecb
|
11
|
+
secure true # https usage. Default: false
|
12
|
+
project_id: 123456 # see errors only under specified proejct. Default: all projects</code></pre>
|
11
13
|
|
12
14
|
h3. Commands
|
13
15
|
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.
|
1
|
+
0.3.0
|
@@ -1,12 +1,37 @@
|
|
1
1
|
require "yaml"
|
2
|
+
require "hoptoad-api"
|
2
3
|
|
3
4
|
|
4
5
|
class Shelltoad::Configuration
|
5
6
|
|
7
|
+
#
|
8
|
+
# Class methods
|
9
|
+
#
|
10
|
+
|
11
|
+
def self.key
|
12
|
+
self.instance.key
|
13
|
+
end
|
14
|
+
|
15
|
+
def self.project_id
|
16
|
+
self.instance.project_id
|
17
|
+
end
|
18
|
+
|
19
|
+
def self.secure?
|
20
|
+
self.instance.secure
|
21
|
+
end
|
22
|
+
|
23
|
+
def self.account
|
24
|
+
self.instance.account
|
25
|
+
end
|
26
|
+
|
6
27
|
def self.instance
|
7
28
|
@instance ||= self.new
|
8
29
|
end
|
9
30
|
|
31
|
+
#
|
32
|
+
# API
|
33
|
+
#
|
34
|
+
|
10
35
|
def initialize
|
11
36
|
if File.exists?(".shelltoadrc")
|
12
37
|
@config = YAML.load(File.new(".shelltoadrc"))
|
@@ -15,20 +40,23 @@ class Shelltoad::Configuration
|
|
15
40
|
end
|
16
41
|
end
|
17
42
|
|
18
|
-
def
|
19
|
-
|
43
|
+
def key
|
44
|
+
@config["key"] || raise(::Shelltoad::NoApiKey, "key option not specified in .shelltoadrc")
|
20
45
|
end
|
21
46
|
|
22
|
-
def
|
23
|
-
|
47
|
+
def project_id
|
48
|
+
@config["project_id"]
|
24
49
|
end
|
25
50
|
|
26
|
-
def
|
27
|
-
@config
|
51
|
+
def account
|
52
|
+
(@config["account"] || @config["project"]) || raise(::Shelltoad::BaseException, "account option not specified in .shelltoadrc")
|
28
53
|
end
|
29
54
|
|
30
|
-
def
|
31
|
-
@config
|
55
|
+
def secure
|
56
|
+
@config["secure"] # false by default
|
32
57
|
end
|
58
|
+
|
33
59
|
end
|
34
60
|
|
61
|
+
Hoptoad.auth_token = Shelltoad::Configuration.key
|
62
|
+
Hoptoad.account = Shelltoad::Configuration.account
|
data/lib/shelltoad/error.rb
CHANGED
@@ -1,127 +1,126 @@
|
|
1
|
-
require "active_support/core_ext/hash/conversions"
|
2
|
-
require "active_support/core_ext/hash/indifferent_access"
|
3
|
-
require "net/http"
|
4
1
|
require "uri"
|
5
2
|
require "cgi"
|
3
|
+
require "hoptoad-api"
|
6
4
|
|
7
|
-
class Shelltoad
|
5
|
+
class Shelltoad
|
6
|
+
class Error
|
8
7
|
|
9
|
-
|
8
|
+
URL = URI.parse("#{Configuration.secure? ? "https" : "http"}://#{Configuration.account}.hoptoadapp.com:80")
|
10
9
|
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
10
|
+
#
|
11
|
+
# Class methods
|
12
|
+
#
|
13
|
+
|
14
|
+
def self.all(options = {})
|
15
|
+
options[:project_id] ||= Configuration.project_id if Configuration.project_id
|
16
|
+
Hoptoad::Error.find(:all, options).map! do |attributes|
|
17
|
+
self.new(attributes)
|
18
|
+
end
|
18
19
|
end
|
19
|
-
end
|
20
20
|
|
21
|
-
|
22
|
-
|
23
|
-
|
21
|
+
def self.magic_find(id)
|
22
|
+
error = id.to_s.size > 5 ? simple_finder(id) : magic_finder(id)
|
23
|
+
if block_given?
|
24
|
+
return yield(error)
|
25
|
+
end
|
26
|
+
error
|
24
27
|
end
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
+
|
29
|
+
def self.magic_finder(id)
|
30
|
+
1.upto(3) do |page|
|
31
|
+
self.all(:show_resolved => true, :page => page).each do |error|
|
32
|
+
return self.new(error) if error.id.to_s =~ /#{id}$/
|
33
|
+
end
|
34
|
+
end
|
35
|
+
raise ErrorNotFound, "Error with id like *#{id} not found among last 90 errors.\n Try input full id."
|
28
36
|
end
|
29
|
-
error
|
30
|
-
end
|
31
37
|
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
def initialize(attributes)
|
37
|
-
@attributes = attributes
|
38
|
-
end
|
38
|
+
def self.simple_finder(id)
|
39
|
+
attributes = Hoptoad::Error.find(id) || raise(ErrorNotFound, "Error with id #{id} not found under this account.")
|
40
|
+
self.new(attributes, true)
|
41
|
+
end
|
39
42
|
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
+
#
|
44
|
+
# API
|
45
|
+
#
|
43
46
|
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
EOI
|
49
|
-
end
|
47
|
+
def initialize(attributes, full = false)
|
48
|
+
@attributes = attributes
|
49
|
+
@data = attributes if full
|
50
|
+
end
|
50
51
|
|
51
|
-
|
52
|
-
|
53
|
-
|
52
|
+
def data
|
53
|
+
@data ||= Hoptoad::Error.find(self.id)
|
54
|
+
end
|
54
55
|
|
55
|
-
|
56
|
-
|
57
|
-
output = `git commit -m "#{message}"`
|
58
|
-
if $?.success?
|
59
|
-
resolve!
|
56
|
+
def lines
|
57
|
+
self.data[:backtrace][:line]
|
60
58
|
end
|
61
|
-
output
|
62
|
-
end
|
63
59
|
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
:_method => :put,
|
71
|
-
:auth_token => ::Shelltoad::Configuration.key
|
72
|
-
)
|
73
|
-
raise "HTTP error: #{response}" unless response.is_a?(Net::HTTPSuccess)
|
74
|
-
true
|
75
|
-
end
|
60
|
+
def view
|
61
|
+
<<-EOI
|
62
|
+
#{self.error_message}
|
63
|
+
#{self.lines.join("\n")}
|
64
|
+
EOI
|
65
|
+
end
|
76
66
|
|
67
|
+
def commit!
|
68
|
+
message = <<-EOI.gsub(/`/, "'")
|
69
|
+
#{url.to_s}
|
70
|
+
|
71
|
+
#{self.error_message}
|
72
|
+
EOI
|
73
|
+
output = `git commit -m "#{message}"`
|
74
|
+
if $?.success?
|
75
|
+
resolve!
|
76
|
+
end
|
77
|
+
output
|
78
|
+
end
|
77
79
|
|
78
|
-
|
79
|
-
|
80
|
-
|
80
|
+
def resolve!
|
81
|
+
return true if self.resolved?
|
82
|
+
Hoptoad::Error.put(path("xml"), :body => {:group => {:resolved => 1}})
|
83
|
+
true
|
84
|
+
end
|
81
85
|
|
82
|
-
def id
|
83
|
-
@attributes[:id]
|
84
|
-
end
|
85
86
|
|
86
|
-
|
87
|
-
|
88
|
-
|
87
|
+
def to_s
|
88
|
+
"[##{self.id}] #{self.rails_env.first} #{self.error_message} #{self.file}:#{self.line_number}"
|
89
|
+
end
|
89
90
|
|
90
|
-
|
91
|
-
|
92
|
-
attr
|
93
|
-
else
|
94
|
-
super(meth, *args, &blk)
|
91
|
+
def id
|
92
|
+
@attributes[:id]
|
95
93
|
end
|
96
|
-
end
|
97
94
|
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
protected
|
103
|
-
def path(format = nil)
|
104
|
-
"/errors/#{self.id}" + (format ? ".#{format}" : "")
|
105
|
-
end
|
95
|
+
def resolved?
|
96
|
+
@attributes[:resolved]
|
97
|
+
end
|
106
98
|
|
107
|
-
|
108
|
-
|
109
|
-
|
99
|
+
def [](key)
|
100
|
+
@attributes[key] || self.data[key]
|
101
|
+
end
|
110
102
|
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
103
|
+
def method_missing(meth, *args, &blk)
|
104
|
+
if attr = @attributes[meth]
|
105
|
+
attr
|
106
|
+
else
|
107
|
+
super(meth, *args, &blk)
|
108
|
+
end
|
109
|
+
end
|
110
|
+
|
111
|
+
#
|
112
|
+
# Implementation
|
113
|
+
#
|
114
|
+
|
115
|
+
protected
|
116
|
+
def path(format = nil)
|
117
|
+
"/errors/#{self.id}" + (format ? ".#{format}" : "")
|
118
|
+
end
|
119
|
+
|
120
|
+
def url(format = nil)
|
121
|
+
URI.parse(URL.to_s + path(format))
|
122
|
+
end
|
121
123
|
|
122
|
-
def self.parse(string)
|
123
|
-
Hash.from_xml(string).with_indifferent_access
|
124
124
|
end
|
125
125
|
|
126
126
|
end
|
127
|
-
|
data/shelltoad.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{shelltoad}
|
8
|
-
s.version = "0.2.
|
8
|
+
s.version = "0.2.5"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Bogdan Gusiev"]
|
12
|
-
s.date = %q{2011-04-
|
12
|
+
s.date = %q{2011-04-06}
|
13
13
|
s.default_executable = %q{shelltoad}
|
14
14
|
s.description = %q{
|
15
15
|
}
|
@@ -51,19 +51,16 @@ Gem::Specification.new do |s|
|
|
51
51
|
|
52
52
|
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
53
53
|
s.add_runtime_dependency(%q<rake>, [">= 0"])
|
54
|
-
s.add_runtime_dependency(%q<
|
55
|
-
s.add_runtime_dependency(%q<i18n>, [">= 0"])
|
54
|
+
s.add_runtime_dependency(%q<hoptoad-api>, [">= 0"])
|
56
55
|
s.add_development_dependency(%q<jeweler>, [">= 0"])
|
57
56
|
else
|
58
57
|
s.add_dependency(%q<rake>, [">= 0"])
|
59
|
-
s.add_dependency(%q<
|
60
|
-
s.add_dependency(%q<i18n>, [">= 0"])
|
58
|
+
s.add_dependency(%q<hoptoad-api>, [">= 0"])
|
61
59
|
s.add_dependency(%q<jeweler>, [">= 0"])
|
62
60
|
end
|
63
61
|
else
|
64
62
|
s.add_dependency(%q<rake>, [">= 0"])
|
65
|
-
s.add_dependency(%q<
|
66
|
-
s.add_dependency(%q<i18n>, [">= 0"])
|
63
|
+
s.add_dependency(%q<hoptoad-api>, [">= 0"])
|
67
64
|
s.add_dependency(%q<jeweler>, [">= 0"])
|
68
65
|
end
|
69
66
|
end
|
data/spec/assets/error.xml
CHANGED
@@ -8,7 +8,7 @@
|
|
8
8
|
<resolved type="boolean">false</resolved>
|
9
9
|
<error-class>ActiveRecord::StatementInvalid</error-class>
|
10
10
|
<error-message>ActiveRecord::StatementInvalid: PGError: ERROR: duplicate key value violates unique constraint "index_companies_on_slug" : INSERT INTO "companies" ("slug", "created_at", "title", "updated_at", "external_url", "logo_id", "custom") VALUES('abbott-associates</error-message>
|
11
|
-
<id type="integer">
|
11
|
+
<id type="integer">4040123</id>
|
12
12
|
<lighthouse-ticket-id type="integer" nil="true"></lighthouse-ticket-id>
|
13
13
|
<controller>domU-12-31-39-15-22-AC:14720:critical,high,medium,low</controller>
|
14
14
|
<file>/var/data/www/apps/startwire/shared/bundle/ruby/1.8/gems/activerecord-2.3.8/lib/active_record/connection_adapters/abstract_adapter.rb</file>
|
data/spec/shelltoad_spec.rb
CHANGED
@@ -5,7 +5,8 @@ describe Shelltoad do
|
|
5
5
|
|
6
6
|
before(:each) do
|
7
7
|
Shelltoad::Configuration.stubs(:key).returns("whatever")
|
8
|
-
Shelltoad::Configuration.stubs(:
|
8
|
+
Shelltoad::Configuration.stubs(:account).returns("startdatelabs")
|
9
|
+
Shelltoad::Configuration.stubs(:project_id).returns(14951)
|
9
10
|
Shelltoad::Error.any_instance.stubs(:commit).returns(true)
|
10
11
|
end
|
11
12
|
|
@@ -17,23 +18,6 @@ describe Shelltoad do
|
|
17
18
|
end
|
18
19
|
end
|
19
20
|
|
20
|
-
context "when hoptoad service is unavailable" do
|
21
|
-
before(:each) do
|
22
|
-
FakeWeb.register_uri(
|
23
|
-
:any,
|
24
|
-
%r|http://startdatelabs.hoptoadapp.com/errors.xml|,
|
25
|
-
:body => "Service Unavailable. Try again later",
|
26
|
-
:status => 500
|
27
|
-
)
|
28
|
-
Shelltoad.run("errors")
|
29
|
-
|
30
|
-
|
31
|
-
end
|
32
|
-
|
33
|
-
it "should output the server error" do
|
34
|
-
TESTOUT.should =~ /^Hoptoad service not available./
|
35
|
-
end
|
36
|
-
end
|
37
21
|
end
|
38
22
|
|
39
23
|
end
|
data/spec/spec_helper.rb
CHANGED
@@ -32,8 +32,8 @@ RSpec.configure do |config|
|
|
32
32
|
:body => File.new("spec/assets/error.xml").read
|
33
33
|
)
|
34
34
|
FakeWeb.register_uri(
|
35
|
-
:
|
36
|
-
"http://startdatelabs.hoptoadapp.com/errors/4040123" ,
|
35
|
+
:put,
|
36
|
+
"http://startdatelabs.hoptoadapp.com/errors/4040123.xml" ,
|
37
37
|
:body => File.read('spec/assets/error.xml')
|
38
38
|
)
|
39
39
|
|
@@ -47,3 +47,4 @@ RSpec.configure do |config|
|
|
47
47
|
end
|
48
48
|
|
49
49
|
|
50
|
+
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: shelltoad
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 19
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
|
-
-
|
9
|
-
-
|
10
|
-
version: 0.
|
8
|
+
- 3
|
9
|
+
- 0
|
10
|
+
version: 0.3.0
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Bogdan Gusiev
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2011-04-
|
18
|
+
date: 2011-04-06 00:00:00 +03:00
|
19
19
|
default_executable: shelltoad
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|
@@ -34,7 +34,7 @@ dependencies:
|
|
34
34
|
type: :runtime
|
35
35
|
- !ruby/object:Gem::Dependency
|
36
36
|
prerelease: false
|
37
|
-
name:
|
37
|
+
name: hoptoad-api
|
38
38
|
version_requirements: &id002 !ruby/object:Gem::Requirement
|
39
39
|
none: false
|
40
40
|
requirements:
|
@@ -48,7 +48,7 @@ dependencies:
|
|
48
48
|
type: :runtime
|
49
49
|
- !ruby/object:Gem::Dependency
|
50
50
|
prerelease: false
|
51
|
-
name:
|
51
|
+
name: jeweler
|
52
52
|
version_requirements: &id003 !ruby/object:Gem::Requirement
|
53
53
|
none: false
|
54
54
|
requirements:
|
@@ -59,20 +59,6 @@ dependencies:
|
|
59
59
|
- 0
|
60
60
|
version: "0"
|
61
61
|
requirement: *id003
|
62
|
-
type: :runtime
|
63
|
-
- !ruby/object:Gem::Dependency
|
64
|
-
prerelease: false
|
65
|
-
name: jeweler
|
66
|
-
version_requirements: &id004 !ruby/object:Gem::Requirement
|
67
|
-
none: false
|
68
|
-
requirements:
|
69
|
-
- - ">="
|
70
|
-
- !ruby/object:Gem::Version
|
71
|
-
hash: 3
|
72
|
-
segments:
|
73
|
-
- 0
|
74
|
-
version: "0"
|
75
|
-
requirement: *id004
|
76
62
|
type: :development
|
77
63
|
description: |
|
78
64
|
|