streamable 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +17 -0
- data/Gemfile +4 -0
- data/Guardfile +46 -0
- data/LICENSE.txt +22 -0
- data/README.md +43 -0
- data/Rakefile +1 -0
- data/lib/streamable.rb +9 -0
- data/lib/streamable/version.rb +3 -0
- data/spec/spec_helper.rb +11 -0
- data/spec/streamable_spec.rb +44 -0
- data/streamable.gemspec +25 -0
- metadata +115 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 83cc85985345a2dc136d786955c544fb172d81b0
|
4
|
+
data.tar.gz: 55b71e6cbe32c7e680aa368cd5fec98cf8a7f386
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: a5a6cf70b931666357b1cebc1996c2c60c894013a8bf91a1689054bef4328f861ae28638c8574e712ac4752ec1a59c1e1a545e15860c3cca892b32215b04843e
|
7
|
+
data.tar.gz: 365db110fd56c73928f436b80857d9fb95c6250ae8b1b658f0e965d513a293ddc4a36a0bf3e7398b8b2a71e5885b62aa14ae9cf03f441d3700d31781551def22
|
data/.gitignore
ADDED
data/Gemfile
ADDED
data/Guardfile
ADDED
@@ -0,0 +1,46 @@
|
|
1
|
+
# A sample Guardfile
|
2
|
+
# More info at https://github.com/guard/guard#readme
|
3
|
+
|
4
|
+
guard :rspec do
|
5
|
+
watch(%r{^spec/.+_spec\.rb$})
|
6
|
+
watch(%r{^lib/(.+)\.rb$}) { |m| "spec/lib/#{m[1]}_spec.rb" }
|
7
|
+
watch('spec/spec_helper.rb') { "spec" }
|
8
|
+
|
9
|
+
# Rails example
|
10
|
+
watch(%r{^app/(.+)\.rb$}) { |m| "spec/#{m[1]}_spec.rb" }
|
11
|
+
watch(%r{^app/(.*)(\.erb|\.haml|\.slim)$}) { |m| "spec/#{m[1]}#{m[2]}_spec.rb" }
|
12
|
+
watch(%r{^app/controllers/(.+)_(controller)\.rb$}) { |m| ["spec/routing/#{m[1]}_routing_spec.rb", "spec/#{m[2]}s/#{m[1]}_#{m[2]}_spec.rb", "spec/acceptance/#{m[1]}_spec.rb"] }
|
13
|
+
watch(%r{^spec/support/(.+)\.rb$}) { "spec" }
|
14
|
+
watch('config/routes.rb') { "spec/routing" }
|
15
|
+
watch('app/controllers/application_controller.rb') { "spec/controllers" }
|
16
|
+
|
17
|
+
# Capybara features specs
|
18
|
+
watch(%r{^app/views/(.+)/.*\.(erb|haml|slim)$}) { |m| "spec/features/#{m[1]}_spec.rb" }
|
19
|
+
|
20
|
+
# Turnip features and steps
|
21
|
+
watch(%r{^spec/acceptance/(.+)\.feature$})
|
22
|
+
watch(%r{^spec/acceptance/steps/(.+)_steps\.rb$}) { |m| Dir[File.join("**/#{m[1]}.feature")][0] || 'spec/acceptance' }
|
23
|
+
end
|
24
|
+
|
25
|
+
|
26
|
+
guard :rspec do
|
27
|
+
watch(%r{^spec/.+_spec\.rb$})
|
28
|
+
watch(%r{^lib/(.+)\.rb$}) { |m| "spec/lib/#{m[1]}_spec.rb" }
|
29
|
+
watch('spec/spec_helper.rb') { "spec" }
|
30
|
+
|
31
|
+
# Rails example
|
32
|
+
watch(%r{^app/(.+)\.rb$}) { |m| "spec/#{m[1]}_spec.rb" }
|
33
|
+
watch(%r{^app/(.*)(\.erb|\.haml|\.slim)$}) { |m| "spec/#{m[1]}#{m[2]}_spec.rb" }
|
34
|
+
watch(%r{^app/controllers/(.+)_(controller)\.rb$}) { |m| ["spec/routing/#{m[1]}_routing_spec.rb", "spec/#{m[2]}s/#{m[1]}_#{m[2]}_spec.rb", "spec/acceptance/#{m[1]}_spec.rb"] }
|
35
|
+
watch(%r{^spec/support/(.+)\.rb$}) { "spec" }
|
36
|
+
watch('config/routes.rb') { "spec/routing" }
|
37
|
+
watch('app/controllers/application_controller.rb') { "spec/controllers" }
|
38
|
+
|
39
|
+
# Capybara features specs
|
40
|
+
watch(%r{^app/views/(.+)/.*\.(erb|haml|slim)$}) { |m| "spec/features/#{m[1]}_spec.rb" }
|
41
|
+
|
42
|
+
# Turnip features and steps
|
43
|
+
watch(%r{^spec/acceptance/(.+)\.feature$})
|
44
|
+
watch(%r{^spec/acceptance/steps/(.+)_steps\.rb$}) { |m| Dir[File.join("**/#{m[1]}.feature")][0] || 'spec/acceptance' }
|
45
|
+
end
|
46
|
+
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2014 Brandon Weaver
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,43 @@
|
|
1
|
+
# Streamable
|
2
|
+
|
3
|
+
Allows you to stream data through a set of functions:
|
4
|
+
|
5
|
+
```ruby
|
6
|
+
[1] pry(main)> stream 1, :Float
|
7
|
+
=> 1.0
|
8
|
+
[2] pry(main)> stream 1, :Float, :p, :Integer
|
9
|
+
1.0
|
10
|
+
=> 1
|
11
|
+
[3] pry(main)> stream 1, :Float, -> i { i * 5 }
|
12
|
+
=> 5.0
|
13
|
+
```
|
14
|
+
|
15
|
+
Multistream lets you do this with multiple sets of initial data:
|
16
|
+
|
17
|
+
```ruby
|
18
|
+
[4] pry(main)> multistream data: [1,2], methods:[->(a,b) { a * b }]
|
19
|
+
=> 2
|
20
|
+
```
|
21
|
+
|
22
|
+
## Installation
|
23
|
+
|
24
|
+
Add this line to your application's Gemfile:
|
25
|
+
|
26
|
+
gem 'streamable'
|
27
|
+
|
28
|
+
And then execute:
|
29
|
+
|
30
|
+
$ bundle
|
31
|
+
|
32
|
+
Or install it yourself as:
|
33
|
+
|
34
|
+
$ gem install streamable
|
35
|
+
|
36
|
+
|
37
|
+
## Contributing
|
38
|
+
|
39
|
+
1. Fork it ( http://github.com/baweaver/streamable/fork )
|
40
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
41
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
42
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
43
|
+
5. Create new Pull Request
|
data/Rakefile
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require "bundler/gem_tasks"
|
data/lib/streamable.rb
ADDED
@@ -0,0 +1,9 @@
|
|
1
|
+
require "streamable/version"
|
2
|
+
|
3
|
+
def stream(data, *methods)
|
4
|
+
methods.reduce(data) { |d, m| m.is_a?(Symbol) ? Kernel.send(m, d) : m[d] }
|
5
|
+
end
|
6
|
+
|
7
|
+
def multistream(data: [], methods: [])
|
8
|
+
methods.reduce(data) { |d, m| m.is_a?(Symbol) ? Kernel.send(m, *d) : m[*d] }
|
9
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,44 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe 'Streamable' do
|
4
|
+
describe '#stream' do
|
5
|
+
context 'With methods as Symbols' do
|
6
|
+
it 'returns 5 after piping through method :plus_two' do
|
7
|
+
expect(stream 3, :plus_two).to eq(5)
|
8
|
+
end
|
9
|
+
|
10
|
+
it 'returns a float when also passed through :Float' do
|
11
|
+
expect(stream 3, :plus_two, :Float).to eq(5)
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
context 'With lambdas' do
|
16
|
+
it 'returns 5 after piping through a lambda' do
|
17
|
+
expect(stream 3, -> i { i + 2}).to eq(5)
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
context 'With mixed lambdas and symbols' do
|
22
|
+
it 'returns 10 after piping through #plus_two and a lambda' do
|
23
|
+
expect(stream 3, :plus_two, -> i { i * 2 }).to eq(10)
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
describe '#multistream' do
|
29
|
+
context 'With methods as Symbols' do
|
30
|
+
it 'returns the two numbers added' do
|
31
|
+
expect(multistream data: [1,2], methods: [:add_nums]).to eq(3)
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
context 'With lambdas' do
|
36
|
+
it 'returns the two numbers multiplied' do
|
37
|
+
expect(multistream data: [1,2], methods: [-> (a,b) { a * b }]).to eq(2)
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
def plus_two(i) i + 2 end
|
44
|
+
def add_nums(a,b) a + b end
|
data/streamable.gemspec
ADDED
@@ -0,0 +1,25 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'streamable/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "streamable"
|
8
|
+
spec.version = Streamable::VERSION
|
9
|
+
spec.authors = ["Brandon Weaver"]
|
10
|
+
spec.email = ["keystonelemur@gmail.com"]
|
11
|
+
spec.summary = %q{Allows streaming of data through a set of functions, like Clojure's ->}
|
12
|
+
spec.description = %q{Allows streaming of data througs a set of functions in order to simulate Clojure's and Unix's piping}
|
13
|
+
spec.homepage = "https://www.github.com/baweaver/streamable"
|
14
|
+
spec.license = "MIT"
|
15
|
+
|
16
|
+
spec.files = `git ls-files -z`.split("\x0")
|
17
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
18
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
|
+
spec.require_paths = ["lib"]
|
20
|
+
|
21
|
+
spec.add_development_dependency "bundler", "~> 1.5"
|
22
|
+
spec.add_development_dependency "rake"
|
23
|
+
spec.add_development_dependency "guard"
|
24
|
+
spec.add_development_dependency "guard-rspec"
|
25
|
+
end
|
metadata
ADDED
@@ -0,0 +1,115 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: streamable
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Brandon Weaver
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2014-06-26 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ~>
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.5'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ~>
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.5'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - '>='
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - '>='
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: guard
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - '>='
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - '>='
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: guard-rspec
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - '>='
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - '>='
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
69
|
+
description: Allows streaming of data througs a set of functions in order to simulate
|
70
|
+
Clojure's and Unix's piping
|
71
|
+
email:
|
72
|
+
- keystonelemur@gmail.com
|
73
|
+
executables: []
|
74
|
+
extensions: []
|
75
|
+
extra_rdoc_files: []
|
76
|
+
files:
|
77
|
+
- .gitignore
|
78
|
+
- Gemfile
|
79
|
+
- Guardfile
|
80
|
+
- LICENSE.txt
|
81
|
+
- README.md
|
82
|
+
- Rakefile
|
83
|
+
- lib/streamable.rb
|
84
|
+
- lib/streamable/version.rb
|
85
|
+
- spec/spec_helper.rb
|
86
|
+
- spec/streamable_spec.rb
|
87
|
+
- streamable.gemspec
|
88
|
+
homepage: https://www.github.com/baweaver/streamable
|
89
|
+
licenses:
|
90
|
+
- MIT
|
91
|
+
metadata: {}
|
92
|
+
post_install_message:
|
93
|
+
rdoc_options: []
|
94
|
+
require_paths:
|
95
|
+
- lib
|
96
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
97
|
+
requirements:
|
98
|
+
- - '>='
|
99
|
+
- !ruby/object:Gem::Version
|
100
|
+
version: '0'
|
101
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
102
|
+
requirements:
|
103
|
+
- - '>='
|
104
|
+
- !ruby/object:Gem::Version
|
105
|
+
version: '0'
|
106
|
+
requirements: []
|
107
|
+
rubyforge_project:
|
108
|
+
rubygems_version: 2.2.1
|
109
|
+
signing_key:
|
110
|
+
specification_version: 4
|
111
|
+
summary: Allows streaming of data through a set of functions, like Clojure's ->
|
112
|
+
test_files:
|
113
|
+
- spec/spec_helper.rb
|
114
|
+
- spec/streamable_spec.rb
|
115
|
+
has_rdoc:
|