redhead 0.0.5 → 0.0.6
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +6 -0
- data/lib/redhead.rb +1 -1
- data/lib/redhead/header_set.rb +1 -1
- data/redhead.gemspec +1 -1
- data/test/redhead_string_spec.rb +9 -0
- metadata +2 -2
data/README.md
CHANGED
@@ -2,6 +2,10 @@
|
|
2
2
|
|
3
3
|
Redhead is for header metadata in strings, in the style of HTTP and email. It makes just a few assumptions about your header names and values, keeps them all as strings, and leaves the rest to you.
|
4
4
|
|
5
|
+
# License
|
6
|
+
|
7
|
+
MIT License. See LICENSE for details.
|
8
|
+
|
5
9
|
# How do I use this thing?
|
6
10
|
|
7
11
|
To install from RubyGems:
|
@@ -22,6 +26,8 @@ To contribute:
|
|
22
26
|
* Make a new feature branch: `git checkout -b some-new-thing master`
|
23
27
|
* Pull request
|
24
28
|
|
29
|
+
It will be assumed that your contribution will be licensed under the same terms as the project.
|
30
|
+
|
25
31
|
## Basics
|
26
32
|
|
27
33
|
A variable `post` referencing a simple string can be wrapped up in a `Redhead::String` object.
|
data/lib/redhead.rb
CHANGED
@@ -10,7 +10,7 @@ module Redhead
|
|
10
10
|
HEADERS_SEPARATOR = "\n\n"
|
11
11
|
|
12
12
|
# The actual pattern used to split headers from content.
|
13
|
-
HEADERS_SEPARATOR_PATTERN =
|
13
|
+
HEADERS_SEPARATOR_PATTERN = /\r?\n\r?\n/m
|
14
14
|
|
15
15
|
# The default code to convert a given key to a raw header name.
|
16
16
|
TO_RAW = lambda { |key| key.to_s.split(/_/).map(&:capitalize).join("-") }
|
data/lib/redhead/header_set.rb
CHANGED
data/redhead.gemspec
CHANGED
data/test/redhead_string_spec.rb
CHANGED
@@ -13,6 +13,15 @@ describe Redhead::String do
|
|
13
13
|
it "is equal (==) in result to using .new" do
|
14
14
|
Redhead::String[@string].should == Redhead::String.new(@string)
|
15
15
|
end
|
16
|
+
|
17
|
+
context "with \\r\\n separators" do
|
18
|
+
subject { Redhead::String["foo: 1\r\nbar: 2\r\n\r\nbody"] }
|
19
|
+
|
20
|
+
it "parses the headers in a retrievable way" do
|
21
|
+
subject.headers[:foo].value.should == "1"
|
22
|
+
subject.headers[:bar].value.should == "2"
|
23
|
+
end
|
24
|
+
end
|
16
25
|
end
|
17
26
|
end
|
18
27
|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: redhead
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.6
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-10-
|
12
|
+
date: 2012-10-13 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rake
|