copy 0.1.0 → 0.1.1
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/lib/copy/server.rb +4 -0
- data/lib/copy/storage/relational.rb +1 -1
- data/lib/copy/version.rb +1 -1
- data/test/server_test.rb +10 -0
- data/test/test_app/views/indented.html.erb +9 -0
- metadata +6 -4
data/lib/copy/server.rb
CHANGED
@@ -57,12 +57,16 @@ module Copy
|
|
57
57
|
content = yield
|
58
58
|
@_out_buf = old_buffer
|
59
59
|
|
60
|
+
# Remove newlines from the beginning
|
61
|
+
content.gsub!(/^\n/, '')
|
60
62
|
# Get the first line from captured text.
|
61
63
|
first_line = content.split("\n").first
|
62
64
|
# Determine how much white space it has in front.
|
63
65
|
white_space = first_line.match(/^(\s)*/)[0]
|
64
66
|
# Remove that same amount of white space from the beginning of every line.
|
65
67
|
content.gsub!(Regexp.new("^#{white_space}"), '')
|
68
|
+
# Remove all whitespace from the end, but keep the newline if present.
|
69
|
+
content.gsub!(/\s*$/, '') << "\n" if content =~ /\n/
|
66
70
|
|
67
71
|
# Save the content so it can be edited.
|
68
72
|
Copy::Storage.set(name, content) if Copy::Storage.connected?
|
data/lib/copy/version.rb
CHANGED
data/test/server_test.rb
CHANGED
@@ -113,6 +113,16 @@ class ServerCopyHelperTest < Test::Unit::TestCase
|
|
113
113
|
assert_match %Q(<span class="_copy_editable" data-name="headline">Important!</span>), last_response.body
|
114
114
|
end
|
115
115
|
|
116
|
+
test "copy helper indented in view" do
|
117
|
+
Copy::Storage.stubs(:connected?).returns(true)
|
118
|
+
Copy::Storage.expects(:get).with(:three).returns(nil)
|
119
|
+
Copy::Storage.expects(:set).with(:three, "three\n").returns(true)
|
120
|
+
|
121
|
+
get 'indented'
|
122
|
+
assert last_response.ok?, last_response.errors
|
123
|
+
assert_match %Q(<div class="_copy_editable" data-name="three"><p>three</p></div>), last_response.body
|
124
|
+
end
|
125
|
+
|
116
126
|
test "partial rendering" do
|
117
127
|
get 'renders_partials'
|
118
128
|
assert last_response.ok?, last_response.errors
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: copy
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 25
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 1
|
9
|
-
-
|
10
|
-
version: 0.1.
|
9
|
+
- 1
|
10
|
+
version: 0.1.1
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Javan Makhmali
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2011-05-
|
18
|
+
date: 2011-05-20 00:00:00 -04:00
|
19
19
|
default_executable:
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|
@@ -113,6 +113,7 @@ files:
|
|
113
113
|
- test/test_app/views/about/us.html.erb
|
114
114
|
- test/test_app/views/data/people.csv.erb
|
115
115
|
- test/test_app/views/data/people.xml.erb
|
116
|
+
- test/test_app/views/indented.html.erb
|
116
117
|
- test/test_app/views/index.html.erb
|
117
118
|
- test/test_app/views/layout.html.erb
|
118
119
|
- test/test_app/views/renders_partials.html.erb
|
@@ -164,6 +165,7 @@ test_files:
|
|
164
165
|
- test/test_app/views/about/us.html.erb
|
165
166
|
- test/test_app/views/data/people.csv.erb
|
166
167
|
- test/test_app/views/data/people.xml.erb
|
168
|
+
- test/test_app/views/indented.html.erb
|
167
169
|
- test/test_app/views/index.html.erb
|
168
170
|
- test/test_app/views/layout.html.erb
|
169
171
|
- test/test_app/views/renders_partials.html.erb
|