reactive_support 0.5.0.beta → 0.5.0.beta2

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: e484324b27a831addea4d4f31a5a4343219dae84
4
- data.tar.gz: 69b6a58c8ab40a915a92f6f2f87da0719edf918a
3
+ metadata.gz: 24b7a1145615fef1ac0807e4d156380e7a50df4b
4
+ data.tar.gz: c5a986289af301086f0edd20a4abca612febf9ab
5
5
  SHA512:
6
- metadata.gz: 273d1eaf8a1db8b34e9b0e71dc08fd8af31ef0d6d4f4fa408d53d37d87e3e49a2e84bc8b17a51c459bf5458958fbbf662f8d4ad6f5c8a929a1d6bcb7dce9562c
7
- data.tar.gz: c114dca660f79679fdb6a59ac7d6ca866c6a9806cf76492f88aa6a7ff1d307fa88f936272eec3b2f493d5f21e0f675abc346c8828a0aaa8bb64ed9b32d9757f5
6
+ metadata.gz: a580a90272eb5f566c4c6857811a94808b1fbc925407787bc07dc6cb02cbc6410c8b6494f4de13c3d42a8153fdd5f170c4fd9930b8d4bcf6f32fd2f7cc0420de
7
+ data.tar.gz: 4b0aed3dd541395299404d7611f9ee29f76d82c4f64bfecd1829347c11ac0bb5f1cb66141a33e4f2018c973e9abb1b59283eb95652172d19d4470518f1249bb3
data/README.md CHANGED
@@ -5,24 +5,22 @@ The ReactiveSupport gem provides a re-implementation of certain [ActiveSupport](
5
5
  methods, allowing them to be used outside of the Rails ecosystem. This gem can
6
6
  be used in any kind of project and is not dependent on any frameworks, gemsets, etc.
7
7
  To add ReactiveSupport to your project, add this to your Gemfile and run `bundle install`:
8
- <pre><code>gem 'reactive_support', '~> 0.4.0'</code></pre>
8
+ <pre><code>gem 'reactive_support', '~> 0.5.0'</code></pre>
9
9
  To install locally:
10
10
  <pre><code>sudo gem install reactive_support</code></pre>
11
11
  Or if you're using RVM:
12
12
  <pre><code>gem install reactive_support</code></pre>
13
13
 
14
14
  You can also point your Gemfile to this repo:
15
- <pre><code>gem 'reactive_support', '~> 0.4.0.beta', git: 'https://github.com/danascheider/reactive_support.git</code></pre>
15
+ <pre><code>gem 'reactive_support', '~> 0.5.0.beta', git: 'https://github.com/danascheider/reactive_support.git</code></pre>
16
16
 
17
17
  Like ActiveSupport, ReactiveSupport is designed to load only the code you are actually
18
18
  using in your app. For that reason, you will need to specify in your project files
19
19
  exactly what you're using. For example, in Canto, I have the following requires:
20
- <pre><code>require 'reactive_support'
21
- require 'reactive_support/core_ext/object/blank'
20
+ <pre><code>require 'reactive_support/core_ext/object/blank'
22
21
  require 'reactive_support/core_ext/object/inclusion'
23
22
  require 'reactive_support/core_ext/object/try'
24
- require 'reactive_support/extensions/reactive_extensions'</code></pre>
25
- The ReactiveExtensions module should be required as a whole. I do have plans to add the ability to require the entire gem, or broader parts of it, in the future. This would also be a welcome contribution to the project if you're interested.
23
+ I do have plans to add the ability to require the entire gem, or broader parts of it, in the future. This would also be a welcome contribution to the project if you're interested.
26
24
 
27
25
  Please note that version 0.1.2 is the earliest available version of ReactiveSupport.
28
26
 
@@ -37,12 +35,6 @@ That means that, while not all ActiveSupport methods are available, those that a
37
35
  as of September 2014, be found in ActiveSupport's API documentation with no functional
38
36
  differences. (This is true of ReactiveSupport 0.1.x and ActiveSupport 4.1.6.)
39
37
 
40
- ReactiveSupport includes an extension module, ReactiveExtensions, that houses additional
41
- methods in the spirit of, but not included in, ActiveSupport. This module needs to
42
- be included separately; the default configuration is that only ActiveSupport methods
43
- are added to your project. You can include ReactiveExtensions with a simple `require`:
44
- <pre><code>require 'reactive_support/extensions/reactive_extensions'</pre></code>
45
-
46
38
  ### FAQ
47
39
  ##### Why not just use ActiveSupport?
48
40
  There are three main reasons why you might prefer ReactiveSupport over ActiveSupport:
@@ -0,0 +1,25 @@
1
+ class Hash
2
+
3
+ # By default, only instances of +Hash+ itself are extractable.
4
+ # Subclasses of +Hash+ may implement this method and return
5
+ # true to declare themselves extractable. +Array#extract_options!+
6
+ # then pops the hash if it comes as the last argument in a set of
7
+ # splat args.
8
+
9
+ def extractable_options?
10
+ instance_of? Hash
11
+ end
12
+ end
13
+
14
+ class Array
15
+
16
+ # The +#extract_options!+ method retrieves a hash of options from
17
+ # the end of a set of splat args. If the last element of the set
18
+ # is +Hash+ or instance of another class implementing the
19
+ # +#extractable_options?+ method, +#extract_options!+ method pops
20
+ # and returns that object. Otherwise, it returns an empty +Hash+.
21
+
22
+ def extract_options!
23
+ return last.is_a?(Hash) && last.extractable_options? ? pop : {}
24
+ end
25
+ end
data/spec/array_spec.rb CHANGED
@@ -1,7 +1,27 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  describe Array do
4
- describe '#from method' do
4
+ describe 'extract_options!' do
5
+ context 'when there are options' do
6
+ let(:array) { ['a', 'b', :foo => :bar] }
7
+
8
+ it 'returns the options' do
9
+ expect(array.extract_options!).to eql({:foo => :bar})
10
+ end
11
+
12
+ it 'is destructive' do
13
+ expect{ array.extract_options! }.to change(array, :length)
14
+ end
15
+ end
16
+
17
+ context 'when there are no options' do
18
+ it 'returns an empty hash' do
19
+ expect(['a', 'b'].extract_options!).to eql({})
20
+ end
21
+ end
22
+ end
23
+
24
+ describe 'from' do
5
25
  context 'normal use' do
6
26
  context 'positive position' do
7
27
  it 'returns the end of the array' do
@@ -35,7 +55,7 @@ describe Array do
35
55
  end
36
56
  end
37
57
 
38
- describe '#to method' do
58
+ describe 'to' do
39
59
  context 'normal use' do
40
60
  context 'positive position' do
41
61
  it 'returns the beginning of the array' do
data/version.rb CHANGED
@@ -7,7 +7,7 @@ module ReactiveSupport
7
7
  MAJOR = '0'
8
8
  MINOR = '5'
9
9
  PATCH = '0'
10
- PRE = 'beta'
10
+ PRE = 'beta2'
11
11
 
12
12
  STRING = [MAJOR, MINOR, PATCH, PRE].compact.join('.').chomp('.')
13
13
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: reactive_support
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.0.beta
4
+ version: 0.5.0.beta2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dana Scheider
@@ -79,6 +79,7 @@ files:
79
79
  - "./lib/reactive_support/core_ext.rb"
80
80
  - "./lib/reactive_support/core_ext/array.rb"
81
81
  - "./lib/reactive_support/core_ext/array/access.rb"
82
+ - "./lib/reactive_support/core_ext/array/extract_options.rb"
82
83
  - "./lib/reactive_support/core_ext/hash.rb"
83
84
  - "./lib/reactive_support/core_ext/hash/keys.rb"
84
85
  - "./lib/reactive_support/core_ext/object.rb"