pie 0.2.11 → 0.2.12

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (4) hide show
  1. data/README.md +1 -0
  2. data/lib/place.rb +53 -2
  3. data/lib/test.rb +23 -0
  4. metadata +3 -2
data/README.md CHANGED
@@ -52,6 +52,7 @@ Core team (in order of appearance)
52
52
 
53
53
  Contributors
54
54
 
55
+ * Sean Durham
55
56
  * Matthew Bass @pelargir
56
57
  * Dan Steinicke
57
58
  * Akira Matsuda
data/lib/place.rb CHANGED
@@ -1,3 +1,5 @@
1
+ #require_relative 'pie.rb'
2
+
1
3
  class Pie::Place
2
4
 
3
5
  attr_reader :name, :description, :paths
@@ -5,6 +7,7 @@ class Pie::Place
5
7
  def initialize(places, options)
6
8
  @paths = {}
7
9
  @places = places
10
+
8
11
  extract_standard_options(options)
9
12
  extract_name_and_description(options)
10
13
  @places[@name] = self
@@ -25,13 +28,61 @@ class Pie::Place
25
28
  end
26
29
 
27
30
  private
28
-
29
31
  def extract_name_and_description(options)
30
32
  raise "You seem to have extras option in this place!" unless options.length == 1
31
- @name = options.keys.first
33
+ self.name = options.keys.first
32
34
  @description = options.values.first
33
35
  end
34
36
 
35
37
  def extract_standard_options(options)
36
38
  end
39
+
40
+ def name=(name)
41
+ valid = false
42
+ begin
43
+ result = eval name.to_s
44
+ # if there is no exception, it's a problem like String or something Ruby knows
45
+
46
+ rescue NameError
47
+ # this is what we want, so that method_missing will be called if we use this as a place name
48
+ valid = true
49
+
50
+ rescue SyntaxError => e
51
+ msg = case e.message
52
+ when /syntax error, unexpected \$end/
53
+ "#{e.message}\n"+
54
+ "Sorry, You can't name a place 'class' "+
55
+ "because Ruby was expecting you to define a 'class' "+
56
+ "which is always followed by an 'end'"
57
+ when /syntax error, unexpected keyword/
58
+ "#{e.message}\nSorry, you can't name a place with a Ruby keyword, like '#{name}'"
59
+ else
60
+ # don't have an example where this happens, but I would guess there is one
61
+ "#{e.message}\nSorry, Ruby doesn't think that '#{name}' makes sense as the name of a place."
62
+
63
+ end
64
+
65
+
66
+ raise e.class, msg
67
+
68
+ rescue ArgumentError => e
69
+ msg = "#{e.message}\n"+
70
+ "You probably weren't trying to argue with Ruby, but it recognized '#{name}' and expected it to be followed by "+
71
+ "some more input, which it calls 'arguments'. Sorry '#{name}' can't be a place name."
72
+ raise e.class, msg
73
+
74
+ rescue Exception => e
75
+ # other kinds of inappropriate names
76
+ msg = "#{e.message}\nSorry, you can't name a place with something like '#{name}'"
77
+ raise e.class, msg
78
+ end
79
+
80
+ if !valid
81
+ raise("Sorry, you can't name a place with a name that Ruby already knows like '#{name}'")
82
+ end
83
+
84
+ @name = name
85
+ end
86
+
87
+
37
88
  end
data/lib/test.rb ADDED
@@ -0,0 +1,23 @@
1
+ class Foo
2
+ attr_reader :bar
3
+
4
+ def initialize(value)
5
+ puts "initialize value= #{value}"
6
+ setup(value)
7
+ end
8
+
9
+ def bar=(value)
10
+ puts "bar= value= #{value}"
11
+ raise Exception, "5 not allowed" if value == 5
12
+ @bar = value
13
+ end
14
+
15
+ def setup(value)
16
+ puts "setup value= #{value}, #{self}"
17
+ self.bar=value
18
+ end
19
+ private
20
+
21
+
22
+
23
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pie
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.11
4
+ version: 0.2.12
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2011-08-14 00:00:00.000000000 -07:00
12
+ date: 2011-08-15 00:00:00.000000000 -07:00
13
13
  default_executable:
14
14
  dependencies: []
15
15
  description:
@@ -23,6 +23,7 @@ files:
23
23
  - lib/pie.rb
24
24
  - lib/pie_server.rb
25
25
  - lib/place.rb
26
+ - lib/test.rb
26
27
  - views/full_screen.erb
27
28
  - views/game_screen.erb
28
29
  - views/image_page.erb