ravengar 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/.gitignore +17 -0
- data/Gemfile +4 -0
- data/Guardfile +5 -0
- data/LICENSE.txt +22 -0
- data/README.md +29 -0
- data/Rakefile +1 -0
- data/lib/ravengar.rb +4 -0
- data/lib/ravengar/all.rb +5 -0
- data/lib/ravengar/array.rb +9 -0
- data/lib/ravengar/base_library.rb +29 -0
- data/lib/ravengar/engine/source_wrapper.rb +50 -0
- data/lib/ravengar/proc.rb +17 -0
- data/lib/ravengar/version.rb +3 -0
- data/ravengar.gemspec +24 -0
- data/spec/lib/ravengar/base_library_spec.rb +61 -0
- metadata +104 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 442c28486c2484032151adad55bc7bf53791706d
|
4
|
+
data.tar.gz: 14c0677b419ff65c3ed8517518edc05e3f03100b
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 8ce2a1ad4b8aa836504f31c99dd34a1b2dbb5b95004fb025849945273cc1c82bce19575214d7462ac45d06f267392030994ac1459f23cb0bd86d73f4f37c3783
|
7
|
+
data.tar.gz: 824a8a4ede30f7ddfb75e6e51370ec1c9e8f20bc74f80d3b549c180cf417976fdb38939c42cd6e9508d9cdb1b7d479e20f5fe96b483f184a60f92e0150a9c34e
|
data/.gitignore
ADDED
data/Gemfile
ADDED
data/Guardfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2013 Ronie Uliana
|
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,29 @@
|
|
1
|
+
# Ravengar
|
2
|
+
|
3
|
+
TODO: Write a gem description
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
gem 'ravengar'
|
10
|
+
|
11
|
+
And then execute:
|
12
|
+
|
13
|
+
$ bundle
|
14
|
+
|
15
|
+
Or install it yourself as:
|
16
|
+
|
17
|
+
$ gem install ravengar
|
18
|
+
|
19
|
+
## Usage
|
20
|
+
|
21
|
+
TODO: Write usage instructions here
|
22
|
+
|
23
|
+
## Contributing
|
24
|
+
|
25
|
+
1. Fork it
|
26
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
27
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
28
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
29
|
+
5. Create new Pull Request
|
data/Rakefile
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require "bundler/gem_tasks"
|
data/lib/ravengar.rb
ADDED
data/lib/ravengar/all.rb
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
using Ravengar
|
2
|
+
module Ravengar
|
3
|
+
refine Object do
|
4
|
+
def show(output = $stdout, separator: "\n")
|
5
|
+
->(it) { output << it.inspect << separator; it }
|
6
|
+
end
|
7
|
+
def filter(lambd)
|
8
|
+
->(it) do
|
9
|
+
value = lambd.call(it)
|
10
|
+
if value
|
11
|
+
it
|
12
|
+
else
|
13
|
+
skip!
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
def replicator(*lambds)
|
18
|
+
->(it) do
|
19
|
+
lambds.map { |lambd| lambd.call(it) }
|
20
|
+
end
|
21
|
+
end
|
22
|
+
def diffuser(*lambds)
|
23
|
+
diffus = lambds.cycle
|
24
|
+
->(*args) do
|
25
|
+
diffus.next.call(*args)
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
@@ -0,0 +1,50 @@
|
|
1
|
+
require 'ravengar/proc'
|
2
|
+
using Ravengar
|
3
|
+
module Ravengar
|
4
|
+
class SourceWrapper
|
5
|
+
include Enumerable
|
6
|
+
def initialize(source)
|
7
|
+
@source = source
|
8
|
+
@head_lambda = ->(it) { it }
|
9
|
+
end
|
10
|
+
|
11
|
+
def |(lambd)
|
12
|
+
@head_lambda = @head_lambda | lambd
|
13
|
+
self
|
14
|
+
end
|
15
|
+
|
16
|
+
def call
|
17
|
+
run
|
18
|
+
end
|
19
|
+
|
20
|
+
def each
|
21
|
+
catch :abort_proc do
|
22
|
+
@source.each do |it|
|
23
|
+
catch :skip_proc do
|
24
|
+
yield @head_lambda.call(it)
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
ensure
|
29
|
+
@source.close if @source.respond_to?(:close)
|
30
|
+
end
|
31
|
+
|
32
|
+
def ~@
|
33
|
+
self.each { |it| it }
|
34
|
+
@source
|
35
|
+
end
|
36
|
+
|
37
|
+
def !@
|
38
|
+
self.map { |it| it }
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
refine Object do
|
43
|
+
def skip!
|
44
|
+
throw :skip_proc
|
45
|
+
end
|
46
|
+
def abort!
|
47
|
+
throw :abort_proc
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
require 'ravengar/base_library'
|
2
|
+
using Ravengar
|
3
|
+
module Ravengar
|
4
|
+
refine Proc do
|
5
|
+
def |(lambd)
|
6
|
+
->(args) { lambd.call(self.call(args)) }
|
7
|
+
end
|
8
|
+
|
9
|
+
def ~@
|
10
|
+
filter(self)
|
11
|
+
end
|
12
|
+
|
13
|
+
def !@
|
14
|
+
filter(->(it) { not self[it] })
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
data/ravengar.gemspec
ADDED
@@ -0,0 +1,24 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'ravengar/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = 'ravengar'
|
8
|
+
spec.version = Ravengar::VERSION
|
9
|
+
spec.authors = ['Ronie Uliana']
|
10
|
+
spec.email = ['ronie.uliana@gmail.com']
|
11
|
+
spec.description = %q{Flow Based Programming as a Programming Paradigm}
|
12
|
+
spec.summary = %q{What would happen if all base programming units were "pipes" a la a *nix shell? This is trying to answer the question. It's an exploratory DSL to check "what if"}
|
13
|
+
spec.homepage = ''
|
14
|
+
spec.license = 'MIT'
|
15
|
+
|
16
|
+
spec.files = `git ls-files`.split($/)
|
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.3'
|
22
|
+
spec.add_development_dependency 'rake'
|
23
|
+
spec.add_development_dependency 'guard-rspec'
|
24
|
+
end
|
@@ -0,0 +1,61 @@
|
|
1
|
+
require 'ravengar/all'
|
2
|
+
using Ravengar
|
3
|
+
|
4
|
+
describe 'base library' do
|
5
|
+
let(:source) { %w(This is SOMEthing aWesoME) }
|
6
|
+
describe 'filter' do
|
7
|
+
it 'is called by the method name' do
|
8
|
+
result = !(source | filter(->(it) { it =~ /^[A-Z]/ }) )
|
9
|
+
expect(result).to eq(%w(This SOMEthing))
|
10
|
+
end
|
11
|
+
it 'is called using "~"' do
|
12
|
+
result = !(source | ~->(it) { it =~ /^[A-Z]/ } )
|
13
|
+
expect(result).to eq(%w(This SOMEthing))
|
14
|
+
end
|
15
|
+
it 'reverses the filter with "!"' do
|
16
|
+
result = !(source | !->(it) { it =~ /^[A-Z]/ } )
|
17
|
+
expect(result).to eq(%w(is aWesoME))
|
18
|
+
end
|
19
|
+
end
|
20
|
+
describe 'show' do
|
21
|
+
it 'outputs data to arg' do
|
22
|
+
result = ""
|
23
|
+
!(source | show(result))
|
24
|
+
expect(result).to eq %("This"\n"is"\n"SOMEthing"\n"aWesoME"\n)
|
25
|
+
end
|
26
|
+
it 'outputs data to STDOUT with no args' do
|
27
|
+
begin
|
28
|
+
result = StringIO.new
|
29
|
+
$stdout, previous_stdout = result, $stdout
|
30
|
+
!(source | show)
|
31
|
+
expect(result.string).to eq %("This"\n"is"\n"SOMEthing"\n"aWesoME"\n)
|
32
|
+
ensure
|
33
|
+
$stdout = previous_stdout
|
34
|
+
end
|
35
|
+
end
|
36
|
+
it 'outputs data using other separator' do
|
37
|
+
result = ""
|
38
|
+
!(source | show(result, separator: '|'))
|
39
|
+
expect(result).to eq %("This"|"is"|"SOMEthing"|"aWesoME"|)
|
40
|
+
end
|
41
|
+
end
|
42
|
+
describe 'replicator' do
|
43
|
+
it 'outputs the same thing to n lambdas' do
|
44
|
+
result = []
|
45
|
+
collector = ->(it) { result << it }
|
46
|
+
!(source | replicator(collector, collector))
|
47
|
+
expect(result).to eq %w(This This is is SOMEthing SOMEthing aWesoME aWesoME)
|
48
|
+
end
|
49
|
+
end
|
50
|
+
describe 'diffuser' do
|
51
|
+
it 'sends each output to a different lambda' do
|
52
|
+
result1 = []
|
53
|
+
result2 = []
|
54
|
+
collector1 = ->(it) { result1 << it }
|
55
|
+
collector2 = ->(it) { result2 << it }
|
56
|
+
!(source | diffuser(collector1, collector2))
|
57
|
+
expect(result1).to eq %w(This SOMEthing)
|
58
|
+
expect(result2).to eq %w(is aWesoME)
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
metadata
ADDED
@@ -0,0 +1,104 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: ravengar
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Ronie Uliana
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2013-10-01 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.3'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ~>
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.3'
|
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-rspec
|
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
|
+
description: Flow Based Programming as a Programming Paradigm
|
56
|
+
email:
|
57
|
+
- ronie.uliana@gmail.com
|
58
|
+
executables: []
|
59
|
+
extensions: []
|
60
|
+
extra_rdoc_files: []
|
61
|
+
files:
|
62
|
+
- .gitignore
|
63
|
+
- Gemfile
|
64
|
+
- Guardfile
|
65
|
+
- LICENSE.txt
|
66
|
+
- README.md
|
67
|
+
- Rakefile
|
68
|
+
- lib/ravengar.rb
|
69
|
+
- lib/ravengar/all.rb
|
70
|
+
- lib/ravengar/array.rb
|
71
|
+
- lib/ravengar/base_library.rb
|
72
|
+
- lib/ravengar/engine/source_wrapper.rb
|
73
|
+
- lib/ravengar/proc.rb
|
74
|
+
- lib/ravengar/version.rb
|
75
|
+
- ravengar.gemspec
|
76
|
+
- spec/lib/ravengar/base_library_spec.rb
|
77
|
+
homepage: ''
|
78
|
+
licenses:
|
79
|
+
- MIT
|
80
|
+
metadata: {}
|
81
|
+
post_install_message:
|
82
|
+
rdoc_options: []
|
83
|
+
require_paths:
|
84
|
+
- lib
|
85
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - '>='
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '0'
|
90
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
91
|
+
requirements:
|
92
|
+
- - '>='
|
93
|
+
- !ruby/object:Gem::Version
|
94
|
+
version: '0'
|
95
|
+
requirements: []
|
96
|
+
rubyforge_project:
|
97
|
+
rubygems_version: 2.0.3
|
98
|
+
signing_key:
|
99
|
+
specification_version: 4
|
100
|
+
summary: What would happen if all base programming units were "pipes" a la a *nix
|
101
|
+
shell? This is trying to answer the question. It's an exploratory DSL to check "what
|
102
|
+
if"
|
103
|
+
test_files:
|
104
|
+
- spec/lib/ravengar/base_library_spec.rb
|