sentencify 0.1.0 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.coveralls.yml +1 -0
- data/.rspec +2 -0
- data/.travis.yml +6 -0
- data/CHANGELOG.md +4 -0
- data/Gemfile +0 -1
- data/README.md +6 -1
- data/Rakefile +1 -1
- data/lib/sentencify.rb +1 -1
- data/lib/sentencify/version.rb +1 -1
- data/sentencify.gemspec +3 -1
- data/spec/sentencify_spec.rb +99 -0
- data/spec/spec_helper.rb +9 -0
- metadata +46 -7
data/.coveralls.yml
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
service_name: travis-ci
|
data/.rspec
ADDED
data/.travis.yml
ADDED
data/CHANGELOG.md
CHANGED
data/Gemfile
CHANGED
data/README.md
CHANGED
@@ -1,5 +1,8 @@
|
|
1
1
|
# Sentencify
|
2
2
|
|
3
|
+
[![Build Status](https://travis-ci.org/baptistelecocq/sentencify.png?branch=develop)](https://travis-ci.org/baptistelecocq/sentencify)
|
4
|
+
[![Coverage Status](https://coveralls.io/repos/baptistelecocq/sentencify/badge.png?branch=develop)](https://coveralls.io/r/baptistelecocq/sentencify?branch=develop)
|
5
|
+
|
3
6
|
With Sentencify, you can create sentences with array of Active Record objects.
|
4
7
|
It supports `I18n`.
|
5
8
|
|
@@ -41,8 +44,10 @@ In your `index.html.erb` view:
|
|
41
44
|
```
|
42
45
|
|
43
46
|
It will display all your users by login with a default limit of 5.
|
47
|
+
|
44
48
|
You can change this value by passing a limit parameter as following: `limit: 10`
|
45
|
-
|
49
|
+
|
50
|
+
**Extra**: You can display images by turning the image option to true.
|
46
51
|
|
47
52
|
### Advanced
|
48
53
|
#### Parameters
|
data/Rakefile
CHANGED
@@ -1 +1 @@
|
|
1
|
-
require
|
1
|
+
require 'bundler/gem_tasks'
|
data/lib/sentencify.rb
CHANGED
data/lib/sentencify/version.rb
CHANGED
data/sentencify.gemspec
CHANGED
@@ -20,6 +20,8 @@ Gem::Specification.new do |spec|
|
|
20
20
|
|
21
21
|
spec.add_dependency 'activesupport'
|
22
22
|
|
23
|
-
spec.add_development_dependency 'bundler'
|
23
|
+
spec.add_development_dependency 'bundler'
|
24
|
+
spec.add_development_dependency 'coveralls'
|
24
25
|
spec.add_development_dependency 'rake'
|
26
|
+
spec.add_development_dependency 'rspec'
|
25
27
|
end
|
@@ -0,0 +1,99 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'sentencify'
|
3
|
+
|
4
|
+
describe Array do
|
5
|
+
let(:to_sentence) { [] }
|
6
|
+
|
7
|
+
describe '#sentencize' do
|
8
|
+
it 'allows :on option' do
|
9
|
+
expect { to_sentence.sentencize(on: :field) }.to_not raise_error
|
10
|
+
end
|
11
|
+
|
12
|
+
it 'allows :image option' do
|
13
|
+
expect { to_sentence.sentencize(image: :field) }.to_not raise_error
|
14
|
+
end
|
15
|
+
|
16
|
+
it 'allows :limit option' do
|
17
|
+
expect { to_sentence.sentencize(limit: :field) }.to_not raise_error
|
18
|
+
end
|
19
|
+
|
20
|
+
it 'allows :empty option' do
|
21
|
+
expect { to_sentence.sentencize(empty: :field) }.to_not raise_error
|
22
|
+
end
|
23
|
+
|
24
|
+
it 'allows :words_connector option' do
|
25
|
+
expect { to_sentence.sentencize(words_connector: :field) }.to_not raise_error
|
26
|
+
end
|
27
|
+
|
28
|
+
it 'allows :two_words_connector option' do
|
29
|
+
expect { to_sentence.sentencize(two_words_connector: :field) }.to_not raise_error
|
30
|
+
end
|
31
|
+
|
32
|
+
it 'allows :last_word_connector option' do
|
33
|
+
expect { to_sentence.sentencize(last_word_connector: :field) }.to_not raise_error
|
34
|
+
end
|
35
|
+
|
36
|
+
it 'allows :final_singular_connector option' do
|
37
|
+
expect { to_sentence.sentencize(final_singular_connector: :field) }.to_not raise_error
|
38
|
+
end
|
39
|
+
|
40
|
+
it 'allows :final_plural_connector option' do
|
41
|
+
expect { to_sentence.sentencize(final_plural_connector: :field) }.to_not raise_error
|
42
|
+
end
|
43
|
+
|
44
|
+
it 'denies other options' do
|
45
|
+
expect { to_sentence.sentencize(test: :field) }.to raise_error
|
46
|
+
end
|
47
|
+
|
48
|
+
context 'when there is no object' do
|
49
|
+
it 'returns a no element found string' do
|
50
|
+
to_sentence.sentencize(on: :login).should == 'No element found'
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
context 'when there is one object' do
|
55
|
+
let(:to_sentence) { [
|
56
|
+
{ name: 'Baptiste Lecocq', login: 'Tiste' }
|
57
|
+
] }
|
58
|
+
|
59
|
+
it 'returns a one element string' do
|
60
|
+
to_sentence.sentencize(on: :login).should == 'Tiste'
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
64
|
+
context 'when there is two objects' do
|
65
|
+
let(:to_sentence) { [
|
66
|
+
{ name: 'Baptiste Lecocq', login: 'Tiste' },
|
67
|
+
{ name: 'Chuck Norris', login: 'Chucky' }
|
68
|
+
] }
|
69
|
+
|
70
|
+
it 'returns a two elements string' do
|
71
|
+
to_sentence.sentencize(on: :login).should == 'Tiste and Chucky'
|
72
|
+
end
|
73
|
+
end
|
74
|
+
|
75
|
+
context 'when there is a number of objects less than the limit' do
|
76
|
+
let(:to_sentence) { [
|
77
|
+
{ name: 'Baptiste Lecocq', login: 'Tiste' },
|
78
|
+
{ name: 'Chuck Norris', login: 'Chucky' },
|
79
|
+
{ name: 'Van Damme', login: 'JCVD' }
|
80
|
+
] }
|
81
|
+
|
82
|
+
it 'returns a two elements string' do
|
83
|
+
to_sentence.sentencize(on: :login).should == 'Tiste, Chucky and JCVD'
|
84
|
+
end
|
85
|
+
end
|
86
|
+
|
87
|
+
context 'when there is a number of objects greater than the limit' do
|
88
|
+
let(:to_sentence) { [
|
89
|
+
{ name: 'Baptiste Lecocq', login: 'Tiste' },
|
90
|
+
{ name: 'Chuck Norris', login: 'Chucky' },
|
91
|
+
{ name: 'Van Damme', login: 'JCVD' }
|
92
|
+
] }
|
93
|
+
|
94
|
+
it 'returns a two elements string' do
|
95
|
+
to_sentence.sentencize(on: :login, limit: 2).should == 'Tiste, Chucky and 1 other'
|
96
|
+
end
|
97
|
+
end
|
98
|
+
end
|
99
|
+
end
|
data/spec/spec_helper.rb
ADDED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sentencify
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-07-
|
12
|
+
date: 2013-07-11 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: activesupport
|
@@ -32,17 +32,33 @@ dependencies:
|
|
32
32
|
requirement: !ruby/object:Gem::Requirement
|
33
33
|
none: false
|
34
34
|
requirements:
|
35
|
-
- -
|
35
|
+
- - ! '>='
|
36
|
+
- !ruby/object:Gem::Version
|
37
|
+
version: '0'
|
38
|
+
type: :development
|
39
|
+
prerelease: false
|
40
|
+
version_requirements: !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
42
|
+
requirements:
|
43
|
+
- - ! '>='
|
36
44
|
- !ruby/object:Gem::Version
|
37
|
-
version: '
|
45
|
+
version: '0'
|
46
|
+
- !ruby/object:Gem::Dependency
|
47
|
+
name: coveralls
|
48
|
+
requirement: !ruby/object:Gem::Requirement
|
49
|
+
none: false
|
50
|
+
requirements:
|
51
|
+
- - ! '>='
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
version: '0'
|
38
54
|
type: :development
|
39
55
|
prerelease: false
|
40
56
|
version_requirements: !ruby/object:Gem::Requirement
|
41
57
|
none: false
|
42
58
|
requirements:
|
43
|
-
- -
|
59
|
+
- - ! '>='
|
44
60
|
- !ruby/object:Gem::Version
|
45
|
-
version: '
|
61
|
+
version: '0'
|
46
62
|
- !ruby/object:Gem::Dependency
|
47
63
|
name: rake
|
48
64
|
requirement: !ruby/object:Gem::Requirement
|
@@ -59,6 +75,22 @@ dependencies:
|
|
59
75
|
- - ! '>='
|
60
76
|
- !ruby/object:Gem::Version
|
61
77
|
version: '0'
|
78
|
+
- !ruby/object:Gem::Dependency
|
79
|
+
name: rspec
|
80
|
+
requirement: !ruby/object:Gem::Requirement
|
81
|
+
none: false
|
82
|
+
requirements:
|
83
|
+
- - ! '>='
|
84
|
+
- !ruby/object:Gem::Version
|
85
|
+
version: '0'
|
86
|
+
type: :development
|
87
|
+
prerelease: false
|
88
|
+
version_requirements: !ruby/object:Gem::Requirement
|
89
|
+
none: false
|
90
|
+
requirements:
|
91
|
+
- - ! '>='
|
92
|
+
- !ruby/object:Gem::Version
|
93
|
+
version: '0'
|
62
94
|
description: With Sentencify, you can create sentences with array of Active Record
|
63
95
|
objects. It supports I18n.
|
64
96
|
email:
|
@@ -67,9 +99,12 @@ executables: []
|
|
67
99
|
extensions: []
|
68
100
|
extra_rdoc_files: []
|
69
101
|
files:
|
102
|
+
- .coveralls.yml
|
70
103
|
- .gitignore
|
104
|
+
- .rspec
|
71
105
|
- .ruby-gemset
|
72
106
|
- .ruby-version
|
107
|
+
- .travis.yml
|
73
108
|
- CHANGELOG.md
|
74
109
|
- Gemfile
|
75
110
|
- LICENSE.txt
|
@@ -78,6 +113,8 @@ files:
|
|
78
113
|
- lib/sentencify.rb
|
79
114
|
- lib/sentencify/version.rb
|
80
115
|
- sentencify.gemspec
|
116
|
+
- spec/sentencify_spec.rb
|
117
|
+
- spec/spec_helper.rb
|
81
118
|
homepage: https://github.com/baptistelecocq/sentencify
|
82
119
|
licenses:
|
83
120
|
- MIT
|
@@ -103,4 +140,6 @@ rubygems_version: 1.8.25
|
|
103
140
|
signing_key:
|
104
141
|
specification_version: 3
|
105
142
|
summary: Create sentences with array of Active Record objects
|
106
|
-
test_files:
|
143
|
+
test_files:
|
144
|
+
- spec/sentencify_spec.rb
|
145
|
+
- spec/spec_helper.rb
|