doctor_ipsum 0.2 → 0.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +4 -2
- data/lib/doctor_ipsum/lorem.rb +1 -1
- data/lib/doctor_ipsum/markdown.rb +22 -7
- data/lib/doctor_ipsum/version.rb +1 -1
- data/spec/markdown_spec.rb +3 -0
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 45a2d19010791c5ebeed8a915e78f8738cf94191
|
4
|
+
data.tar.gz: 68b900c59ba5dd11d66ad4106817c8ae809a01cc
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 953d4866e629db3374b986835a6ad2fb84057db71366e97d564a85f53a3a2854329b2dfec4354c8f58ca4fe8429b1fe228880c1a8449929115a64c85aa1606bc
|
7
|
+
data.tar.gz: f2565ca4f2b24992bf94556c4ab212d0c0522c27e285392c95874842f05a33159409cf5de2fee8d3f9d83885b980745d176d64b438cf7166f4835160e16b62bd
|
data/README.md
CHANGED
@@ -69,6 +69,9 @@ For Markdown:
|
|
69
69
|
=> "![Suscipit nostrum distinctio eligendi voluptates repudiandae
|
70
70
|
doloribus](http://placehold.it/459x466 \"consectetur\")"
|
71
71
|
|
72
|
+
# To produce random blog entry with every random markdown elements
|
73
|
+
DoctorIpsum::Markdown.entry
|
74
|
+
|
72
75
|
```
|
73
76
|
|
74
77
|
Most of the above functions also take arguments and can be found by
|
@@ -80,8 +83,7 @@ Most of the above functions also take arguments and can be found by
|
|
80
83
|
Features to look for in future updates:
|
81
84
|
|
82
85
|
* Code blocks (regular and Github flavor)
|
83
|
-
* More flexibility
|
84
|
-
* Full blog post generator
|
86
|
+
* More flexibility for each method
|
85
87
|
|
86
88
|
|
87
89
|
## Contributing
|
data/lib/doctor_ipsum/lorem.rb
CHANGED
@@ -25,7 +25,7 @@ module DoctorIpsum
|
|
25
25
|
def paragraph(sentence_count = 5, supplemental = false)
|
26
26
|
sentences(resolve(sentence_count), supplemental)
|
27
27
|
end
|
28
|
-
def paragraphs(paragraph_count =
|
28
|
+
def paragraphs(paragraph_count = 3, supplemental = false)
|
29
29
|
[].tap { |p|
|
30
30
|
resolve(paragraph_count).times { p << paragraph(5, supplemental) }
|
31
31
|
}.join("\n\n")
|
@@ -16,7 +16,7 @@ module DoctorIpsum
|
|
16
16
|
|
17
17
|
# Simple Blockquote (no Markdown inside...yet)
|
18
18
|
def blockquote(input = nil, level = 5)
|
19
|
-
|
19
|
+
input ||= sentences
|
20
20
|
[].tap { |x| resolve_md(input).split(' ').each_slice(level) { |s| x << s.join(' ').prepend('> ') } }.join("\n")
|
21
21
|
end
|
22
22
|
|
@@ -42,22 +42,37 @@ module DoctorIpsum
|
|
42
42
|
end
|
43
43
|
|
44
44
|
# Images from placehold.it
|
45
|
-
def image(
|
45
|
+
def image(width = rand(100..500), height = rand(100..500))
|
46
46
|
url = 'placehold.it/'+width.to_s+'x'+height.to_s
|
47
47
|
basic_format( nil, url, nil).prepend('!')
|
48
48
|
end
|
49
49
|
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
50
|
+
# Random markdown blog entry
|
51
|
+
def entry(*args)
|
52
|
+
out = []
|
53
|
+
allowed = ["header","emphasis","paragraphs","blockquote",
|
54
|
+
"horizontal","list","link","image"]
|
55
|
+
args = ( nil ? allowed : filter(args.flatten,allowed) )
|
56
|
+
out << header if args.include? 'header'
|
57
|
+
rand(3..10).times { out << send(allowed.sample) << paragraphs }
|
58
|
+
out.join("\n\n")
|
55
59
|
end
|
56
60
|
|
57
61
|
end #END SELF
|
58
62
|
|
59
63
|
private
|
60
64
|
|
65
|
+
def self.filter(arr, allowed)
|
66
|
+
arr.keep_if { |x| allowed.include? x }
|
67
|
+
end
|
68
|
+
|
69
|
+
def self.basic_format( text = nil, url = nil, tag = nil )
|
70
|
+
text ||= sentence.chomp('.')
|
71
|
+
url ||= 'google.com'
|
72
|
+
tag ||= word.join(' ')
|
73
|
+
"[" + text + "](http://" + url + ' "' + tag + '")'
|
74
|
+
end
|
75
|
+
|
61
76
|
def self.resolve_md(input, title=false)
|
62
77
|
case input
|
63
78
|
when Array then title ? input.map {|x| x.capitalize}.join(' ') : input.join(' ')
|
data/lib/doctor_ipsum/version.rb
CHANGED
data/spec/markdown_spec.rb
CHANGED