undine 0.1.0 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/FUNDING.yml +12 -0
- data/.travis.yml +13 -1
- data/CHANGELOG.md +9 -0
- data/Gemfile.lock +1 -1
- data/README.md +3 -0
- data/examples/with_configuration.rb +12 -0
- data/lib/undine.rb +34 -7
- data/lib/undine/autoload.rb +5 -0
- data/lib/undine/configuration.rb +21 -0
- data/lib/undine/version.rb +4 -2
- data/undine.gemspec +3 -0
- metadata +36 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 17e7187dda0e57d54a2400ef1b3d6fec3972c5c70dd6bc54bf2be0cda2654b2c
|
4
|
+
data.tar.gz: b408c47525bf5010eb00169db88bef4ba17e737459be8f04d46e11e4d1ed5ca2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d8ee88b77e636cce3ad74faa1143e030a271001f3fbe6fa1dc77fd52eb269a5179d7fd744c123a1be85ddae1163c4b46724aff0accef15fa6829839fc9aa6b29
|
7
|
+
data.tar.gz: 1e6ef9a71208a162bb8bfd5208ca54b00095745f547047f7b4e36dd898ea30bca951221b66d44d9beda9d866409da64023c981603a8b79af44ee13b9eff0f87c
|
data/.github/FUNDING.yml
ADDED
@@ -0,0 +1,12 @@
|
|
1
|
+
# These are supported funding model platforms
|
2
|
+
|
3
|
+
github: [satoryu]
|
4
|
+
patreon: # Replace with a single Patreon username
|
5
|
+
open_collective: # Replace with a single Open Collective username
|
6
|
+
ko_fi: # Replace with a single Ko-fi username
|
7
|
+
tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel
|
8
|
+
community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry
|
9
|
+
liberapay: # Replace with a single Liberapay username
|
10
|
+
issuehunt: # Replace with a single IssueHunt username
|
11
|
+
otechie: # Replace with a single Otechie username
|
12
|
+
custom: # Replace with up to 4 custom sponsorship URLs e.g., ['link1', 'link2']
|
data/.travis.yml
CHANGED
@@ -2,5 +2,17 @@
|
|
2
2
|
language: ruby
|
3
3
|
cache: bundler
|
4
4
|
rvm:
|
5
|
-
- 2.
|
5
|
+
- 2.5
|
6
|
+
- 2.6
|
7
|
+
- 2.7
|
8
|
+
- ruby-head
|
6
9
|
before_install: gem install bundler -v 2.1.4
|
10
|
+
|
11
|
+
script: bundle exec rake
|
12
|
+
|
13
|
+
matrix:
|
14
|
+
allow_failures:
|
15
|
+
- rvm: ruby-head
|
16
|
+
|
17
|
+
notifications:
|
18
|
+
email: false
|
data/CHANGELOG.md
ADDED
@@ -0,0 +1,9 @@
|
|
1
|
+
# CHANGELOG
|
2
|
+
|
3
|
+
## v0.2.0 (2020/04/29)
|
4
|
+
|
5
|
+
### Enhancements
|
6
|
+
|
7
|
+
- Configuration allows to specify exception classes to be ignored [#3](https://github.com/satoryu/undine/pull/3)
|
8
|
+
- Define autoload [#2](https://github.com/satoryu/undine/pull/2)
|
9
|
+
- Define Undine::Configuratio for users to customize query message from exceptions [#1](https://github.com/satoryu/undine/pull/1)
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -1,5 +1,8 @@
|
|
1
1
|
# Undine
|
2
2
|
|
3
|
+
[![Gem Version](https://badge.fury.io/rb/undine.svg)](https://badge.fury.io/rb/undine)
|
4
|
+
[![Build Status](https://travis-ci.org/satoryu/undine.svg?branch=master)](https://travis-ci.org/satoryu/undine)
|
5
|
+
|
3
6
|
Undine is a gem to help your development experience: When an exception unrescued in your code is raised, opens google search with the errror message in your browser.
|
4
7
|
|
5
8
|
## Installation
|
@@ -0,0 +1,12 @@
|
|
1
|
+
require 'undine'
|
2
|
+
|
3
|
+
Undine.load
|
4
|
+
|
5
|
+
Undine.configure do |config|
|
6
|
+
config.query_message_from = proc { |e| e.message.lines.join(' ') }
|
7
|
+
end
|
8
|
+
|
9
|
+
'hoge'.foo
|
10
|
+
# This statement raises the following exception:
|
11
|
+
# examples/with_configuration.rb:9:in `<main>': undefined method `foo' for "hoge":String (NoMethodError)
|
12
|
+
# Did you mean? for
|
data/lib/undine.rb
CHANGED
@@ -1,18 +1,45 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
require 'undine/version'
|
4
|
+
require 'undine/configuration'
|
4
5
|
require 'cgi'
|
6
|
+
require 'English'
|
5
7
|
|
6
|
-
|
8
|
+
class Undine
|
7
9
|
def self.load
|
8
10
|
at_exit do
|
9
|
-
exception =
|
11
|
+
exception = $ERROR_INFO
|
10
12
|
|
11
|
-
unless exception.nil?
|
12
|
-
search_url = "https://www.google.com/search?q=#{CGI.escape(exception.message)}"
|
13
|
-
puts search_url
|
14
|
-
system "open '#{search_url}'"
|
15
|
-
end
|
13
|
+
Undine.process(exception) unless exception.nil?
|
16
14
|
end
|
17
15
|
end
|
16
|
+
|
17
|
+
def self.process(exception)
|
18
|
+
new(Undine.configuration).process(exception)
|
19
|
+
end
|
20
|
+
|
21
|
+
def initialize(configuration)
|
22
|
+
@configuration = configuration
|
23
|
+
end
|
24
|
+
|
25
|
+
def process(exception)
|
26
|
+
return if ignore?(exception)
|
27
|
+
|
28
|
+
url = "https://www.google.com/search?q=#{CGI.escape(query_message_from(exception))}"
|
29
|
+
|
30
|
+
system "open '#{url}'"
|
31
|
+
end
|
32
|
+
|
33
|
+
def query_message_from(exception)
|
34
|
+
@configuration.query_message_from.call(exception)
|
35
|
+
end
|
36
|
+
|
37
|
+
private
|
38
|
+
|
39
|
+
def ignore?(exception)
|
40
|
+
return false unless @configuration.respond_to?(:except_for)
|
41
|
+
|
42
|
+
ignored_exceptions = Array(@configuration.except_for)
|
43
|
+
ignored_exceptions.any? { |klass| exception.is_a?(klass) }
|
44
|
+
end
|
18
45
|
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
class Undine
|
4
|
+
def self.configuration
|
5
|
+
@configuration ||= Configuration.new
|
6
|
+
end
|
7
|
+
|
8
|
+
def self.configure
|
9
|
+
yield configuration
|
10
|
+
end
|
11
|
+
|
12
|
+
class Configuration
|
13
|
+
attr_accessor :query_message_from
|
14
|
+
attr_accessor :except_for
|
15
|
+
|
16
|
+
def initialize
|
17
|
+
@query_message_from = :message.to_proc
|
18
|
+
@except_for = SystemExit
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
data/lib/undine/version.rb
CHANGED
data/undine.gemspec
CHANGED
@@ -25,4 +25,7 @@ Gem::Specification.new do |spec|
|
|
25
25
|
spec.bindir = 'exe'
|
26
26
|
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
27
27
|
spec.require_paths = ['lib']
|
28
|
+
|
29
|
+
spec.add_development_dependency 'rake', '~> 12.3.3'
|
30
|
+
spec.add_development_dependency 'rspec', '~> 3.9.0'
|
28
31
|
end
|
metadata
CHANGED
@@ -1,15 +1,43 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: undine
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Tatsuya Sato
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-04-
|
12
|
-
dependencies:
|
11
|
+
date: 2020-04-29 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: rake
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: 12.3.3
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: 12.3.3
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rspec
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: 3.9.0
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: 3.9.0
|
13
41
|
description: Open your browser for searching the message of an unrescued exception
|
14
42
|
email:
|
15
43
|
- satoryu.1981@gmail.com
|
@@ -17,9 +45,11 @@ executables: []
|
|
17
45
|
extensions: []
|
18
46
|
extra_rdoc_files: []
|
19
47
|
files:
|
48
|
+
- ".github/FUNDING.yml"
|
20
49
|
- ".gitignore"
|
21
50
|
- ".rspec"
|
22
51
|
- ".travis.yml"
|
52
|
+
- CHANGELOG.md
|
23
53
|
- CODE_OF_CONDUCT.md
|
24
54
|
- Gemfile
|
25
55
|
- Gemfile.lock
|
@@ -29,7 +59,10 @@ files:
|
|
29
59
|
- bin/console
|
30
60
|
- bin/setup
|
31
61
|
- examples/unrescued_exception.rb
|
62
|
+
- examples/with_configuration.rb
|
32
63
|
- lib/undine.rb
|
64
|
+
- lib/undine/autoload.rb
|
65
|
+
- lib/undine/configuration.rb
|
33
66
|
- lib/undine/version.rb
|
34
67
|
- undine.gemspec
|
35
68
|
homepage: https://github.com/satoryu/undine
|