djinni 0.1.7 → 0.1.8

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
  SHA1:
3
- metadata.gz: 5248368310688ab43b4da1b8666e400f128bc2a1
4
- data.tar.gz: 6e32bcd778d9be2aa748965343ff13c346659050
3
+ metadata.gz: ef936a21ffbf86d2e3066aa05597c6a5f968f357
4
+ data.tar.gz: 0c3a346b04c8e7413dcb8984ef0e26554f12ad94
5
5
  SHA512:
6
- metadata.gz: 48fc4efc19668aef5ecf4046c74eb031c88cc89bd2f1ce7f9cbedd0b5297dc4d7a3cdd3a366da255cdcfbb818272a9ca6f6c1e695663aad5f4dea207d7f80977
7
- data.tar.gz: 95a37a0f190eecf33346f20d63d1f995ecd94b996e3d5149b96e1ab6f410151253d1a536dc16ce2b235d2e2b8bafdc0198d7cc2df6f4559c41b7a06e1ab8bb50
6
+ metadata.gz: 9b897ad86168a31364fdd9bf91810198798f3bc9200f488500dcd3f95c1530fd7ee271f7ce6ba0a77141501a1d7af4b40eea375f97d5d569b8651d2c1bcb1b1a
7
+ data.tar.gz: 8c091c11e1e68181d39cb188f58000b2322f5e216f19c00587ed6ad52f973a298b1a8027f8ecf2b50fc902369a732ab7eb575ecd5f64a7e9ad59084b68942fca
@@ -1,11 +1,12 @@
1
+ require "djinni_error"
2
+ require "djinni_wish"
1
3
  require "io/console"
2
4
  require "pathname"
3
5
  require "terminfo"
4
6
 
5
- require_relative "djinni_exit"
6
- require_relative "djinni_wish"
7
-
8
7
  class Djinni
8
+ include DjinniError
9
+
9
10
  def grant_wish(input, env = {})
10
11
  return "" if (input.nil? || input.empty?)
11
12
 
@@ -122,8 +123,7 @@ class Djinni
122
123
  begin
123
124
  wish = Object::const_get(clas).new
124
125
  rescue NameError => e
125
- puts "Unknown wish class #{clas}!"
126
- exit DjinniExit::UNKNOWN_WISH
126
+ raise DjinniError::UnknownWish.new(clas)
127
127
  end
128
128
 
129
129
  return if (wish.nil?)
@@ -138,13 +138,11 @@ class Djinni
138
138
 
139
139
  path = Pathname.new(dir).expand_path
140
140
 
141
- # puts "Loading wishes from #{path}"
142
141
  Dir["#{path}/*.rb"].each do |file|
143
- # puts "Loading #{clas}"
144
142
  require_relative file
145
143
 
146
144
  %x(
147
- \grep -E "class .* \< DjinniWish" #{file} | \
145
+ \grep -E "^ *class .+ \< DjinniWish" #{file} | \
148
146
  awk '{print $2}'
149
147
  ).each_line do |clas|
150
148
  load_wish(clas)
@@ -0,0 +1,10 @@
1
+ module DjinniError
2
+ class Error < RuntimeError
3
+ end
4
+
5
+ class UnknownWish < Error
6
+ def initialize(clas = "")
7
+ super("Unknown wish class #{clas}!")
8
+ end
9
+ end
10
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: djinni
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.7
4
+ version: 0.1.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - Miles Whittaker
@@ -62,7 +62,7 @@ files:
62
62
  - lib/builtin/history.rb
63
63
  - lib/builtin/quit.rb
64
64
  - lib/djinni.rb
65
- - lib/djinni_exit.rb
65
+ - lib/djinni_error.rb
66
66
  - lib/djinni_wish.rb
67
67
  homepage: http://mjwhitta.github.io/djinni
68
68
  licenses:
@@ -1,4 +0,0 @@
1
- class DjinniExit
2
- GOOD = 0
3
- UNKNOWN_WISH = 1
4
- end