spicycode-beholder 0.0.4 → 0.5.0
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.
- data/README.textile +49 -0
- data/Rakefile +1 -1
- data/examples/example_helper.rb +0 -1
- data/lib/beholder.rb +95 -19
- metadata +2 -2
data/README.textile
CHANGED
@@ -11,3 +11,52 @@ h2. Requirements
|
|
11
11
|
# OSX 10.5 or higher
|
12
12
|
# RubyCocoa
|
13
13
|
# fsevents gem
|
14
|
+
|
15
|
+
|
16
|
+
|
17
|
+
The default treasure map:
|
18
|
+
|
19
|
+
map_for(:default_dungeon) do |wizard|
|
20
|
+
|
21
|
+
wizard.keep_a_watchful_eye_for 'app', 'config', 'lib', 'examples'
|
22
|
+
|
23
|
+
wizard.prepare_spell_for /\/app\/(.*)\.rb/ do |spell_component|
|
24
|
+
["examples/#{spell_component[1]}.rb"]
|
25
|
+
end
|
26
|
+
|
27
|
+
wizard.prepare_spell_for /\/lib\/(.*)\.rb/ do |spell_component|
|
28
|
+
["examples/lib/#{spell_component[1]}_example.rb"]
|
29
|
+
end
|
30
|
+
|
31
|
+
wizard.prepare_spell_for /\/examples\/(.*)_example\.rb/ do |spell_component|
|
32
|
+
["examples/#{spell_component[1]}_example.rb"]
|
33
|
+
end
|
34
|
+
|
35
|
+
wizard.prepare_spell_for /\/examples\/example_helper\.rb/ do |spell_component|
|
36
|
+
Dir["examples/**/*_example.rb"]
|
37
|
+
end
|
38
|
+
|
39
|
+
wizard.prepare_spell_for /\/config/ do
|
40
|
+
Dir["examples/**/*_example.rb"]
|
41
|
+
end
|
42
|
+
|
43
|
+
end
|
44
|
+
|
45
|
+
|
46
|
+
In your own treasure map (stored as treasure_map.rb, .treasure_map.rb, or config/treasure_map.rb) you could do:
|
47
|
+
|
48
|
+
map_for(:beholders_lair) do |wizard|
|
49
|
+
|
50
|
+
# Clear all watched paths => wizard.paths_to_watch.clear
|
51
|
+
# Add these paths to the paths to watch
|
52
|
+
wizard.keep_a_watchful_eye_for 'coverage'
|
53
|
+
|
54
|
+
# Forget all other treasure maps loaded
|
55
|
+
# wizard.cast_feeble_mind
|
56
|
+
|
57
|
+
# Add your own rules
|
58
|
+
# wizard.prepare_spell_for /\/foobar/ do
|
59
|
+
# Dir["examples/foobar/*_example.rb"]
|
60
|
+
# end
|
61
|
+
|
62
|
+
end
|
data/Rakefile
CHANGED
data/examples/example_helper.rb
CHANGED
data/lib/beholder.rb
CHANGED
@@ -2,20 +2,27 @@ require 'rubygems'
|
|
2
2
|
gem :fsevents
|
3
3
|
require 'fsevents'
|
4
4
|
|
5
|
+
class Proc
|
6
|
+
alias :cast! :call
|
7
|
+
end
|
8
|
+
|
5
9
|
class Beholder
|
6
10
|
|
7
|
-
attr_reader :paths_to_watch, :sent_an_int, :mappings, :working_directory, :be_verbose, :the_eye
|
11
|
+
attr_reader :paths_to_watch, :sent_an_int, :mappings, :working_directory, :be_verbose, :the_eye, :treasure_maps, :corpses
|
8
12
|
|
9
13
|
def initialize
|
10
|
-
@paths_to_watch = [
|
14
|
+
@paths_to_watch = []
|
11
15
|
@sent_an_int = false
|
12
16
|
@mappings = {}
|
13
17
|
@working_directory = Dir.pwd
|
14
18
|
@be_verbose = ARGV.include?("-v") || ARGV.include?("--verbose")
|
19
|
+
@treasure_maps = {}
|
20
|
+
@corpses = ["#{@working_directory}/.treasure_map.rb", "#{@working_directory}/treasure_map.rb", "#{@working_directory}/config/treasure_map.rb"]
|
15
21
|
end
|
16
22
|
|
17
23
|
def self.cast_thy_gaze
|
18
24
|
beholder = new
|
25
|
+
beholder.read_all_the_maps
|
19
26
|
beholder.prepare_for_interlopers
|
20
27
|
beholder.open_your_eye
|
21
28
|
end
|
@@ -28,6 +35,66 @@ class Beholder
|
|
28
35
|
puts "\n\nWaiting to hear from the disk since #{Time.now}"
|
29
36
|
end
|
30
37
|
@the_eye.run
|
38
|
+
end
|
39
|
+
|
40
|
+
def map_for(map_name)
|
41
|
+
@treasure_maps[map_name] ||= []
|
42
|
+
@current_map = @treasure_maps[map_name]
|
43
|
+
yield self if block_given?
|
44
|
+
@current_map = nil
|
45
|
+
end
|
46
|
+
|
47
|
+
def prepare_spell_for(arcane_enemy, &spell)
|
48
|
+
@current_map << [arcane_enemy, spell]
|
49
|
+
end
|
50
|
+
alias :add_mapping :prepare_spell_for
|
51
|
+
|
52
|
+
def cast_feeble_mind
|
53
|
+
@treasure_maps = {}
|
54
|
+
end
|
55
|
+
|
56
|
+
def keep_a_watchful_eye_for(*paths)
|
57
|
+
@paths_to_watch.concat(paths)
|
58
|
+
end
|
59
|
+
|
60
|
+
def read_all_the_maps
|
61
|
+
map_for(:default_dungeon) do |wizard|
|
62
|
+
|
63
|
+
wizard.keep_a_watchful_eye_for 'app', 'config', 'lib', 'examples'
|
64
|
+
|
65
|
+
wizard.prepare_spell_for /\/app\/(.*)\.rb/ do |spell_component|
|
66
|
+
["examples/#{spell_component[1]}.rb"]
|
67
|
+
end
|
68
|
+
|
69
|
+
wizard.prepare_spell_for /\/lib\/(.*)\.rb/ do |spell_component|
|
70
|
+
["examples/lib/#{spell_component[1]}_example.rb"]
|
71
|
+
end
|
72
|
+
|
73
|
+
wizard.prepare_spell_for /\/examples\/(.*)_example\.rb/ do |spell_component|
|
74
|
+
["examples/#{spell_component[1]}_example.rb"]
|
75
|
+
end
|
76
|
+
|
77
|
+
wizard.prepare_spell_for /\/examples\/example_helper\.rb/ do |spell_component|
|
78
|
+
Dir["examples/**/*_example.rb"]
|
79
|
+
end
|
80
|
+
|
81
|
+
wizard.prepare_spell_for /\/config/ do
|
82
|
+
Dir["examples/**/*_example.rb"]
|
83
|
+
end
|
84
|
+
|
85
|
+
end
|
86
|
+
|
87
|
+
loot_corpses
|
88
|
+
end
|
89
|
+
|
90
|
+
def loot_corpses
|
91
|
+
corpses.each do |corpse|
|
92
|
+
if File.exist?(corpse)
|
93
|
+
say "Found a treasure map on #{corpse}"
|
94
|
+
instance_eval(File.readlines(corpse).join("\n"))
|
95
|
+
return
|
96
|
+
end
|
97
|
+
end
|
31
98
|
end
|
32
99
|
|
33
100
|
def blink
|
@@ -40,27 +107,36 @@ class Beholder
|
|
40
107
|
end
|
41
108
|
|
42
109
|
def identify_stolen_treasure(treasure)
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
puts "Unknown file: #{treasure}"
|
55
|
-
''
|
110
|
+
treasure_maps.each do |name, treasure_locations|
|
111
|
+
|
112
|
+
treasure_locations.each do |stolen_by_enemy, spell|
|
113
|
+
|
114
|
+
if spell_components = treasure.match(stolen_by_enemy)
|
115
|
+
say "Found the stolen treasure using the #{name} map "
|
116
|
+
return spell.cast!(spell_components)
|
117
|
+
end
|
118
|
+
|
119
|
+
end
|
120
|
+
|
56
121
|
end
|
122
|
+
|
123
|
+
puts "Unknown file: #{treasure}"
|
124
|
+
return []
|
57
125
|
end
|
58
126
|
|
59
127
|
def reclaim_stolen_treasure_at(coordinates)
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
128
|
+
coordinates.flatten!
|
129
|
+
|
130
|
+
coordinates.reject! do |coordinate|
|
131
|
+
not_there = !File.exist?(coordinate)
|
132
|
+
puts "Example #{coordinate} does not actually exist." if not_there
|
133
|
+
not_there
|
134
|
+
end
|
135
|
+
|
136
|
+
return if coordinates.empty?
|
137
|
+
|
138
|
+
puts "\nRunning #{coordinates.join(', ').inspect}"
|
139
|
+
system "ruby #{coordinates.join(' ')}"
|
64
140
|
end
|
65
141
|
|
66
142
|
def notice_thief_taking(treasure)
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: spicycode-beholder
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0
|
4
|
+
version: 0.5.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Chad Humphries
|
@@ -9,7 +9,7 @@ autorequire: beholder
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2009-01-
|
12
|
+
date: 2009-01-16 00:00:00 -08:00
|
13
13
|
default_executable: beholder
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|