irsh 0.2.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.
Files changed (4) hide show
  1. checksums.yaml +7 -0
  2. data/bin/irsh +8 -0
  3. data/lib/shell.rb +71 -0
  4. metadata +47 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 7e4da2bf963bd703c377995330ca5a780acf5098
4
+ data.tar.gz: 474ecff12fdf172315917a1967c542e09d47affb
5
+ SHA512:
6
+ metadata.gz: 2ea47dfdeec69069315179b36e1d237bb39edd85d0db6663bc150b0d903267c90b78773a77f8409adff9cbca69bf3e07fcd75be8201659339bd8a56b46d8703a
7
+ data.tar.gz: c22f8f11b0d1c1cca48fec64a25d91709456cadaa13aee5422aadd41a8ea7d45782831fab1fdcf59570bad77f337cfe41e06ca741487f90e62adc0a565edfb29
data/bin/irsh ADDED
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require File.dirname(__FILE__) + '/../lib/shell'
4
+ #require_relative '../lib/shell'
5
+
6
+ shell = Irsh::Shell.new
7
+
8
+ shell.init
data/lib/shell.rb ADDED
@@ -0,0 +1,71 @@
1
+ require 'readline'
2
+
3
+ module Irsh
4
+ class Shell
5
+ def runliteral
6
+ loop do
7
+ cmd = Readline.readline("ir$h> ")
8
+ exittime if cmd.nil? or cmd == "exit"
9
+ next if cmd == ""
10
+ Readline::HISTORY.push(cmd)
11
+ handleliteral(cmd)
12
+ end
13
+ end
14
+
15
+ def runoop
16
+ loop do
17
+ cmd = Readline.readline("iRsh> ")
18
+ exittime if cmd.nil? or cmd == "exit"
19
+ next if cmd == ""
20
+ Readline::HISTORY.push(cmd)
21
+ handleoop(cmd)
22
+ end
23
+ end
24
+
25
+ def init
26
+ @binding = binding
27
+ runliteral
28
+ end
29
+
30
+ def exittime
31
+ #write stuff to file maybe?
32
+ exit
33
+ end
34
+
35
+ def handleliteral(cmd)
36
+ rawcmd = cmd.split(' ')[0]
37
+ args = cmd.split(' ')[1..-1].join(' ')
38
+ case rawcmd
39
+ when "$irsh"
40
+ runoop
41
+ when "cd"
42
+ Dir.chdir(args)
43
+ #puts "CDAH"
44
+ #when "pwd"
45
+ #puts "PWDEE"
46
+ else
47
+ #puts "stuff"
48
+ puts `#{cmd}`
49
+ end
50
+ end
51
+
52
+ def handleoop(cmd)
53
+ runliteral if cmd.split(' ')[0] == "$irsh"
54
+ res = eval(cmd, @binding)
55
+ $last_res = res
56
+ eval("_ = $last_res", @binding)
57
+ #print_result res
58
+ puts res
59
+ #rescue Rush::Exception => e
60
+ #puts "Exception #{e.class} -> #{e.message}"
61
+ rescue ::Exception => e
62
+ puts "Exception #{e.class} -> #{e.message}"
63
+ e.backtrace.each do |t|
64
+ puts " #{::File.expand_path(t)}"
65
+ end
66
+ end
67
+ end
68
+ end
69
+
70
+ #puts Dir.pwd
71
+ #runliteral
metadata ADDED
@@ -0,0 +1,47 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: irsh
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.2.0
5
+ platform: ruby
6
+ authors:
7
+ - Havear
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-06-11 00:00:00.000000000 Z
12
+ dependencies: []
13
+ description: Shell written in ruby with a bash-like "literal" mode and an "oop" mode
14
+ that accepts Ruby code.
15
+ email: haveargamer@yahoo.com
16
+ executables:
17
+ - irsh
18
+ extensions: []
19
+ extra_rdoc_files: []
20
+ files:
21
+ - bin/irsh
22
+ - lib/shell.rb
23
+ homepage: https://rubygems.org/gems/irsh
24
+ licenses:
25
+ - MIT
26
+ metadata: {}
27
+ post_install_message:
28
+ rdoc_options: []
29
+ require_paths:
30
+ - lib
31
+ required_ruby_version: !ruby/object:Gem::Requirement
32
+ requirements:
33
+ - - ">="
34
+ - !ruby/object:Gem::Version
35
+ version: '0'
36
+ required_rubygems_version: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ requirements: []
42
+ rubyforge_project:
43
+ rubygems_version: 2.2.2
44
+ signing_key:
45
+ specification_version: 4
46
+ summary: Interactive Ruby Shell
47
+ test_files: []