wat 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/MIT-LICENSE +20 -0
- data/README.rdoc +3 -0
- data/Rakefile +26 -0
- data/config/routes.rb +2 -0
- data/lib/generators/wat/install/USAGE +8 -0
- data/lib/generators/wat/install/install_generator.rb +16 -0
- data/lib/generators/wat/install/templates/errors.yml +2 -0
- data/lib/generators/wat/install/templates/exception.json.jbuilder +4 -0
- data/lib/generators/wat/install/templates/initializer.rb +4 -0
- data/lib/tasks/wat_tasks.rake +4 -0
- data/lib/wat.rb +33 -0
- data/lib/wat/engine.rb +4 -0
- data/lib/wat/error_handler.rb +13 -0
- data/lib/wat/version.rb +3 -0
- metadata +100 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: a6092efdb5fd6f0d3d317e5ec22c7c33a9839fed
|
4
|
+
data.tar.gz: 82fc9c6761376686863cbc0ab00cb32150616fea
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: ce267c98d6417c7cbd158246bac0f9709510f904e6a901632aa2ae0d8d974869ce964b4b03171c4335939a3364f6775416865d9620509b045ce093ec2f99c6e1
|
7
|
+
data.tar.gz: 50c4b4352a03ac9151596e1f565e99b23f052648311d386e3eceae938bdf24f7357244602eeaa371237503dfcbbcf0b15e3c85f7acd58ee28331c7f09326f07e
|
data/MIT-LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright 2015 Jarod Reid
|
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.
|
data/README.rdoc
ADDED
data/Rakefile
ADDED
@@ -0,0 +1,26 @@
|
|
1
|
+
begin
|
2
|
+
require 'bundler/setup'
|
3
|
+
rescue LoadError
|
4
|
+
puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
|
5
|
+
end
|
6
|
+
|
7
|
+
require 'rdoc/task'
|
8
|
+
|
9
|
+
RDoc::Task.new(:rdoc) do |rdoc|
|
10
|
+
rdoc.rdoc_dir = 'rdoc'
|
11
|
+
rdoc.title = 'Wat'
|
12
|
+
rdoc.options << '--line-numbers'
|
13
|
+
rdoc.rdoc_files.include('README.rdoc')
|
14
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
15
|
+
end
|
16
|
+
|
17
|
+
APP_RAKEFILE = File.expand_path("../spec/dummy/Rakefile", __FILE__)
|
18
|
+
load 'rails/tasks/engine.rake'
|
19
|
+
|
20
|
+
|
21
|
+
load 'rails/tasks/statistics.rake'
|
22
|
+
|
23
|
+
|
24
|
+
|
25
|
+
Bundler::GemHelper.install_tasks
|
26
|
+
|
data/config/routes.rb
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
class Wat::InstallGenerator < Rails::Generators::Base
|
2
|
+
source_root File.expand_path('../templates', __FILE__)
|
3
|
+
|
4
|
+
def install_initializer
|
5
|
+
template 'initializer.rb', 'config/initializers/wat.rb'
|
6
|
+
end
|
7
|
+
|
8
|
+
def install_errors
|
9
|
+
template 'errors.yml', 'config/errors.yml'
|
10
|
+
end
|
11
|
+
|
12
|
+
def install_exception_template
|
13
|
+
template 'exception.json.jbuilder', 'views/shared/exception.json.jbuilder'
|
14
|
+
end
|
15
|
+
|
16
|
+
end
|
data/lib/wat.rb
ADDED
@@ -0,0 +1,33 @@
|
|
1
|
+
require 'yaml'
|
2
|
+
|
3
|
+
require 'wat/engine'
|
4
|
+
require 'wat/error_handler'
|
5
|
+
|
6
|
+
module Wat
|
7
|
+
include ActiveSupport::Configurable
|
8
|
+
|
9
|
+
class << self
|
10
|
+
|
11
|
+
def configure(&block)
|
12
|
+
config.errors = YAML::load(File.new(Rails.root.join('config', 'errors.yml').to_s, 'r'))
|
13
|
+
@lookup_table = lookup_table_from_errors(config.errors)
|
14
|
+
super &block
|
15
|
+
end
|
16
|
+
|
17
|
+
def lookup(exception)
|
18
|
+
@table[exception]
|
19
|
+
end
|
20
|
+
|
21
|
+
private
|
22
|
+
|
23
|
+
def lookup_table_from_errors(errors)
|
24
|
+
table = {}
|
25
|
+
errors.each do |status, e|
|
26
|
+
e.each do |code, exception|
|
27
|
+
table[exception.constantize] = {code: code, status: status}
|
28
|
+
end
|
29
|
+
end
|
30
|
+
table
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
data/lib/wat/engine.rb
ADDED
@@ -0,0 +1,13 @@
|
|
1
|
+
module Wat
|
2
|
+
module ErrorHandler
|
3
|
+
extend ActiveSupport::Concern
|
4
|
+
included do
|
5
|
+
rescue_from StandardError do |error|
|
6
|
+
error_meta = Wat.lookup(error.class)
|
7
|
+
Rails.logger.error "An error #{error_meta[:code]} " +
|
8
|
+
"occurred:\n#{error.class.name}: #{error.message}\n#{error.backtrace.join("\n")}"
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
end
|
13
|
+
end
|
data/lib/wat/version.rb
ADDED
metadata
ADDED
@@ -0,0 +1,100 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: wat
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Jarod Reid
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2015-08-04 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: rails
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '3.2'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '3.2'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: sqlite3
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rspec
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
description: wat provides Rails based API services with error handling abilities
|
56
|
+
email:
|
57
|
+
- jarod@solidalchemy.com
|
58
|
+
executables: []
|
59
|
+
extensions: []
|
60
|
+
extra_rdoc_files: []
|
61
|
+
files:
|
62
|
+
- MIT-LICENSE
|
63
|
+
- README.rdoc
|
64
|
+
- Rakefile
|
65
|
+
- config/routes.rb
|
66
|
+
- lib/generators/wat/install/USAGE
|
67
|
+
- lib/generators/wat/install/install_generator.rb
|
68
|
+
- lib/generators/wat/install/templates/errors.yml
|
69
|
+
- lib/generators/wat/install/templates/exception.json.jbuilder
|
70
|
+
- lib/generators/wat/install/templates/initializer.rb
|
71
|
+
- lib/tasks/wat_tasks.rake
|
72
|
+
- lib/wat.rb
|
73
|
+
- lib/wat/engine.rb
|
74
|
+
- lib/wat/error_handler.rb
|
75
|
+
- lib/wat/version.rb
|
76
|
+
homepage: http://github.com/fugufish/wat
|
77
|
+
licenses:
|
78
|
+
- MIT
|
79
|
+
metadata: {}
|
80
|
+
post_install_message:
|
81
|
+
rdoc_options: []
|
82
|
+
require_paths:
|
83
|
+
- lib
|
84
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
85
|
+
requirements:
|
86
|
+
- - ">="
|
87
|
+
- !ruby/object:Gem::Version
|
88
|
+
version: '0'
|
89
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
90
|
+
requirements:
|
91
|
+
- - ">="
|
92
|
+
- !ruby/object:Gem::Version
|
93
|
+
version: '0'
|
94
|
+
requirements: []
|
95
|
+
rubyforge_project:
|
96
|
+
rubygems_version: 2.4.8
|
97
|
+
signing_key:
|
98
|
+
specification_version: 4
|
99
|
+
summary: wat provides Rails based API services with error handling abilities
|
100
|
+
test_files: []
|