mhennemeyer-rwriteboard 0.1.3 → 0.1.4

Sign up to get free protection for your applications and to get access to all the features.
data/lib/rwriteboard.rb CHANGED
@@ -33,9 +33,9 @@ class Writeboard
33
33
  end
34
34
 
35
35
  def get
36
- response_body = self.http.get(self.path, self.cookie).body
36
+ response_body = self.http.get(self.path, self.cookie).body.html_entity_quotes
37
37
  self.title = response_body.scan(%r{<div class="writeboardtitle">(.*?)</div>}m).to_s.strip_tags
38
- self.body = response_body.scan(%r{<div class="writeboardbody">(.*?)</div>}m).to_s.strip_tags
38
+ self.body = response_body.scan(%r{<div class="writeboardbody">(.*?)</div>}m).to_s.strip_tags.unescape_newlines
39
39
  self
40
40
  end
41
41
 
@@ -3,8 +3,12 @@ String.module_eval do
3
3
  self.gsub(%r(([ \t\f\r])+), " ").gsub(%r(\n+),"\n").gsub(%r(^\s+), "").gsub(%r(\s+$),"")
4
4
  end
5
5
 
6
- def cut_runner_output
7
- self.split(%r(### RUNNER OUTPUT ###)).first.chomp
6
+ def cut_runner_output(separator)
7
+ (self.split(%r(#{separator})).first || "").chomp
8
+ end
9
+
10
+ def html_entity_quotes
11
+ self.gsub(%r(&#8216;), "'").gsub(%r(&#8217;), "'").gsub(%r(&#8220;), '"').gsub(%r(&#8221;), '"')
8
12
  end
9
13
 
10
14
  def replace_newlines
@@ -14,7 +18,12 @@ String.module_eval do
14
18
  def remove_tags
15
19
  self.gsub(%r(<[^>]*>), "")
16
20
  end
21
+
17
22
  def strip_tags
18
23
  self.replace_newlines.remove_tags.compact
19
24
  end
25
+
26
+ def unescape_newlines
27
+ self.gsub(%r(\\n),"\n")
28
+ end
20
29
  end
data/rwriteboard.gemspec CHANGED
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = "rwriteboard"
3
- s.version = "0.1.3"
3
+ s.version = "0.1.4"
4
4
  s.date = "2008-11-15"
5
5
  s.summary = "Interface to writeboard"
6
6
  s.email = "mhennemeyer@gmail.com"
@@ -13,7 +13,9 @@ describe Writeboard do
13
13
  :name => "Feature1",
14
14
  :password => password,
15
15
  :path => path
16
- })
16
+ }) do |wb|
17
+ wb.post_without_revision(:body => 'Feature: FeatureTitle\n In order to gain profits', :title => "first writeboard")
18
+ end
17
19
  end
18
20
 
19
21
  describe ".create(hash)" do
@@ -88,7 +90,7 @@ describe Writeboard do
88
90
  end
89
91
  it "should set the writeboards body" do
90
92
  Writeboard.find :name => "Feature1" do |wb|
91
- wb.get.body.should eql('Feature: FeatureTitle\n In order to gain profits')
93
+ wb.get.body.should eql("Feature: FeatureTitle\n In order to gain profits")
92
94
  end
93
95
  end
94
96
  end
@@ -97,13 +99,21 @@ describe Writeboard do
97
99
  it "should post to the writeboard and make no new revision" do
98
100
  Writeboard.find :name => "Feature1" do |wb|
99
101
  wb.post_without_revision(:body => 'Feature: FeatureTitle\n In order to gain profits')
100
- wb.get.body.should eql('Feature: FeatureTitle\n In order to gain profits')
102
+ wb.get.body.should eql("Feature: FeatureTitle\n In order to gain profits")
101
103
  end
102
104
  end
103
105
 
104
106
  it "should get what it posts" do
105
107
  Writeboard.find :name => "Feature1" do |wb|
106
- string = 'Feature: FeatureTitle\n In order to gain profits'
108
+ string = "Feature: FeatureTitle\nIn order to gain profits"
109
+ wb.post_without_revision(:body => string)
110
+ wb.get.body.should eql(string)
111
+ end
112
+ end
113
+
114
+ it "should post quotes" do
115
+ Writeboard.find :name => "Feature1" do |wb|
116
+ string = "Feature: FeatureTitle\nIn order to 'gain' profits"
107
117
  wb.post_without_revision(:body => string)
108
118
  wb.get.body.should eql(string)
109
119
  end
@@ -28,16 +28,24 @@ describe "String" do
28
28
  end
29
29
  end
30
30
 
31
- describe "#cut_runner_output" do
32
- it "should cut away ### RUNNER OUTPUT ### and any subsequent characters" do
31
+ describe "#cut_runner_output(separator)" do
32
+ it "should cut away the separator and any subsequent characters" do
33
33
  html = '\nFeature: FeatureTitle\nIn order to gain profits\n
34
34
  Scenario: On the new calculation Page\nGiven I am on the new calculation page\n
35
35
  ### RUNNER OUTPUT ###\nPending Scenarios:\n1) FeatureTitle\nIn order to gain profits (On the new calculation Page\n
36
36
  Given I am on the new calculation page)\n'
37
37
 
38
- html.cut_runner_output.should eql('\nFeature: FeatureTitle\nIn order to gain profits\n
38
+ html.cut_runner_output("### RUNNER OUTPUT ###").should eql('\nFeature: FeatureTitle\nIn order to gain profits\n
39
39
  Scenario: On the new calculation Page\nGiven I am on the new calculation page\n')
40
40
  end
41
+
42
+ it "should return self if no separator in string" do
43
+ "shubidu".cut_runner_output("not_in_string").should eql("shubidu")
44
+ end
45
+
46
+ it "should return empty string for empty string" do
47
+ "".cut_runner_output("whatever").should eql("")
48
+ end
41
49
  end
42
50
 
43
51
  describe "#strip_tags" do
@@ -57,5 +65,22 @@ Scenario: On the new calculation Page\nGiven I am on the new calculation page\n'
57
65
  string.strip_tags.should eql(string)
58
66
  end
59
67
  end
68
+
69
+ describe "html_entity_quotes" do
70
+ it "should replace all '&#8216;' and '&#8217;' with single quote" do
71
+ "Hello &#8216;quotes&#8217;".html_entity_quotes.should eql("Hello 'quotes'")
72
+ end
73
+
74
+ it "should replace all '&#8220;' and '&#8221;' with double quote" do
75
+ "Hello &#8220;quotes&#8221;".html_entity_quotes.should eql('Hello "quotes"')
76
+ end
77
+ end
78
+
79
+ describe "unescape_newlines" do
80
+ it 'should replace all \\\n with \n' do
81
+ '\\n'.should eql('\\n')
82
+ 'Hello \\n'.unescape_newlines.should eql("Hello \n")
83
+ end
84
+ end
60
85
  end
61
86
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mhennemeyer-rwriteboard
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.3
4
+ version: 0.1.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Matthias Hennemeyer