hack_tree 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +3 -1
- data/Gemfile.lock +26 -0
- data/README.md +279 -9
- data/hack_tree.gemspec +12 -11
- data/lib/generators/hack_tree/hack_tree_generator.rb +1 -1
- data/lib/hack_tree/action_context.rb +10 -1
- data/lib/hack_tree/instance.rb +2 -6
- data/lib/hack_tree/node/group.rb +1 -1
- data/lib/hack_tree/node/hack.rb +1 -1
- data/lib/hack_tree/parser/desc.rb +1 -1
- data/lib/hack_tree/version.rb +4 -0
- data/lib/hack_tree.rb +10 -86
- data/{hacks → lib/hacks}/hack_tree/reload.rb +0 -1
- data/lib/hacks/hack_tree.rb +5 -0
- data/{hacks → lib/hacks}/ls.rb +4 -3
- data/spec/{lib/hack_tree/parser → parser}/desc_spec/000,brief.txt +0 -0
- data/spec/{lib/hack_tree/parser → parser}/desc_spec/000,full.txt +0 -0
- data/spec/{lib/hack_tree/parser → parser}/desc_spec/000.txt +0 -0
- data/spec/{lib/hack_tree/parser → parser}/desc_spec/010,brief.txt +0 -0
- data/spec/{lib/hack_tree/parser → parser}/desc_spec/010,full.txt +0 -0
- data/spec/{lib/hack_tree/parser → parser}/desc_spec/010.txt +0 -0
- data/spec/{lib/hack_tree/parser → parser}/desc_spec.rb +1 -1
- data/spec/parser/spec_helper.rb +3 -0
- data/spec/spec_helper.rb +26 -9
- metadata +29 -16
- data/spec/lib/hack_tree/parser/spec_helper.rb +0 -3
- data/spec/lib/hack_tree/spec_helper.rb +0 -3
- data/spec/lib/spec_helper.rb +0 -3
data/.gitignore
CHANGED
data/Gemfile.lock
ADDED
@@ -0,0 +1,26 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
hack_tree (0.1.0)
|
5
|
+
|
6
|
+
GEM
|
7
|
+
remote: http://rubygems.org/
|
8
|
+
specs:
|
9
|
+
diff-lcs (1.1.3)
|
10
|
+
rspec (2.8.0)
|
11
|
+
rspec-core (~> 2.8.0)
|
12
|
+
rspec-expectations (~> 2.8.0)
|
13
|
+
rspec-mocks (~> 2.8.0)
|
14
|
+
rspec-core (2.8.0)
|
15
|
+
rspec-expectations (2.8.0)
|
16
|
+
diff-lcs (~> 1.1.2)
|
17
|
+
rspec-mocks (2.8.0)
|
18
|
+
yard (0.7.5)
|
19
|
+
|
20
|
+
PLATFORMS
|
21
|
+
ruby
|
22
|
+
|
23
|
+
DEPENDENCIES
|
24
|
+
hack_tree!
|
25
|
+
rspec
|
26
|
+
yard
|
data/README.md
CHANGED
@@ -2,13 +2,17 @@
|
|
2
2
|
Organize and share your console hacks
|
3
3
|
=====================================
|
4
4
|
|
5
|
-
WARNING! THIS IS WORK IN PROGRESS, NOTHING IS GUARANDEED TO WORK AT ALL
|
6
|
-
-----------------------------------------------------------------------
|
7
|
-
|
8
5
|
Introduction
|
9
6
|
------------
|
10
7
|
|
11
|
-
HackTree lets you organize and share your console hacks in
|
8
|
+
HackTree lets you organize and share your console hacks in a simple and efficient way.
|
9
|
+
|
10
|
+
Console hacks (or tricks) are handy methods you use in IRB console to do repetitive tasks. HackTree gives you the following opportunities:
|
11
|
+
|
12
|
+
* Create hacks using a **simple and uniform DSL**.
|
13
|
+
* **Describe** your hacks, much like you describe tasks in Rakefiles.
|
14
|
+
* **List available** hacks with descriptions right in your console.
|
15
|
+
* **Share** hacks with your teammates, **reuse** them in different projects.
|
12
16
|
|
13
17
|
|
14
18
|
Setup (Rails 3)
|
@@ -17,9 +21,8 @@ Setup (Rails 3)
|
|
17
21
|
Add to your `Gemfile`:
|
18
22
|
|
19
23
|
~~~
|
20
|
-
|
21
|
-
|
22
|
-
end
|
24
|
+
gem "hack_tree"
|
25
|
+
#gem "hack_tree", :git => "git://github.com/dadooda/hack_tree.git" # Edge version.
|
23
26
|
~~~
|
24
27
|
|
25
28
|
Install the gem:
|
@@ -28,6 +31,12 @@ Install the gem:
|
|
28
31
|
$ bundle install
|
29
32
|
~~~
|
30
33
|
|
34
|
+
Generate essentials:
|
35
|
+
|
36
|
+
~~~
|
37
|
+
$ rails generate hack_tree
|
38
|
+
~~~
|
39
|
+
|
31
40
|
|
32
41
|
Usage
|
33
42
|
-----
|
@@ -50,14 +59,275 @@ Request help on a hack:
|
|
50
59
|
>> c.hello?
|
51
60
|
~~~
|
52
61
|
|
53
|
-
Use
|
62
|
+
Use a hack:
|
54
63
|
|
55
64
|
~~~
|
56
65
|
>> c.hello
|
66
|
+
Hello, world!
|
67
|
+
|
68
|
+
>> c.hello "Ruby"
|
69
|
+
Hello, Ruby!
|
70
|
+
~~~
|
71
|
+
|
72
|
+
Create a hack (create and edit `lib/hacks/ping.rb`):
|
73
|
+
|
74
|
+
~~~
|
75
|
+
HackTree.define do
|
76
|
+
desc "Play ping-pong"
|
77
|
+
hack :ping do
|
78
|
+
puts "Pong!"
|
79
|
+
end
|
80
|
+
end
|
81
|
+
~~~
|
82
|
+
|
83
|
+
Reload hacks:
|
84
|
+
|
85
|
+
~~~
|
86
|
+
>> c.hack_tree.reload
|
87
|
+
~~~
|
88
|
+
|
89
|
+
Use your hack:
|
90
|
+
|
91
|
+
~~~
|
92
|
+
>> c.ping
|
93
|
+
Pong!
|
94
|
+
~~~
|
95
|
+
|
96
|
+
That's it for the basics, read further for more detailed information.
|
97
|
+
|
98
|
+
|
99
|
+
Definition language
|
100
|
+
-------------------
|
101
|
+
|
102
|
+
### Overview ###
|
103
|
+
|
104
|
+
The definition language has just 3 statements: `desc`, `group` and `hack`.
|
105
|
+
|
106
|
+
To enter the definition language use the wrapper block:
|
107
|
+
|
108
|
+
~~~
|
109
|
+
HackTree.define do
|
110
|
+
...
|
111
|
+
end
|
112
|
+
~~~
|
113
|
+
|
114
|
+
> NOTE: Inside the wrapper `self` is the object of type `HackTree::Instance`.
|
115
|
+
|
116
|
+
### Defining hacks ###
|
117
|
+
|
118
|
+
To define a hack, use `hack`. To describe it, use `desc`.
|
119
|
+
|
120
|
+
~~~
|
121
|
+
HackTree.define do
|
122
|
+
desc "Say hello to the world"
|
123
|
+
hack :hello do
|
124
|
+
puts "Hello, world!"
|
125
|
+
end
|
126
|
+
end
|
127
|
+
~~~
|
128
|
+
|
129
|
+
### Handling hack arguments ###
|
130
|
+
|
131
|
+
Hack arguments are block arguments in regular Ruby syntax.
|
132
|
+
|
133
|
+
~~~
|
134
|
+
HackTree.define do
|
135
|
+
desc "Say hello to the world or to a specific person"
|
136
|
+
hack :hello do |*args|
|
137
|
+
puts "Hello, %s!" % (args[0] || "world")
|
138
|
+
end
|
139
|
+
~~~
|
140
|
+
|
141
|
+
In Ruby 1.9 this form will also work:
|
142
|
+
|
143
|
+
~~~
|
144
|
+
HackTree.define do
|
145
|
+
desc "Say hello to the world or to a specific person"
|
146
|
+
hack :hello do |who = "world"|
|
147
|
+
puts "Hello, #{who}!"
|
148
|
+
end
|
149
|
+
end
|
150
|
+
~~~
|
151
|
+
|
152
|
+
### Using full descriptions ###
|
153
|
+
|
154
|
+
Once your hack begins to take arguments it is recommended that you extend `desc` to a full block of text. Keep the heading line, **add a few examples** and possibly some other descriptive information.
|
155
|
+
|
156
|
+
~~~
|
157
|
+
HackTree.define do
|
158
|
+
desc <<-EOT
|
159
|
+
Say hello to the world or to a specific person
|
160
|
+
|
161
|
+
Examples:
|
162
|
+
|
163
|
+
>> c.hello
|
164
|
+
Hello, world!
|
165
|
+
|
166
|
+
>> c.hello "Ruby"
|
167
|
+
Hello, Ruby!
|
168
|
+
EOT
|
169
|
+
hack :hello do |*args|
|
170
|
+
puts "Hello, %s!" % (args[0] || "world")
|
171
|
+
end
|
172
|
+
end
|
173
|
+
~~~
|
174
|
+
|
175
|
+
See it in console:
|
176
|
+
|
177
|
+
~~~
|
178
|
+
>> c
|
179
|
+
hello # Say hello to the world or to a specific person
|
180
|
+
|
181
|
+
>> c.hello?
|
182
|
+
Say hello to the world or to a specific person
|
183
|
+
|
184
|
+
Examples:
|
185
|
+
|
186
|
+
>> c.hello
|
187
|
+
Hello, world!
|
188
|
+
|
189
|
+
>> c.hello "Ruby"
|
190
|
+
Hello, Ruby!
|
191
|
+
~~~
|
192
|
+
|
193
|
+
### Defining groups ###
|
194
|
+
|
195
|
+
Groups act as namespaces and are used to encapsulate hacks and other groups. You can nest groups to any level.
|
196
|
+
|
197
|
+
~~~
|
198
|
+
HackTree.define do
|
199
|
+
desc "DB management"
|
200
|
+
group :db do
|
201
|
+
desc "List tables in native format"
|
202
|
+
hack :tables do
|
203
|
+
...
|
204
|
+
end
|
205
|
+
|
206
|
+
desc "Get `ActiveRecord::Base.connection`"
|
207
|
+
hack :conn do
|
208
|
+
...
|
209
|
+
end
|
210
|
+
end
|
211
|
+
end
|
212
|
+
~~~
|
213
|
+
|
214
|
+
See it in console:
|
215
|
+
|
216
|
+
~~~
|
217
|
+
>> c
|
218
|
+
db/ # DB management
|
219
|
+
...
|
220
|
+
|
221
|
+
>> c.db
|
222
|
+
conn # Get `ActiveRecord::Base.connection`
|
223
|
+
tables # List tables in native format
|
224
|
+
~~~
|
225
|
+
|
226
|
+
### Exiting from hacks, returning values ###
|
227
|
+
|
228
|
+
If the hack runs uninterrupted, it returns the result of its last statement.
|
229
|
+
|
230
|
+
~~~
|
231
|
+
>> HackTree.define do
|
232
|
+
hack :five do
|
233
|
+
5
|
234
|
+
end
|
235
|
+
end
|
236
|
+
|
237
|
+
>> c.five
|
238
|
+
=> 5
|
239
|
+
~~~
|
240
|
+
|
241
|
+
To exit from a hack, use `next`. Unfortunately, **you cannot** use `break` or `return`, please keep that in mind.
|
242
|
+
|
243
|
+
~~~
|
244
|
+
HackTree.define do
|
245
|
+
hack :hello do |*args|
|
246
|
+
who = args[0] || "world"
|
247
|
+
|
248
|
+
if who == "Java"
|
249
|
+
puts "Goodbye, Java!"
|
250
|
+
next false
|
251
|
+
end
|
252
|
+
|
253
|
+
puts "Hello, #{who}!"
|
254
|
+
|
255
|
+
true
|
256
|
+
end
|
257
|
+
end
|
258
|
+
~~~
|
259
|
+
|
260
|
+
In the above example, the hack should return `false` if the argument is "Java".
|
261
|
+
|
262
|
+
See it in console:
|
263
|
+
|
264
|
+
~~~
|
57
265
|
>> c.hello "Ruby"
|
266
|
+
Hello, Ruby!
|
267
|
+
=> true
|
268
|
+
|
269
|
+
>> c.hello "Java"
|
270
|
+
Goodbye, Java!
|
271
|
+
=> false
|
272
|
+
~~~
|
273
|
+
|
274
|
+
### Handling external dependencies ###
|
275
|
+
|
276
|
+
In real life it's possible that your hack depends on particular gems, environment settings, etc.
|
277
|
+
|
278
|
+
Please follow these recommendations when dealing with dependencies:
|
279
|
+
|
280
|
+
* Make sure your hack can be loaded regardless of dependencies. In other words, use dependencies **inside** the hack, not outside of it.
|
281
|
+
* Use `begin ... rescue` to catch possible unmet dependencies. Upon an unmet dependency report about it and return a noticeable result, e.g. `false`.
|
282
|
+
|
283
|
+
Example:
|
284
|
+
|
285
|
+
~~~
|
286
|
+
HackTree.define do
|
287
|
+
group :db do
|
288
|
+
desc "Get `ActiveRecord::Base.connection`"
|
289
|
+
hack :conn do
|
290
|
+
begin
|
291
|
+
ActiveRecord::Base.connection
|
292
|
+
rescue
|
293
|
+
puts "Error: ActiveRecord not found"
|
294
|
+
false
|
295
|
+
end
|
296
|
+
end
|
297
|
+
end
|
298
|
+
end
|
58
299
|
~~~
|
59
300
|
|
60
|
-
|
301
|
+
### Defining classes and methods to be used in hacks ###
|
302
|
+
|
303
|
+
If your hack needs to use a custom method or class, it is recommended that you use a hierarchy of Ruby module namespaces matching your hack's name.
|
304
|
+
|
305
|
+
Example (`lib/hacks/db/tables.rb`):
|
306
|
+
|
307
|
+
~~~
|
308
|
+
HackTree.define do
|
309
|
+
group :db do
|
310
|
+
desc "List tables in native format"
|
311
|
+
hack :tables do
|
312
|
+
tables = Hacks::DB::Tables.get_tables
|
313
|
+
tables.each do |table|
|
314
|
+
puts table
|
315
|
+
end
|
316
|
+
end
|
317
|
+
end
|
318
|
+
end
|
319
|
+
|
320
|
+
module Hacks
|
321
|
+
module DB
|
322
|
+
module Tables
|
323
|
+
def self.get_tables
|
324
|
+
# Some logic here.
|
325
|
+
["authors", "books"]
|
326
|
+
end
|
327
|
+
end
|
328
|
+
end
|
329
|
+
end
|
330
|
+
~~~
|
61
331
|
|
62
332
|
|
63
333
|
Copyright
|
data/hack_tree.gemspec
CHANGED
@@ -1,22 +1,23 @@
|
|
1
|
-
|
2
|
-
require "hack_tree"
|
1
|
+
require File.expand_path("../lib/hack_tree/version", __FILE__)
|
3
2
|
|
4
3
|
Gem::Specification.new do |s|
|
5
|
-
s.name
|
6
|
-
s.version
|
7
|
-
s.authors
|
8
|
-
s.email
|
9
|
-
s.homepage
|
4
|
+
s.name = "hack_tree"
|
5
|
+
s.version = HackTree::VERSION
|
6
|
+
s.authors = ["Alex Fortuna"]
|
7
|
+
s.email = ["alex.r@askit.org"]
|
8
|
+
s.homepage = "http://github.com/dadooda/hack_tree"
|
10
9
|
|
11
10
|
# Copy these from class's description, adjust markup.
|
12
|
-
s.summary
|
11
|
+
s.summary = %q{Organize and share your console hacks}
|
12
|
+
# TODO: Proper text.
|
13
13
|
s.description = %q{HackTree lets you organize and share your console hacks in an effective and uniform way. Blah-blah-blah.}
|
14
14
|
# end of s.description=
|
15
15
|
|
16
|
-
s.files
|
17
|
-
s.test_files
|
18
|
-
s.executables
|
16
|
+
s.files = `git ls-files`.split("\n")
|
17
|
+
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
18
|
+
s.executables = `git ls-files -- bin/*`.split("\n").map {|f| File.basename(f)}
|
19
19
|
s.require_paths = ["lib"]
|
20
20
|
|
21
21
|
s.add_development_dependency "rspec"
|
22
|
+
s.add_development_dependency "yard"
|
22
23
|
end
|
@@ -42,7 +42,10 @@ module HackTree
|
|
42
42
|
end
|
43
43
|
|
44
44
|
def inspect
|
45
|
-
#
|
45
|
+
# NOTES:
|
46
|
+
#
|
47
|
+
# * Exceptions raised here result in `(Object doesn't support #inspect)`. No other details are available, be careful.
|
48
|
+
# * We don't return value from here, we **print** it directly.
|
46
49
|
|
47
50
|
nodes = @instance.nodes.select {|node| node.parent == @parent}
|
48
51
|
|
@@ -103,7 +106,13 @@ module HackTree
|
|
103
106
|
(["", node.full_desc] if node.full_desc),
|
104
107
|
].flatten(1).compact
|
105
108
|
|
109
|
+
# `out` are lines of text, eventually.
|
106
110
|
::Kernel.puts out.empty?? "No description, please provide one" : out
|
111
|
+
|
112
|
+
# For groups list contents after description.
|
113
|
+
#if node.is_a? Node::Group
|
114
|
+
# ::Kernel.puts ["", self.class.new(@instance, node).inspect]
|
115
|
+
#end
|
107
116
|
else
|
108
117
|
# Group/hack request.
|
109
118
|
case node
|
data/lib/hack_tree/instance.rb
CHANGED
@@ -12,21 +12,17 @@ module HackTree
|
|
12
12
|
attrs.each {|k, v| send("#{k}=", v)}
|
13
13
|
end
|
14
14
|
|
15
|
-
#
|
15
|
+
# Create action object.
|
16
16
|
#
|
17
17
|
# >> r.action
|
18
18
|
# hello # Say hello
|
19
|
+
#
|
19
20
|
# >> r.action.hello
|
20
21
|
# Hello, world!
|
21
22
|
def action
|
22
23
|
ActionContext.new(self)
|
23
24
|
end
|
24
25
|
|
25
|
-
# Create action object. See HackTree::action for examples.
|
26
|
-
def action
|
27
|
-
ActionContext.new(self)
|
28
|
-
end
|
29
|
-
|
30
26
|
# List direct children of <tt>node</tt>. Return Array, possibly an empty one.
|
31
27
|
#
|
32
28
|
# children_of(nil) # => [...], children of root.
|
data/lib/hack_tree/node/group.rb
CHANGED
data/lib/hack_tree/node/hack.rb
CHANGED
data/lib/hack_tree.rb
CHANGED
@@ -1,14 +1,14 @@
|
|
1
|
+
|
2
|
+
# Load all stuff.
|
1
3
|
[
|
2
4
|
"hack_tree/**/*.rb",
|
3
5
|
].each do |fmask|
|
4
|
-
Dir[File.
|
6
|
+
Dir[File.expand_path("../#{fmask}", __FILE__)].each do |fn|
|
5
7
|
require fn
|
6
8
|
end
|
7
9
|
end
|
8
10
|
|
9
11
|
module HackTree
|
10
|
-
VERSION = "0.1.0"
|
11
|
-
|
12
12
|
# Standard hacks bundled with the gem, their global names.
|
13
13
|
STD_HACKS = [
|
14
14
|
"hack_tree.reload",
|
@@ -57,22 +57,20 @@ module HackTree
|
|
57
57
|
# Enable HackTree globally.
|
58
58
|
#
|
59
59
|
# >> HackTree.enable
|
60
|
-
#
|
60
|
+
# Console hacks are available. Use `c`, `c.hack?`, `c.hack [args]`
|
61
|
+
#
|
61
62
|
# >> c
|
62
63
|
# hello # Say hello
|
64
|
+
#
|
63
65
|
# >> c.hello
|
64
66
|
# Hello, world!
|
65
67
|
#
|
66
68
|
# Options:
|
67
69
|
#
|
68
|
-
# :completion => T|F # Enable completion enhancement. Default is true
|
70
|
+
# :completion => T|F # Enable completion enhancement. Default is `true`.
|
69
71
|
# :with_std => [...] # Load only these standard hacks.
|
70
72
|
# :without_std => [...] # Load all but these standard hacks.
|
71
|
-
# :quiet => T|F # Be quiet. Default is false
|
72
|
-
#
|
73
|
-
# Examples:
|
74
|
-
#
|
75
|
-
# TODO.
|
73
|
+
# :quiet => T|F # Be quiet. Default is `false`.
|
76
74
|
def self.enable(method_name = :c, options = {})
|
77
75
|
options = options.dup
|
78
76
|
o = {}
|
@@ -142,8 +140,8 @@ module HackTree
|
|
142
140
|
|
143
141
|
global_names.each do |global_name|
|
144
142
|
bn = global_name.gsub(".", "/") + ".rb"
|
145
|
-
fn = File.
|
146
|
-
|
143
|
+
fn = File.expand_path("../hacks/#{bn}", __FILE__)
|
144
|
+
require fn
|
147
145
|
end
|
148
146
|
|
149
147
|
nil
|
@@ -157,77 +155,3 @@ module HackTree
|
|
157
155
|
@instance ||= Instance.new
|
158
156
|
end
|
159
157
|
end
|
160
|
-
|
161
|
-
#--------------------------------------- Junk
|
162
|
-
|
163
|
-
if false
|
164
|
-
# * Using array is a reliable way to ensure a newline after the banner.
|
165
|
-
::Kernel.puts [
|
166
|
-
#"",
|
167
|
-
"Console hacks are available. Use `%s`, `%s.hack?`, `%s.hack [args]`" % ([@enabled_as]*3),
|
168
|
-
#"",
|
169
|
-
]
|
170
|
-
end
|
171
|
-
|
172
|
-
if false
|
173
|
-
# Node (group/hack) regexp without delimiters.
|
174
|
-
NAME_REGEXP = /[a-zA-Z_]\w*/
|
175
|
-
|
176
|
-
# Node names which can't be used due to serious reasons.
|
177
|
-
FORBIDDEN_NAMES = [
|
178
|
-
:inspect,
|
179
|
-
:method_missing,
|
180
|
-
:to_s,
|
181
|
-
]
|
182
|
-
end
|
183
|
-
|
184
|
-
if false
|
185
|
-
# Create the action object.
|
186
|
-
#
|
187
|
-
# module Kernel
|
188
|
-
# # Access our hacks via <tt>c</tt>.
|
189
|
-
# def c
|
190
|
-
# ::HackTree.action
|
191
|
-
# end
|
192
|
-
# end
|
193
|
-
#
|
194
|
-
# >> c
|
195
|
-
# hello # Say hello
|
196
|
-
# >> c.hello
|
197
|
-
# Hello, world!
|
198
|
-
#
|
199
|
-
# See also ::enable.
|
200
|
-
def self.action
|
201
|
-
ActionContext.new(@nodes)
|
202
|
-
end
|
203
|
-
|
204
|
-
# Clear self.
|
205
|
-
def self.clear
|
206
|
-
# Request re-initialization upon first use of any kind.
|
207
|
-
@is_initialized = false
|
208
|
-
end
|
209
|
-
|
210
|
-
# Access nodes (groups/hacks) created via the DSL.
|
211
|
-
def self.nodes
|
212
|
-
@nodes
|
213
|
-
end
|
214
|
-
|
215
|
-
# See #nodes.
|
216
|
-
def self.nodes=(ar)
|
217
|
-
@nodes = ar
|
218
|
-
end
|
219
|
-
|
220
|
-
# NOTE: We need this wrapper to create private singletons.
|
221
|
-
class << self
|
222
|
-
private
|
223
|
-
|
224
|
-
# On-the-fly initializer.
|
225
|
-
def _otf_init
|
226
|
-
return if @is_initialized
|
227
|
-
|
228
|
-
@is_initialized = true
|
229
|
-
@nodes = []
|
230
|
-
@dsl_root = DslContext.new(@nodes)
|
231
|
-
end
|
232
|
-
end # class << self
|
233
|
-
end
|
data/{hacks → lib/hacks}/ls.rb
RENAMED
@@ -41,8 +41,9 @@ HackTree.define do
|
|
41
41
|
r.global_name =~ re,
|
42
42
|
r.brief_desc && r.brief_desc =~ re,
|
43
43
|
|
44
|
-
#
|
45
|
-
#
|
44
|
+
# Might some time include search in `full_desc` as an option.
|
45
|
+
# Must not be enabled by default since it returns too many results.
|
46
|
+
#r.full_desc && r.full_desc =~ re,
|
46
47
|
].any?
|
47
48
|
end
|
48
49
|
end
|
@@ -50,7 +51,7 @@ HackTree.define do
|
|
50
51
|
nodes = nodes.sort_by do |node|
|
51
52
|
[
|
52
53
|
node.is_a?(::HackTree::Node::Group) ? 0 : 1, # Groups first.
|
53
|
-
node.
|
54
|
+
node.global_name,
|
54
55
|
]
|
55
56
|
end
|
56
57
|
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
data/spec/spec_helper.rb
CHANGED
@@ -1,16 +1,33 @@
|
|
1
|
-
|
1
|
+
# NOTE: I usually support `STANDALONE` mode in specs for Rails projects' components
|
2
|
+
# to be able to test them without loading the environment. This project does not
|
3
|
+
# depend on Rails *BUT* I still want a consistent RSpec file structure.
|
4
|
+
# If this is confusing, feel free to propose something better. :)
|
2
5
|
|
3
|
-
#
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
6
|
+
# No Rails, we're always standalone... and free! :)
|
7
|
+
STANDALONE = 1
|
8
|
+
|
9
|
+
if STANDALONE
|
10
|
+
# Provide root path object.
|
11
|
+
module Standalone
|
12
|
+
eval <<-EOT
|
13
|
+
def self.root
|
14
|
+
# This is an absolute path, it's perfectly safe to do a `+` and then `require`.
|
15
|
+
Pathname("#{File.expand_path('../..', __FILE__)}")
|
16
|
+
end
|
17
|
+
EOT
|
18
|
+
end
|
19
|
+
|
20
|
+
# Load stuff.
|
21
|
+
[
|
22
|
+
"lib/hack_tree/**/*.rb",
|
23
|
+
].each do |fmask|
|
24
|
+
Dir[Standalone.root + fmask].each do |fn|
|
25
|
+
require fn
|
26
|
+
end
|
10
27
|
end
|
11
28
|
end
|
12
29
|
|
13
|
-
#
|
30
|
+
# When this becomes a gem, use gem instead of direct copy.
|
14
31
|
module RSpec
|
15
32
|
module PrintOnFailure
|
16
33
|
module Helpers
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: hack_tree
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,11 +9,11 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-03-
|
12
|
+
date: 2012-03-09 00:00:00.000000000Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rspec
|
16
|
-
requirement: &
|
16
|
+
requirement: &75379870 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ! '>='
|
@@ -21,7 +21,18 @@ dependencies:
|
|
21
21
|
version: '0'
|
22
22
|
type: :development
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *75379870
|
25
|
+
- !ruby/object:Gem::Dependency
|
26
|
+
name: yard
|
27
|
+
requirement: &75361840 !ruby/object:Gem::Requirement
|
28
|
+
none: false
|
29
|
+
requirements:
|
30
|
+
- - ! '>='
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: '0'
|
33
|
+
type: :development
|
34
|
+
prerelease: false
|
35
|
+
version_requirements: *75361840
|
25
36
|
description: HackTree lets you organize and share your console hacks in an effective
|
26
37
|
and uniform way. Blah-blah-blah.
|
27
38
|
email:
|
@@ -33,12 +44,11 @@ files:
|
|
33
44
|
- .gitignore
|
34
45
|
- .rspec
|
35
46
|
- Gemfile
|
47
|
+
- Gemfile.lock
|
36
48
|
- MIT-LICENSE
|
37
49
|
- README.md
|
38
50
|
- Rakefile
|
39
51
|
- hack_tree.gemspec
|
40
|
-
- hacks/hack_tree/reload.rb
|
41
|
-
- hacks/ls.rb
|
42
52
|
- lib/generators/hack_tree/USAGE
|
43
53
|
- lib/generators/hack_tree/hack_tree_generator.rb
|
44
54
|
- lib/generators/hack_tree/templates/INSTALL
|
@@ -56,16 +66,18 @@ files:
|
|
56
66
|
- lib/hack_tree/parser/base.rb
|
57
67
|
- lib/hack_tree/parser/desc.rb
|
58
68
|
- lib/hack_tree/tools.rb
|
59
|
-
-
|
60
|
-
-
|
61
|
-
-
|
62
|
-
-
|
63
|
-
- spec/
|
64
|
-
- spec/
|
65
|
-
- spec/
|
66
|
-
- spec/
|
67
|
-
- spec/
|
68
|
-
- spec/
|
69
|
+
- lib/hack_tree/version.rb
|
70
|
+
- lib/hacks/hack_tree.rb
|
71
|
+
- lib/hacks/hack_tree/reload.rb
|
72
|
+
- lib/hacks/ls.rb
|
73
|
+
- spec/parser/desc_spec.rb
|
74
|
+
- spec/parser/desc_spec/000,brief.txt
|
75
|
+
- spec/parser/desc_spec/000,full.txt
|
76
|
+
- spec/parser/desc_spec/000.txt
|
77
|
+
- spec/parser/desc_spec/010,brief.txt
|
78
|
+
- spec/parser/desc_spec/010,full.txt
|
79
|
+
- spec/parser/desc_spec/010.txt
|
80
|
+
- spec/parser/spec_helper.rb
|
69
81
|
- spec/spec_helper.rb
|
70
82
|
homepage: http://github.com/dadooda/hack_tree
|
71
83
|
licenses: []
|
@@ -92,3 +104,4 @@ signing_key:
|
|
92
104
|
specification_version: 3
|
93
105
|
summary: Organize and share your console hacks
|
94
106
|
test_files: []
|
107
|
+
has_rdoc:
|
data/spec/lib/spec_helper.rb
DELETED