tourmaline 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/LICENSE +22 -0
- data/README.md +18 -0
- data/bin/rb +14 -0
- data/img/logo200.jpg +0 -0
- data/lib/doing.rb +67 -0
- data/tourmaline.gemspec +21 -0
- metadata +66 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 5112bb6fe8c0929d526eb0cae41cd8dca8ea8b16
|
4
|
+
data.tar.gz: bcb7f62a181627788f5d10deb849b8d9c693d978
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 70612f91ef9353ee58950eb781f9ee434f6ac08a2dfe7ad2ac0d202960c0a65366a36253e517116eca2d1f3b5d19ce11167b069d6c711d89e20dd2b227a8b0e9
|
7
|
+
data.tar.gz: ee1c7c84566d7124d81bf5b9ec5346d6ae6ad684ffaef4e2a623e94ea2aaf02e3503095bb43cf0c8949c07acc21d699bab76a4c5ebadbaba29a75c7f4c6b8823
|
data/LICENSE
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2015 Mateu Adsuara
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
13
|
+
copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
21
|
+
SOFTWARE.
|
22
|
+
|
data/README.md
ADDED
@@ -0,0 +1,18 @@
|
|
1
|
+
#Tourmaline
|
2
|
+
![Tourmaline logo](https://raw.githubusercontent.com/demonh3x/tourmaline/master/img/logo200.jpg)
|
3
|
+
|
4
|
+
A configurable ruby interpreter for the command line
|
5
|
+
|
6
|
+
### Setup
|
7
|
+
* Clone this repo.
|
8
|
+
* Make sure the `rb` script has execution permissions by running `chmod +x rb` if necessary.
|
9
|
+
* Make sure the `rb` script is accessible in one of the execution paths in your `$PATH`. More information can be found [here](http://stackoverflow.com/questions/1234424/add-a-single-bash-command).
|
10
|
+
|
11
|
+
### Examples
|
12
|
+
`ping www.google.com | rb 'lines.include?("time=").split("time=")[1].puts.each'`
|
13
|
+
|
14
|
+
`echo -e '1\n5\n3\n7\n' | rb 'puts lines.to_i.take(3).inject(:+)'`
|
15
|
+
|
16
|
+
`rb 'lines.upcase.take_while{|l| !l.include?("QUIT")}.puts.each'`
|
17
|
+
|
18
|
+
`rb 'doing{rand(1..6)}.print.each'`
|
data/bin/rb
ADDED
data/img/logo200.jpg
ADDED
Binary file
|
data/lib/doing.rb
ADDED
@@ -0,0 +1,67 @@
|
|
1
|
+
module Doing
|
2
|
+
def doing(stop_value = nil, &producer)
|
3
|
+
enumerator = Enumerator.new do |yielder|
|
4
|
+
loop do
|
5
|
+
value = producer.call
|
6
|
+
break if value.eql? stop_value
|
7
|
+
yielder.yield value
|
8
|
+
end
|
9
|
+
end
|
10
|
+
|
11
|
+
FluentEnumerator.new(enumerator)
|
12
|
+
end
|
13
|
+
|
14
|
+
private
|
15
|
+
class FluentEnumerator
|
16
|
+
def initialize(base_enumerator)
|
17
|
+
@enum = Enumerator::Lazy.new(base_enumerator) do |yielder, *values|
|
18
|
+
yielder.yield *values
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
def next
|
23
|
+
@enum.next
|
24
|
+
end
|
25
|
+
|
26
|
+
def each(&block)
|
27
|
+
block ||= Proc.new{}
|
28
|
+
@enum.each(&block)
|
29
|
+
end
|
30
|
+
|
31
|
+
def inject(*args, &block)
|
32
|
+
@enum.send(:inject, *args, &block)
|
33
|
+
end
|
34
|
+
|
35
|
+
def select(*args, &block)
|
36
|
+
self.class.new(@enum.send(:select, *args, &block))
|
37
|
+
end
|
38
|
+
|
39
|
+
def map(*args, &block)
|
40
|
+
self.class.new(@enum.send(:map, *args, &block))
|
41
|
+
end
|
42
|
+
|
43
|
+
def take(*args, &block)
|
44
|
+
self.class.new(@enum.send(:take, *args, &block))
|
45
|
+
end
|
46
|
+
|
47
|
+
def take_while(*args, &block)
|
48
|
+
self.class.new(@enum.send(:take_while, *args, &block))
|
49
|
+
end
|
50
|
+
|
51
|
+
def method_missing(method, *args, &block)
|
52
|
+
return select{|e| e.send(method, *args, &block)} if predicate?(method)
|
53
|
+
map do |e|
|
54
|
+
if e.respond_to?(method)
|
55
|
+
e.send(method, *args, &block)
|
56
|
+
else
|
57
|
+
Kernel.send(method, *args.clone.unshift(e), &block)
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
62
|
+
private
|
63
|
+
def predicate?(method)
|
64
|
+
method.to_s.end_with?("?")
|
65
|
+
end
|
66
|
+
end
|
67
|
+
end
|
data/tourmaline.gemspec
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
|
5
|
+
Gem::Specification.new do |gem|
|
6
|
+
gem.name = "tourmaline"
|
7
|
+
gem.version = "0.1.1"
|
8
|
+
gem.authors = ["Mateu Adsuara"]
|
9
|
+
gem.email = ["mateuadsuara@gmail.com"]
|
10
|
+
|
11
|
+
gem.summary = %q{A configurable ruby interpreter for the command line}
|
12
|
+
gem.homepage = "https://github.com/demonh3x/tourmaline"
|
13
|
+
gem.license = "MIT"
|
14
|
+
|
15
|
+
gem.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
16
|
+
gem.bindir = "bin"
|
17
|
+
gem.executables = ["rb"]
|
18
|
+
gem.require_paths = ["lib"]
|
19
|
+
|
20
|
+
gem.add_development_dependency "rspec"
|
21
|
+
end
|
metadata
ADDED
@@ -0,0 +1,66 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: tourmaline
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Mateu Adsuara
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2015-09-14 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: rspec
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
27
|
+
description:
|
28
|
+
email:
|
29
|
+
- mateuadsuara@gmail.com
|
30
|
+
executables:
|
31
|
+
- rb
|
32
|
+
extensions: []
|
33
|
+
extra_rdoc_files: []
|
34
|
+
files:
|
35
|
+
- LICENSE
|
36
|
+
- README.md
|
37
|
+
- bin/rb
|
38
|
+
- img/logo200.jpg
|
39
|
+
- lib/doing.rb
|
40
|
+
- tourmaline.gemspec
|
41
|
+
homepage: https://github.com/demonh3x/tourmaline
|
42
|
+
licenses:
|
43
|
+
- MIT
|
44
|
+
metadata: {}
|
45
|
+
post_install_message:
|
46
|
+
rdoc_options: []
|
47
|
+
require_paths:
|
48
|
+
- lib
|
49
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
50
|
+
requirements:
|
51
|
+
- - ">="
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
version: '0'
|
54
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
55
|
+
requirements:
|
56
|
+
- - ">="
|
57
|
+
- !ruby/object:Gem::Version
|
58
|
+
version: '0'
|
59
|
+
requirements: []
|
60
|
+
rubyforge_project:
|
61
|
+
rubygems_version: 2.4.6
|
62
|
+
signing_key:
|
63
|
+
specification_version: 4
|
64
|
+
summary: A configurable ruby interpreter for the command line
|
65
|
+
test_files: []
|
66
|
+
has_rdoc:
|