betterlorem 0.0.7 → 0.0.8

Sign up to get free protection for your applications and to get access to all the features.
data/lib/betterlorem.rb CHANGED
@@ -13,7 +13,7 @@ module BetterLorem
13
13
  PUNCTUATION = ['.', ',', '!', '?', ':']
14
14
 
15
15
  # Return Words
16
- def self.w(count, line_ending = "<br>", surround_with_tag = "p")
16
+ def self.w(count, line_ending = "<br>", surround_with_tag = "p", no_html = false)
17
17
  loader = Loader.new
18
18
 
19
19
  # Merge paragraphs into one line and split into words
@@ -37,11 +37,15 @@ module BetterLorem
37
37
  # Correct the sentence's punctuation
38
38
  correct_punctuation(return_words)
39
39
 
40
- return_words = "<#{surround_with_tag}>#{return_words}</#{surround_with_tag}>#{line_ending}"
40
+ if no_html
41
+ "#{return_words}#{line_ending}"
42
+ else
43
+ "<#{surround_with_tag}>#{return_words}</#{surround_with_tag}>#{line_ending}"
44
+ end
41
45
  end
42
46
 
43
47
  # Return Paragraphs
44
- def self.p(count, line_ending = "<br>", surround_with_tag = "p")
48
+ def self.p(count, line_ending = "<br>", surround_with_tag = "p", no_html = false)
45
49
  loader = Loader.new
46
50
 
47
51
  # Start at a random index in the array but do not overrun array
@@ -55,14 +59,18 @@ module BetterLorem
55
59
 
56
60
  # Build final format based on parameters
57
61
  paragraphs.map! do |line|
58
- line = "<#{surround_with_tag}>#{line}</#{surround_with_tag}>#{line_ending}"
62
+ if no_html
63
+ line = "#{line}#{line_ending}"
64
+ else
65
+ line = "<#{surround_with_tag}>#{line}</#{surround_with_tag}>#{line_ending}"
66
+ end
59
67
  end
60
68
 
61
69
  paragraphs.join('\n')
62
70
  end
63
71
 
64
72
  # Return Characters
65
- def self.c(count, line_ending = "<br>", surround_with_tag = "p")
73
+ def self.c(count, line_ending = "<br>", surround_with_tag = "p", no_html = false)
66
74
  loader = Loader.new
67
75
 
68
76
  # Merge paragraphs into one line
@@ -87,7 +95,12 @@ module BetterLorem
87
95
  # Capitalize the sentence
88
96
  sentence = lines[start_inx, count]
89
97
  sentence[0] = sentence[0].to_s.capitalize
90
- sentence
98
+
99
+ if no_html
100
+ "#{sentence}#{line_ending}"
101
+ else
102
+ "<#{surround_with_tag}>#{sentence}</#{surround_with_tag}>#{line_ending}"
103
+ end
91
104
  end
92
105
 
93
106
 
@@ -21,7 +21,7 @@ describe BetterLorem do
21
21
  describe ".c" do
22
22
  it "should return 100 characters" do
23
23
  chars = BetterLorem.c(100)
24
- chars.length.should == 100
24
+ chars.length.should == 111 # 111 with HTML tags
25
25
  end
26
26
  end
27
27
 
metadata CHANGED
@@ -1,32 +1,22 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: betterlorem
3
- version: !ruby/object:Gem::Version
4
- prerelease: false
5
- segments:
6
- - 0
7
- - 0
8
- - 7
9
- version: 0.0.7
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.8
5
+ prerelease:
10
6
  platform: ruby
11
- authors:
7
+ authors:
12
8
  - Caedmon Judd
13
9
  autorequire:
14
10
  bindir: bin
15
11
  cert_chain: []
16
-
17
- date: 2012-10-09 00:00:00 -05:00
18
- default_executable:
12
+ date: 2012-10-09 00:00:00.000000000 Z
19
13
  dependencies: []
20
-
21
- description: "A better Lorem Ipsum generator. See the GitHub project for more information: https://github.com/statedigital/BetterLorem"
14
+ description: ! 'A better Lorem Ipsum generator. See the GitHub project for more information: https://github.com/statedigital/BetterLorem'
22
15
  email: caedmon@statebuilt.com
23
16
  executables: []
24
-
25
17
  extensions: []
26
-
27
18
  extra_rdoc_files: []
28
-
29
- files:
19
+ files:
30
20
  - lib/betterlorem.rb
31
21
  - lib/lorem.txt
32
22
  - spec/betterlorem_spec.rb
@@ -37,35 +27,28 @@ files:
37
27
  - doc/lorem_txt.html
38
28
  - doc/rdoc.css
39
29
  - doc/table_of_contents.html
40
- has_rdoc: true
41
30
  homepage: https://github.com/statedigital/BetterLorem
42
31
  licenses: []
43
-
44
32
  post_install_message:
45
33
  rdoc_options: []
46
-
47
- require_paths:
34
+ require_paths:
48
35
  - lib
49
- required_ruby_version: !ruby/object:Gem::Requirement
50
- requirements:
51
- - - ">="
52
- - !ruby/object:Gem::Version
53
- segments:
54
- - 0
55
- version: "0"
56
- required_rubygems_version: !ruby/object:Gem::Requirement
57
- requirements:
58
- - - ">="
59
- - !ruby/object:Gem::Version
60
- segments:
61
- - 0
62
- version: "0"
36
+ required_ruby_version: !ruby/object:Gem::Requirement
37
+ none: false
38
+ requirements:
39
+ - - ! '>='
40
+ - !ruby/object:Gem::Version
41
+ version: '0'
42
+ required_rubygems_version: !ruby/object:Gem::Requirement
43
+ none: false
44
+ requirements:
45
+ - - ! '>='
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
63
48
  requirements: []
64
-
65
49
  rubyforge_project:
66
- rubygems_version: 1.3.6
50
+ rubygems_version: 1.8.24
67
51
  signing_key:
68
52
  specification_version: 3
69
53
  summary: Better Lorem Ipsum
70
54
  test_files: []
71
-