recurator 0.0.1 → 0.0.2

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: 8d91922d6a4571ec2efad5e92de14b23f27fd776
4
- data.tar.gz: 8db2aa655e17fe33a8e6efeb3b170b09dac620d8
3
+ metadata.gz: 4ebc6ac323bdeda01058b39bace9d73db809d9dd
4
+ data.tar.gz: 1f026d693b80d11dd2585008c64b3f6dbc82a8d4
5
5
  SHA512:
6
- metadata.gz: 25a398f1ebd16af4714ca75b546b772f541910f311fcb223c99f670d688d6495d29931e6a1fbb81f25af576a31d7abb39e77aadb2391867525bc42c3283e17d9
7
- data.tar.gz: 1c80847c3ec3b24f9ccd2073584ab1dc6b4cea44bb5cbb91b10c094dae5b2ea8111c5672babbc4436cf71761705127e9bd5ce5bc5fb6cfbaf0f8c7af23613b71
6
+ metadata.gz: 41418111bbffef2d5eff5c9fa445aada11de076bcc66aa28d3e49fc4999c5234950bae1396b275fa5fb49f25edc92f51a1888a9dc94b44d08323ea3ad96f981b
7
+ data.tar.gz: f8870bbd230ac2e60bf0e4c63136700437529447e0c1c902e991cd4157e2231840e581f479b82ac3e7bc1a5655a31127f984585cf9659138930926a7fc6b859b
@@ -0,0 +1,4 @@
1
+ language: ruby
2
+ rvm:
3
+ - 1.9.3
4
+ - 2.0.0
data/README.md CHANGED
@@ -1,5 +1,8 @@
1
1
  # Recurator
2
2
 
3
+ [![Gem Version](https://badge.fury.io/rb/recurator.png)](http://badge.fury.io/rb/recurator)
4
+ [![Build Status](https://travis-ci.org/ksss/Recurator.png?branch=master)](https://travis-ci.org/ksss/Recurator)
5
+
3
6
  Recurator is object for recursive processing like Enumeator.
4
7
 
5
8
  Recurator is included `Enumeable` module.
data/Rakefile CHANGED
@@ -8,3 +8,5 @@ RSpec::Core::RakeTask.new(:spec) do |t|
8
8
  t.pattern = 'spec/**/*_spec.rb'
9
9
  t.verbose = true
10
10
  end
11
+
12
+ task :default => [:spec]
@@ -0,0 +1,3 @@
1
+ require 'mkmf'
2
+
3
+ create_makefile('recurator/recurator')
@@ -1,49 +1,3 @@
1
- class Recurator
2
- include Enumerable
3
-
4
- def initialize (obj)
5
- @obj = obj
6
- end
7
-
8
- def each
9
- looper = lambda { |o|
10
- case o
11
- when Array
12
- o.each_with_index {|i, index|
13
- yield [index, i]
14
- looper.call(i)
15
- }
16
- when Hash
17
- o.each { |key, value|
18
- yield [key, value]
19
- looper.call(value)
20
- }
21
- end
22
- }
23
-
24
- if block_given?
25
- looper.call(@obj)
26
- else
27
- self.to_enum
28
- end
29
- end
30
-
31
- def keys
32
- map { |key, value| key }
33
- end
34
-
35
- def values
36
- map { |key, value| value }
37
- end
38
-
39
- def flatten
40
- ret = []
41
- each { |key, value|
42
- ret << key
43
- if !value.kind_of?(Array) && !value.kind_of?(Hash)
44
- ret << value
45
- end
46
- }
47
- ret
48
- end
49
- end
1
+ require 'recurator/recurator'
2
+ require 'recurator/extention'
3
+ require 'recurator/version'
@@ -0,0 +1,13 @@
1
+ require 'recurator/recurator'
2
+
3
+ class Array
4
+ def to_recur
5
+ Recurator.new self
6
+ end
7
+ end
8
+
9
+ class Hash
10
+ def to_recur
11
+ Recurator.new self
12
+ end
13
+ end
@@ -0,0 +1,49 @@
1
+ class Recurator
2
+ include Enumerable
3
+
4
+ def initialize (obj)
5
+ @obj = obj
6
+ end
7
+
8
+ def each
9
+ looper = lambda { |o|
10
+ case o
11
+ when Array
12
+ o.each_with_index {|i, index|
13
+ yield [index, i]
14
+ looper.call(i)
15
+ }
16
+ when Hash
17
+ o.each { |key, value|
18
+ yield [key, value]
19
+ looper.call(value)
20
+ }
21
+ end
22
+ }
23
+
24
+ if block_given?
25
+ looper.call(@obj)
26
+ else
27
+ self.to_enum
28
+ end
29
+ end
30
+
31
+ def keys
32
+ map { |key, value| key }
33
+ end
34
+
35
+ def values
36
+ map { |key, value| value }
37
+ end
38
+
39
+ def flatten
40
+ ret = []
41
+ each { |key, value|
42
+ ret << key
43
+ if !value.kind_of?(Array) && !value.kind_of?(Hash)
44
+ ret << value
45
+ end
46
+ }
47
+ ret
48
+ end
49
+ end
@@ -1,3 +1,3 @@
1
1
  class Recurator
2
- VERSION = "0.0.1"
2
+ VERSION = "0.0.2"
3
3
  end
@@ -17,8 +17,10 @@ Gem::Specification.new do |spec|
17
17
  spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
18
  spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
19
  spec.require_paths = ["lib"]
20
+ spec.extensions = ["ext/recurator/extconf.rb"]
20
21
 
21
22
  spec.add_development_dependency "bundler", "~> 1.3"
22
23
  spec.add_development_dependency "rake"
23
24
  spec.add_development_dependency "rspec", "~> 2.11"
25
+ spec.add_development_dependency 'rake-compiler', ['~> 0.8.3']
24
26
  end
@@ -7,16 +7,20 @@ describe Recurator do
7
7
  "two" => {
8
8
  "three" => 3
9
9
  }
10
- }
10
+ }
11
11
  })
12
12
  end
13
13
 
14
14
  it "initialize" do
15
- Recurator.new({})
15
+ expect(Recurator.new([])).to be_a_instance_of(Recurator)
16
+ expect(Recurator.new({})).to be_a_instance_of(Recurator)
17
+ expect([].to_recur).to be_a_instance_of(Recurator)
18
+ expect({}.to_recur).to be_a_instance_of(Recurator)
16
19
  end
17
20
 
18
21
  it "include Enumerable" do
19
- Recurator.include?(Enumerable)
22
+ expect(Recurator).to include(Enumerable)
23
+ expect(Recurator.new({}).to_enum).to be_a_instance_of(Enumerator)
20
24
  end
21
25
 
22
26
  it "each" do
@@ -30,4 +34,8 @@ describe Recurator do
30
34
  it "keys" do
31
35
  expect(recur.keys).to eq(["one","two","three"])
32
36
  end
37
+
38
+ it "values" do
39
+ expect(recur.values).to eq([{"two"=>{"three"=>3}}, {"three"=>3}, 3])
40
+ end
33
41
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: recurator
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - ksss
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-10-03 00:00:00.000000000 Z
11
+ date: 2013-10-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -52,23 +52,41 @@ dependencies:
52
52
  - - ~>
53
53
  - !ruby/object:Gem::Version
54
54
  version: '2.11'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rake-compiler
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ~>
60
+ - !ruby/object:Gem::Version
61
+ version: 0.8.3
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ~>
67
+ - !ruby/object:Gem::Version
68
+ version: 0.8.3
55
69
  description: Recurator is object for recursive processing like Enumeator.
56
70
  email:
57
71
  - co000ri@gmail.com
58
72
  executables: []
59
- extensions: []
73
+ extensions:
74
+ - ext/recurator/extconf.rb
60
75
  extra_rdoc_files: []
61
76
  files:
77
+ - .travis.yml
62
78
  - Gemfile
63
79
  - LICENSE.txt
64
80
  - README.md
65
81
  - Rakefile
66
- - lib/recurator.bundle
67
82
  - lib/recurator.rb
83
+ - lib/recurator/extention.rb
84
+ - lib/recurator/recurator.rb
68
85
  - lib/recurator/version.rb
69
86
  - recurator.gemspec
70
87
  - spec/helper.rb
71
88
  - spec/recurator_spec.rb
89
+ - ext/recurator/extconf.rb
72
90
  homepage: ''
73
91
  licenses:
74
92
  - MIT
Binary file