jackdempsey-beet 0.0.8 → 0.0.9
Sign up to get free protection for your applications and to get access to all the features.
- data/Rakefile +18 -10
- data/VERSION +1 -1
- data/beet.gemspec +6 -6
- data/lib/beet/file_system.rb +19 -1
- data/test/file_system_shoulda_test.rb +59 -0
- data/{spec/spec_helper.rb → test/test_helper.rb} +6 -5
- metadata +6 -6
- data/spec/beet_spec.rb +0 -7
data/Rakefile
CHANGED
@@ -17,20 +17,28 @@ rescue LoadError
|
|
17
17
|
puts "Jeweler (or a dependency) not available. Install it with: sudo gem install jeweler"
|
18
18
|
end
|
19
19
|
|
20
|
-
require '
|
21
|
-
|
22
|
-
|
23
|
-
|
20
|
+
require 'rake/testtask'
|
21
|
+
Rake::TestTask.new(:test) do |test|
|
22
|
+
test.libs << 'lib' << 'test'
|
23
|
+
test.pattern = 'test/**/*_test.rb'
|
24
|
+
test.verbose = true
|
24
25
|
end
|
25
26
|
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
27
|
+
begin
|
28
|
+
require 'rcov/rcovtask'
|
29
|
+
Rcov::RcovTask.new do |test|
|
30
|
+
test.libs << 'test'
|
31
|
+
test.pattern = 'test/**/*_test.rb'
|
32
|
+
test.verbose = true
|
33
|
+
end
|
34
|
+
rescue LoadError
|
35
|
+
task :rcov do
|
36
|
+
abort "RCov is not available. In order to run rcov, you must: sudo gem install spicycode-rcov"
|
37
|
+
end
|
30
38
|
end
|
31
39
|
|
32
40
|
|
33
|
-
task :default => :
|
41
|
+
task :default => :test
|
34
42
|
|
35
43
|
require 'rake/rdoctask'
|
36
44
|
Rake::RDocTask.new do |rdoc|
|
@@ -42,7 +50,7 @@ Rake::RDocTask.new do |rdoc|
|
|
42
50
|
end
|
43
51
|
|
44
52
|
rdoc.rdoc_dir = 'rdoc'
|
45
|
-
rdoc.title = "
|
53
|
+
rdoc.title = "beet_shoulda #{version}"
|
46
54
|
rdoc.rdoc_files.include('README*')
|
47
55
|
rdoc.rdoc_files.include('lib/**/*.rb')
|
48
56
|
end
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.0.
|
1
|
+
0.0.9
|
data/beet.gemspec
CHANGED
@@ -2,11 +2,11 @@
|
|
2
2
|
|
3
3
|
Gem::Specification.new do |s|
|
4
4
|
s.name = %q{beet}
|
5
|
-
s.version = "0.0.
|
5
|
+
s.version = "0.0.9"
|
6
6
|
|
7
7
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
8
8
|
s.authors = ["Jack Dempsey"]
|
9
|
-
s.date = %q{2009-05-
|
9
|
+
s.date = %q{2009-05-30}
|
10
10
|
s.default_executable = %q{beet}
|
11
11
|
s.email = %q{jack.dempsey@gmail.com}
|
12
12
|
s.executables = ["beet"]
|
@@ -42,8 +42,8 @@ Gem::Specification.new do |s|
|
|
42
42
|
"lib/beet/scm.rb",
|
43
43
|
"lib/beet/scm/git.rb",
|
44
44
|
"lib/beet/scm/svn.rb",
|
45
|
-
"
|
46
|
-
"
|
45
|
+
"test/file_system_shoulda_test.rb",
|
46
|
+
"test/test_helper.rb"
|
47
47
|
]
|
48
48
|
s.homepage = %q{http://github.com/jackdempsey/beet}
|
49
49
|
s.rdoc_options = ["--charset=UTF-8"]
|
@@ -51,8 +51,8 @@ Gem::Specification.new do |s|
|
|
51
51
|
s.rubygems_version = %q{1.3.3}
|
52
52
|
s.summary = %q{A gem to help with easily generating projects}
|
53
53
|
s.test_files = [
|
54
|
-
"
|
55
|
-
"
|
54
|
+
"test/file_system_shoulda_test.rb",
|
55
|
+
"test/test_helper.rb"
|
56
56
|
]
|
57
57
|
|
58
58
|
if s.respond_to? :specification_version then
|
data/lib/beet/file_system.rb
CHANGED
@@ -89,7 +89,11 @@ module Beet
|
|
89
89
|
#
|
90
90
|
def gsub_file(relative_destination, regexp, *args, &block)
|
91
91
|
path = destination_path(relative_destination)
|
92
|
-
content = File.read(path)
|
92
|
+
content = File.read(path)
|
93
|
+
check_for = args.first || yield('')
|
94
|
+
regex = Regexp.new(regexp.source + Regexp.escape(check_for))
|
95
|
+
return if content =~ regex # if we can match the text and its leadin regex, don't add again
|
96
|
+
content = content.gsub(regexp, *args, &block)
|
93
97
|
File.open(path, 'wb') { |file| file.write(content) }
|
94
98
|
end
|
95
99
|
|
@@ -104,6 +108,20 @@ module Beet
|
|
104
108
|
File.open(path, 'ab') { |file| file.write(data) }
|
105
109
|
end
|
106
110
|
|
111
|
+
# Add text after matching line
|
112
|
+
#
|
113
|
+
# ==== Example
|
114
|
+
#
|
115
|
+
# add_after 'config/environment.rb', '# config.gem "aws-s3", :lib => "aws/s3"'
|
116
|
+
#
|
117
|
+
def add_after(filename, matching_text, data=nil, &block)
|
118
|
+
gsub_file filename, /(#{Regexp.escape(matching_text)})/mi do |match|
|
119
|
+
"#{match}\n#{data || block.call}"
|
120
|
+
end
|
121
|
+
end
|
122
|
+
|
123
|
+
protected
|
124
|
+
|
107
125
|
def destination_path(relative_destination)
|
108
126
|
File.join(root, relative_destination)
|
109
127
|
end
|
@@ -0,0 +1,59 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
include Beet::FileSystem
|
4
|
+
|
5
|
+
# define some methods that file_system recipes expect to exist
|
6
|
+
def root; '.'; end
|
7
|
+
class FileSystemShouldaTest < Test::Unit::TestCase
|
8
|
+
context "#add_after" do
|
9
|
+
setup do
|
10
|
+
@filename = 'test.file'
|
11
|
+
File.open(@filename,'w') do |f|
|
12
|
+
f.puts "first line"
|
13
|
+
f.puts "second line"
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
teardown do
|
18
|
+
File.unlink(@filename)
|
19
|
+
end
|
20
|
+
|
21
|
+
should "add the given text after the specified text" do
|
22
|
+
add_after @filename, "first line", "middle line"
|
23
|
+
assert_equal "first line\nmiddle line\nsecond line\n", File.read(@filename)
|
24
|
+
end
|
25
|
+
|
26
|
+
should "not add the given text if it already exists after the specified text" do
|
27
|
+
add_after @filename, "first line", "middle line"
|
28
|
+
assert_equal "first line\nmiddle line\nsecond line\n", File.read(@filename)
|
29
|
+
add_after @filename, "first line", "middle line"
|
30
|
+
assert_equal "first line\nmiddle line\nsecond line\n", File.read(@filename)
|
31
|
+
end
|
32
|
+
|
33
|
+
should "add the given text if it exists but only elsewhere in the specified text" do
|
34
|
+
add_after @filename, "first line", "middle line"
|
35
|
+
assert_equal "first line\nmiddle line\nsecond line\n", File.read(@filename)
|
36
|
+
add_after @filename, "first line", "second line"
|
37
|
+
assert_equal "first line\nsecond line\nmiddle line\nsecond line\n", File.read(@filename)
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
context "#append_file" do
|
42
|
+
setup do
|
43
|
+
@filename = 'test.file'
|
44
|
+
File.open(@filename,'w') do |f|
|
45
|
+
f.puts "first line"
|
46
|
+
f.puts "second line"
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
teardown do
|
51
|
+
File.unlink(@filename)
|
52
|
+
end
|
53
|
+
|
54
|
+
should "add text to the end of the file" do
|
55
|
+
append_file @filename, "third line"
|
56
|
+
assert_equal "first line\nsecond line\nthird line", File.read(@filename)
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
@@ -1,9 +1,10 @@
|
|
1
|
-
require '
|
1
|
+
require 'rubygems'
|
2
|
+
require 'test/unit'
|
3
|
+
require 'shoulda'
|
2
4
|
|
3
|
-
$LOAD_PATH.unshift(File.dirname(__FILE__))
|
4
5
|
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
|
6
|
+
$LOAD_PATH.unshift(File.dirname(__FILE__))
|
5
7
|
require 'beet'
|
6
|
-
|
7
|
-
|
8
|
-
|
8
|
+
require 'ruby-debug'
|
9
|
+
class Test::Unit::TestCase
|
9
10
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: jackdempsey-beet
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.9
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jack Dempsey
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2009-05-
|
12
|
+
date: 2009-05-30 00:00:00 -07:00
|
13
13
|
default_executable: beet
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
@@ -59,8 +59,8 @@ files:
|
|
59
59
|
- lib/beet/scm.rb
|
60
60
|
- lib/beet/scm/git.rb
|
61
61
|
- lib/beet/scm/svn.rb
|
62
|
-
-
|
63
|
-
-
|
62
|
+
- test/file_system_shoulda_test.rb
|
63
|
+
- test/test_helper.rb
|
64
64
|
has_rdoc: false
|
65
65
|
homepage: http://github.com/jackdempsey/beet
|
66
66
|
post_install_message:
|
@@ -88,5 +88,5 @@ signing_key:
|
|
88
88
|
specification_version: 3
|
89
89
|
summary: A gem to help with easily generating projects
|
90
90
|
test_files:
|
91
|
-
-
|
92
|
-
-
|
91
|
+
- test/file_system_shoulda_test.rb
|
92
|
+
- test/test_helper.rb
|