flannel 0.2.3 → 0.2.4

Sign up to get free protection for your applications and to get access to all the features.
data/VERSION.yml CHANGED
@@ -1,5 +1,5 @@
1
1
  ---
2
2
  :major: 0
3
3
  :minor: 2
4
- :patch: 3
4
+ :patch: 4
5
5
  :build:
data/flannel.gemspec CHANGED
@@ -5,7 +5,7 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{flannel}
8
- s.version = "0.2.3"
8
+ s.version = "0.2.4"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Jamal Hansen"]
@@ -52,14 +52,12 @@ Gem::Specification.new do |s|
52
52
  "lib/flannel.rb",
53
53
  "lib/flannel/block_cutter.rb",
54
54
  "lib/flannel/cache_location_does_not_exist_error.rb",
55
- "lib/flannel/cutting_board.rb",
56
55
  "lib/flannel/feed_parser.rb",
57
56
  "lib/flannel/file_cache.rb",
58
57
  "lib/flannel/html_formatter.rb",
59
58
  "lib/flannel/text_block.rb",
60
59
  "lib/flannel/wrappable.rb",
61
60
  "test/block_cutter_test.rb",
62
- "test/cutting_board_test.rb",
63
61
  "test/feed_parser_test.rb",
64
62
  "test/file_cache_test.rb",
65
63
  "test/flannel_test.rb",
@@ -78,7 +76,6 @@ Gem::Specification.new do |s|
78
76
  "test/block_cutter_test.rb",
79
77
  "test/test_helper.rb",
80
78
  "test/file_cache_test.rb",
81
- "test/cutting_board_test.rb",
82
79
  "test/text_block_test.rb",
83
80
  "test/feed_parser_test.rb",
84
81
  "test/flannel_test.rb"
data/lib/flannel.rb CHANGED
@@ -1,8 +1,4 @@
1
- require 'flannel/cutting_board'
2
1
  require 'flannel/wrappable'
3
- require 'flannel/square'
4
- require 'flannel/shears'
5
- require 'flannel/stripe'
6
2
  require 'flannel/feed_parser'
7
3
  require 'flannel/file_cache'
8
4
 
@@ -12,13 +8,15 @@ require 'flannel/html_formatter'
12
8
 
13
9
  module Flannel
14
10
  def self.quilt markup, params={}
15
- @@cache_params = params
11
+ @@cache = params[:cache]
16
12
  return nil unless markup
17
- shears = Flannel::CuttingBoard.new
18
- shears.cut markup
13
+
14
+ cutter = Flannel::BlockCutter.new
15
+ text_blocks = cutter.cut markup
16
+ text_blocks.map { |text| text.to_h }.join("\n\n")
19
17
  end
20
18
 
21
- def self.cache_params
22
- @@cache_params
19
+ def self.cache
20
+ @@cache
23
21
  end
24
22
  end
@@ -4,7 +4,7 @@ require 'open-uri'
4
4
  module Flannel
5
5
  class FeedParser
6
6
  def initialize params={}
7
- @cache = params[:cache] if params.has_key?(:cache)
7
+ @cache = params[:cache] if params
8
8
  end
9
9
 
10
10
  def sub_feeds(url)
@@ -98,7 +98,7 @@ module Flannel
98
98
  end
99
99
 
100
100
  def parse_feed text
101
- parser = Flannel::FeedParser.new Flannel.cache_params
101
+ parser = Flannel::FeedParser.new Flannel.cache
102
102
  parser.sub_feeds text
103
103
  end
104
104
  end
data/test/flannel_test.rb CHANGED
@@ -15,4 +15,42 @@ class FlannelTest < Test::Unit::TestCase
15
15
  output = "<p>This is paragraph one.</p>\n\n<p>This is paragraph two.</p>\n\n<p>This is paragraph three. Watchout for the end of file.</p>"
16
16
  assert_equal output, Flannel.quilt(input)
17
17
  end
18
+
19
+ context "basic behavior" do
20
+ should "strip and convert underscores to pre tags" do
21
+ markup = "_foo\n\n bar\n_"
22
+ assert_equal "<pre>foo\n\n bar</pre>", Flannel.quilt(markup)
23
+ end
24
+
25
+ should "not replace in preformatted text" do
26
+ markup = "_4 - 2 > 2 - 2\n_"
27
+ assert_equal '<pre>4 - 2 &gt; 2 - 2</pre>', Flannel.quilt(markup)
28
+ end
29
+ end
30
+
31
+ context "When block starts with one or more equals signs, it" do
32
+ should "convert one equals to a header one" do
33
+ markup = "= Some header"
34
+ result = "<h1>Some header</h1>"
35
+
36
+ assert_equal result, Flannel.quilt(markup)
37
+ end
38
+
39
+ should "convert two equals to a header two" do
40
+ markup = "== Some header"
41
+ result = "<h2>Some header</h2>"
42
+
43
+ assert_equal result, Flannel.quilt(markup)
44
+ end
45
+ end
46
+
47
+ context "When block starts with a star, it" do
48
+ should "tell square that it's a list, so that it will be wrapped in ul tags" do
49
+
50
+ markup = "* Yadda"
51
+ result = "<ul><li>Yadda</li></ul>"
52
+
53
+ assert_equal result, Flannel.quilt(markup)
54
+ end
55
+ end
18
56
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: flannel
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.3
4
+ version: 0.2.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jamal Hansen
@@ -78,14 +78,12 @@ files:
78
78
  - lib/flannel.rb
79
79
  - lib/flannel/block_cutter.rb
80
80
  - lib/flannel/cache_location_does_not_exist_error.rb
81
- - lib/flannel/cutting_board.rb
82
81
  - lib/flannel/feed_parser.rb
83
82
  - lib/flannel/file_cache.rb
84
83
  - lib/flannel/html_formatter.rb
85
84
  - lib/flannel/text_block.rb
86
85
  - lib/flannel/wrappable.rb
87
86
  - test/block_cutter_test.rb
88
- - test/cutting_board_test.rb
89
87
  - test/feed_parser_test.rb
90
88
  - test/file_cache_test.rb
91
89
  - test/flannel_test.rb
@@ -125,7 +123,6 @@ test_files:
125
123
  - test/block_cutter_test.rb
126
124
  - test/test_helper.rb
127
125
  - test/file_cache_test.rb
128
- - test/cutting_board_test.rb
129
126
  - test/text_block_test.rb
130
127
  - test/feed_parser_test.rb
131
128
  - test/flannel_test.rb
@@ -1,10 +0,0 @@
1
-
2
- module Flannel
3
- class CuttingBoard
4
- def cut markup
5
- cutter = Flannel::BlockCutter.new
6
- text_blocks = cutter.cut markup
7
- text_blocks.map { |text| text.to_h }.join("\n\n")
8
- end
9
- end
10
- end
@@ -1,49 +0,0 @@
1
- require 'test_helper'
2
-
3
- class CuttingBoardTest < Test::Unit::TestCase
4
- context "basic behavior" do
5
- setup do
6
- @board = Flannel::CuttingBoard.new
7
- end
8
-
9
- should "strip and convert underscores to pre tags" do
10
- markup = "_foo\n\n bar\n_"
11
- assert_equal "<pre>foo\n\n bar</pre>", @board.cut(markup)
12
- end
13
-
14
- should "not replace in preformatted text" do
15
- markup = "_4 - 2 > 2 - 2\n_"
16
- assert_equal '<pre>4 - 2 &gt; 2 - 2</pre>', @board.cut(markup)
17
- end
18
- end
19
-
20
- context "When block starts with one or more equals signs, it" do
21
- setup do
22
- @board = Flannel::CuttingBoard.new
23
- end
24
-
25
- should "convert one equals to a header one" do
26
- markup = "= Some header"
27
- result = "<h1>Some header</h1>"
28
-
29
- assert_equal result, @board.cut(markup)
30
- end
31
-
32
- should "convert two equals to a header two" do
33
- markup = "== Some header"
34
- result = "<h2>Some header</h2>"
35
-
36
- assert_equal result, @board.cut(markup)
37
- end
38
- end
39
-
40
- context "When block starts with a star, it" do
41
- should "tell square that it's a list, so that it will be wrapped in ul tags" do
42
- board = Flannel::CuttingBoard.new
43
- markup = "* Yadda"
44
- result = "<ul><li>Yadda</li></ul>"
45
-
46
- assert_equal result, board.cut(markup)
47
- end
48
- end
49
- end