celerity 0.0.6 → 0.0.7
Sign up to get free protection for your applications and to get access to all the features.
- data/History.txt +36 -0
- data/Manifest.txt +82 -0
- data/README.rdoc +78 -0
- data/Rakefile +25 -10
- data/celerity.gemspec +40 -0
- data/lib/celerity.rb +36 -20
- data/lib/celerity/browser.rb +396 -189
- data/lib/celerity/clickable_element.rb +25 -5
- data/lib/celerity/collections.rb +2 -2
- data/lib/celerity/container.rb +74 -61
- data/lib/celerity/default_viewer.rb +8 -4
- data/lib/celerity/disabled_element.rb +5 -5
- data/lib/celerity/element.rb +57 -35
- data/lib/celerity/element_collection.rb +22 -21
- data/lib/celerity/element_locator.rb +25 -18
- data/lib/celerity/elements/button.rb +13 -11
- data/lib/celerity/elements/file_field.rb +8 -4
- data/lib/celerity/elements/form.rb +7 -5
- data/lib/celerity/elements/frame.rb +6 -4
- data/lib/celerity/elements/image.rb +4 -4
- data/lib/celerity/elements/label.rb +1 -1
- data/lib/celerity/elements/link.rb +5 -5
- data/lib/celerity/elements/meta.rb +2 -1
- data/lib/celerity/elements/non_control_elements.rb +3 -3
- data/lib/celerity/elements/option.rb +7 -7
- data/lib/celerity/elements/radio_check.rb +18 -18
- data/lib/celerity/elements/select_list.rb +55 -25
- data/lib/celerity/elements/table.rb +21 -18
- data/lib/celerity/elements/table_cell.rb +1 -1
- data/lib/celerity/elements/table_elements.rb +1 -1
- data/lib/celerity/elements/table_row.rb +5 -5
- data/lib/celerity/elements/text_field.rb +33 -28
- data/lib/celerity/exception.rb +11 -5
- data/lib/celerity/htmlunit.rb +24 -8
- data/lib/celerity/htmlunit/commons-codec-1.4.jar +0 -0
- data/lib/celerity/htmlunit/htmlunit-2.6.jar +0 -0
- data/lib/celerity/htmlunit/htmlunit-core-js-2.6.jar +0 -0
- data/lib/celerity/htmlunit/nekohtml-1.9.13.jar +0 -0
- data/lib/celerity/htmlunit/{xercesImpl-2.8.1.jar → xercesImpl-2.9.1.jar} +0 -0
- data/lib/celerity/ignoring_web_connection.rb +15 -0
- data/lib/celerity/input_element.rb +1 -1
- data/lib/celerity/listener.rb +23 -17
- data/lib/celerity/short_inspect.rb +20 -0
- data/lib/celerity/util.rb +5 -2
- data/lib/celerity/version.rb +3 -10
- data/lib/celerity/viewer_connection.rb +89 -0
- data/lib/celerity/watir_compatibility.rb +2 -5
- data/lib/celerity/xpath_support.rb +48 -0
- data/spec/browser_authentication_spec.rb +16 -0
- data/spec/browser_spec.rb +300 -0
- data/spec/clickable_element_spec.rb +39 -0
- data/spec/default_viewer_spec.rb +23 -0
- data/spec/element_spec.rb +51 -0
- data/spec/filefield_spec.rb +18 -0
- data/spec/htmlunit_spec.rb +56 -0
- data/spec/index_offset_spec.rb +24 -0
- data/spec/listener_spec.rb +142 -0
- data/spec/spec_helper.rb +8 -0
- data/tasks/benchmark.rake +4 -0
- data/tasks/deployment.rake +43 -0
- data/tasks/environment.rake +7 -0
- data/tasks/fix.rake +25 -0
- data/tasks/jar.rake +4 -6
- data/tasks/rspec.rake +43 -0
- data/tasks/simple_ci.rake +94 -0
- data/tasks/snapshot.rake +22 -0
- data/tasks/website.rake +17 -0
- data/tasks/yard.rake +9 -0
- metadata +59 -26
- data/README.txt +0 -69
- data/lib/celerity/extra/method_generator.rb +0 -170
- data/lib/celerity/htmlunit/commons-codec-1.3.jar +0 -0
- data/lib/celerity/htmlunit/htmlunit-2.5-SNAPSHOT.jar +0 -0
- data/lib/celerity/htmlunit/htmlunit-core-js-2.5-SNAPSHOT.jar +0 -0
- data/lib/celerity/htmlunit/nekohtml-1.9.12-20090308.130127-11.jar +0 -0
@@ -0,0 +1,39 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/watirspec/spec_helper'
|
2
|
+
|
3
|
+
describe "ClickableElement" do
|
4
|
+
|
5
|
+
before :each do
|
6
|
+
browser.goto(WatirSpec.files + "/non_control_elements.html")
|
7
|
+
end
|
8
|
+
|
9
|
+
describe "#click_and_attach" do
|
10
|
+
it 'opens a page in a new browser with the same options' do
|
11
|
+
b = browser.link(:name, /bad_attribute/).click_and_attach
|
12
|
+
b.text.include?("User administration").should be_true # to make sure it is open.
|
13
|
+
b.options.should == browser.options
|
14
|
+
b.cookies.should == browser.cookies
|
15
|
+
end
|
16
|
+
|
17
|
+
it "opens the page in a new browser with the same cookies" do
|
18
|
+
browser.add_cookie("localhost", "foo", "bar")
|
19
|
+
old_cookies = browser.cookies
|
20
|
+
old_cookies.should_not be_empty
|
21
|
+
|
22
|
+
browser.goto(WatirSpec.files + "/non_control_elements.html")
|
23
|
+
b = browser.link(:name, /bad_attribute/).click_and_attach
|
24
|
+
|
25
|
+
b.should_not == browser
|
26
|
+
b.cookies.should == old_cookies
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
describe "#download" do
|
31
|
+
it 'returns a click-opened page as io' do
|
32
|
+
expected = File.read "#{WatirSpec.files}/forms_with_input_elements.html".sub("file://", '')
|
33
|
+
|
34
|
+
browser.link(:name, /bad_attribute/).download.read.should == expected
|
35
|
+
browser.link(:name, /bad_attribute/).should exist
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/watirspec/spec_helper'
|
2
|
+
|
3
|
+
describe "DefaultViewer" do
|
4
|
+
|
5
|
+
before :all do
|
6
|
+
browser.goto(WatirSpec.files + "/definition_lists.html")
|
7
|
+
end
|
8
|
+
|
9
|
+
describe ".save" do
|
10
|
+
it "saves the default image to the given path" do
|
11
|
+
fail("don't run specs with CelerityViewer") if browser.viewer != Celerity::DefaultViewer
|
12
|
+
fname = File.expand_path "default_viewer_test.png"
|
13
|
+
default = "#{File.dirname(__FILE__)}/../lib/celerity/resources/no_viewer.png"
|
14
|
+
|
15
|
+
browser.viewer.save(fname)
|
16
|
+
File.exist?(fname).should be_true
|
17
|
+
File.read(fname).should == File.read(default)
|
18
|
+
|
19
|
+
File.delete(fname)
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
@@ -0,0 +1,51 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
require File.dirname(__FILE__) + '/spec_helper'
|
3
|
+
|
4
|
+
describe "Element" do
|
5
|
+
|
6
|
+
before :each do
|
7
|
+
browser.goto(WatirSpec.files + "/forms_with_input_elements.html")
|
8
|
+
end
|
9
|
+
|
10
|
+
describe "#identifier_string" do
|
11
|
+
it "doesn't make the next locate find the wrong element" do
|
12
|
+
elem = browser.div(:id, 'hidden_parent')
|
13
|
+
elem.should exist
|
14
|
+
def elem.public_identifier_string; identifier_string end # method is private
|
15
|
+
elem.public_identifier_string
|
16
|
+
elem.id.should == 'hidden_parent'
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
describe "#method_missing" do
|
21
|
+
it "magically returns the requested attribute if the attribute is defined in the attribute list" do
|
22
|
+
browser.form(:index, 1).action.should == 'post_to_me'
|
23
|
+
end
|
24
|
+
|
25
|
+
it "raises NoMethodError if the requested method isn't among the attributes" do
|
26
|
+
lambda { browser.button(:index, 1).no_such_attribute_or_method }.should raise_error(NoMethodError)
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
describe "#xpath" do
|
31
|
+
it "gets the canonical xpath of this element" do
|
32
|
+
browser.text_field(:id, "new_user_email").xpath.should == '/html/body/form[1]/fieldset[1]/input[3]'
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
describe "#javascript_object" do
|
37
|
+
it "should return the JavaScript object representing the receiver" do
|
38
|
+
obj = browser.div(:id, "onfocus_test").javascript_object
|
39
|
+
obj.should be_kind_of(com.gargoylesoftware.htmlunit.javascript.host.html.HTMLElement)
|
40
|
+
obj.should be_instance_of(com.gargoylesoftware.htmlunit.javascript.host.html.HTMLDivElement)
|
41
|
+
obj.client_width.should be_kind_of(Integer)
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
describe "#locate" do
|
46
|
+
it "raises ArgumentError when used with :object and the object given isn't an HtmlElement subclass" do
|
47
|
+
lambda { Link.new(browser, :object, "foo").locate }.should raise_error(ArgumentError)
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
require File.dirname(__FILE__) + '/watirspec/spec_helper'
|
3
|
+
|
4
|
+
describe "FileField" do
|
5
|
+
|
6
|
+
before :each do
|
7
|
+
browser.goto(WatirSpec.files + "/forms_with_input_elements.html")
|
8
|
+
end
|
9
|
+
|
10
|
+
describe "#set" do
|
11
|
+
it "sends content as correct content type for common file types" do
|
12
|
+
browser.file_field(:name, "new_user_portrait").set("foo.doc")
|
13
|
+
obj = browser.file_field(:name, "new_user_portrait").locate
|
14
|
+
obj.getContentType.should == "application/msword"
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
end
|
@@ -0,0 +1,56 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/watirspec/spec_helper'
|
2
|
+
|
3
|
+
describe "HtmlUnit bugs" do
|
4
|
+
describe "HtmlUnit bug 1968686: https://sourceforge.net/tracker/index.php?func=detail&aid=1968686&group_id=47038&atid=448266" do
|
5
|
+
it "does not raise NativeException: java.lang.StackOverflowError when going to a page where Javascripts prints a <body> tag inside another <body> tag" do
|
6
|
+
lambda { browser.goto(WatirSpec.files + "/bug_javascript_001.html") }.should_not raise_error(NativeException)
|
7
|
+
end
|
8
|
+
end
|
9
|
+
|
10
|
+
describe "HtmlUnit bug 1968708: https://sourceforge.net/tracker/index.php?func=detail&aid=1968708&group_id=47038&atid=448266" do
|
11
|
+
it "only considers the first attribute if there are duplicate attributes" do
|
12
|
+
browser.goto(WatirSpec.files + "/bug_duplicate_attributes.html")
|
13
|
+
browser.text_field(:index, 1).id.should == "org_id"
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
describe "NekoHtml parser bug: https://sourceforge.net/tracker/?func=detail&aid=2824922&group_id=47038&atid=448266" do
|
18
|
+
it "does not run out of java heap space" do
|
19
|
+
lambda { browser.goto(WatirSpec.files + "/parser_bug_001.html") }.should_not raise_error
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
# disabled for CI - need fix from HtmlUnit
|
24
|
+
# describe "HtmlUnit bug XXXXXX" do
|
25
|
+
# it "returns strings as UTF-8 when there's a charset mismatch between HTTP response header and <meta> tag" do
|
26
|
+
# browser.goto(WatirSpec.host + "/charset_mismatch")
|
27
|
+
# browser.h1(:index, 1).text.should == "\303\270"
|
28
|
+
# end
|
29
|
+
# end
|
30
|
+
|
31
|
+
it "evaluates <script> tags injected in the DOM through JQuery's replaceWith() - fixed in rev. 3598" do
|
32
|
+
browser.goto(WatirSpec.files + "/jquery.html")
|
33
|
+
browser.link(:class, 'editLink').click
|
34
|
+
browser.div(:id, 'content').text.should == "typeof update: function"
|
35
|
+
end
|
36
|
+
|
37
|
+
it "doesn't return the TinyMCE DOM when executing javascript functions" do
|
38
|
+
b = WatirSpec.new_browser
|
39
|
+
|
40
|
+
b.goto(WatirSpec.files + "/tiny_mce.html")
|
41
|
+
b.text.should include("Beskrivelse")
|
42
|
+
b.checkbox(:id, "exemption").set
|
43
|
+
b.text.should include("Beskrivelse")
|
44
|
+
|
45
|
+
b.close
|
46
|
+
end
|
47
|
+
|
48
|
+
describe "HtmlUnit bug 2811607: https://sourceforge.net/tracker/?func=detail&aid=2811607&group_id=47038&atid=448266" do
|
49
|
+
it "correctly prevents default on <form>#submit()" do
|
50
|
+
browser.goto(WatirSpec.files + "/prevent_form_submit.html")
|
51
|
+
browser.button(:id, "next").click
|
52
|
+
browser.title.should == "preventDefault() on form submission"
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/watirspec/spec_helper'
|
2
|
+
|
3
|
+
describe "Celerity.index_offset" do
|
4
|
+
|
5
|
+
before :all do
|
6
|
+
browser.goto(WatirSpec.files + "/non_control_elements.html")
|
7
|
+
|
8
|
+
Celerity.index_offset = 0
|
9
|
+
end
|
10
|
+
|
11
|
+
it "returns the correct divs" do
|
12
|
+
divs = browser.divs.to_a
|
13
|
+
|
14
|
+
divs.each_with_index do |div, idx|
|
15
|
+
browser.div(:index, idx).id.should == div.id
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
after :all do
|
20
|
+
Celerity.index_offset = 1
|
21
|
+
end
|
22
|
+
|
23
|
+
end
|
24
|
+
|
@@ -0,0 +1,142 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/watirspec/spec_helper'
|
2
|
+
|
3
|
+
describe "Listener" do
|
4
|
+
before(:each) do
|
5
|
+
@web_client = mock("WebClient", :null_object => true)
|
6
|
+
@listener = Celerity::Listener.new(@web_client)
|
7
|
+
end
|
8
|
+
|
9
|
+
it "implements the StatusHandler interface" do
|
10
|
+
@listener.should be_a_kind_of(com.gargoylesoftware.htmlunit.StatusHandler)
|
11
|
+
|
12
|
+
@listener.should respond_to(:statusMessageChanged)
|
13
|
+
lambda { @listener.statusMessageChanged('page', 'message') }.should_not raise_error
|
14
|
+
end
|
15
|
+
|
16
|
+
it "implements the ConfirmHandler interface" do
|
17
|
+
@listener.should be_a_kind_of(com.gargoylesoftware.htmlunit.ConfirmHandler)
|
18
|
+
|
19
|
+
@listener.should respond_to(:handleConfirm)
|
20
|
+
lambda { @listener.handleConfirm('page', 'message') }.should_not raise_error
|
21
|
+
end
|
22
|
+
|
23
|
+
it "implements the AttachmentHandler interface" do
|
24
|
+
@listener.should be_a_kind_of(com.gargoylesoftware.htmlunit.attachment.AttachmentHandler)
|
25
|
+
|
26
|
+
@listener.should respond_to(:handleAttachment)
|
27
|
+
lambda { @listener.handleAttachment('page') }.should_not raise_error
|
28
|
+
end
|
29
|
+
|
30
|
+
it "implements the AlertHandler interface" do
|
31
|
+
@listener.should be_a_kind_of(com.gargoylesoftware.htmlunit.AlertHandler)
|
32
|
+
|
33
|
+
@listener.should respond_to(:handleAlert)
|
34
|
+
lambda { @listener.handleAlert('page', 'message') }.should_not raise_error
|
35
|
+
end
|
36
|
+
|
37
|
+
it "implements the HTMLParserListener interface" do
|
38
|
+
@listener.should be_a_kind_of(com.gargoylesoftware.htmlunit.html.HTMLParserListener)
|
39
|
+
|
40
|
+
@listener.should respond_to(:error)
|
41
|
+
@listener.should respond_to(:warning)
|
42
|
+
|
43
|
+
lambda { @listener.error('message', 'url', 1, 2, "key") }.should_not raise_error
|
44
|
+
lambda { @listener.warning('message', 'url', 1, 2, "key") }.should_not raise_error
|
45
|
+
end
|
46
|
+
|
47
|
+
it "implements the WebWindowListener interface" do
|
48
|
+
@listener.should be_a_kind_of(com.gargoylesoftware.htmlunit.WebWindowListener)
|
49
|
+
|
50
|
+
@listener.should respond_to(:webWindowClosed)
|
51
|
+
@listener.should respond_to(:webWindowContentChanged)
|
52
|
+
@listener.should respond_to(:webWindowOpened)
|
53
|
+
|
54
|
+
lambda { @listener.webWindowClosed('event') }.should_not raise_error
|
55
|
+
lambda { @listener.webWindowContentChanged('event') }.should_not raise_error
|
56
|
+
lambda { @listener.webWindowOpened('event') }.should_not raise_error
|
57
|
+
end
|
58
|
+
|
59
|
+
it "implements the IncorrectnessListener interface" do
|
60
|
+
@listener.should be_a_kind_of(com.gargoylesoftware.htmlunit.IncorrectnessListener)
|
61
|
+
|
62
|
+
@listener.should respond_to(:notify)
|
63
|
+
lambda { @listener.notify('message', 'origin') }.should_not raise_error
|
64
|
+
end
|
65
|
+
|
66
|
+
it "implements the PromptHandler interface" do
|
67
|
+
@listener.should be_a_kind_of(com.gargoylesoftware.htmlunit.PromptHandler)
|
68
|
+
|
69
|
+
@listener.should respond_to(:handlePrompt)
|
70
|
+
lambda { @listener.handlePrompt('page', 'message') }.should_not raise_error
|
71
|
+
end
|
72
|
+
|
73
|
+
|
74
|
+
describe "#add_listener" do
|
75
|
+
it "adds itself as a listener for the :status type" do
|
76
|
+
@web_client.should_receive('setStatusHandler').with(@listener)
|
77
|
+
@listener.add_listener(:status) {}
|
78
|
+
end
|
79
|
+
|
80
|
+
it "adds itself as a listener for the :alert type" do
|
81
|
+
@web_client.should_receive('setAlertHandler').with(@listener)
|
82
|
+
@listener.add_listener(:alert) {}
|
83
|
+
end
|
84
|
+
|
85
|
+
it "adds itself as a listener for the :confirm type" do
|
86
|
+
@web_client.should_receive('setConfirmHandler').with(@listener)
|
87
|
+
@listener.add_listener(:confirm) {}
|
88
|
+
end
|
89
|
+
|
90
|
+
it "adds itself as a listener for the :prompt type" do
|
91
|
+
@web_client.should_receive('setPromptHandler').with(@listener)
|
92
|
+
@listener.add_listener(:prompt) {}
|
93
|
+
end
|
94
|
+
|
95
|
+
it "adds itself as a listener for the :web_window_event type" do
|
96
|
+
@web_client.should_receive('addWebWindowListener').with(@listener)
|
97
|
+
@listener.add_listener(:web_window_event) {}
|
98
|
+
end
|
99
|
+
|
100
|
+
it "adds itself as a listener for the :html_parser type" do
|
101
|
+
@web_client.should_receive('setHTMLParserListener').with(@listener)
|
102
|
+
@listener.add_listener(:html_parser) {}
|
103
|
+
end
|
104
|
+
|
105
|
+
it "adds itself as a listener for the :incorrectness type" do
|
106
|
+
@web_client.should_receive('setIncorrectnessListener').with(@listener)
|
107
|
+
@listener.add_listener(:incorrectness) {}
|
108
|
+
end
|
109
|
+
|
110
|
+
it "adds itself as a listener for the :attachment type" do
|
111
|
+
@web_client.should_receive('setAttachmentHandler').with(@listener)
|
112
|
+
@listener.add_listener(:attachment) {}
|
113
|
+
end
|
114
|
+
end
|
115
|
+
|
116
|
+
describe "#remove_listener" do
|
117
|
+
it "removes the listener at the given index" do
|
118
|
+
updates = []
|
119
|
+
first, second = lambda { updates << :first }, lambda { updates << :second }
|
120
|
+
|
121
|
+
@listener.add_listener(:prompt, &first)
|
122
|
+
@listener.add_listener(:prompt, &second)
|
123
|
+
|
124
|
+
@listener.remove_listener(:prompt, 0)
|
125
|
+
@listener.handlePrompt('foo', 'bar')
|
126
|
+
updates.should == [:second]
|
127
|
+
end
|
128
|
+
end
|
129
|
+
|
130
|
+
it "handles several invocations of all registered listeners" do
|
131
|
+
updates = []
|
132
|
+
@listener.add_listener(:alert) { updates << :first }
|
133
|
+
@listener.add_listener(:alert) { updates << :second }
|
134
|
+
|
135
|
+
@listener.handleAlert('foo', 'bar')
|
136
|
+
updates.should == [:first, :second]
|
137
|
+
|
138
|
+
@listener.handleAlert('foo', 'bar')
|
139
|
+
updates.should == [:first, :second, :first, :second]
|
140
|
+
end
|
141
|
+
|
142
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,43 @@
|
|
1
|
+
#desc 'Release the website and new gem version'
|
2
|
+
#task :deploy => [:check_version, :website, :release] do
|
3
|
+
# puts "Remember to create SVN tag:"
|
4
|
+
# puts "svn copy svn+ssh://#{rubyforge_username}@rubyforge.org/var/svn/#{PATH}/trunk " +
|
5
|
+
# "svn+ssh://#{rubyforge_username}@rubyforge.org/var/svn/#{PATH}/tags/REL-#{VERS} "
|
6
|
+
# puts "Suggested comment:"
|
7
|
+
# puts "Tagging release #{CHANGES}"
|
8
|
+
#end
|
9
|
+
|
10
|
+
desc 'Builds and installs gem locally'
|
11
|
+
task :local_deploy => [:install_gem]
|
12
|
+
|
13
|
+
#task :check_version do
|
14
|
+
# unless ENV['VERSION']
|
15
|
+
# puts 'Must pass a VERSION=x.y.z release version'
|
16
|
+
# exit
|
17
|
+
# end
|
18
|
+
# unless ENV['VERSION'] == VERS
|
19
|
+
# puts "Please update your version.rb to match the release version, currently #{VERS}"
|
20
|
+
# exit
|
21
|
+
# end
|
22
|
+
#end
|
23
|
+
|
24
|
+
#desc 'Install the package as a gem, without generating documentation(ri/rdoc)'
|
25
|
+
#task :install_gem_no_doc => [:clean, :package] do
|
26
|
+
# sh "#{'sudo ' unless Hoe::WINDOZE }gem install pkg/*.gem --no-rdoc --no-ri"
|
27
|
+
#end
|
28
|
+
|
29
|
+
namespace :manifest do
|
30
|
+
desc 'Recreate Manifest.txt to include ALL files'
|
31
|
+
task :refresh do
|
32
|
+
`rake check_manifest | patch -p0 > Manifest.txt`
|
33
|
+
end
|
34
|
+
desc 'Create new Manifest.txt in diff format'
|
35
|
+
task :new do
|
36
|
+
manifest = File.new('Manifest.txt', 'w+')
|
37
|
+
Dir.glob(File.join("**", "*")).each do |f|
|
38
|
+
manifest.puts f
|
39
|
+
end
|
40
|
+
manifest.flush
|
41
|
+
puts "####\n# Remember to edit Manifest.txt and remove unwanted file entries!\n####"
|
42
|
+
end
|
43
|
+
end
|
data/tasks/fix.rake
ADDED
@@ -0,0 +1,25 @@
|
|
1
|
+
namespace :fix do
|
2
|
+
|
3
|
+
desc 'Make all ruby files use LF line endings'
|
4
|
+
task :crlf do
|
5
|
+
files = FileList['**/*.rb']
|
6
|
+
files.each do |f|
|
7
|
+
next if File.directory?(f)
|
8
|
+
s = IO.read(f)
|
9
|
+
s.gsub!(/\r?\n/, "\n")
|
10
|
+
File.open(f, "w") { |io| io.write(s) }
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
desc 'Remove trailing whitespace from all ruby files'
|
15
|
+
task :trailing_whitespace do
|
16
|
+
files = FileList['**/*.rb']
|
17
|
+
files.each do |f|
|
18
|
+
next if File.directory?(f)
|
19
|
+
s = IO.read(f)
|
20
|
+
s.gsub!(/\s*?($)/, '\1')
|
21
|
+
File.open(f, "w") { |io| io.write(s) }
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
end
|