doctor_ipsum 0.2 → 0.3

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: f6c9a59f74a88b6cebb6e9da69bf6df6ad52de06
4
- data.tar.gz: 7860118a5a625051110a6153ec2f15fca3532a0c
3
+ metadata.gz: 45a2d19010791c5ebeed8a915e78f8738cf94191
4
+ data.tar.gz: 68b900c59ba5dd11d66ad4106817c8ae809a01cc
5
5
  SHA512:
6
- metadata.gz: b7ca0c2f89280725db992915368d9deae7e3109c7c016182015621e52946e884daa6ddd876e9e2beb715b1cf8e4843b17b7992ff71ae566088480b11e692b8d1
7
- data.tar.gz: 339d8c81acf7865c4449df0344e9ea23183dc105cb4e784ceb10a7cca14b60e141806ce66260d109a7ac6f1ed127234c523fef30f094b800a8d1a002efa6b557
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
@@ -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 = 5, supplemental = false)
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
- inputs ||= sentences
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( width = rand(100..500), height = rand(100..500) )
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
- def basic_format( text = nil, url = nil, tag = nil )
51
- text ||= sentence.chomp('.')
52
- url ||= 'google.com'
53
- tag ||= word.join(' ')
54
- "[" + text + "](http://" + url + ' "' + tag + '")'
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(' ')
@@ -1,3 +1,3 @@
1
1
  module DoctorIpsum
2
- VERSION = "0.2"
2
+ VERSION = "0.3"
3
3
  end
@@ -96,4 +96,7 @@ describe "DoctorIpsum Markdown: " do
96
96
  pending 'images using local cache'
97
97
  end
98
98
 
99
+ describe 'Entry' do
100
+ end
101
+
99
102
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: doctor_ipsum
3
3
  version: !ruby/object:Gem::Version
4
- version: '0.2'
4
+ version: '0.3'
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nicholas Hwang