blank_element 0.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 +7 -0
- data/.gitignore +17 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +45 -0
- data/Rakefile +1 -0
- data/blank_element.gemspec +27 -0
- data/lib/blank_element.rb +6 -0
- data/lib/blank_element/extention/array.rb +17 -0
- data/lib/blank_element/version.rb +3 -0
- data/spec/blank_element_spec.rb +76 -0
- data/spec/spec_helper.rb +12 -0
- metadata +129 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 25e8eb4722fe17f4a4b8e09cc6dbda2edfd9938b
|
4
|
+
data.tar.gz: 3dc5851fa4f297972f5c7b7cfe4ffd5111340a0b
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 647137382b1db955282a6d57efed5bc886c61d49adb0aa12e2e684160e88b1ee459f3c1d6b01b83ce015af8de94e95bc5589c2da17f346bf0316cadd31389242
|
7
|
+
data.tar.gz: b40c1d9875da576490d2a5bc53c8a69a26955486f83e9fa38edcf87304cb35ef2c6e428ed935b637d54fec7678200138d9ee87052f73e396cff4c2e43609eb87
|
data/.gitignore
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2014 Jun Yokoyama
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,45 @@
|
|
1
|
+
# BlankElement
|
2
|
+
|
3
|
+
TODO: Write a gem description
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
gem 'blank_element'
|
10
|
+
|
11
|
+
And then execute:
|
12
|
+
|
13
|
+
$ bundle
|
14
|
+
|
15
|
+
Or install it yourself as:
|
16
|
+
|
17
|
+
$ gem install blank_element
|
18
|
+
|
19
|
+
## Usage
|
20
|
+
|
21
|
+
```ruby
|
22
|
+
require 'blank_element'
|
23
|
+
|
24
|
+
array = ['battleship', 'cruiser', 'destroyer', ' ']
|
25
|
+
array.blank_all? # => false
|
26
|
+
arra.present_any? # => true
|
27
|
+
array.reject_blank # => ['battleship', 'cruiser', 'destroyer']
|
28
|
+
array.reject_blank! # => bang method
|
29
|
+
|
30
|
+
blank_array = [' ', ' ', ' ']
|
31
|
+
blank_array.blank_all? # => true
|
32
|
+
blank_array.present_any? # => false
|
33
|
+
|
34
|
+
empty_array = []
|
35
|
+
empty_array.blank_all? # => true
|
36
|
+
empty_array.present_any? # => false
|
37
|
+
```
|
38
|
+
|
39
|
+
## Contributing
|
40
|
+
|
41
|
+
1. Fork it ( http://github.com/<my-github-username>/blank_element/fork )
|
42
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
43
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
44
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
45
|
+
5. Create new Pull Request
|
data/Rakefile
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require "bundler/gem_tasks"
|
@@ -0,0 +1,27 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'blank_element/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "blank_element"
|
8
|
+
spec.version = BlankElement::VERSION
|
9
|
+
spec.authors = ["Jun Yokoyama"]
|
10
|
+
spec.email = ["jun@larus.org"]
|
11
|
+
spec.summary = %q{manage blank elements of Array objects.}
|
12
|
+
spec.description = %q{manage blank elements of Array objects.(Rails is not required, but ActiveSupport is required.}
|
13
|
+
spec.homepage = ""
|
14
|
+
spec.license = "MIT"
|
15
|
+
|
16
|
+
spec.files = `git ls-files -z`.split("\x0")
|
17
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
18
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
|
+
spec.require_paths = ["lib"]
|
20
|
+
|
21
|
+
spec.add_development_dependency "bundler", "~> 1.5"
|
22
|
+
spec.add_development_dependency "rake"
|
23
|
+
spec.add_dependency 'activesupport'
|
24
|
+
|
25
|
+
spec.add_development_dependency "rspec"
|
26
|
+
spec.add_development_dependency "faker"
|
27
|
+
end
|
@@ -0,0 +1,76 @@
|
|
1
|
+
describe "BlankElement" do
|
2
|
+
require 'spec_helper'
|
3
|
+
|
4
|
+
let(:str) { Faker::Lorem.characters(10) }
|
5
|
+
let(:original_array) { str.split('').shuffle }
|
6
|
+
|
7
|
+
shared_examples_for "array with elements" do
|
8
|
+
it "blank_all? returns false" do
|
9
|
+
array.should_not be_blank_all
|
10
|
+
end
|
11
|
+
|
12
|
+
it "present_any? returns true" do
|
13
|
+
array.should be_present_any
|
14
|
+
end
|
15
|
+
|
16
|
+
it "reject_blank returns array without blank elements" do
|
17
|
+
array.reject_blank.should =~ original_array
|
18
|
+
end
|
19
|
+
|
20
|
+
it "reject_blank! removes blank elements from original array" do
|
21
|
+
target_array = array
|
22
|
+
target_array.reject_blank!
|
23
|
+
target_array.should =~ original_array
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
shared_examples_for "array full of blank elements" do
|
28
|
+
it "blank_all? returns true" do
|
29
|
+
array.should be_blank_all
|
30
|
+
end
|
31
|
+
|
32
|
+
it "present_any? returns false" do
|
33
|
+
array.should_not be_present_any
|
34
|
+
end
|
35
|
+
|
36
|
+
it "reject_blank returns empty array" do
|
37
|
+
array.reject_blank.should be_empty
|
38
|
+
end
|
39
|
+
|
40
|
+
it "reject_blank! removes allelements" do
|
41
|
+
target_array = array
|
42
|
+
target_array.reject_blank!
|
43
|
+
target_array.should be_empty
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
context "array with blank elements" do
|
48
|
+
let(:array) { (str + ' ' * 3).split('').shuffle }
|
49
|
+
it_should_behave_like 'array with elements'
|
50
|
+
end
|
51
|
+
|
52
|
+
context "array without blank elements" do
|
53
|
+
let(:array) { original_array.shuffle }
|
54
|
+
it_should_behave_like 'array with elements'
|
55
|
+
end
|
56
|
+
|
57
|
+
context "array with null" do
|
58
|
+
let(:array) { original_array.push([nil] * 3).shuffle }
|
59
|
+
it_should_behave_like 'array with elements'
|
60
|
+
end
|
61
|
+
|
62
|
+
context "blank array" do
|
63
|
+
let(:array) { [' '] * 10 }
|
64
|
+
it_should_behave_like 'array full of blank elements'
|
65
|
+
end
|
66
|
+
|
67
|
+
context "null array" do
|
68
|
+
let(:array) { [nil] * 10 }
|
69
|
+
it_should_behave_like 'array full of blank elements'
|
70
|
+
end
|
71
|
+
|
72
|
+
context "empty array" do
|
73
|
+
let(:array) { [] }
|
74
|
+
it_should_behave_like 'array full of blank elements'
|
75
|
+
end
|
76
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,12 @@
|
|
1
|
+
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
|
2
|
+
$LOAD_PATH.unshift(File.dirname(__FILE__))
|
3
|
+
require 'rspec'
|
4
|
+
require 'blank_element'
|
5
|
+
require 'faker'
|
6
|
+
|
7
|
+
# Requires supporting files with custom matchers and macros, etc,
|
8
|
+
# in ./support/ and its subdirectories.
|
9
|
+
Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each {|f| require f}
|
10
|
+
|
11
|
+
RSpec.configure do |config|
|
12
|
+
end
|
metadata
ADDED
@@ -0,0 +1,129 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: blank_element
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Jun Yokoyama
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2014-05-06 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.5'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.5'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: activesupport
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: rspec
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: faker
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ">="
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - ">="
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
83
|
+
description: manage blank elements of Array objects.(Rails is not required, but ActiveSupport
|
84
|
+
is required.
|
85
|
+
email:
|
86
|
+
- jun@larus.org
|
87
|
+
executables: []
|
88
|
+
extensions: []
|
89
|
+
extra_rdoc_files: []
|
90
|
+
files:
|
91
|
+
- ".gitignore"
|
92
|
+
- Gemfile
|
93
|
+
- LICENSE.txt
|
94
|
+
- README.md
|
95
|
+
- Rakefile
|
96
|
+
- blank_element.gemspec
|
97
|
+
- lib/blank_element.rb
|
98
|
+
- lib/blank_element/extention/array.rb
|
99
|
+
- lib/blank_element/version.rb
|
100
|
+
- spec/blank_element_spec.rb
|
101
|
+
- spec/spec_helper.rb
|
102
|
+
homepage: ''
|
103
|
+
licenses:
|
104
|
+
- MIT
|
105
|
+
metadata: {}
|
106
|
+
post_install_message:
|
107
|
+
rdoc_options: []
|
108
|
+
require_paths:
|
109
|
+
- lib
|
110
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
111
|
+
requirements:
|
112
|
+
- - ">="
|
113
|
+
- !ruby/object:Gem::Version
|
114
|
+
version: '0'
|
115
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
116
|
+
requirements:
|
117
|
+
- - ">="
|
118
|
+
- !ruby/object:Gem::Version
|
119
|
+
version: '0'
|
120
|
+
requirements: []
|
121
|
+
rubyforge_project:
|
122
|
+
rubygems_version: 2.2.2
|
123
|
+
signing_key:
|
124
|
+
specification_version: 4
|
125
|
+
summary: manage blank elements of Array objects.
|
126
|
+
test_files:
|
127
|
+
- spec/blank_element_spec.rb
|
128
|
+
- spec/spec_helper.rb
|
129
|
+
has_rdoc:
|