inquisitive 2.0.0 → 2.0.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 82f138341b19063e39338834d96ff3cd4bb479e1
4
- data.tar.gz: d518c1b744f8ac23092a992b39cf38cc49ffb97b
3
+ metadata.gz: ae129b66c1055352e43e907ac246009511ef0cd2
4
+ data.tar.gz: 4cc0713d97d9ed273f904a186bd12cc2d8bdf8b3
5
5
  SHA512:
6
- metadata.gz: 829304a8b3326698f81ce23868356a969578344ac7b93d39ed59687269a0574c095ce9cee48e11fc8c2216e99bff06339ab8da0d5ef76cc73827ce682f070e82
7
- data.tar.gz: cd501e9fbb4651689562457adc90b1f94bd0e076caf70c150550e1019788aaa2eef8e56d7ab1b8d81dd786c772fcd9cdb237c76eba62c7a458c0c48c032b0dba
6
+ metadata.gz: 82aa740e308e0cc964700818ce3ea10446a90c586788ea8e856102a89ec00676a23ccfb60de5b3670ef48333c720e6dc20cc6c15ff66a3b46e854579eb76f368
7
+ data.tar.gz: b6d575e5815e3ee08fb6c933779604288f5a6995f6ad7d03ac78f01f3fbf91a6b766b45169fad54fdf2463d401aeafda30701f53643da9919891b0ed3d450b96
data/.coveralls.yml ADDED
@@ -0,0 +1 @@
1
+ service_name: travis-ci
data/.gitignore CHANGED
@@ -2,6 +2,7 @@
2
2
  *.rbc
3
3
  .bundle
4
4
  .config
5
+ .coverage
5
6
  .yardoc
6
7
  Gemfile.lock
7
8
  InstalledFiles
data/.travis.yml ADDED
@@ -0,0 +1,42 @@
1
+ language: ruby
2
+
3
+ rvm:
4
+ - 1.9.3
5
+ - 2.0.0
6
+ - 2.1
7
+ - ruby-head
8
+ - rbx-2
9
+ - jruby
10
+
11
+ gemfile:
12
+ - Gemfile
13
+ - Gemfile.ActiveSupport
14
+
15
+ env:
16
+ - ""
17
+ - "activesupport=3.2.18"
18
+ - "activesupport=4.1.1"
19
+ - "activesupport=master"
20
+
21
+ matrix:
22
+ fast_finish: true
23
+ allow_failures:
24
+ - rvm: rbx-2
25
+ - rvm: jruby
26
+ - rvm: ruby-head
27
+ exclude:
28
+ - gemfile: Gemfile.ActiveSupport
29
+ env: ""
30
+ - gemfile: Gemfile
31
+ env: "activesupport=3.2.18"
32
+ - gemfile: Gemfile
33
+ env: "activesupport=4.1.1"
34
+ - gemfile: Gemfile
35
+ env: "activesupport=master"
36
+
37
+ branches:
38
+ except:
39
+ - gh-pages
40
+
41
+ after_success:
42
+ - coveralls
data/CHANGELOG.md CHANGED
@@ -8,12 +8,23 @@ Starting with **[2.0.0](#2.0.0)**, Inquisitive follows [symantic versioning](sym
8
8
  Releases
9
9
  --------
10
10
 
11
+ [2.0.1]: https://github.com/christhekeele/inquisitive/tree/2.0.1
11
12
  [2.0.0]: https://github.com/christhekeele/inquisitive/tree/2.0.0
12
13
  [1.2.0]: https://github.com/christhekeele/inquisitive/tree/f314eaf84f7c3d9a2d56ae684d031dd81d2f7b85
13
14
 
14
15
  - [2.0.0](#2.0.0)
15
16
  - [1.2.0](#1.2.0)
16
17
 
18
+ 2.0.1 - [2014.09.24][2.0.1]
19
+ ---------------------------
20
+
21
+ ### Non-breaking
22
+
23
+ - `Inquisitive::Environment.truthy`: **helper regex**
24
+
25
+ The `truthy` method provides an easy way to handle various command-line representations of truthiness.
26
+
27
+
17
28
  2.0.0 - [2014.06.19][2.0.0]
18
29
  ---------------------------
19
30
 
@@ -22,7 +33,7 @@ Releases
22
33
  - `Inquisitive::Environment`: **hash detection**
23
34
 
24
35
  Previously `inquires_about` needed a special syntax to detect when you want to parse a group of environment variables as a hash. This was accomplished by leaving a trailing `_` in the declaration, such as:
25
-
36
+
26
37
  ```ruby
27
38
  ENV['PREFIX_KEY1'] = "value1"
28
39
  ENV['PREFIX_KEY2'] = "value2"
@@ -33,9 +44,9 @@ Releases
33
44
  Mine.prefix
34
45
  #=> { 'key1' => 'value1', 'key2' => 'value2' }
35
46
  ```
36
-
47
+
37
48
  Now it auto-detects hash groupings by looking for a double-`_` in the key itself:
38
-
49
+
39
50
  ```ruby
40
51
  ENV['PREFIX__KEY1'] = "value1"
41
52
  ENV['PREFIX__KEY2'] = "value2"
@@ -52,11 +63,11 @@ Releases
52
63
  - `Inquisitive::Environment`: **default modes**
53
64
 
54
65
  Previously the default mode was `:dynamic`. This was mostly to prevent unexpected behaviour for newcomers.
55
-
66
+
56
67
  Now `:static` is the default. This is because `Inquisitive::Environment` is meant to be loaded immediately after a boot script that prepares your environment variables, and queried often later. `:static` optimizes to this usecase.
57
-
68
+
58
69
  To reproduce the old behaviour, you must explicitly pass `mode: :dynamic` each to `inquires_about` invocation. Alternatively, `mode: :lazy` might be a viable way to get the benefits of `:static` without refactoring your boot process.
59
-
70
+
60
71
  ### Non-breaking
61
72
 
62
73
  - `Inquisitive::Environment`: **cached mode now lazy mode**
data/Gemfile CHANGED
@@ -1,6 +1,14 @@
1
1
  source 'https://rubygems.org'
2
2
 
3
- # Specify your gem's dependencies in inquisitive.gemspec
4
3
  gemspec
5
4
 
6
- gem 'pry'
5
+ gem 'pry',
6
+ group: [:development, :test]
7
+
8
+ gem 'simplecov', '>= 0.7.0',
9
+ require: false,
10
+ group: :test
11
+
12
+ gem 'coveralls',
13
+ require: false,
14
+ group: :test
@@ -0,0 +1,16 @@
1
+ source 'https://rubygems.org'
2
+
3
+ gemspec
4
+
5
+ gem 'activesupport'
6
+
7
+ gem 'pry',
8
+ group: [:development, :test]
9
+
10
+ gem 'simplecov', '>= 0.7.0',
11
+ require: false,
12
+ group: :test
13
+
14
+ gem 'coveralls',
15
+ require: false,
16
+ group: :test
data/README.md CHANGED
@@ -3,12 +3,47 @@ Inquisitive
3
3
 
4
4
  > **Predicate methods for those curious about their datastructures.**
5
5
 
6
+
7
+ Synopsis
8
+ --------
9
+
6
10
  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`.
7
11
 
8
12
  It also allows you to auto-instanciate and read inquisitive datastructures straight from your `ENV` hash through the `Inquisitive::Environment` module.
9
13
 
10
14
  Inquisitive will try to use ActiveSupport's `HashWithIndifferentAccess`, but if that cannot be found it will bootstrap itself with a minimal, well-tested version extracted from ActiveSupport 4.0.
11
15
 
16
+
17
+ Status
18
+ ------
19
+
20
+ [status]: https://travis-ci.org/christhekeele/inquisitive
21
+
22
+ [version]: https://rubygems.org/gems/inquisitive/versions
23
+ [version-image]: https://badge.fury.io/rb/inquisitive@2x.svg
24
+
25
+ [quality]: https://codeclimate.com/github/christhekeele/inquisitive
26
+ [quality-image]: https://img.shields.io/codeclimate/github/christhekeele/inquisitive.svg
27
+
28
+ [dependencies]: https://gemnasium.com/christhekeele/inquisitive
29
+ [dependencies-image]: http://img.shields.io/gemnasium/christhekeele/inquisitive.svg
30
+
31
+ [master]: https://github.com/christhekeele/inquisitive/tree/master
32
+ [master-status]: https://img.shields.io/travis/christhekeele/inquisitive/master.svg
33
+ [master-coverage]: https://img.shields.io/coveralls/christhekeele/inquisitive/master.svg
34
+
35
+ [development]: https://github.com/christhekeele/inquisitive/tree/development
36
+ [development-status]: https://img.shields.io/travis/christhekeele/inquisitive/development.svg
37
+ [development-coverage]: https://img.shields.io/coveralls/christhekeele/inquisitive/development.svg
38
+
39
+ [![Version][version-image]][version] [![Quality][quality-image]][quality] [![Dependencies][dependencies-image]][dependencies]
40
+
41
+ | :thumbsup: | [Continuous Integration][status] | Test Coverage |
42
+ |:--------------------------:|:-----------------------------------:|:----------------------------------------:|
43
+ | [Master][master] | ![Build Status][master-status] | ![Coverage Status][master-coverage] |
44
+ | [Development][development] | ![Build Status][development-status] | ![Coverage Status][development-coverage] |
45
+
46
+
12
47
  Installation
13
48
  ------------
14
49
 
@@ -22,9 +57,10 @@ $ bundle install
22
57
  Otherwise:
23
58
 
24
59
  ```bash
25
- gem install inquisitive
60
+ $ gem install inquisitive
26
61
  ```
27
62
 
63
+
28
64
  Usage
29
65
  -----
30
66
 
@@ -236,6 +272,43 @@ This only works on top-level inquirers, so there's no way to get our nested `MyG
236
272
 
237
273
  The `present_if` check uses `===` under the covers for maximum expressiveness, so you can also use it to match against regexs, classes, and other constructs.
238
274
 
275
+ ##### Truthy Booleans
276
+
277
+ `Inquisitive::Environment.truthy` contains a regex useful for reading booleans from environment variables.
278
+
279
+ ```ruby
280
+ ENV['NO'] = 'no'
281
+ ENV['YES'] = 'yes'
282
+ ENV['TRUTHY'] = 'TrUe'
283
+ ENV['FALSEY'] = 'FaLsE'
284
+ ENV['BOOLEAN'] = '1'
285
+ ENV['BOOLENOPE'] = '0'
286
+ class MyCli
287
+ extend Inquisitive::Environment
288
+ inquires_about 'NO', present_if: truthy
289
+ inquires_about 'YES', present_if: truthy
290
+ inquires_about 'TRUTHY', present_if: truthy
291
+ inquires_about 'FALSEY', present_if: truthy
292
+ inquires_about 'BOOLEAN', present_if: truthy
293
+ inquires_about 'BOOLENOPE', present_if: truthy
294
+ end
295
+
296
+ MyGame.no?
297
+ #=> false
298
+ MyGame.yes?
299
+ #=> true
300
+
301
+ MyGame.truthy?
302
+ #=> true
303
+ MyGame.falsey?
304
+ #=> false
305
+
306
+ MyGame.boolean?
307
+ #=> true
308
+ MyGame.boolenope?
309
+ #=> false
310
+ ```
311
+
239
312
  #### Inquiry mode
240
313
 
241
314
  Environment inquirers have three configurable modes, defaulting to `:static`.
@@ -265,6 +338,7 @@ end
265
338
 
266
339
  Use if your application is well-behaved and doesn't go mucking around with the environment at runtime.
267
340
 
341
+
268
342
  Contributing
269
343
  ------------
270
344
 
data/inquisitive.gemspec CHANGED
@@ -4,17 +4,17 @@ $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 = "2.0.0"
7
+ spec.version = "2.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."
11
11
  spec.description = <<-DESC
12
12
  Predicate methods for those curious about their datastructures.
13
-
13
+
14
14
  Provides String, Array, and Hash subclasses with dynamic predicate methods that
15
15
  allow you to interrogate the contents of the most common Ruby datastructures
16
16
  in a readable, friendly fashion.
17
-
17
+
18
18
  Also allows you to auto-instanciate and read inquisitive datastructures straight
19
19
  from your `ENV` hash.
20
20
  DESC
@@ -28,5 +28,4 @@ Gem::Specification.new do |spec|
28
28
  spec.add_development_dependency "bundler", ">= 1.3"
29
29
  spec.add_development_dependency "rake", ">= 10.0"
30
30
  spec.add_development_dependency "minitest", ">= 5.0"
31
- spec.add_development_dependency "simplecov", ">= 0.7"
32
31
  end
@@ -2,6 +2,10 @@ module Inquisitive
2
2
  module Environment
3
3
  include Inquisitive
4
4
 
5
+ def truthy
6
+ /true|yes|1/i
7
+ end
8
+
5
9
  def inquires_about(env_var, opts={})
6
10
 
7
11
  env_accessor = opts.fetch(:with, env_var.downcase[/(.*?)(?=(?:_$|$))/])
@@ -43,6 +47,7 @@ module Inquisitive
43
47
  Inquisitive.present? send(predication(__method__))
44
48
  end
45
49
  end
50
+
46
51
  end
47
52
 
48
53
  private
@@ -52,7 +57,7 @@ module Inquisitive
52
57
 
53
58
  def [](var_name)
54
59
  if ENV.has_key? var_name
55
-
60
+
56
61
  env_var = ENV[var_name]
57
62
  if env_var.include? ','
58
63
  env_var.split(',').map(&:strip)
@@ -71,7 +76,7 @@ module Inquisitive
71
76
  ""
72
77
  end
73
78
  end
74
-
79
+
75
80
  def can_find_env_keys_from(var_name)
76
81
  found = env_keys_from(var_name)
77
82
  found.empty? ? nil : found
@@ -1,3 +1,5 @@
1
+ require 'test_helper'
2
+
1
3
  class InquisitiveCombinatorialEnvironmentTest < EnvironmentTest
2
4
 
3
5
  def setup
@@ -43,4 +43,12 @@ class InquisitiveEnvironmentTest < EnvironmentTest
43
43
  refute App.authorizable?
44
44
  end
45
45
 
46
+ %w[true True TrUe TRUE yes Yes YeS YES 1].each do |truthy_var|
47
+ define_method :"test_truthy_var_#{truthy_var}" do
48
+ ENV['TRUTHY'] = truthy_var
49
+ App.inquires_about 'TRUTHY', present_if: App.truthy
50
+ assert App.truthy?
51
+ end
52
+ end
53
+
46
54
  end
@@ -336,7 +336,7 @@ class InquisitiveHashWithIndifferentAccessTest < Test
336
336
 
337
337
  # Should preserve the default proc.
338
338
  mixed_with_default_proc = @mixed.dup
339
- mixed_with_default_proc.default_proc = -> (h, k) { '1234' }
339
+ mixed_with_default_proc.default_proc = lambda { |h, k| '1234' }
340
340
  roundtrip = HashWithIndifferentAccess.new(mixed_with_default_proc).to_hash
341
341
  assert_equal @strings, roundtrip
342
342
  assert_equal '1234', roundtrip.default
data/test/test_helper.rb CHANGED
@@ -1,11 +1,23 @@
1
1
  require "rubygems"
2
- require "simplecov"
3
- require "minitest/autorun"
4
2
 
5
- SimpleCov.start do
6
- add_filter "/test"
3
+ begin
4
+ require 'simplecov'
5
+ SimpleCov.coverage_dir '.coverage'
6
+ if ENV['CI']
7
+ require 'coveralls'
8
+ SimpleCov.formatter = SimpleCov::Formatter::MultiFormatter[
9
+ SimpleCov::Formatter::HTMLFormatter,
10
+ Coveralls::SimpleCov::Formatter
11
+ ]
12
+ end
13
+ SimpleCov.start do
14
+ add_filter "/test"
15
+ add_filter "/vendor"
16
+ end
7
17
  end
8
18
 
19
+ require "minitest/autorun"
20
+
9
21
  class Test < MiniTest::Test
10
22
 
11
23
  def assert_change(lambda_getter)
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: 2.0.0
4
+ version: 2.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: 2014-06-19 00:00:00.000000000 Z
11
+ date: 2014-09-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -52,34 +52,27 @@ dependencies:
52
52
  - - ">="
53
53
  - !ruby/object:Gem::Version
54
54
  version: '5.0'
55
- - !ruby/object:Gem::Dependency
56
- name: simplecov
57
- requirement: !ruby/object:Gem::Requirement
58
- requirements:
59
- - - ">="
60
- - !ruby/object:Gem::Version
61
- version: '0.7'
62
- type: :development
63
- prerelease: false
64
- version_requirements: !ruby/object:Gem::Requirement
65
- requirements:
66
- - - ">="
67
- - !ruby/object:Gem::Version
68
- version: '0.7'
69
- description: " Predicate methods for those curious about their datastructures.\n
70
- \ \n Provides String, Array, and Hash subclasses with dynamic predicate methods
71
- that\n allow you to interrogate the contents of the most common Ruby datastructures\n
72
- \ in a readable, friendly fashion.\n \n Also allows you to auto-instanciate
73
- and read inquisitive datastructures straight\n from your `ENV` hash.\n"
55
+ description: |2
56
+ Predicate methods for those curious about their datastructures.
57
+
58
+ Provides String, Array, and Hash subclasses with dynamic predicate methods that
59
+ allow you to interrogate the contents of the most common Ruby datastructures
60
+ in a readable, friendly fashion.
61
+
62
+ Also allows you to auto-instanciate and read inquisitive datastructures straight
63
+ from your `ENV` hash.
74
64
  email:
75
65
  - dev@chriskeele.com
76
66
  executables: []
77
67
  extensions: []
78
68
  extra_rdoc_files: []
79
69
  files:
70
+ - ".coveralls.yml"
80
71
  - ".gitignore"
72
+ - ".travis.yml"
81
73
  - CHANGELOG.md
82
74
  - Gemfile
75
+ - Gemfile.ActiveSupport
83
76
  - LICENSE.md
84
77
  - README.md
85
78
  - Rakefile
@@ -139,4 +132,3 @@ test_files:
139
132
  - test/shared/hash_tests.rb
140
133
  - test/shared/string_tests.rb
141
134
  - test/test_helper.rb
142
- has_rdoc: