string-present-blank 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +25 -19
- data/Rakefile +3 -3
- data/lib/string-present-blank.rb +1 -3
- data/lib/string_present_blank.rb +3 -0
- data/lib/{string-present-blank → string_present_blank}/string.rb +0 -0
- data/lib/{string-present-blank → string_present_blank}/version.rb +1 -1
- data/string-present-blank.gemspec +5 -5
- data/test/test_string.rb +3 -2
- metadata +6 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 32608198f53b418a69966e5c693f34a20b1ab6a2
|
4
|
+
data.tar.gz: b53f5b49254bbf9fa4083e2774ef63f8775028cf
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ecc5ede38158c6dc31120ec256674c2e9e2f57effb12ea6fefa3c21c9cbad7f18eb7d03de3e110584d0569f5d4745abd8ca2fe3ceba80f9e5f7ff4e45d1a9d24
|
7
|
+
data.tar.gz: dc40044e0c654edebf309a908a8ab2df5974da9809772431acd78777f9c10826464d196cdc6ce9f61edd4199fd00a9f8e8b9ff1b5ab3ebbe905863c8ca39418b
|
data/README.md
CHANGED
@@ -2,41 +2,47 @@
|
|
2
2
|
|
3
3
|
This gem provides String#present and String#blank.
|
4
4
|
|
5
|
-
##
|
5
|
+
## Usage
|
6
6
|
|
7
|
-
|
7
|
+
### Before
|
8
8
|
|
9
|
-
|
9
|
+
```ruby
|
10
|
+
'abc' + 'efg' #=> 'abcefg'
|
11
|
+
'abc' + 'efg' if false #=> nil
|
12
|
+
'abc' + ('efg' if false) #=> TypeError: no implicit conversion of nil into String
|
13
|
+
'abc' + if false then 'efg' else '' end #=> 'abc'
|
14
|
+
```
|
10
15
|
|
11
|
-
|
16
|
+
### After
|
12
17
|
|
13
|
-
|
18
|
+
```ruby
|
19
|
+
'abc' + 'efg'.blank(if: true) #=> 'abc'
|
20
|
+
'abc' + 'efg'.present(unless: true) #=> 'abc'
|
21
|
+
```
|
14
22
|
|
15
|
-
|
23
|
+
### Examples
|
16
24
|
|
17
|
-
|
25
|
+
```haml
|
26
|
+
%div= link_to('abc', abc_path, class: 'abc'.present(if: abc?))
|
27
|
+
```
|
18
28
|
|
19
|
-
##
|
29
|
+
## Installation
|
20
30
|
|
21
|
-
|
22
|
-
# before
|
31
|
+
Add this line to your application's Gemfile:
|
23
32
|
|
24
|
-
|
33
|
+
gem 'string-present-blank'
|
25
34
|
|
26
|
-
|
27
|
-
'abc' + ('efg' if false) #=> TypeError: no implicit conversion of nil into String
|
28
|
-
'abc' + if false then 'efg' else '' end #=> 'abc'
|
35
|
+
And then execute:
|
29
36
|
|
30
|
-
|
37
|
+
$ bundle
|
31
38
|
|
32
|
-
|
33
|
-
'abc' + 'efg'.present(unless: false) #=> 'abc'
|
39
|
+
Or install it yourself as:
|
34
40
|
|
35
|
-
|
41
|
+
$ gem install string-present-blank
|
36
42
|
|
37
43
|
## Contributing
|
38
44
|
|
39
|
-
1. Fork it ( https://github.com/
|
45
|
+
1. Fork it ( https://github.com/tachiba/string-present-blank/fork )
|
40
46
|
2. Create your feature branch (`git checkout -b my-new-feature`)
|
41
47
|
3. Commit your changes (`git commit -am 'Add some feature'`)
|
42
48
|
4. Push to the branch (`git push origin my-new-feature`)
|
data/Rakefile
CHANGED
@@ -1,9 +1,9 @@
|
|
1
|
-
require
|
1
|
+
require "bundler/gem_tasks"
|
2
2
|
require 'rake/testtask'
|
3
3
|
|
4
4
|
Rake::TestTask.new do |t|
|
5
|
-
t.libs <<
|
6
|
-
t.libs <<
|
5
|
+
t.libs << "test"
|
6
|
+
t.libs << "."
|
7
7
|
t.test_files = FileList['test/test*.rb']
|
8
8
|
t.verbose = true
|
9
9
|
t.warning = true
|
data/lib/string-present-blank.rb
CHANGED
File without changes
|
@@ -1,15 +1,15 @@
|
|
1
1
|
# coding: utf-8
|
2
2
|
lib = File.expand_path('../lib', __FILE__)
|
3
3
|
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
-
require '
|
4
|
+
require 'string_present_blank/version'
|
5
5
|
|
6
6
|
Gem::Specification.new do |spec|
|
7
|
-
spec.name =
|
7
|
+
spec.name = "string-present-blank"
|
8
8
|
spec.version = StringPresentBlank::VERSION
|
9
|
-
spec.authors = [
|
10
|
-
spec.email = [
|
9
|
+
spec.authors = ["Takashi Chiba"]
|
10
|
+
spec.email = ["contact@takashi.me"]
|
11
11
|
spec.summary = %q{Provides String#present and String#blank.}
|
12
|
-
spec.homepage = '
|
12
|
+
spec.homepage = 'https://github.com/tachiba/ruby-string-present-blank'
|
13
13
|
spec.license = 'MIT'
|
14
14
|
|
15
15
|
spec.files = `git ls-files -z`.split("\x0")
|
data/test/test_string.rb
CHANGED
@@ -1,7 +1,8 @@
|
|
1
1
|
require 'minitest/autorun'
|
2
|
-
require '
|
2
|
+
require 'string_present_blank'
|
3
|
+
require 'string-present-blank' # raises no error
|
3
4
|
|
4
|
-
class TestString <
|
5
|
+
class TestString < Minitest::Test
|
5
6
|
def test_present
|
6
7
|
assert_equal 'hogehoge', 'hogehoge'.present
|
7
8
|
assert_equal 'hogehoge', 'hogehoge'.present(if: true)
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: string-present-blank
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Takashi Chiba
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-09-
|
11
|
+
date: 2014-09-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -66,11 +66,12 @@ files:
|
|
66
66
|
- README.md
|
67
67
|
- Rakefile
|
68
68
|
- lib/string-present-blank.rb
|
69
|
-
- lib/
|
70
|
-
- lib/string
|
69
|
+
- lib/string_present_blank.rb
|
70
|
+
- lib/string_present_blank/string.rb
|
71
|
+
- lib/string_present_blank/version.rb
|
71
72
|
- string-present-blank.gemspec
|
72
73
|
- test/test_string.rb
|
73
|
-
homepage:
|
74
|
+
homepage: https://github.com/tachiba/ruby-string-present-blank
|
74
75
|
licenses:
|
75
76
|
- MIT
|
76
77
|
metadata: {}
|