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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: b0d448d450cb0d0b130f96146e4639a6ecd49940d87dd59c01eb2f3e93560d0e
4
- data.tar.gz: 4b3803800cdab31ac8ddea2e69667a5421da6dc8c0163708c304dcc0958e426a
3
+ metadata.gz: 17e7187dda0e57d54a2400ef1b3d6fec3972c5c70dd6bc54bf2be0cda2654b2c
4
+ data.tar.gz: b408c47525bf5010eb00169db88bef4ba17e737459be8f04d46e11e4d1ed5ca2
5
5
  SHA512:
6
- metadata.gz: edfcc2da49771f64f45f8b3849748d58be446557f386cf4b63a660f51afa8ed7c2f0c0a13930441e8cc8418e5ac8ba2c4cad1663524a03170d2b10d3fcd0cf79
7
- data.tar.gz: 48cb2ccf86ccb964f1a8083cac4c729bf7978b5f658bc2214f76f5cef294b6eef2483082c97bbb0533172a3f227c70a2a6c087f779fd0ad8233e9dafb05310b6
6
+ metadata.gz: d8ee88b77e636cce3ad74faa1143e030a271001f3fbe6fa1dc77fd52eb269a5179d7fd744c123a1be85ddae1163c4b46724aff0accef15fa6829839fc9aa6b29
7
+ data.tar.gz: 1e6ef9a71208a162bb8bfd5208ca54b00095745f547047f7b4e36dd898ea30bca951221b66d44d9beda9d866409da64023c981603a8b79af44ee13b9eff0f87c
@@ -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']
@@ -2,5 +2,17 @@
2
2
  language: ruby
3
3
  cache: bundler
4
4
  rvm:
5
- - 2.7.0
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
@@ -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)
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- undine (0.1.0)
4
+ undine (0.2.0)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
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
@@ -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
- module Undine
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,5 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'undine'
4
+
5
+ Undine.load
@@ -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
@@ -1,3 +1,5 @@
1
- module Undine
2
- VERSION = "0.1.0"
1
+ # frozen_string_literal: true
2
+
3
+ class Undine
4
+ VERSION = '0.2.0'
3
5
  end
@@ -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.1.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-24 00:00:00.000000000 Z
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