exception_alarm 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: adfb0f8a882bcba39343fb6d70926129b9445e95
4
+ data.tar.gz: c075dd01293a7e54a21d982513f85e0d7e864c69
5
+ SHA512:
6
+ metadata.gz: 97a2215fa7b21ed977f201805cf7c083c15a187c21f444d397b72ac1d21758f1a166f9957c380a48d57700844b9e6358c2f3e273ac80423cc7681a3d6bf99c89
7
+ data.tar.gz: 82c095a3e4abb90740eb3a9350708d9ff19b8bbd0ae621b7d3fe918ff8861064e92d15f9408f043e15e4d24d34b39523e1fbfc9303557b2484ebe99d46b529a3
@@ -0,0 +1,10 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
10
+ main.rb
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in exception_alarm.gemspec
4
+ gemspec
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2017 pioz
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
@@ -0,0 +1,33 @@
1
+ # ExceptionAlarm
2
+
3
+ This simple gem play an alarm sound when an exception is raised on your Ruby
4
+ code.
5
+
6
+ ## Installation
7
+
8
+ $ brew install mpg123
9
+ or
10
+ $ apt-get install mpg123
11
+
12
+ $ gem install exception_alarm
13
+
14
+ ExceptionAlarm use the command line program [`mpg123`](https://www.mpg123.de/)
15
+ to play mp3 alarm file. So you have to install it on your environment.
16
+
17
+ ## Usage
18
+
19
+ require 'exception_alarm'
20
+
21
+ alarm do
22
+ # your code...
23
+ raise 'play alarm sound'
24
+ end
25
+
26
+ ## Contributing
27
+
28
+ Bug reports and pull requests are welcome on GitHub at https://github.com/pioz/exception_alarm.
29
+
30
+
31
+ ## License
32
+
33
+ The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
@@ -0,0 +1,2 @@
1
+ require "bundler/gem_tasks"
2
+ task :default => :spec
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "exception_alarm"
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ # (If you use this, don't forget to add pry to your Gemfile!)
10
+ # require "pry"
11
+ # Pry.start
12
+
13
+ require "irb"
14
+ IRB.start(__FILE__)
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,43 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'exception_alarm/version'
5
+ require 'exception_alarm/mpg123'
6
+ require 'mkmf'
7
+
8
+ Gem::Specification.new do |spec|
9
+ spec.name = "exception_alarm"
10
+ spec.version = ExceptionAlarm::VERSION
11
+ spec.authors = ["pioz"]
12
+ spec.email = ["epilotto@gmx.com"]
13
+
14
+ spec.summary = %q{Play alarm sound when an exception is raised}
15
+ spec.description = %q{Play alarm sound when an exception is raised.}
16
+ spec.homepage = "https://github.com/pioz/exception_alarm"
17
+ spec.license = "MIT"
18
+
19
+ # Prevent pushing this gem to RubyGems.org. To allow pushes either set the 'allowed_push_host'
20
+ # to allow pushing to a single host or delete this section to allow pushing to any host.
21
+ if spec.respond_to?(:metadata)
22
+ spec.metadata['allowed_push_host'] = "https://rubygems.org"
23
+ else
24
+ raise "RubyGems 2.0 or newer is required to protect against " \
25
+ "public gem pushes."
26
+ end
27
+
28
+ spec.files = `git ls-files -z`.split("\x0").reject do |f|
29
+ f.match(%r{^(test|spec|features)/})
30
+ end
31
+ spec.bindir = "exe"
32
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
33
+ spec.require_paths = ["lib"]
34
+
35
+ spec.add_runtime_dependency "os", "~> 1.0"
36
+
37
+ spec.add_development_dependency "bundler", "~> 1.14"
38
+ spec.add_development_dependency "rake", "~> 10.0"
39
+
40
+ unless find_executable0(ExceptionAlarm::PLAY_COMMAND)
41
+ spec.post_install_message = ExceptionAlarm.mpg123_not_found
42
+ end
43
+ end
Binary file
@@ -0,0 +1,25 @@
1
+ require 'exception_alarm/version'
2
+ require 'exception_alarm/mpg123'
3
+
4
+ module ExceptionAlarmInclusion
5
+
6
+ def alarm(&block)
7
+ begin
8
+ block.call
9
+ rescue => e
10
+ mpg123_command = find_executable0 ExceptionAlarm::PLAY_COMMAND
11
+ if mpg123_command
12
+ Thread.new do
13
+ `#{mpg123_command} '#{File.expand_path('../alarm.mp3', __FILE__)}' &> '#{File::NULL}'`
14
+ end
15
+ else
16
+ $stderr.puts ExceptionAlarm.mpg123_not_found
17
+ end
18
+ e.backtrace.select!{|b| !b.include?(__FILE__)}
19
+ raise e
20
+ end
21
+ end
22
+
23
+ end
24
+
25
+ include ExceptionAlarmInclusion
@@ -0,0 +1,21 @@
1
+ require 'mkmf'
2
+ require 'os'
3
+
4
+ module ExceptionAlarm
5
+
6
+ PLAY_COMMAND = 'mpg123'
7
+
8
+ def self.mpg123_not_found
9
+ m = "exception_alarm warning: #{PLAY_COMMAND} command not found! #{PLAY_COMMAND} is required to play the mp3 alarm file."
10
+ ic = self.mpg123_install_command
11
+ m += " Please install #{PLAY_COMMAND} with '#{ic}'" if ic
12
+ return m
13
+ end
14
+
15
+ def self.mpg123_install_command
16
+ return "brew install #{PLAY_COMMAND}" if OS.osx?
17
+ return "apt-get install #{PLAY_COMMAND}" if OS.linux?
18
+ return nil
19
+ end
20
+
21
+ end
@@ -0,0 +1,3 @@
1
+ module ExceptionAlarm
2
+ VERSION = "0.1.0"
3
+ end
metadata ADDED
@@ -0,0 +1,99 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: exception_alarm
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - pioz
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2017-08-02 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: os
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: bundler
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '1.14'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '1.14'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rake
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '10.0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '10.0'
55
+ description: Play alarm sound when an exception is raised.
56
+ email:
57
+ - epilotto@gmx.com
58
+ executables: []
59
+ extensions: []
60
+ extra_rdoc_files: []
61
+ files:
62
+ - ".gitignore"
63
+ - Gemfile
64
+ - LICENSE.txt
65
+ - README.md
66
+ - Rakefile
67
+ - bin/console
68
+ - bin/setup
69
+ - exception_alarm.gemspec
70
+ - lib/alarm.mp3
71
+ - lib/exception_alarm.rb
72
+ - lib/exception_alarm/mpg123.rb
73
+ - lib/exception_alarm/version.rb
74
+ homepage: https://github.com/pioz/exception_alarm
75
+ licenses:
76
+ - MIT
77
+ metadata:
78
+ allowed_push_host: https://rubygems.org
79
+ post_install_message:
80
+ rdoc_options: []
81
+ require_paths:
82
+ - lib
83
+ required_ruby_version: !ruby/object:Gem::Requirement
84
+ requirements:
85
+ - - ">="
86
+ - !ruby/object:Gem::Version
87
+ version: '0'
88
+ required_rubygems_version: !ruby/object:Gem::Requirement
89
+ requirements:
90
+ - - ">="
91
+ - !ruby/object:Gem::Version
92
+ version: '0'
93
+ requirements: []
94
+ rubyforge_project:
95
+ rubygems_version: 2.6.12
96
+ signing_key:
97
+ specification_version: 4
98
+ summary: Play alarm sound when an exception is raised
99
+ test_files: []