reactive_support 0.1.3.beta2 → 0.1.3.beta4

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: 603609fc550e2e3282984a2dbbc193d6c6c4ebb1
4
- data.tar.gz: 622aa5e7ec4d21b51b7f1e4bac87c038577a5d35
3
+ metadata.gz: 991c3b772cd39007b6c20e62aa1f36c09dd1aaa6
4
+ data.tar.gz: d4215aeae27ab97e9affea441894d10149110cd9
5
5
  SHA512:
6
- metadata.gz: 26d3d0c1bac92201597b553074c200000333a53b1a48e8bb32b75c7233bdd3166109cc3ca4dd4b771dc4db8a2f7b40b17b8303bf129eaa5d74d0974822aa5781
7
- data.tar.gz: 418935b71536d600905f9a53dc300ba755e9afc3b1b65869dcbd97d242261f9f501f926c4beae2a397c01c2da76f9ce1f07415cadbc54c9b376a0aacd652e260
6
+ metadata.gz: baee1ff86bcd13000c1dd7e3479fea01d567bf7dedf4d91f1eeab7065b1b8c8990ae5eff0162a4bc9f8655f1baca6901e372c8ce6f9418aa9aa98aefe7f1e65d
7
+ data.tar.gz: fdf0688e33bd9d4009ebd0976fb09dd86ae7aec503597fcc541c2d6983560a182c56c94ed3602e450831a2fecbedbcbc0993b07eebed4a975d939b2efb1f5a13
data/CONTRIBUTING.md CHANGED
@@ -40,6 +40,18 @@ Thank you for your contributions!
40
40
  I'll consider all contributions, but the following would be
41
41
  particularly helpful.
42
42
 
43
+ ##### Issue Reports
44
+ Issue reports need not adhere to the rest of the contributing guidelines.
45
+ I welcome questions, problems, and feature requests (i.e., ActiveSupport
46
+ functionality you'd like to see in this gem) and will respond promptly in
47
+ most cases. When reporting a problem or bug, please include as much
48
+ information as possible, including the following:
49
+ * Version of ReactiveSupport and other tools in your project
50
+ * Version(s) of Ruby you're using or testing against
51
+ * Code samples and error messages you're getting
52
+ * What you have already tried
53
+ * Any additional information relevant to your particular problem
54
+
43
55
  ##### Bug fixes
44
56
  If you find a bug affecting ReactiveSupport's interaction with other gems,
45
57
  frameworks, tools, platforms, rubies, or environments, your issue report
data/README.md CHANGED
@@ -20,7 +20,7 @@ If you would like to install an earlier version, you can specify that version's
20
20
  using the standard branch naming scheme:
21
21
  <pre><code>gem 'reactive_support', '~> 0.1.2', git: 'https://github.com/danascheider/reactive_support.git, branch: 'version-0.1.2'</code></pre>
22
22
 
23
- Please note that version 0.1.2 is the earliest available version of ReactiveSupport.
23
+ Please note that version 0.1.2 is the earliest available version of ReactiveSupport, and is currently the only release labeled production ready.
24
24
 
25
25
  ### Usage
26
26
  In its current version, ReactiveSupport adds methods to Ruby's `Object` class, so
@@ -0,0 +1,26 @@
1
+ class Array
2
+
3
+ # The +#scope+ method is called on an array of hashes. It returns a sub-array
4
+ # including only hashes for which the given +key+ equals the given +value+.
5
+ # The +#scope+ method is non-destructive; the original array will remain intact
6
+ # after it is called. The +#scope+ method is known to work for string or symbol
7
+ # keys. It should work for other data type keys as well.
8
+ #
9
+ # Example:
10
+ # array = [
11
+ # { name: 'Jean-Paul Sartre', nationality: 'French' },
12
+ # { name: 'Bertrand Russell', nationality: 'English' },
13
+ # { name: 'Ludwig Wittgenstein', nationality: 'Austrian' },
14
+ # { name: 'Albert Camus', nationality: 'French' }
15
+ # ]
16
+ #
17
+ # array.scope(:nationality, 'French')
18
+ # # => [
19
+ # { name: 'Jean-Paul Sartre', nationality: 'French' },
20
+ # { name: 'Albert Camus', nationality: 'French' }
21
+ # ]
22
+
23
+ def scope(key, value)
24
+ self.reject {|hash| hash[key] != value }
25
+ end
26
+ end
@@ -1,6 +1,6 @@
1
1
  require 'reactive_support'
2
2
 
3
- # The ReactiveAddOns module consists of methods I wish ActiveSupport provided.
3
+ # The ReactiveExtensions module consists of methods I wish ActiveSupport provided.
4
4
  # These methods do not adhere to the ActiveSupport API. If you wish to include
5
5
  # them in your project, you will need to put this in your main project file:
6
6
  # require 'reactive_support/extensions'
@@ -2,19 +2,6 @@
2
2
  # The +#blank?+ method returns +true+ if the object is undefined, blank, false,
3
3
  # empty, or nil. The +#present?+ method returns the opposite of +#blank?+
4
4
 
5
- class Object
6
-
7
- # In general, +#blank?+ returns true if the receiving object is false, empty,
8
- # or a whitespace string. This simplifies
9
- # address.nil? || address.empty?
10
- # to
11
- # address.blank?
12
-
13
- def blank?
14
- respond_to? :empty? ? !!empty? : !self
15
- end
16
- end
17
-
18
5
  # Ruby's core String class. See documentation for version
19
6
  # 2.1.3[http://ruby-doc.org/core-2.1.3/String.html],
20
7
  # 2.0.0[http://ruby-doc.org/core-2.1.3/String.html], or
@@ -8,7 +8,7 @@ Gem::Specification.new do |s|
8
8
 
9
9
  s.name = 'reactive_support'
10
10
  s.version = ReactiveSupport.gem_version
11
- s.date = '2014-09-24'
11
+ s.date = '2014-11-17'
12
12
 
13
13
  s.description = "ActiveSupport methods re-implemented independently of the Rails ecosystem"
14
14
  s.summary = "ReactiveSupport provides useful ActiveSupport methods in a gem that is simple, stable, agnostic, and transparent."
@@ -1,7 +1,6 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  describe ReactiveExtensions do
4
-
5
4
  describe '#try_rescue method' do
6
5
  context 'when self is nil' do
7
6
  it 'returns nil' do
@@ -21,4 +20,30 @@ describe ReactiveExtensions do
21
20
  end
22
21
  end
23
22
  end
23
+
24
+ describe 'array #scope method' do
25
+ context 'symbol keys' do
26
+ let(:sartre) { { name: 'Jean-Paul Sartre', nationality: 'French' } }
27
+ let(:russell) { { name: 'Bertrand Russell', nationality: 'English' } }
28
+ let(:wittgenstein) { { name: 'Ludwig Wittgenstein', nationality: 'Austrian' } }
29
+ let(:camus) { { name: 'Albert Camus', nationality: 'French' } }
30
+ let(:array) { [sartre, russell, wittgenstein, camus] }
31
+
32
+ it 'returns scoped hashes' do
33
+ expect(array.scope(:nationality, 'French')).to eql([sartre, camus])
34
+ end
35
+ end
36
+
37
+ context 'string keys' do
38
+ let(:sartre) { {'name' => 'Jean-Paul Sartre', 'nationality' => 'French' } }
39
+ let(:russell) { { 'name' => 'Bertrand Russell', 'nationality' => 'English' } }
40
+ let(:wittgenstein) { { 'name' => 'Ludwig Wittgenstein', 'nationality' => 'Austrian' } }
41
+ let(:camus) { { 'name' => 'Albert Camus', 'nationality' => 'French' } }
42
+ let(:array) { [sartre, russell, wittgenstein, camus] }
43
+
44
+ it 'returns scoped hashes' do
45
+ expect(array.scope('nationality', 'French')).to eql([sartre, camus])
46
+ end
47
+ end
48
+ end
24
49
  end
data/spec/spec_helper.rb CHANGED
@@ -10,7 +10,7 @@ SimpleCov.start if ENV["COVERAGE"]
10
10
  Coveralls.wear!
11
11
 
12
12
  require_relative '../lib/reactive_support'
13
- require_relative '../lib/reactive_support/extensions/reactive_extensions'
13
+ Dir['./lib/extensions/**/*.rb'].each {|f| require f }
14
14
 
15
15
  RSpec.configure do |c|
16
16
  c.order = 'random'
data/version.rb CHANGED
@@ -7,7 +7,7 @@ module ReactiveSupport
7
7
  MAJOR = '0'
8
8
  MINOR = '1'
9
9
  PATCH = '3'
10
- PRE = 'beta2'
10
+ PRE = 'beta4'
11
11
 
12
12
  STRING = [MAJOR, MINOR, PATCH, PRE].compact.join('.').chomp('.')
13
13
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: reactive_support
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.3.beta2
4
+ version: 0.1.3.beta4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dana Scheider
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-09-24 00:00:00.000000000 Z
11
+ date: 2014-11-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rspec
@@ -75,6 +75,7 @@ extra_rdoc_files:
75
75
  - README.md
76
76
  - LICENSE
77
77
  files:
78
+ - "./lib/extensions/array_extensions.rb"
78
79
  - "./lib/extensions/reactive_extensions.rb"
79
80
  - "./lib/reactive_support.rb"
80
81
  - "./lib/reactive_support/core_ext/array/access.rb"
@@ -127,4 +128,3 @@ specification_version: 1
127
128
  summary: ReactiveSupport provides useful ActiveSupport methods in a gem that is simple,
128
129
  stable, agnostic, and transparent.
129
130
  test_files: []
130
- has_rdoc: true