ruby-try 1.1.0 → 1.1.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/.rspec +0 -2
- data/.travis.yml +9 -0
- data/README.md +21 -10
- data/Rakefile +1 -0
- data/ruby-try.gemspec +3 -1
- data/spec/spec_helper.rb +9 -0
- metadata +20 -25
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 7cd35bcdeff6ed4ef20f767981497ca921805223
|
4
|
+
data.tar.gz: 367682a5f0059d4497a9b42705df148464f4bee3
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: f5c7b515e291114d86481459de941a20161b6912dd679769e81774a4e648a4605bc871afc5c2d94fa590bbc18bc749cc099d2c5546ae6ad249b6baffec23882d
|
7
|
+
data.tar.gz: 70ab4bb99388dc9f7987474805add8c20015d2a12535d8184fd0c5da2c1b57807480b6232ec529f31e93c4cde8975c55f4a4d90eee5b28b0d0ce65686cb4542d
|
data/.rspec
CHANGED
data/.travis.yml
ADDED
data/README.md
CHANGED
@@ -2,6 +2,7 @@ Ruby Try
|
|
2
2
|
========
|
3
3
|
[](http://badge.fury.io/rb/ruby-try)
|
4
4
|
[](https://gemnasium.com/OrelSokolov/ruby-try)
|
5
|
+
[](https://travis-ci.org/OrelSokolov/ruby-try)
|
5
6
|
[](https://codeclimate.com/github/OrelSokolov/ruby-try)
|
6
7
|
|
7
8
|
This gem has two versions of `try()`.
|
@@ -17,8 +18,12 @@ irb(main):001:0> require 'ruby-try'
|
|
17
18
|
=> true
|
18
19
|
irb(main):002:0> nil.try(:admin?)
|
19
20
|
=> nil
|
20
|
-
irb(main):003:0> nil.try
|
21
|
+
irb(main):003:0> nil.try(:nil?)
|
22
|
+
=> nil # does it make sense?
|
23
|
+
irb(main):004:0> nil.try?(:admin?)
|
21
24
|
=> false
|
25
|
+
irb(main):005:0> nil.try?(:nil?) # IMHO, it makes sense
|
26
|
+
=> true
|
22
27
|
```
|
23
28
|
|
24
29
|
Why boolean `try?`
|
@@ -38,7 +43,7 @@ end
|
|
38
43
|
|
39
44
|
Of course, it is better to write something like
|
40
45
|
|
41
|
-
```
|
46
|
+
```ruby
|
42
47
|
def admin_in_team?(team)
|
43
48
|
team_members.find_by_team_id(team.id).try(:admin?)
|
44
49
|
end
|
@@ -52,6 +57,12 @@ First idea is to patch `try()`. But it is not best idea. Many developers expects
|
|
52
57
|
vanilla behavior from `try()`, so that's why a new `try?()` method appears. It is looks not
|
53
58
|
elegant, but one line is better than 5 with misty logic.
|
54
59
|
|
60
|
+
## Compatibility
|
61
|
+
- 2.1.2
|
62
|
+
- 2.0.0
|
63
|
+
- 1.9.3
|
64
|
+
- jruby-19mode # JRuby in 1.9 mode
|
65
|
+
|
55
66
|
|
56
67
|
## Installation
|
57
68
|
|
@@ -70,14 +81,14 @@ Or install it yourself as:
|
|
70
81
|
$ gem install ruby-try
|
71
82
|
|
72
83
|
## Documentation
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
84
|
+
Please, use specs to explore behavior of this gem. Or refer to RoR documentation.
|
85
|
+
|
86
|
+
```bash
|
87
|
+
git clone https://github.com/OrelSokolov/ruby-try
|
88
|
+
cd ruby-try
|
89
|
+
bundle
|
90
|
+
rspec spec/
|
91
|
+
```
|
81
92
|
|
82
93
|
## Contributing
|
83
94
|
|
data/Rakefile
CHANGED
data/ruby-try.gemspec
CHANGED
@@ -4,7 +4,7 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
|
4
4
|
|
5
5
|
Gem::Specification.new do |spec|
|
6
6
|
spec.name = 'ruby-try'
|
7
|
-
spec.version = '1.1.
|
7
|
+
spec.version = '1.1.1'
|
8
8
|
spec.date = '2014-08-02'
|
9
9
|
spec.summary = "Provides RoR try() and extends it by new try?() method."
|
10
10
|
spec.description = "Provides RoR try() and extends it by new try?() method."
|
@@ -18,6 +18,8 @@ Gem::Specification.new do |spec|
|
|
18
18
|
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
19
|
spec.require_paths = ["lib"]
|
20
20
|
|
21
|
+
spec.required_ruby_version = '>= 1.9.1'
|
22
|
+
|
21
23
|
spec.add_development_dependency "bundler", "~> 1.6"
|
22
24
|
spec.add_development_dependency "rake", "~> 10.0"
|
23
25
|
end
|
data/spec/spec_helper.rb
CHANGED
@@ -6,6 +6,15 @@ end
|
|
6
6
|
|
7
7
|
|
8
8
|
RSpec.configure do |config|
|
9
|
+
# Use color in STDOUT
|
10
|
+
config.color = true
|
11
|
+
|
12
|
+
# Use color not only in STDOUT but also in pagers and files
|
13
|
+
config.tty = true
|
14
|
+
|
15
|
+
# Use the specified formatter
|
16
|
+
config.formatter = :documentation # :progress, :html, :textmate
|
17
|
+
|
9
18
|
config.expect_with :rspec do |c|
|
10
19
|
c.syntax = [:should, :expect] # Disable warnings
|
11
20
|
end
|
metadata
CHANGED
@@ -1,48 +1,43 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ruby-try
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.1.
|
5
|
-
prerelease:
|
4
|
+
version: 1.1.1
|
6
5
|
platform: ruby
|
7
6
|
authors:
|
8
7
|
- Oleg Orlov
|
9
|
-
autorequire:
|
8
|
+
autorequire:
|
10
9
|
bindir: bin
|
11
10
|
cert_chain: []
|
12
11
|
date: 2014-08-02 00:00:00.000000000 Z
|
13
12
|
dependencies:
|
14
13
|
- !ruby/object:Gem::Dependency
|
15
14
|
name: bundler
|
16
|
-
|
17
|
-
none: false
|
15
|
+
version_requirements: !ruby/object:Gem::Requirement
|
18
16
|
requirements:
|
19
17
|
- - ~>
|
20
18
|
- !ruby/object:Gem::Version
|
21
19
|
version: '1.6'
|
22
|
-
|
23
|
-
prerelease: false
|
24
|
-
version_requirements: !ruby/object:Gem::Requirement
|
25
|
-
none: false
|
20
|
+
requirement: !ruby/object:Gem::Requirement
|
26
21
|
requirements:
|
27
22
|
- - ~>
|
28
23
|
- !ruby/object:Gem::Version
|
29
24
|
version: '1.6'
|
25
|
+
prerelease: false
|
26
|
+
type: :development
|
30
27
|
- !ruby/object:Gem::Dependency
|
31
28
|
name: rake
|
32
|
-
|
33
|
-
none: false
|
29
|
+
version_requirements: !ruby/object:Gem::Requirement
|
34
30
|
requirements:
|
35
31
|
- - ~>
|
36
32
|
- !ruby/object:Gem::Version
|
37
33
|
version: '10.0'
|
38
|
-
|
39
|
-
prerelease: false
|
40
|
-
version_requirements: !ruby/object:Gem::Requirement
|
41
|
-
none: false
|
34
|
+
requirement: !ruby/object:Gem::Requirement
|
42
35
|
requirements:
|
43
36
|
- - ~>
|
44
37
|
- !ruby/object:Gem::Version
|
45
38
|
version: '10.0'
|
39
|
+
prerelease: false
|
40
|
+
type: :development
|
46
41
|
description: Provides RoR try() and extends it by new try?() method.
|
47
42
|
email: orelcokolov@gmail.com
|
48
43
|
executables: []
|
@@ -51,6 +46,7 @@ extra_rdoc_files: []
|
|
51
46
|
files:
|
52
47
|
- .gitignore
|
53
48
|
- .rspec
|
49
|
+
- .travis.yml
|
54
50
|
- Gemfile
|
55
51
|
- LICENSE.txt
|
56
52
|
- README.md
|
@@ -62,27 +58,26 @@ files:
|
|
62
58
|
homepage: http://rubygems.org/gems/ruby-try
|
63
59
|
licenses:
|
64
60
|
- MIT
|
65
|
-
|
61
|
+
metadata: {}
|
62
|
+
post_install_message:
|
66
63
|
rdoc_options: []
|
67
64
|
require_paths:
|
68
65
|
- lib
|
69
66
|
required_ruby_version: !ruby/object:Gem::Requirement
|
70
|
-
none: false
|
71
67
|
requirements:
|
72
|
-
- -
|
68
|
+
- - '>='
|
73
69
|
- !ruby/object:Gem::Version
|
74
|
-
version:
|
70
|
+
version: 1.9.1
|
75
71
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
76
|
-
none: false
|
77
72
|
requirements:
|
78
|
-
- -
|
73
|
+
- - '>='
|
79
74
|
- !ruby/object:Gem::Version
|
80
75
|
version: '0'
|
81
76
|
requirements: []
|
82
|
-
rubyforge_project:
|
83
|
-
rubygems_version: 1.
|
84
|
-
signing_key:
|
85
|
-
specification_version:
|
77
|
+
rubyforge_project:
|
78
|
+
rubygems_version: 2.1.9
|
79
|
+
signing_key:
|
80
|
+
specification_version: 4
|
86
81
|
summary: Provides RoR try() and extends it by new try?() method.
|
87
82
|
test_files:
|
88
83
|
- spec/ruby_try_spec.rb
|