compact_blank 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.coveralls.yml +1 -0
- data/.gitignore +12 -0
- data/.rspec +1 -0
- data/.travis.yml +24 -0
- data/CHANGELOG.md +5 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +21 -0
- data/README.md +79 -0
- data/Rakefile +6 -0
- data/bin/console +16 -0
- data/bin/setup +8 -0
- data/compact_blank.gemspec +35 -0
- data/lib/compact_blank.rb +24 -0
- data/lib/compact_blank/version.rb +3 -0
- metadata +170 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 0e02290bbd171978286fd87bb3c3c1cd6d88747b
|
4
|
+
data.tar.gz: 64270c54a88c5a22ca00c812f6f51ca3d1157035
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 8ddce86de5f9d6ec7536faae1e5f244f8dbfec2eff33e83e5c3bb9609a1fee7f89cc76a7c543c2c3f34b3ae78a79aef7f1c496ea6b8eedcb74be86416f1a4784
|
7
|
+
data.tar.gz: 86ba51d3dae3a538bc3f6c2c00d2c895bb4024f712f9304982cbb83030c6a50d225f8c1678eeca528e5bedefb7da169d7f72ed705747669a3396a712651d78da
|
data/.coveralls.yml
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
repo_token: JfrrkEswkVNHjbWI3J8sJfdbroppsI39O
|
data/.gitignore
ADDED
data/.rspec
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
--require spec_helper
|
data/.travis.yml
ADDED
@@ -0,0 +1,24 @@
|
|
1
|
+
sudo: false
|
2
|
+
language: ruby
|
3
|
+
cache: bundler
|
4
|
+
rvm:
|
5
|
+
- 2.2.2
|
6
|
+
- 2.3
|
7
|
+
- 2.4.1
|
8
|
+
- ruby-head
|
9
|
+
before_install: gem install bundler -v 1.14.6
|
10
|
+
before_script:
|
11
|
+
- export CODECLIMATE_REPO_TOKEN=5a1c95e9c71ba0cd4c1a5aef955b7fe0cb4958d3b78e6b94c6a62d0653136ea0
|
12
|
+
- export CI=true
|
13
|
+
script:
|
14
|
+
- bundle exec rspec
|
15
|
+
- bundle exec codeclimate-test-reporter
|
16
|
+
branches:
|
17
|
+
only:
|
18
|
+
- master
|
19
|
+
matrix:
|
20
|
+
allow_failures:
|
21
|
+
- rvm: ruby-head
|
22
|
+
notifications:
|
23
|
+
slack:
|
24
|
+
secure: NQ3WpJRRXxBaxUanRr0GzTXaBqoj1dQagkH3EqgLAF68+1DabWMhfVDRXRGRvBOoZtY7WrqWViv5nQ4y6kqgrsXdc6aZwgiGZj8kFPdYdxTDQKnDnL3TMJkvMgQlmbADEuyCz7DsM6eUzkomtVcJG/ZREBoMqzRwkgSNu3QCi183RYaCiMTFmAu2P4XSuX3ypVQrLxKmUdlPCzj2eww6Kr4ob9a6B9CwLrbkSv4W8UpsH6ue6qEGjyglj+dfHowzn9UfCkHb7wPHXvcjD25xVNxsNgeZ/htQojmxI5sb1UmH3Q+8faHDh+ckKfnq+HkZXY/9ekSkQVtpbxwxMvghg0NjNWWnx+n3zwECMa3YxAK1KuAAyafkGJ90htdVf4SJgsSrLFfP3Dh7tCksa+/BpwG1nPt3rrLu+Y0cBsXyH/9tM4qkmLIwBiQJ8H9GmZBn6kRDWKEv0uxaoVxSyjCc+CIVpOdd3bxhJ1b46siP3pVzVEch60dhPpb1hp6KEHBRlZtibB94zIjRs4Sw4AJwTZuthYfabhotxp29tJox8xnMo870i0FtV3ptdb+Jn+JVnpA5vvp3mktgZALGQd32Rk0JoluxCsNw5IC0cIECNT4R2L6R/vF1TvajlPGblZiYruaqqXDmuCZrBu8L4JK32Jdv+KTm2zFEmBs/dWBDDuY=
|
data/CHANGELOG.md
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2017 sue445
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,79 @@
|
|
1
|
+
# CompactBlank
|
2
|
+
|
3
|
+
Adds `compact_blank` and `compact_blank!` to `Array` and `Hash`
|
4
|
+
|
5
|
+
[![Build Status](https://travis-ci.org/sue445/compact_blank.svg?branch=master)](https://travis-ci.org/sue445/compact_blank)
|
6
|
+
[![Coverage Status](https://coveralls.io/repos/github/sue445/compact_blank/badge.svg)](https://coveralls.io/github/sue445/compact_blank)
|
7
|
+
[![Code Climate](https://codeclimate.com/github/sue445/compact_blank.png)](https://codeclimate.com/github/sue445/compact_blank)
|
8
|
+
[![Dependency Status](https://gemnasium.com/badges/github.com/sue445/compact_blank.svg)](https://gemnasium.com/github.com/sue445/compact_blank)
|
9
|
+
|
10
|
+
## Installation
|
11
|
+
|
12
|
+
Add this line to your application's Gemfile:
|
13
|
+
|
14
|
+
```ruby
|
15
|
+
gem 'compact_blank'
|
16
|
+
```
|
17
|
+
|
18
|
+
And then execute:
|
19
|
+
|
20
|
+
$ bundle
|
21
|
+
|
22
|
+
Or install it yourself as:
|
23
|
+
|
24
|
+
$ gem install compact_blank
|
25
|
+
|
26
|
+
## Usage
|
27
|
+
|
28
|
+
### `Array#compact_blank`, `Array#compact_blank!`
|
29
|
+
```ruby
|
30
|
+
using CompactBlank
|
31
|
+
|
32
|
+
array = ["a", nil, "b", ""]
|
33
|
+
|
34
|
+
array.compact
|
35
|
+
#=> ["a", "b", ""]
|
36
|
+
|
37
|
+
array.compact_blank
|
38
|
+
#=> ["a", "b"]
|
39
|
+
|
40
|
+
array.compact_blank!
|
41
|
+
#=> ["a", "b"]
|
42
|
+
array
|
43
|
+
#=> ["a", "b"]
|
44
|
+
```
|
45
|
+
|
46
|
+
### `Hash#compact_blank`, `Hash#compact_blank!`
|
47
|
+
```ruby
|
48
|
+
using CompactBlank
|
49
|
+
|
50
|
+
hash = { a: "1", b: nil, c: "3", d: "" }
|
51
|
+
|
52
|
+
# NOTE: Hash#compact is feature of activesupport
|
53
|
+
hash.compact
|
54
|
+
#=> {:a=>"1", :c=>"3", :d=>""}
|
55
|
+
|
56
|
+
hash.compact_blank
|
57
|
+
#=> {:a=>"1", :c=>"3"}
|
58
|
+
|
59
|
+
hash.compact_blank!
|
60
|
+
#=> {:a=>"1", :c=>"3"}
|
61
|
+
hash
|
62
|
+
#=> {:a=>"1", :c=>"3"}
|
63
|
+
```
|
64
|
+
|
65
|
+
## Development
|
66
|
+
|
67
|
+
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
68
|
+
|
69
|
+
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
70
|
+
|
71
|
+
## Contributing
|
72
|
+
|
73
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/sue445/compact_blank.
|
74
|
+
|
75
|
+
|
76
|
+
## License
|
77
|
+
|
78
|
+
The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
|
79
|
+
|
data/Rakefile
ADDED
data/bin/console
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "compact_blank"
|
5
|
+
|
6
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
7
|
+
# with your gem easier. You can also use a different console, if you like.
|
8
|
+
|
9
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
10
|
+
# require "pry"
|
11
|
+
# Pry.start
|
12
|
+
|
13
|
+
using CompactBlank
|
14
|
+
|
15
|
+
require "irb"
|
16
|
+
IRB.start(__FILE__)
|
data/bin/setup
ADDED
@@ -0,0 +1,35 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'compact_blank/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "compact_blank"
|
8
|
+
spec.version = CompactBlank::VERSION
|
9
|
+
spec.authors = ["sue445"]
|
10
|
+
spec.email = ["sue445@sue445.net"]
|
11
|
+
|
12
|
+
spec.summary = %q{Adds compact_blank and compact_blank! to Array and Hash}
|
13
|
+
spec.description = %q{Adds compact_blank and compact_blank! to Array and Hash}
|
14
|
+
spec.homepage = "https://github.com/sue445/compact_blank"
|
15
|
+
spec.license = "MIT"
|
16
|
+
|
17
|
+
spec.required_ruby_version = ">= 2.2.2"
|
18
|
+
|
19
|
+
spec.files = `git ls-files -z`.split("\x0").reject do |f|
|
20
|
+
f.match(%r{^(test|spec|features)/})
|
21
|
+
end
|
22
|
+
spec.bindir = "exe"
|
23
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
24
|
+
spec.require_paths = ["lib"]
|
25
|
+
|
26
|
+
spec.add_dependency "activesupport"
|
27
|
+
|
28
|
+
spec.add_development_dependency "bundler", "~> 1.14"
|
29
|
+
spec.add_development_dependency "codeclimate-test-reporter", "~> 1.0.0"
|
30
|
+
spec.add_development_dependency "coveralls"
|
31
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
32
|
+
spec.add_development_dependency "rspec", "~> 3.0"
|
33
|
+
spec.add_development_dependency "rspec-parameterized"
|
34
|
+
spec.add_development_dependency "simplecov"
|
35
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
require "compact_blank/version"
|
2
|
+
require "active_support/core_ext/object/blank"
|
3
|
+
|
4
|
+
module CompactBlank
|
5
|
+
refine Array do
|
6
|
+
def compact_blank
|
7
|
+
reject(&:blank?)
|
8
|
+
end
|
9
|
+
|
10
|
+
def compact_blank!
|
11
|
+
reject!(&:blank?)
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
refine Hash do
|
16
|
+
def compact_blank
|
17
|
+
reject { |_, v| v.blank? }
|
18
|
+
end
|
19
|
+
|
20
|
+
def compact_blank!
|
21
|
+
reject! { |_, v| v.blank? }
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
metadata
ADDED
@@ -0,0 +1,170 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: compact_blank
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- sue445
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2017-07-09 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: activesupport
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: bundler
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '1.14'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '1.14'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: codeclimate-test-reporter
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: 1.0.0
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: 1.0.0
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: coveralls
|
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: rake
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - "~>"
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '10.0'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - "~>"
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '10.0'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: rspec
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - "~>"
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '3.0'
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - "~>"
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '3.0'
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: rspec-parameterized
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - ">="
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: '0'
|
104
|
+
type: :development
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - ">="
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: '0'
|
111
|
+
- !ruby/object:Gem::Dependency
|
112
|
+
name: simplecov
|
113
|
+
requirement: !ruby/object:Gem::Requirement
|
114
|
+
requirements:
|
115
|
+
- - ">="
|
116
|
+
- !ruby/object:Gem::Version
|
117
|
+
version: '0'
|
118
|
+
type: :development
|
119
|
+
prerelease: false
|
120
|
+
version_requirements: !ruby/object:Gem::Requirement
|
121
|
+
requirements:
|
122
|
+
- - ">="
|
123
|
+
- !ruby/object:Gem::Version
|
124
|
+
version: '0'
|
125
|
+
description: Adds compact_blank and compact_blank! to Array and Hash
|
126
|
+
email:
|
127
|
+
- sue445@sue445.net
|
128
|
+
executables: []
|
129
|
+
extensions: []
|
130
|
+
extra_rdoc_files: []
|
131
|
+
files:
|
132
|
+
- ".coveralls.yml"
|
133
|
+
- ".gitignore"
|
134
|
+
- ".rspec"
|
135
|
+
- ".travis.yml"
|
136
|
+
- CHANGELOG.md
|
137
|
+
- Gemfile
|
138
|
+
- LICENSE.txt
|
139
|
+
- README.md
|
140
|
+
- Rakefile
|
141
|
+
- bin/console
|
142
|
+
- bin/setup
|
143
|
+
- compact_blank.gemspec
|
144
|
+
- lib/compact_blank.rb
|
145
|
+
- lib/compact_blank/version.rb
|
146
|
+
homepage: https://github.com/sue445/compact_blank
|
147
|
+
licenses:
|
148
|
+
- MIT
|
149
|
+
metadata: {}
|
150
|
+
post_install_message:
|
151
|
+
rdoc_options: []
|
152
|
+
require_paths:
|
153
|
+
- lib
|
154
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
155
|
+
requirements:
|
156
|
+
- - ">="
|
157
|
+
- !ruby/object:Gem::Version
|
158
|
+
version: 2.2.2
|
159
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
160
|
+
requirements:
|
161
|
+
- - ">="
|
162
|
+
- !ruby/object:Gem::Version
|
163
|
+
version: '0'
|
164
|
+
requirements: []
|
165
|
+
rubyforge_project:
|
166
|
+
rubygems_version: 2.6.11
|
167
|
+
signing_key:
|
168
|
+
specification_version: 4
|
169
|
+
summary: Adds compact_blank and compact_blank! to Array and Hash
|
170
|
+
test_files: []
|