inquisitive 4.0.0 → 4.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 +4 -4
- data/.travis.yml +11 -8
- data/README.md +20 -9
- data/inquisitive.gemspec +1 -1
- data/lib/inquisitive/nil_class.rb +4 -0
- data/test/inquisitive/environment_test.rb +16 -0
- data/test/shared/nil_object_tests.rb +8 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 29f4741cd183b7dec38982c69c052fb110100dae
|
4
|
+
data.tar.gz: 1817fdcfcf9abdb0c0c345881789097dcda517d6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4c71a6dd16ddf4da130641cfa791fe5c53d84ae1a9b886aff048d5619aecf6279b69fc3e0bc8a9efb2293402a2d5cda341cdb1594b4682dc64cc5b6747723ca3
|
7
|
+
data.tar.gz: b02442864df34a6a8eced15f51d5a7f0ca7a4988220efb6fe92e1acb178ce548fa5a5f3e7142d32c6452bd76f51193e167208633887a35ea6519a4c4408b449d
|
data/.travis.yml
CHANGED
@@ -1,7 +1,8 @@
|
|
1
1
|
language: ruby
|
2
2
|
|
3
|
+
sudo: false
|
4
|
+
|
3
5
|
rvm:
|
4
|
-
- 1.9.3
|
5
6
|
- 2.0.0
|
6
7
|
- 2.1
|
7
8
|
- 2.2
|
@@ -15,23 +16,25 @@ gemfile:
|
|
15
16
|
|
16
17
|
env:
|
17
18
|
- ""
|
18
|
-
- "activesupport=3.2.
|
19
|
-
- "activesupport=4.1.
|
19
|
+
- "activesupport=3.2.22"
|
20
|
+
- "activesupport=4.1.12"
|
21
|
+
- "activesupport=4.2.3"
|
20
22
|
- "activesupport=master"
|
21
23
|
|
22
24
|
matrix:
|
23
25
|
fast_finish: true
|
24
26
|
allow_failures:
|
25
|
-
- rvm:
|
26
|
-
- rvm:
|
27
|
-
- rvm: rbx-2 # Ditto
|
27
|
+
- rvm: jruby
|
28
|
+
- rvm: rbx-2
|
28
29
|
exclude:
|
29
30
|
- gemfile: Gemfile.ActiveSupport
|
30
31
|
env: ""
|
31
32
|
- gemfile: Gemfile
|
32
|
-
env: "activesupport=3.2.
|
33
|
+
env: "activesupport=3.2.22"
|
34
|
+
- gemfile: Gemfile
|
35
|
+
env: "activesupport=4.1.12"
|
33
36
|
- gemfile: Gemfile
|
34
|
-
env: "activesupport=4.
|
37
|
+
env: "activesupport=4.2.3"
|
35
38
|
- gemfile: Gemfile
|
36
39
|
env: "activesupport=master"
|
37
40
|
|
data/README.md
CHANGED
@@ -3,18 +3,18 @@ Inquisitive
|
|
3
3
|
|
4
4
|
> **Predicate methods for those curious about their datastructures.**
|
5
5
|
|
6
|
-
|
7
|
-
|
8
6
|
Synopsis
|
9
7
|
--------
|
10
8
|
|
11
|
-
Inquisitive provides String, Array, and Hash subclasses with dynamic predicate methods that allow you to interrogate the most common Ruby datastructures in a readable, friendly fashion. It's the inevitable evolution of ActiveSupport's `StringInquirer
|
9
|
+
Inquisitive provides String, Array, and Hash subclasses with dynamic predicate methods that allow you to interrogate the most common Ruby datastructures in a readable, friendly fashion. It's the inevitable evolution of ActiveSupport's [`StringInquirer`](https://github.com/rails/rails/blob/master/activesupport/lib/active_support/string_inquirer.rb).
|
12
10
|
|
13
11
|
It also allows you to elegantly interrogate your `ENV` hash through the `Inquisitive::Environment` module.
|
14
12
|
|
15
|
-
Inquisitive will try to use ActiveSupport's `HashWithIndifferentAccess
|
13
|
+
Inquisitive will try to use ActiveSupport's [`HashWithIndifferentAccess`](guides.rubyonrails.org/active_support_core_extensions.html#indifferent-access), but if that cannot be found it will bootstrap itself with a minimal, well-tested version extracted from [ActiveSupport 4.0](https://github.com/rails/rails/blob/4-0-stable/activesupport/lib/active_support/hash_with_indifferent_access.rb).
|
16
14
|
|
15
|
+
Inquisitive is tested against all maintained versions of Ruby and ActiveSupport.
|
17
16
|
|
17
|
+
--------------------------------------------------------------------------------
|
18
18
|
|
19
19
|
Status
|
20
20
|
------
|
@@ -41,12 +41,12 @@ Status
|
|
41
41
|
|
42
42
|
[![Version][version-image]][version] [![Quality][quality-image]][quality] [![Dependencies][dependencies-image]][dependencies]
|
43
43
|
|
44
|
-
|
|
44
|
+
| :thumbsup: | [Continuous Integration][status] | [Test Coverage][coverage] |
|
45
45
|
|:--------------------------:|:-----------------------------------:|:----------------------------------------:|
|
46
|
-
|
|
46
|
+
| [Master][master] | ![Build Status][master-status] | ![Coverage Status][master-coverage] |
|
47
47
|
| [Development][development] | ![Build Status][development-status] | ![Coverage Status][development-coverage] |
|
48
48
|
|
49
|
-
|
49
|
+
--------------------------------------------------------------------------------
|
50
50
|
|
51
51
|
Installation
|
52
52
|
------------
|
@@ -64,7 +64,7 @@ Otherwise:
|
|
64
64
|
$ gem install inquisitive
|
65
65
|
```
|
66
66
|
|
67
|
-
|
67
|
+
--------------------------------------------------------------------------------
|
68
68
|
|
69
69
|
Usage
|
70
70
|
-----
|
@@ -499,7 +499,7 @@ ENV['TRUTHY'] = 'TrUe'
|
|
499
499
|
ENV['FALSEY'] = 'FaLsE'
|
500
500
|
ENV['BOOLEAN'] = '1'
|
501
501
|
ENV['BOOLENOPE'] = '0'
|
502
|
-
class
|
502
|
+
class MyApp
|
503
503
|
extend Inquisitive::Environment
|
504
504
|
inquires_about 'NO', present_if: truthy
|
505
505
|
inquires_about 'YES', present_if: truthy
|
@@ -525,7 +525,18 @@ MyApp.boolenope?
|
|
525
525
|
#=> false
|
526
526
|
```
|
527
527
|
|
528
|
+
--------------------------------------------------------------------------------
|
529
|
+
|
530
|
+
Origins
|
531
|
+
-------
|
532
|
+
|
533
|
+
The idea for Inquisitive originated with [this pull request](https://github.com/rails/rails/pull/12587), as I was going through a complicated Rails application and making it more 12-factor friendly by extracting much of the configuration into environment variables.
|
534
|
+
|
535
|
+
By the end of my effort, my configuration was substantially more *centralized* and *standardized*, but far more *complicated*. These complications arose in two places: adding, managing, permuting, and documenting my `.env` file consumed by [dotenv](https://github.com/bkeepers/dotenv); and organizing, parsing, and switching on those values injected into the `ENV`.
|
536
|
+
|
537
|
+
My pull request, and later Inquisitive, was extracted from my treatment of the latter complication. My solution to the former, [starenv](https://github.com/christhekeele/starenv), was a generally more complicated beast.
|
528
538
|
|
539
|
+
--------------------------------------------------------------------------------
|
529
540
|
|
530
541
|
Contributing
|
531
542
|
------------
|
data/inquisitive.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 = 'inquisitive'
|
7
|
-
spec.version = '4.0.
|
7
|
+
spec.version = '4.0.1'
|
8
8
|
spec.authors = ['Chris Keele']
|
9
9
|
spec.email = ['dev@chriskeele.com']
|
10
10
|
spec.summary = 'Predicate methods for those curious about their datastructures.'
|
@@ -46,6 +46,22 @@ class InquisitiveEnvironmentTest < EnvironmentTest
|
|
46
46
|
end
|
47
47
|
end
|
48
48
|
|
49
|
+
%w[false False FaLsE FALSE no No nO NO 0 anything_else].each do |falsey_var|
|
50
|
+
define_method :"test_falsey_var_#{falsey_var}" do
|
51
|
+
App.inquires_about 'TRUTHY', present_if: App.truthy
|
52
|
+
ENV['TRUTHY'] = 'true'
|
53
|
+
assert App.truthy?
|
54
|
+
ENV['TRUTHY'] = falsey_var
|
55
|
+
refute App.truthy?
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
59
|
+
def test_array_squishing
|
60
|
+
App.inquires_about 'SQUISHIBLE_ARRAY'
|
61
|
+
ENV['SQUISHIBLE_ARRAY'] = 'foo, bar, baz'
|
62
|
+
assert_equal %w[foo bar baz], App.squishible_array
|
63
|
+
end
|
64
|
+
|
49
65
|
def test_default_accessor_for_missing
|
50
66
|
App.inquires_about 'MISSING_WITH_DEFAULT', default: 'default'
|
51
67
|
assert_equal 'default', App.missing_with_default
|
@@ -7,6 +7,10 @@ module NilObjectTests
|
|
7
7
|
assert_instance_of Inquisitive::NilClass, nil_object.chain
|
8
8
|
end
|
9
9
|
|
10
|
+
def test_nil_object_acts_as_black_hole
|
11
|
+
assert nil_object.respond_to? :anything
|
12
|
+
end
|
13
|
+
|
10
14
|
def test_nil_object_match
|
11
15
|
assert nil_object.nil?
|
12
16
|
end
|
@@ -62,4 +66,8 @@ module NilObjectTests
|
|
62
66
|
refute hash.no.no.development?
|
63
67
|
end
|
64
68
|
|
69
|
+
def test_nil_coercable_to_empty_string
|
70
|
+
assert_equal nil_object.to_str, ""
|
71
|
+
end
|
72
|
+
|
65
73
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: inquisitive
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 4.0.
|
4
|
+
version: 4.0.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Chris Keele
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2016-03-01 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|