wat-shell 0.0.1
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 +9 -0
- data/.travis.yml +4 -0
- data/Gemfile +3 -0
- data/LICENSE +21 -0
- data/README.md +65 -0
- data/Rakefile +6 -0
- data/exe/wat +40 -0
- data/lib/wat-shell.rb +33 -0
- data/wat-shell.gemspec +24 -0
- metadata +95 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 3181ff45a39343d30d6a546cd7ca92f771cc3e20
|
4
|
+
data.tar.gz: 3f09cf799c7aa60922d48a51a69eb8ef1f472448
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 443dae56b2bdd206fe2a01f4c2e26d4b406c481af5cc1b8bd6a080b232be72bf44c004c57333f794ab12e7e723ff5142a7e6210ef5db62dd3bfc76b0cd3c53d1
|
7
|
+
data.tar.gz: 1b66c91a613ab7e7c15966330aec57ff3ba45e545c26cf364dcd9b8707ec8ee2b19fbff208c92052561b7cfa6afb2ceaae61363fc5a2558e873040707705065a
|
data/.gitignore
ADDED
data/.travis.yml
ADDED
data/Gemfile
ADDED
data/LICENSE
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2016 Nick Johnstone
|
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.
|
data/README.md
ADDED
@@ -0,0 +1,65 @@
|
|
1
|
+
# wat-shell
|
2
|
+
Replace Bash with Ruby, because why not?
|
3
|
+
|
4
|
+
`wat` is a shell built on top of Ruby. It provides easy access to bash commands like `cat`, `git` and `wget`. The output is returned as an array of lines, so you can intermix ruby and a limited form of bash.
|
5
|
+
|
6
|
+
Installation
|
7
|
+
---
|
8
|
+
|
9
|
+
```bash
|
10
|
+
$ gem install wat-shell
|
11
|
+
```
|
12
|
+
|
13
|
+
Interactive wat shell
|
14
|
+
---
|
15
|
+
|
16
|
+
To start the `wat` repl, simply run `wat`.
|
17
|
+
|
18
|
+
```bash
|
19
|
+
$ wat
|
20
|
+
wat(main):001:0>
|
21
|
+
```
|
22
|
+
|
23
|
+
This is a version of `irb` with `wat-shell` included.
|
24
|
+
|
25
|
+
```ruby
|
26
|
+
wat(main):001:0> cat(LICENSE).sample
|
27
|
+
=> "IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,"
|
28
|
+
wat(main):002:0> puts git log --oneline
|
29
|
+
47ffa5a Rename wat.rb executable to wat
|
30
|
+
90acaa2 Support "cat LICENSE" by implementing const_missing
|
31
|
+
4f2701c Execute wat-shell scripts with exe/wat script.rb
|
32
|
+
a7369e9 Set up wat with interpreter
|
33
|
+
a7a2f80 Initial commit
|
34
|
+
=> nil
|
35
|
+
wat(main):003:0>
|
36
|
+
```
|
37
|
+
|
38
|
+
Scripting with wat
|
39
|
+
---
|
40
|
+
|
41
|
+
And of course, what shell wouldn't be complete without the ability to execute files?
|
42
|
+
|
43
|
+
If we create a file, `test.rb`, with this content:
|
44
|
+
```ruby
|
45
|
+
puts du('-sh .').first
|
46
|
+
```
|
47
|
+
|
48
|
+
We can run it like so:
|
49
|
+
|
50
|
+
```bash
|
51
|
+
$ wat test.rb
|
52
|
+
344K .
|
53
|
+
```
|
54
|
+
|
55
|
+
You can't be serious?
|
56
|
+
---
|
57
|
+
|
58
|
+
I'm not. This is a joke! Please don't use it for anything serious.
|
59
|
+
|
60
|
+
|
61
|
+
How on earth?
|
62
|
+
---
|
63
|
+
I overload `method_missing` to shell out if a command exists, or to return a string otherwise.
|
64
|
+
|
65
|
+
Check out the code. It's short and nasty.
|
data/Rakefile
ADDED
data/exe/wat
ADDED
@@ -0,0 +1,40 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
$LOAD_PATH.unshift File.expand_path('../../lib', __FILE__)
|
3
|
+
require 'wat-shell'
|
4
|
+
|
5
|
+
require 'irb'
|
6
|
+
|
7
|
+
def run
|
8
|
+
STDOUT.sync = true
|
9
|
+
|
10
|
+
IRB.setup(nil)
|
11
|
+
|
12
|
+
irb = IRB::Irb.new
|
13
|
+
|
14
|
+
IRB.conf[:MAIN_CONTEXT] = irb.context
|
15
|
+
irb.context.irb_name = 'wat'
|
16
|
+
|
17
|
+
Wat.included(irb.context.main)
|
18
|
+
|
19
|
+
trap("SIGINT") do
|
20
|
+
irb.signal_handle
|
21
|
+
end
|
22
|
+
|
23
|
+
begin
|
24
|
+
catch(:IRB_EXIT) do
|
25
|
+
irb.eval_input
|
26
|
+
end
|
27
|
+
ensure
|
28
|
+
irb_at_exit
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
if ARGV.size > 0
|
33
|
+
Wat.included(self)
|
34
|
+
|
35
|
+
path_to_load = File.join(Dir.pwd, ARGV.shift)
|
36
|
+
|
37
|
+
require path_to_load
|
38
|
+
else
|
39
|
+
run
|
40
|
+
end
|
data/lib/wat-shell.rb
ADDED
@@ -0,0 +1,33 @@
|
|
1
|
+
module Wat
|
2
|
+
VERSION = '0.0.1'
|
3
|
+
|
4
|
+
def self.included(base)
|
5
|
+
base.instance_eval do
|
6
|
+
def respond_to_missing?(method, *args)
|
7
|
+
`which #{method}` != ""
|
8
|
+
end
|
9
|
+
|
10
|
+
def method_missing(method, *args)
|
11
|
+
if respond_to_missing?(method, *args)
|
12
|
+
`#{method} #{args.join(' ')}`.split("\n")
|
13
|
+
else
|
14
|
+
[method, *args].join(' ')
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
def Object.const_missing(const)
|
19
|
+
const.to_s
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
class String
|
26
|
+
def -@
|
27
|
+
"-#{self}"
|
28
|
+
end
|
29
|
+
|
30
|
+
def /(other)
|
31
|
+
[self, other].join()
|
32
|
+
end
|
33
|
+
end
|
data/wat-shell.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 'wat-shell'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "wat-shell"
|
8
|
+
spec.version = Wat::VERSION
|
9
|
+
spec.authors = ["Nick Johnstone"]
|
10
|
+
spec.email = ["ncwjohnstone@gmail.com"]
|
11
|
+
|
12
|
+
spec.summary = %q{Replace Ruby with Bash, because why not?}
|
13
|
+
spec.description = %q{Inspired by Gary Bernhardt's excellent wat talk.}
|
14
|
+
spec.homepage = "https://github.com/Widdershin/wat-shell"
|
15
|
+
|
16
|
+
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
17
|
+
spec.bindir = "exe"
|
18
|
+
spec.executables = ["wat"]
|
19
|
+
spec.require_paths = ["lib"]
|
20
|
+
|
21
|
+
spec.add_development_dependency "bundler", "~> 1.10"
|
22
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
23
|
+
spec.add_development_dependency "minitest"
|
24
|
+
end
|
metadata
ADDED
@@ -0,0 +1,95 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: wat-shell
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Nick Johnstone
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2016-02-17 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.10'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.10'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '10.0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '10.0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: minitest
|
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: Inspired by Gary Bernhardt's excellent wat talk.
|
56
|
+
email:
|
57
|
+
- ncwjohnstone@gmail.com
|
58
|
+
executables:
|
59
|
+
- wat
|
60
|
+
extensions: []
|
61
|
+
extra_rdoc_files: []
|
62
|
+
files:
|
63
|
+
- ".gitignore"
|
64
|
+
- ".travis.yml"
|
65
|
+
- Gemfile
|
66
|
+
- LICENSE
|
67
|
+
- README.md
|
68
|
+
- Rakefile
|
69
|
+
- exe/wat
|
70
|
+
- lib/wat-shell.rb
|
71
|
+
- wat-shell.gemspec
|
72
|
+
homepage: https://github.com/Widdershin/wat-shell
|
73
|
+
licenses: []
|
74
|
+
metadata: {}
|
75
|
+
post_install_message:
|
76
|
+
rdoc_options: []
|
77
|
+
require_paths:
|
78
|
+
- lib
|
79
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
80
|
+
requirements:
|
81
|
+
- - ">="
|
82
|
+
- !ruby/object:Gem::Version
|
83
|
+
version: '0'
|
84
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
85
|
+
requirements:
|
86
|
+
- - ">="
|
87
|
+
- !ruby/object:Gem::Version
|
88
|
+
version: '0'
|
89
|
+
requirements: []
|
90
|
+
rubyforge_project:
|
91
|
+
rubygems_version: 2.2.5
|
92
|
+
signing_key:
|
93
|
+
specification_version: 4
|
94
|
+
summary: Replace Ruby with Bash, because why not?
|
95
|
+
test_files: []
|