wriggle 1.2.0 → 1.3.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/.gitignore +4 -3
- data/Gemfile +4 -0
- data/Gemfile.lock +26 -0
- data/LICENSE +1 -1
- data/README.md +18 -3
- data/Rakefile +4 -20
- data/lib/wriggle.rb +100 -33
- data/lib/wriggle/version.rb +3 -0
- data/spec/spec_helper.rb +4 -0
- data/spec/support/temporary_files.rb +79 -0
- data/spec/wriggle_spec.rb +126 -47
- data/wriggle.gemspec +14 -48
- metadata +28 -30
- data/VERSION +0 -1
- data/spec/empty.txt +0 -0
data/.gitignore
CHANGED
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,26 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
wriggle (1.3.0)
|
5
|
+
|
6
|
+
GEM
|
7
|
+
remote: http://rubygems.org/
|
8
|
+
specs:
|
9
|
+
diff-lcs (1.1.2)
|
10
|
+
rspec (2.5.0)
|
11
|
+
rspec-core (~> 2.5.0)
|
12
|
+
rspec-expectations (~> 2.5.0)
|
13
|
+
rspec-mocks (~> 2.5.0)
|
14
|
+
rspec-core (2.5.1)
|
15
|
+
rspec-expectations (2.5.0)
|
16
|
+
diff-lcs (~> 1.1.2)
|
17
|
+
rspec-mocks (2.5.0)
|
18
|
+
yard (0.6.3)
|
19
|
+
|
20
|
+
PLATFORMS
|
21
|
+
ruby
|
22
|
+
|
23
|
+
DEPENDENCIES
|
24
|
+
rspec (~> 2.5)
|
25
|
+
wriggle!
|
26
|
+
yard (~> 0.6)
|
data/LICENSE
CHANGED
data/README.md
CHANGED
@@ -7,23 +7,38 @@ A simple directory crawler DSL.
|
|
7
7
|
require 'wriggle'
|
8
8
|
|
9
9
|
wriggle '/path/to/files' do |w|
|
10
|
+
# Print a list of files
|
11
|
+
w.file { |path| puts path }
|
12
|
+
|
13
|
+
# Build a list of Rails controller files
|
14
|
+
controllers = []
|
15
|
+
w.files /_controller\.rb/ do |path|
|
16
|
+
controllers << path
|
17
|
+
end
|
18
|
+
|
19
|
+
# Print the path of any file named "spec_helper.rb"
|
20
|
+
w.file 'spec_helper.rb' { |path| puts path }
|
10
21
|
|
11
22
|
# Build an array of Ruby code files
|
12
23
|
ruby_files = []
|
13
|
-
w.
|
24
|
+
w.extension :rb do |path|
|
14
25
|
ruby_files << path
|
15
26
|
end
|
16
27
|
|
17
28
|
# Build an array of video files
|
18
29
|
video_files = []
|
19
|
-
w.
|
30
|
+
w.extensions %w(mpg mpeg wmv avi mkv) do |path|
|
20
31
|
video_files << path
|
21
32
|
end
|
22
33
|
|
23
34
|
# Delete directories that are empty
|
24
|
-
w.
|
35
|
+
w.directories do |path|
|
25
36
|
Dir.rmdir(path) unless Dir.entries(path).length > 2
|
26
37
|
end
|
38
|
+
|
39
|
+
# Print a list of directories matching "foo"
|
40
|
+
# NOTE: Matches "/baz/bar/foo" and "/foo" but not "/foo/bar/baz"
|
41
|
+
w.directory /foo/ { |path| puts path }
|
27
42
|
end
|
28
43
|
|
29
44
|
## Note on Patches/Pull Requests
|
data/Rakefile
CHANGED
@@ -1,21 +1,5 @@
|
|
1
|
-
require '
|
2
|
-
|
3
|
-
|
4
|
-
begin
|
5
|
-
require 'jeweler'
|
6
|
-
Jeweler::Tasks.new do |gem|
|
7
|
-
gem.name = "wriggle"
|
8
|
-
gem.summary = %Q{A simple directory crawler DSL.}
|
9
|
-
gem.description = %Q{A simple directory crawler DSL.}
|
10
|
-
gem.email = "rspeicher@gmail.com"
|
11
|
-
gem.homepage = "http://github.com/tsigo/wriggle"
|
12
|
-
gem.authors = ["Robert Speicher"]
|
13
|
-
gem.add_development_dependency "rspec", "~> 2.0.0"
|
14
|
-
end
|
15
|
-
Jeweler::GemcutterTasks.new
|
16
|
-
rescue LoadError
|
17
|
-
puts "Jeweler (or a dependency) not available. Install it with: gem install jeweler"
|
18
|
-
end
|
1
|
+
require 'bundler'
|
2
|
+
Bundler::GemHelper.install_tasks
|
19
3
|
|
20
4
|
require 'rspec/core/rake_task'
|
21
5
|
RSpec::Core::RakeTask.new(:spec)
|
@@ -25,7 +9,7 @@ begin
|
|
25
9
|
require 'yard'
|
26
10
|
YARD::Rake::YardocTask.new
|
27
11
|
rescue LoadError
|
28
|
-
task :
|
29
|
-
abort "YARD is not available. In order to run
|
12
|
+
task :yard do
|
13
|
+
abort "YARD is not available. In order to run yard, you must: sudo gem install yard"
|
30
14
|
end
|
31
15
|
end
|
data/lib/wriggle.rb
CHANGED
@@ -9,23 +9,38 @@ require 'find'
|
|
9
9
|
# require 'wriggle'
|
10
10
|
#
|
11
11
|
# wriggle '/path/to/files' do |w|
|
12
|
+
# # Print a list of files
|
13
|
+
# w.file { |path| puts path }
|
14
|
+
#
|
15
|
+
# # Build a list of Rails controller files
|
16
|
+
# controllers = []
|
17
|
+
# w.files /_controller\.rb/ do |path|
|
18
|
+
# controllers << path
|
19
|
+
# end
|
20
|
+
#
|
21
|
+
# # Print the path of any file named "spec_helper.rb"
|
22
|
+
# w.file 'spec_helper.rb' { |path| puts path }
|
12
23
|
#
|
13
24
|
# # Build an array of Ruby code files
|
14
25
|
# ruby_files = []
|
15
|
-
# w.
|
26
|
+
# w.extension :rb do |path|
|
16
27
|
# ruby_files << path
|
17
28
|
# end
|
18
29
|
#
|
19
30
|
# # Build an array of video files
|
20
31
|
# video_files = []
|
21
|
-
# w.
|
32
|
+
# w.extensions %w(mpg mpeg wmv avi mkv) do |path|
|
22
33
|
# video_files << path
|
23
34
|
# end
|
24
35
|
#
|
25
36
|
# # Delete directories that are empty
|
26
|
-
# w.
|
37
|
+
# w.directories do |path|
|
27
38
|
# Dir.rmdir(path) unless Dir.entries(path).length > 2
|
28
39
|
# end
|
40
|
+
#
|
41
|
+
# # Print a list of directories matching "foo"
|
42
|
+
# # NOTE: Matches "/baz/bar/foo" and "/foo" but not "/foo/bar/baz"
|
43
|
+
# w.directory /foo/ { |path| puts path }
|
29
44
|
# end
|
30
45
|
module Wriggle
|
31
46
|
# Crawl the given +path+
|
@@ -38,72 +53,124 @@ module Wriggle
|
|
38
53
|
end
|
39
54
|
|
40
55
|
class Wriggle
|
41
|
-
attr_accessor :root, :file_blocks, :directory_blocks
|
42
|
-
|
43
56
|
def initialize(root, &block)
|
44
57
|
@root = root
|
45
58
|
@file_blocks = []
|
46
59
|
@directory_blocks = []
|
60
|
+
@extension_blocks = []
|
47
61
|
|
48
62
|
crawl(&block)
|
49
63
|
end
|
50
64
|
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
65
|
+
# Define a block to be called when a file is encountered
|
66
|
+
#
|
67
|
+
# @example All files
|
68
|
+
# file { |file| ... }
|
69
|
+
#
|
70
|
+
# @yield [path] Full, absolute file path
|
71
|
+
# @raise ArgumentError When no block provided
|
72
|
+
def file(*names, &block)
|
73
|
+
raise ArgumentError, "a block is required" unless block_given?
|
74
|
+
@file_blocks << {:names => names.flatten, :block => block}
|
61
75
|
end
|
62
76
|
|
63
|
-
# Define a block to be called when a
|
77
|
+
# Define a block to be called when a directory is encountered
|
64
78
|
#
|
65
|
-
# Provide one or more
|
79
|
+
# Provide one or more patterns to match the directory's basename against
|
66
80
|
#
|
67
|
-
#
|
68
|
-
#
|
69
|
-
#
|
70
|
-
#
|
81
|
+
# @example All directories
|
82
|
+
# directory { |dir| ... }
|
83
|
+
# @example Directories matching <tt>/lib/</tt>
|
84
|
+
# directory /lib/ { |dir| ... }
|
85
|
+
# @example Directories matching <tt>/lib/</tt> or <tt>/spec/</tt>
|
86
|
+
# directories /lib/, /spec/ { |dir| ... }
|
71
87
|
#
|
88
|
+
# @param [Array] patterns Limit the yielded directory paths only to those matching the provided pattern(s)
|
89
|
+
# @yield [path] Full, absolute directory path
|
72
90
|
# @raise ArgumentError When no block provided
|
73
|
-
def
|
91
|
+
def directory(*patterns, &block)
|
74
92
|
raise ArgumentError, "a block is required" unless block_given?
|
75
|
-
|
93
|
+
@directory_blocks << {:pattern => patterns.flatten, :block => block}
|
76
94
|
end
|
77
95
|
|
78
|
-
# Define a block to be called when a
|
96
|
+
# Define a block to be called when a file of a certain extension is encountered
|
97
|
+
#
|
98
|
+
# @example All <tt>.rb</tt> files
|
99
|
+
# extension '.rb' { |file| ... }
|
100
|
+
# @example All <tt>.rb</tt> or <tt>.erb</tt> files
|
101
|
+
# extensions :rb, :erb { |file| ... }
|
102
|
+
# @example All video files
|
103
|
+
# extensions %w(mpeg mpeg wmv avi mkv) { |file| ... }
|
79
104
|
#
|
105
|
+
# @param [Array] extensions Limit the yielded file paths to the provided extensions
|
106
|
+
# @yield [path] Full, absolute file path
|
80
107
|
# @raise ArgumentError When no block provided
|
81
|
-
|
108
|
+
# @raise ArgumentError When no extension argument provided
|
109
|
+
def extension(*extensions, &block)
|
82
110
|
raise ArgumentError, "a block is required" unless block_given?
|
83
|
-
|
111
|
+
raise ArgumentError, "at least one extension is required" unless extensions.length > 0
|
112
|
+
@extension_blocks << {:ext => extensions.flatten, :block => block}
|
84
113
|
end
|
85
114
|
|
115
|
+
alias_method :files, :file
|
116
|
+
alias_method :directories, :directory
|
117
|
+
alias_method :extensions, :extension
|
118
|
+
|
86
119
|
private
|
87
120
|
|
121
|
+
# Yields <tt>self</tt> to allow the user to define file/directory blocks, and then
|
122
|
+
# crawl the root directory, dispatching the user's defined blocks as each
|
123
|
+
# file type is encountered
|
124
|
+
def crawl(&block)
|
125
|
+
yield self
|
126
|
+
|
127
|
+
Find.find(@root) do |current|
|
128
|
+
if File.file?(current)
|
129
|
+
dispatch_file(current)
|
130
|
+
elsif File.directory?(current)
|
131
|
+
dispatch_directory(current)
|
132
|
+
end
|
133
|
+
end
|
134
|
+
end
|
135
|
+
|
136
|
+
# Called whenever <tt>crawl</tt> encounters a file
|
137
|
+
#
|
138
|
+
# Handles both <tt>file_blocks</tt> and <tt>extension_blocks</tt>.
|
88
139
|
def dispatch_file(path)
|
89
140
|
extension = File.extname(path)
|
90
141
|
|
91
|
-
file_blocks.each do |group|
|
92
|
-
if group[:
|
142
|
+
@file_blocks.each do |group|
|
143
|
+
if group[:names].empty?
|
93
144
|
group[:block].call(path)
|
94
145
|
else
|
95
|
-
|
96
|
-
|
97
|
-
if group[:ext].any? { |v| v.to_s == extension or v.to_s == extension[1..-1] }
|
146
|
+
filename = File.basename(path)
|
147
|
+
if group[:names].any? { |v| (v.is_a?(String) and filename == v) or (v.is_a?(Regexp) and filename =~ v) }
|
98
148
|
group[:block].call(path)
|
99
149
|
end
|
100
150
|
end
|
101
151
|
end
|
152
|
+
|
153
|
+
@extension_blocks.each do |group|
|
154
|
+
# Check if any of the extensions match the current file's extension (with or without the period)
|
155
|
+
if group[:ext].any? { |v| v.to_s == extension or v.to_s == extension[1..-1] }
|
156
|
+
group[:block].call(path)
|
157
|
+
end
|
158
|
+
end
|
102
159
|
end
|
103
160
|
|
161
|
+
# Called whenever <tt>crawl</tt> encounters a file
|
104
162
|
def dispatch_directory(path)
|
105
|
-
directory_blocks.each do |group|
|
106
|
-
group[:
|
163
|
+
@directory_blocks.each do |group|
|
164
|
+
if group[:pattern].empty?
|
165
|
+
group[:block].call(path)
|
166
|
+
else
|
167
|
+
# User requested only directories matching a certain pattern
|
168
|
+
# Check if any of the patterns match the directory name
|
169
|
+
base = File.basename(path)
|
170
|
+
if group[:pattern].any? { |v| base =~ v }
|
171
|
+
group[:block].call(path)
|
172
|
+
end
|
173
|
+
end
|
107
174
|
end
|
108
175
|
end
|
109
176
|
end
|
data/spec/spec_helper.rb
CHANGED
@@ -3,5 +3,9 @@ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
|
|
3
3
|
|
4
4
|
require 'wriggle'
|
5
5
|
|
6
|
+
Dir[File.expand_path('../support/**/*.rb', __FILE__)].each { |f| require f }
|
7
|
+
|
6
8
|
RSpec.configure do |config|
|
9
|
+
config.before(:all) { TemporaryFiles.setup }
|
10
|
+
config.after(:all) { TemporaryFiles.teardown }
|
7
11
|
end
|
@@ -0,0 +1,79 @@
|
|
1
|
+
require 'fileutils'
|
2
|
+
|
3
|
+
module TemporaryFiles
|
4
|
+
def self.path
|
5
|
+
File.expand_path("../../../tmp", __FILE__)
|
6
|
+
end
|
7
|
+
|
8
|
+
def self.setup
|
9
|
+
path = self.path
|
10
|
+
|
11
|
+
files = %w(app/views/wishlists/index.html.haml
|
12
|
+
app/views/shared/_moderation.html.haml
|
13
|
+
app/views/shared/_maintitle.html.haml
|
14
|
+
app/views/shared/_form_errors.html.haml
|
15
|
+
app/views/shared/_contextual_search.html.haml
|
16
|
+
app/views/members/wishlists/update.js.rjs
|
17
|
+
app/views/members/wishlists/new.html.haml
|
18
|
+
app/views/members/wishlists/index.lua.erb
|
19
|
+
app/views/members/wishlists/index.html.haml
|
20
|
+
app/views/members/wishlists/edit.html.haml
|
21
|
+
app/views/members/wishlists/create.js.rjs
|
22
|
+
app/views/members/wishlists/_wishlist_row.html.haml
|
23
|
+
app/views/members/wishlists/_form.html.haml
|
24
|
+
app/views/members/show.html.haml
|
25
|
+
app/views/members/new.html.haml
|
26
|
+
app/views/members/index.lua.erb
|
27
|
+
app/views/members/index.html.haml
|
28
|
+
app/views/members/edit.html.haml
|
29
|
+
app/views/members/_form.html.haml
|
30
|
+
app/views/layouts/application.lua.erb
|
31
|
+
app/views/layouts/application.html.haml
|
32
|
+
app/views/items/show.html.haml
|
33
|
+
app/views/items/new.html.haml
|
34
|
+
app/views/items/index.html.haml
|
35
|
+
app/views/items/edit.html.haml
|
36
|
+
app/views/items/_form.html.haml
|
37
|
+
app/sweepers/index_sweeper.rb
|
38
|
+
app/models/zone.rb
|
39
|
+
app/models/wishlist.rb
|
40
|
+
app/models/user_session.rb
|
41
|
+
app/models/user.rb
|
42
|
+
app/models/session.rb
|
43
|
+
app/models/raid.rb
|
44
|
+
app/models/member_rank.rb
|
45
|
+
app/models/member.rb
|
46
|
+
app/models/loot_table.rb
|
47
|
+
app/models/loot.rb
|
48
|
+
app/models/live_raid.rb
|
49
|
+
app/models/live_loot.rb
|
50
|
+
app/models/live_attendee.rb
|
51
|
+
app/models/item_price.rb
|
52
|
+
app/models/item.rb
|
53
|
+
app/models/completed_achievement.rb
|
54
|
+
app/models/boss.rb
|
55
|
+
app/models/attendee.rb
|
56
|
+
app/models/achievement.rb
|
57
|
+
app/helpers/members_helper.rb
|
58
|
+
app/helpers/members/wishlists_helper.rb
|
59
|
+
app/helpers/items_helper.rb
|
60
|
+
app/helpers/application_helper.rb
|
61
|
+
app/controllers/wishlists_controller.rb
|
62
|
+
app/controllers/user_sessions_controller.rb
|
63
|
+
app/controllers/searches_controller.rb
|
64
|
+
app/controllers/members_controller.rb
|
65
|
+
app/controllers/members/wishlists_controller.rb
|
66
|
+
app/controllers/items_controller.rb
|
67
|
+
app/controllers/application_controller.rb)
|
68
|
+
|
69
|
+
files.each do |file|
|
70
|
+
file = File.join(path, file)
|
71
|
+
FileUtils.mkdir_p(File.dirname(file))
|
72
|
+
FileUtils.touch(file)
|
73
|
+
end
|
74
|
+
end
|
75
|
+
|
76
|
+
def self.teardown
|
77
|
+
FileUtils.rm_rf(self.path)
|
78
|
+
end
|
79
|
+
end
|
data/spec/wriggle_spec.rb
CHANGED
@@ -1,73 +1,152 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
describe Wriggle do
|
4
|
-
# 1.8.7's Find uses relative paths, while 1.9.2's uses absolutes,
|
5
|
-
# so we'll call expand_path and make sure our specs use this method
|
6
|
-
def valid_dir
|
7
|
-
File.expand_path(File.dirname(__FILE__))
|
8
|
-
end
|
9
|
-
|
10
4
|
it "should require a path argument" do
|
11
|
-
|
5
|
+
expect { wriggle() {} }.to raise_error(ArgumentError)
|
12
6
|
end
|
13
7
|
|
14
8
|
it "should raise an ArgumentError when given an invalid path" do
|
15
|
-
|
9
|
+
expect { wriggle('/path/to/nothing') {} }.to raise_error(ArgumentError, /does not exist/)
|
16
10
|
end
|
17
11
|
|
18
12
|
it "should raise an ArgumentError when given a non-directory" do
|
19
|
-
|
13
|
+
expect { wriggle(__FILE__) {} }.to raise_error(ArgumentError, /is not a directory/)
|
14
|
+
end
|
15
|
+
|
16
|
+
it "should alias 'files' to 'file'" do
|
17
|
+
expect { wriggle(TemporaryFiles.path) { |w| w.files } }.to_not raise_error(NoMethodError)
|
18
|
+
end
|
19
|
+
|
20
|
+
it "should alias 'directories' to 'directory'" do
|
21
|
+
expect { wriggle(TemporaryFiles.path) { |w| w.directories } }.to_not raise_error(NoMethodError)
|
20
22
|
end
|
21
23
|
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
24
|
+
it "should alias 'extensions' to 'extension'" do
|
25
|
+
expect { wriggle(TemporaryFiles.path) { |w| w.extensions } }.to_not raise_error(NoMethodError)
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
describe Wriggle, "#file" do
|
30
|
+
it "should raise an ArgumentError when not given a block" do
|
31
|
+
expect { wriggle(TemporaryFiles.path) { |w| w.file } }.to raise_error(ArgumentError, /a block is required/)
|
32
|
+
end
|
33
|
+
|
34
|
+
it "should only include files matching a pattern when given a regex argument" do
|
35
|
+
actual = []
|
36
|
+
wriggle(TemporaryFiles.path) do |w|
|
37
|
+
w.file /controller/ do |path|
|
38
|
+
actual << path
|
26
39
|
end
|
40
|
+
end
|
41
|
+
|
42
|
+
actual.should include("#{TemporaryFiles.path}/app/controllers/members_controller.rb")
|
43
|
+
actual.should include("#{TemporaryFiles.path}/app/controllers/members/wishlists_controller.rb")
|
44
|
+
actual.should_not include("#{TemporaryFiles.path}/app/controllers")
|
45
|
+
actual.should_not include("#{TemporaryFiles.path}/app/helpers/items_helper.rb")
|
46
|
+
end
|
47
|
+
|
48
|
+
it "should only include files matching a string when given a string argument" do
|
49
|
+
actual = []
|
50
|
+
wriggle(TemporaryFiles.path) do |w|
|
51
|
+
w.file 'members_controller.rb', 'wishlists_controller.rb' do |path|
|
52
|
+
actual << path
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
actual.should include("#{TemporaryFiles.path}/app/controllers/members_controller.rb")
|
57
|
+
actual.should include("#{TemporaryFiles.path}/app/controllers/members/wishlists_controller.rb")
|
58
|
+
actual.should include("#{TemporaryFiles.path}/app/controllers/wishlists_controller.rb")
|
59
|
+
actual.should_not include("#{TemporaryFiles.path}/app/controllers")
|
60
|
+
actual.should_not include("#{TemporaryFiles.path}/app/helpers/items_helper.rb")
|
61
|
+
end
|
27
62
|
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
end
|
34
|
-
end
|
35
|
-
|
36
|
-
actual.should include("#{valid_dir}/empty.txt")
|
37
|
-
actual.should include("#{valid_dir}/wriggle_spec.rb")
|
38
|
-
actual.should_not include("#{valid_dir}/spec")
|
63
|
+
it "should not include directories when only a file block is provided" do
|
64
|
+
actual = []
|
65
|
+
wriggle(TemporaryFiles.path) do |w|
|
66
|
+
w.file do |path|
|
67
|
+
actual << path
|
39
68
|
end
|
69
|
+
end
|
70
|
+
|
71
|
+
actual.should include("#{TemporaryFiles.path}/app/controllers/members_controller.rb")
|
72
|
+
actual.should include("#{TemporaryFiles.path}/app/models/item.rb")
|
73
|
+
actual.should include("#{TemporaryFiles.path}/app/views/layouts/application.lua.erb")
|
74
|
+
actual.should include("#{TemporaryFiles.path}/app/views/layouts/application.html.haml")
|
75
|
+
actual.should include("#{TemporaryFiles.path}/app/views/members/wishlists/create.js.rjs")
|
76
|
+
actual.should_not include("#{TemporaryFiles.path}/app/views/")
|
77
|
+
end
|
78
|
+
end
|
79
|
+
|
80
|
+
describe Wriggle, "#directory" do
|
81
|
+
it "should raise an ArgumentError when not given a block" do
|
82
|
+
expect { wriggle(TemporaryFiles.path) { |w| w.directory } }.to raise_error(ArgumentError, /a block is required/)
|
83
|
+
end
|
40
84
|
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
end
|
47
|
-
end
|
48
|
-
|
49
|
-
actual.should include("#{valid_dir}/wriggle_spec.rb")
|
50
|
-
actual.should_not include("#{valid_dir}/empty.txt")
|
51
|
-
actual.should_not include("#{valid_dir}")
|
85
|
+
it "should not include files when only a directory block is provided" do
|
86
|
+
actual = []
|
87
|
+
wriggle(TemporaryFiles.path) do |w|
|
88
|
+
w.directory do |path|
|
89
|
+
actual << path
|
52
90
|
end
|
53
91
|
end
|
54
92
|
|
55
|
-
|
56
|
-
|
57
|
-
|
93
|
+
actual.should include("#{TemporaryFiles.path}")
|
94
|
+
actual.should include("#{TemporaryFiles.path}/app")
|
95
|
+
actual.should include("#{TemporaryFiles.path}/app/models")
|
96
|
+
actual.should_not include("#{TemporaryFiles.path}/models/member.rb")
|
97
|
+
end
|
98
|
+
|
99
|
+
it "should only include directories matching a pattern when given an argument" do
|
100
|
+
actual = []
|
101
|
+
wriggle(TemporaryFiles.path) do |w|
|
102
|
+
w.directory /member/, /model/ do |path|
|
103
|
+
actual << path
|
58
104
|
end
|
105
|
+
end
|
59
106
|
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
107
|
+
actual.should include("#{TemporaryFiles.path}/app/controllers/members")
|
108
|
+
actual.should include("#{TemporaryFiles.path}/app/helpers/members")
|
109
|
+
actual.should include("#{TemporaryFiles.path}/app/views/members")
|
110
|
+
actual.should_not include("#{TemporaryFiles.path}/app/views/members/wishlists")
|
111
|
+
actual.should include("#{TemporaryFiles.path}/app/models")
|
112
|
+
actual.should_not include("#{TemporaryFiles.path}/app/views/items")
|
113
|
+
actual.should_not include("#{TemporaryFiles.path}/app/views/layouts")
|
114
|
+
end
|
115
|
+
end
|
116
|
+
|
117
|
+
describe Wriggle, "#extension" do
|
118
|
+
it "should raise an ArgumentError when not given a block" do
|
119
|
+
expect { wriggle(TemporaryFiles.path) { |w| w.extension(:rb) } }.to raise_error(ArgumentError, /a block is required/)
|
120
|
+
end
|
121
|
+
|
122
|
+
it "should raise an ArgumentError when not given any extensions to match" do
|
123
|
+
expect { wriggle(TemporaryFiles.path) { |w| w.extension {} } }.to raise_error(ArgumentError, /at least one extension is required/)
|
124
|
+
end
|
67
125
|
|
68
|
-
|
69
|
-
|
126
|
+
it "should only include files of the extension specified" do
|
127
|
+
ruby, view = [], []
|
128
|
+
wriggle(TemporaryFiles.path) do |w|
|
129
|
+
w.extension :rb, :erb do |path|
|
130
|
+
ruby << path
|
131
|
+
end
|
132
|
+
|
133
|
+
w.extension %w(rjs haml) do |path|
|
134
|
+
view << path
|
70
135
|
end
|
71
136
|
end
|
137
|
+
|
138
|
+
ruby.should include("#{TemporaryFiles.path}/app/controllers/members_controller.rb")
|
139
|
+
ruby.should include("#{TemporaryFiles.path}/app/models/item.rb")
|
140
|
+
ruby.should include("#{TemporaryFiles.path}/app/views/layouts/application.lua.erb")
|
141
|
+
ruby.should_not include("#{TemporaryFiles.path}/app/views/layouts/application.html.haml")
|
142
|
+
ruby.should_not include("#{TemporaryFiles.path}/app/views/members/wishlists/create.js.rjs")
|
143
|
+
ruby.should_not include("#{TemporaryFiles.path}/app/views/")
|
144
|
+
|
145
|
+
view.should_not include("#{TemporaryFiles.path}/app/controllers/members_controller.rb")
|
146
|
+
view.should_not include("#{TemporaryFiles.path}/app/models/item.rb")
|
147
|
+
view.should_not include("#{TemporaryFiles.path}/app/views/layouts/application.lua.erb")
|
148
|
+
view.should include("#{TemporaryFiles.path}/app/views/layouts/application.html.haml")
|
149
|
+
view.should include("#{TemporaryFiles.path}/app/views/members/wishlists/create.js.rjs")
|
150
|
+
view.should_not include("#{TemporaryFiles.path}/app/views/")
|
72
151
|
end
|
73
152
|
end
|
data/wriggle.gemspec
CHANGED
@@ -1,55 +1,21 @@
|
|
1
|
-
# Generated by jeweler
|
2
|
-
# DO NOT EDIT THIS FILE DIRECTLY
|
3
|
-
# Instead, edit Jeweler::Tasks in Rakefile, and run the gemspec command
|
4
1
|
# -*- encoding: utf-8 -*-
|
2
|
+
$:.push File.expand_path("../lib", __FILE__)
|
3
|
+
require "wriggle/version"
|
5
4
|
|
6
5
|
Gem::Specification.new do |s|
|
7
|
-
s.name
|
8
|
-
s.version
|
9
|
-
|
10
|
-
s.
|
11
|
-
s.
|
12
|
-
s.
|
6
|
+
s.name = "wriggle"
|
7
|
+
s.version = Wriggle::VERSION
|
8
|
+
s.platform = Gem::Platform::RUBY
|
9
|
+
s.authors = ["Robert Speicher"]
|
10
|
+
s.email = ["rspeicher@gmail.com"]
|
11
|
+
s.homepage = "http://github.com/tsigo/wriggle"
|
12
|
+
s.summary = %q{A simple directory crawler DSL}
|
13
13
|
s.description = %q{A simple directory crawler DSL.}
|
14
|
-
s.email = %q{rspeicher@gmail.com}
|
15
|
-
s.extra_rdoc_files = [
|
16
|
-
"LICENSE",
|
17
|
-
"README.md"
|
18
|
-
]
|
19
|
-
s.files = [
|
20
|
-
".document",
|
21
|
-
".gitignore",
|
22
|
-
"LICENSE",
|
23
|
-
"README.md",
|
24
|
-
"Rakefile",
|
25
|
-
"VERSION",
|
26
|
-
"lib/wriggle.rb",
|
27
|
-
"spec/empty.txt",
|
28
|
-
"spec/spec_helper.rb",
|
29
|
-
"spec/wriggle_spec.rb",
|
30
|
-
"wriggle.gemspec"
|
31
|
-
]
|
32
|
-
s.homepage = %q{http://github.com/tsigo/wriggle}
|
33
|
-
s.rdoc_options = ["--charset=UTF-8"]
|
34
|
-
s.require_paths = ["lib"]
|
35
|
-
s.rubygems_version = %q{1.3.7}
|
36
|
-
s.summary = %q{A simple directory crawler DSL.}
|
37
|
-
s.test_files = [
|
38
|
-
"spec/spec_helper.rb",
|
39
|
-
"spec/wriggle_spec.rb"
|
40
|
-
]
|
41
14
|
|
42
|
-
|
43
|
-
|
44
|
-
|
15
|
+
s.files = `git ls-files`.split("\n")
|
16
|
+
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
17
|
+
s.require_paths = ["lib"]
|
45
18
|
|
46
|
-
|
47
|
-
|
48
|
-
else
|
49
|
-
s.add_dependency(%q<rspec>, ["~> 2.0.0"])
|
50
|
-
end
|
51
|
-
else
|
52
|
-
s.add_dependency(%q<rspec>, ["~> 2.0.0"])
|
53
|
-
end
|
19
|
+
s.add_development_dependency "rspec", "~> 2.5"
|
20
|
+
s.add_development_dependency "yard", "~> 0.6"
|
54
21
|
end
|
55
|
-
|
metadata
CHANGED
@@ -1,13 +1,8 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: wriggle
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
|
5
|
-
|
6
|
-
segments:
|
7
|
-
- 1
|
8
|
-
- 2
|
9
|
-
- 0
|
10
|
-
version: 1.2.0
|
4
|
+
prerelease:
|
5
|
+
version: 1.3.0
|
11
6
|
platform: ruby
|
12
7
|
authors:
|
13
8
|
- Robert Speicher
|
@@ -15,7 +10,7 @@ autorequire:
|
|
15
10
|
bindir: bin
|
16
11
|
cert_chain: []
|
17
12
|
|
18
|
-
date:
|
13
|
+
date: 2011-03-09 00:00:00 -05:00
|
19
14
|
default_executable:
|
20
15
|
dependencies:
|
21
16
|
- !ruby/object:Gem::Dependency
|
@@ -26,33 +21,41 @@ dependencies:
|
|
26
21
|
requirements:
|
27
22
|
- - ~>
|
28
23
|
- !ruby/object:Gem::Version
|
29
|
-
|
30
|
-
segments:
|
31
|
-
- 2
|
32
|
-
- 0
|
33
|
-
- 0
|
34
|
-
version: 2.0.0
|
24
|
+
version: "2.5"
|
35
25
|
type: :development
|
36
26
|
version_requirements: *id001
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: yard
|
29
|
+
prerelease: false
|
30
|
+
requirement: &id002 !ruby/object:Gem::Requirement
|
31
|
+
none: false
|
32
|
+
requirements:
|
33
|
+
- - ~>
|
34
|
+
- !ruby/object:Gem::Version
|
35
|
+
version: "0.6"
|
36
|
+
type: :development
|
37
|
+
version_requirements: *id002
|
37
38
|
description: A simple directory crawler DSL.
|
38
|
-
email:
|
39
|
+
email:
|
40
|
+
- rspeicher@gmail.com
|
39
41
|
executables: []
|
40
42
|
|
41
43
|
extensions: []
|
42
44
|
|
43
|
-
extra_rdoc_files:
|
44
|
-
|
45
|
-
- README.md
|
45
|
+
extra_rdoc_files: []
|
46
|
+
|
46
47
|
files:
|
47
48
|
- .document
|
48
49
|
- .gitignore
|
50
|
+
- Gemfile
|
51
|
+
- Gemfile.lock
|
49
52
|
- LICENSE
|
50
53
|
- README.md
|
51
54
|
- Rakefile
|
52
|
-
- VERSION
|
53
55
|
- lib/wriggle.rb
|
54
|
-
-
|
56
|
+
- lib/wriggle/version.rb
|
55
57
|
- spec/spec_helper.rb
|
58
|
+
- spec/support/temporary_files.rb
|
56
59
|
- spec/wriggle_spec.rb
|
57
60
|
- wriggle.gemspec
|
58
61
|
has_rdoc: true
|
@@ -60,8 +63,8 @@ homepage: http://github.com/tsigo/wriggle
|
|
60
63
|
licenses: []
|
61
64
|
|
62
65
|
post_install_message:
|
63
|
-
rdoc_options:
|
64
|
-
|
66
|
+
rdoc_options: []
|
67
|
+
|
65
68
|
require_paths:
|
66
69
|
- lib
|
67
70
|
required_ruby_version: !ruby/object:Gem::Requirement
|
@@ -69,26 +72,21 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
69
72
|
requirements:
|
70
73
|
- - ">="
|
71
74
|
- !ruby/object:Gem::Version
|
72
|
-
hash: 3
|
73
|
-
segments:
|
74
|
-
- 0
|
75
75
|
version: "0"
|
76
76
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
77
77
|
none: false
|
78
78
|
requirements:
|
79
79
|
- - ">="
|
80
80
|
- !ruby/object:Gem::Version
|
81
|
-
hash: 3
|
82
|
-
segments:
|
83
|
-
- 0
|
84
81
|
version: "0"
|
85
82
|
requirements: []
|
86
83
|
|
87
84
|
rubyforge_project:
|
88
|
-
rubygems_version: 1.
|
85
|
+
rubygems_version: 1.6.1
|
89
86
|
signing_key:
|
90
87
|
specification_version: 3
|
91
|
-
summary: A simple directory crawler DSL
|
88
|
+
summary: A simple directory crawler DSL
|
92
89
|
test_files:
|
93
90
|
- spec/spec_helper.rb
|
91
|
+
- spec/support/temporary_files.rb
|
94
92
|
- spec/wriggle_spec.rb
|
data/VERSION
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
1.2.0
|
data/spec/empty.txt
DELETED
File without changes
|