ipsummer 0.0.5 → 1.0.1

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,15 +1,7 @@
1
1
  ---
2
- !binary "U0hBMQ==":
3
- metadata.gz: !binary |-
4
- ZWEwYzVmMDI0YzlkOTdjZGY3MjhhYTZjNmJmMmYyNTRjNmY4YTMxNA==
5
- data.tar.gz: !binary |-
6
- MWY5MWVlMDM3NWQzN2MyOTkxNDA0YTU4NDU4NDAzMGFmY2ZmMjc5MQ==
7
- !binary "U0hBNTEy":
8
- metadata.gz: !binary |-
9
- YjQzMmNhZWJmNjVlMDUyN2E5NjY2ZWI4YTg0NTM2YTQ0NWI2YjYzOWVjNjQx
10
- MzQ5NzU5ZmJmNzFkODM1NWZiODYyYTMyZDFkMjVhYzdhZjg2M2UxODQ5ZTdi
11
- NmFiMjNmM2FjZWQ3ZmU2ZWFkYWFkN2E0MDM5N2NmOGViYjg3YzE=
12
- data.tar.gz: !binary |-
13
- MGEyYWU0Yjg2ODUyYjMyZTExYmY3N2JiODA3NTYzZGZmNmU2Nzc1MTFkNWEz
14
- ZDg2ZTFkNzdhNDQwMDkwMjExMDg3OGRkZmU2NjgxZjRkYjQ1MzI2NWUyODQ5
15
- Y2I5MzliOTg5ZmE4MjkxYjJiMTBmZjVmNmNjM2MxZTAzYzE5ZDk=
2
+ SHA256:
3
+ metadata.gz: cff05b8a2b45b78df3e91e7de4130bca9c61c03aefac3a8f738730a5c6ababe2
4
+ data.tar.gz: e9cdf2b04a48b91044ab04d3159a1db972e3f8b6650a41a798130ea3b8256760
5
+ SHA512:
6
+ metadata.gz: 9f0d7cd04e0172d5192966d02edce878172f14b3b09331d4d9a6fc0e3f684b261011992f0113b665ee1eae9da1547dcce1d7d1025ef888b3f40a98bfb44d759c
7
+ data.tar.gz: 4cd5634f360f0f8fe372944161253358ac5009c6a270b1acc82e47b681c936a8e236c6d22ca72db711609096df740b942bd211348dc3071b98729aa33be11a5d
data/README.md CHANGED
@@ -1,3 +1,5 @@
1
+ [![Code Climate](https://codeclimate.com/github/taylorkearns/ipsummer.png)](https://codeclimate.com/github/taylorkearns/ipsummer)
2
+
1
3
  # Ipsummer
2
4
 
3
5
  Inject dynamic lorem ipsum directly into your markup with customized length and link options.
data/ipsummer.gemspec CHANGED
@@ -12,12 +12,10 @@ Gem::Specification.new do |spec|
12
12
  spec.summary = %q{Dynamic, customized lorem ipsum.}
13
13
  spec.homepage = "http://github.com/taylorkearns/ipsummer"
14
14
  spec.license = "MIT"
15
-
16
15
  spec.files = `git ls-files`.split($/)
17
16
  spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
17
  spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
18
  spec.require_paths = ["lib"]
20
-
21
- spec.add_development_dependency "bundler", "~> 1.3"
22
- spec.add_development_dependency "rake"
19
+ spec.add_development_dependency "bundler", "~> 2"
20
+ spec.add_development_dependency "rake", "~> 13"
23
21
  end
@@ -2,6 +2,6 @@ class HtmlWrapper
2
2
  attr_accessor :linked_words
3
3
 
4
4
  def linked_words(w)
5
- "<a>#{w}</a>"
5
+ %(<a href="#">#{w}</a>)
6
6
  end
7
7
  end
@@ -6,18 +6,10 @@ module Lengthable
6
6
  def length_min
7
7
  if min_no_max?
8
8
  min
9
- elsif max_no_min?
10
- if max < default_min
11
- low_limit
12
- else
13
- default_min
14
- end
15
- elsif min_and_max?
16
- if min <= max
17
- min
18
- else
19
- default_min
20
- end
9
+ elsif max_no_min? && max < default_min
10
+ low_limit
11
+ elsif min_and_max? && min <= max
12
+ min
21
13
  else
22
14
  default_min
23
15
  end
@@ -26,18 +18,10 @@ module Lengthable
26
18
  def length_max
27
19
  if max_no_min?
28
20
  max
29
- elsif min_no_max?
30
- if min > default_max
31
- high_limit
32
- else
33
- default_max
34
- end
35
- elsif min_and_max?
36
- if min <= max
37
- max
38
- else
39
- default_max
40
- end
21
+ elsif min_no_max? && min > default_max
22
+ high_limit
23
+ elsif min_and_max? && max >= min
24
+ max
41
25
  else
42
26
  default_max
43
27
  end
@@ -7,7 +7,8 @@ class Linker
7
7
  end
8
8
 
9
9
  def linked_paragraph
10
- phrases.map { |phrase| phrase_with_link phrase }.join(' ').gsub(/\w\z/, 't.')
10
+ phrases.map { |phrase| phrase_with_link phrase }
11
+ .join(' ').gsub(/\w\z/, 't.').gsub(/>\z/, '>.')
11
12
  end
12
13
 
13
14
  private
@@ -25,9 +26,9 @@ class Linker
25
26
  phrase_words = phrase.split
26
27
  position = rand phrase_words.count
27
28
  length = [1, 2, 3].sample
28
- selected_words = phrase_words[position, length].join(' ').gsub(/[\.,\?!]/, '')
29
+ selected_words = phrase_words[position, length].join(' ').gsub(/[,\?!]/, '')
29
30
  phrase_words[position, length] = linked_words(selected_words)
30
- phrase_words.join(' ')
31
+ phrase_words.join(' ').gsub(/\.<\/a>/, '</a>.')
31
32
  end
32
33
 
33
34
  def break_point
@@ -1,4 +1,3 @@
1
- require 'rubygems'
2
1
  require_relative 'linker.rb'
3
2
  require_relative 'html_wrapper'
4
3
 
@@ -1,3 +1,3 @@
1
1
  module Ipsummer
2
- VERSION = "0.0.5"
2
+ VERSION = '1.0.1'
3
3
  end
data/spec/linker_spec.rb CHANGED
@@ -3,10 +3,18 @@ require_relative '../lib/ipsummer/linker.rb'
3
3
  require_relative '../lib/ipsummer/paragraph_text.rb'
4
4
 
5
5
  describe Linker do
6
- it 'returns an HTML paragraph with links' do
7
- paragraph_text = ParagraphText.new
8
- linker = Linker.new(paragraph_text: paragraph_text, wrapper: HtmlWrapper.new)
6
+ describe '#linked_paragraph' do
7
+ before do
8
+ @paragraph_text = ParagraphText.new
9
+ @linker = Linker.new(paragraph_text: @paragraph_text, wrapper: HtmlWrapper.new)
10
+ end
9
11
 
10
- linker.linked_paragraph.should match /(<a>.*<\/a>)/
12
+ it 'returns an HTML paragraph with links' do
13
+ @linker.linked_paragraph.should match /(<a href="#">.*<\/a>)/
14
+ end
15
+
16
+ it 'ends in a period' do
17
+ @linker.linked_paragraph.should match /\.\z/
18
+ end
11
19
  end
12
20
  end
@@ -9,7 +9,7 @@ describe Paragraph do
9
9
  paragraph_text = ParagraphText.new
10
10
  paragraph = Paragraph.new(paragraph_text: paragraph_text)
11
11
 
12
- paragraph.wrapped_paragraph.should match /<p>.*<\/p>$/
12
+ paragraph.wrapped_paragraph.should match /<p>.*\.<\/p>$/
13
13
  end
14
14
  end
15
15
 
metadata CHANGED
@@ -1,43 +1,43 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ipsummer
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.5
4
+ version: 1.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Taylor Kearns
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-06-02 00:00:00.000000000 Z
11
+ date: 2022-06-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - ~>
17
+ - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: '1.3'
19
+ version: '2'
20
20
  type: :development
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - ~>
24
+ - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: '1.3'
26
+ version: '2'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: rake
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - ! '>='
31
+ - - "~>"
32
32
  - !ruby/object:Gem::Version
33
- version: '0'
33
+ version: '13'
34
34
  type: :development
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - ! '>='
38
+ - - "~>"
39
39
  - !ruby/object:Gem::Version
40
- version: '0'
40
+ version: '13'
41
41
  description: Inject dynamic lorem ipsum directly into your markup with customized
42
42
  length and link options.
43
43
  email:
@@ -46,7 +46,7 @@ executables: []
46
46
  extensions: []
47
47
  extra_rdoc_files: []
48
48
  files:
49
- - .gitignore
49
+ - ".gitignore"
50
50
  - Gemfile
51
51
  - LICENSE.txt
52
52
  - README.md
@@ -76,17 +76,16 @@ require_paths:
76
76
  - lib
77
77
  required_ruby_version: !ruby/object:Gem::Requirement
78
78
  requirements:
79
- - - ! '>='
79
+ - - ">="
80
80
  - !ruby/object:Gem::Version
81
81
  version: '0'
82
82
  required_rubygems_version: !ruby/object:Gem::Requirement
83
83
  requirements:
84
- - - ! '>='
84
+ - - ">="
85
85
  - !ruby/object:Gem::Version
86
86
  version: '0'
87
87
  requirements: []
88
- rubyforge_project:
89
- rubygems_version: 2.0.3
88
+ rubygems_version: 3.0.3
90
89
  signing_key:
91
90
  specification_version: 4
92
91
  summary: Dynamic, customized lorem ipsum.