arsh 1.0.1 → 1.0.4

Sign up to get free protection for your applications and to get access to all the features.
data/bin/arsh CHANGED
@@ -1,5 +1,6 @@
1
1
  #!/usr/bin/env ruby
2
2
  ARSH_INSTALL_PATH=File.expand_path("../../",__FILE__)
3
+ require 'rubygems'
3
4
  require 'rb-readline'
4
5
 
5
6
  Dir.glob("#{ARSH_INSTALL_PATH}/libs/*.rb").each { |mod| load(mod) }
@@ -115,7 +116,7 @@ end
115
116
  # Load rbshrc's
116
117
  ["/etc/arshrc","#{ENV['HOME']}/.arshrc"].each do |arshrc|
117
118
  File.open(arshrc,"r").readlines.each do |line|
118
- ArshCommands.parseinput(line) if line != ""
119
+ ArshCommands.ruby_eval(line,false) if line != ""
119
120
  end if File.exist?(arshrc)
120
121
  end
121
122
 
@@ -0,0 +1,34 @@
1
+ #!/usr/bin/env ruby
2
+ arsh = []
3
+ ruby = "#!" + ENV['MY_RUBY_HOME'] + "/bin/ruby"
4
+ gem_path = ENV['GEM_PATH']
5
+ ENV['PATH'].split(':').each do |path|
6
+ Dir.glob("#{path}/arsh").each { |a| arsh << File.expand_path(a) }
7
+ end
8
+
9
+ if arsh.count > 1
10
+ puts "Duplicate entries found, which number you like to edit?\n\n"
11
+ 0.upto(arsh.count - 1) do |elem|
12
+ puts "[#{elem}] #{arsh[elem]}"
13
+ end
14
+ edit = ""
15
+ until edit =~ /[0-9]+/
16
+ print "\nChoice: "
17
+ STDOUT.flush
18
+ edit = gets
19
+ unless edit =~ /[0-9]+/
20
+ puts "Invalid selection"
21
+ end
22
+ end
23
+ edit = edit.chomp.to_i
24
+ else
25
+ edit = 0
26
+ end
27
+
28
+ unless arsh.empty?
29
+ file = File.open(arsh[edit]).readlines
30
+ file[0] = ruby + "\n" + "ENV['GEM_PATH']='#{gem_path}'\n"
31
+ File.open(arsh[edit],"w") { |f| f.puts file }
32
+ else
33
+ puts "No arsh binaries found in your PATH"
34
+ end
@@ -1,29 +1,37 @@
1
1
  # Evaluate ruby code typed into command line. Allow multiple lines of code before evaluting blcoks.
2
2
  module ArshCommands
3
- @rubyeval_proc = Proc.new {}
4
- @rubyeval_indent = 0
5
- @rubyeval_history = Array.new
6
- def self.rubyeval_indent
7
- return @rubyeval_indent
8
- end
9
- def self.ruby_eval(input)
10
- # keywords that start a block
11
- start_strings = ["class,","module","def","do","{","("]
12
- # Keywords that end a block
13
- end_strings = ["end","}",")"]
14
- # Add last line typed to
15
- @rubyeval_history << input
16
- start_strings.each {|string| @rubyeval_indent += 1 if input.include? string}
17
- end_strings.each {|string| @rubyeval_indent -=1 if input.include? string}
18
- #input.strip.each(" ") {|string| @rubyeval_indent += 1 if start_strings.include? string }
19
- #input.strip.each(" ") {|string| @rubyeval_indent -= 1 if end_strings.include? string }
20
- if @rubyeval_indent <= 0
21
- @rubyeval_indent = 0
3
+ @rubyeval_proc = Proc.new {}
4
+ @rubyeval_indent = 0
5
+ @rubyeval_history = Array.new
6
+ def self.rubyeval_indent
7
+ return @rubyeval_indent
8
+ end
9
+ def self.ruby_eval(input,blocks=true)
10
+ if blocks
11
+ # keywords that start a block
12
+ start_strings = ["class,","module","def","do","{","("]
13
+ # Keywords that end a block
14
+ end_strings = ["end","}",")"]
15
+ # Add last line typed to
16
+ @rubyeval_history << input
17
+ start_strings.each {|string| @rubyeval_indent += 1 if input.include? string}
18
+ end_strings.each {|string| @rubyeval_indent -=1 if input.include? string}
19
+ #input.strip.each(" ") {|string| @rubyeval_indent += 1 if start_strings.include? string }
20
+ #input.strip.each(" ") {|string| @rubyeval_indent -= 1 if end_strings.include? string }
21
+ if @rubyeval_indent <= 0
22
+ @rubyeval_indent = 0
23
+ begin
24
+ eval(@rubyeval_history.join("\n"),@rubyeval_proc.binding)
25
+ @rubyeval_history = Array.new
26
+ rescue ScriptError, StandardError
27
+ @rubyeval_history = Array.new
28
+ puts "#{$!}"
29
+ end
30
+ end
31
+ else
22
32
  begin
23
- eval(@rubyeval_history.join("\n"),@rubyeval_proc.binding)
24
- @rubyeval_history = Array.new
33
+ eval(input,@rubyeval_proc.binding)
25
34
  rescue ScriptError, StandardError
26
- @rubyeval_history = Array.new
27
35
  puts "#{$!}"
28
36
  end
29
37
  end
@@ -1,3 +1,3 @@
1
1
  module Arsh
2
- VERSION = "1.0.1"
2
+ VERSION = "1.0.4"
3
3
  end
@@ -0,0 +1,7 @@
1
+ module ArshCommands
2
+ def self.config_rvm
3
+ ENV['PATH'].each do |p|
4
+
5
+ end
6
+ end
7
+ end
@@ -6,11 +6,11 @@
6
6
  # The ArshCommands module holds all internal commands.
7
7
  module ArshCommands
8
8
  def self.lsa(args = "")
9
- directories = Dir.entries("#{Dir.pwd}").sort
9
+ directories = Dir.entries("#{Dir.pwd}").sort
10
10
  directories.delete_if { |x| x =~ /^\./ unless args.include?("-a") }
11
11
  directories.map! { |x| "#{("0x"+File.stat(x).mode.to_s)} #{File.stat(x).uid} #{File.stat(x).gid} #{File.stat(x).mtime} #{x} "} if args.include?("-l")
12
- return directories
13
- end
12
+ return directories
13
+ end
14
14
  def self.lsx(args) # Each command is a method.
15
15
  puts self.lsa(args)
16
16
  end
metadata CHANGED
@@ -1,70 +1,97 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: arsh
3
- version: !ruby/object:Gem::Version
4
- version: 1.0.1
3
+ version: !ruby/object:Gem::Version
4
+ hash: 68939834360191079
5
5
  prerelease:
6
+ segments:
7
+ - 1
8
+ - 0
9
+ - 4
10
+ version: 1.0.4
6
11
  platform: ruby
7
- authors:
12
+ authors:
8
13
  - James Paterni
9
14
  - Brian Faga
10
15
  - Eugene Howe
11
16
  autorequire:
12
17
  bindir: bin
13
18
  cert_chain: []
14
- date: 2011-12-22 00:00:00.000000000Z
15
- dependencies:
16
- - !ruby/object:Gem::Dependency
19
+
20
+ date: 2011-12-23 00:00:00 -05:00
21
+ default_executable:
22
+ dependencies:
23
+ - !ruby/object:Gem::Dependency
17
24
  name: rb-readline
18
- requirement: &9188080 !ruby/object:Gem::Requirement
25
+ prerelease: false
26
+ requirement: &id001 !ruby/object:Gem::Requirement
19
27
  none: false
20
- requirements:
21
- - - ! '>='
22
- - !ruby/object:Gem::Version
23
- version: '0'
28
+ requirements:
29
+ - - ">="
30
+ - !ruby/object:Gem::Version
31
+ hash: 2002549777813010636
32
+ segments:
33
+ - 0
34
+ version: "0"
24
35
  type: :runtime
25
- prerelease: false
26
- version_requirements: *9188080
27
- description: Provides a shell that can run pure Ruby code as well as ordinary linux
28
- commands.
29
- email:
36
+ version_requirements: *id001
37
+ description: Provides a shell that can run pure Ruby code as well as ordinary linux commands.
38
+ email:
30
39
  - james@ruby-code.com
31
40
  - eugene@xtreme-computers.net
32
- executables:
41
+ executables:
33
42
  - arsh
43
+ - arsh_configure_for_rvm
34
44
  extensions: []
45
+
35
46
  extra_rdoc_files: []
36
- files:
47
+
48
+ files:
49
+ - bin/arsh_configure_for_rvm
37
50
  - bin/arsh
38
51
  - plugins/ls.rb
39
52
  - plugins/history.rb
53
+ - plugins/config_rvm.rb
40
54
  - libs/replacestring.rb
41
55
  - libs/compat.rb
42
56
  - libs/rubyeval.rb
43
57
  - libs/cd.rb
44
58
  - libs/alias.rb
45
59
  - libs/version.rb
60
+ has_rdoc: true
46
61
  homepage: http://github.com/jamez01/arsh
47
62
  licenses: []
63
+
48
64
  post_install_message:
49
65
  rdoc_options: []
50
- require_paths:
66
+
67
+ require_paths:
51
68
  - lib
52
- required_ruby_version: !ruby/object:Gem::Requirement
69
+ required_ruby_version: !ruby/object:Gem::Requirement
53
70
  none: false
54
- requirements:
55
- - - ! '>='
56
- - !ruby/object:Gem::Version
57
- version: '0'
58
- required_rubygems_version: !ruby/object:Gem::Requirement
71
+ requirements:
72
+ - - ">="
73
+ - !ruby/object:Gem::Version
74
+ hash: 2002549777813010636
75
+ segments:
76
+ - 0
77
+ version: "0"
78
+ required_rubygems_version: !ruby/object:Gem::Requirement
59
79
  none: false
60
- requirements:
61
- - - ! '>='
62
- - !ruby/object:Gem::Version
80
+ requirements:
81
+ - - ">="
82
+ - !ruby/object:Gem::Version
83
+ hash: 2387630629434237851
84
+ segments:
85
+ - 1
86
+ - 3
87
+ - 6
63
88
  version: 1.3.6
64
89
  requirements: []
90
+
65
91
  rubyforge_project:
66
- rubygems_version: 1.8.10
92
+ rubygems_version: 1.5.2
67
93
  signing_key:
68
94
  specification_version: 3
69
95
  summary: Linux shell implemented in pure Ruby
70
96
  test_files: []
97
+