srbc 0.0.9 → 0.0.10
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile +5 -5
- data/README.md +62 -64
- data/lib/srbc.rb +1 -1
- data/lib/srbc/srbc_cli.rb +115 -116
- data/lib/srbc/srbc_command.rb +78 -75
- data/lib/srbc/version.rb +3 -3
- data/srbc.gemspec +1 -1
- data/test/srbc_command_spec.rb +15 -15
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 31a55f421d86435e6abcf0cab465ec9415c02c3b
|
4
|
+
data.tar.gz: e89a7b022205a789d549cd2ec0a76676476bb689
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 56ff100575c15513a35d11ca0c8660cc281e71b6f14e60c524d947d074bd6f2a5f9d760de19d126190d9a9776e9695ed6114eaa9cbbb0ef2112dfc345918f8d5
|
7
|
+
data.tar.gz: 8497e8275dcbc4fa098f59c2eebd36dd4577dc9ded7824893bd060610318a88fcbaf1a176645af8a43981c2611221630aa4525cf0914d075878abebf7632960b
|
data/Gemfile
CHANGED
@@ -1,5 +1,5 @@
|
|
1
|
-
source 'https://rubygems.org'
|
2
|
-
|
3
|
-
# Specify your gem's dependencies in srbc.gemspec
|
4
|
-
gemspec
|
5
|
-
gem 'rspec'
|
1
|
+
source 'https://rubygems.org'
|
2
|
+
|
3
|
+
# Specify your gem's dependencies in srbc.gemspec
|
4
|
+
gemspec
|
5
|
+
gem 'rspec'
|
data/README.md
CHANGED
@@ -1,64 +1,62 @@
|
|
1
|
-
# Srbc
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
4. Push to the branch (`git push origin my-new-feature`)
|
64
|
-
5. Create a new Pull Request
|
1
|
+
# Srbc
|
2
|
+
SmartRuByConsole its executable gem for simple runing gem scripts.
|
3
|
+
|
4
|
+
You can run *.rb files, or other in ruby, just type "main" to execute "ruby main.rb".
|
5
|
+
|
6
|
+
If in folder same files contains "main" (for example main_foo.rb, main_bar.rb and main.rb) SRBC ask you what file run.
|
7
|
+
|
8
|
+
When SRBC run, default MS symbol in console > replace with~. Every line will start with R : R - is first letter of current executor.
|
9
|
+
|
10
|
+
You can use other executor. Run "srbc -add:cucumber" to add new executor. Then run "srbc -cucumber" to start Smart Ruby Console with cucumber executor.
|
11
|
+
|
12
|
+
## Installation
|
13
|
+
|
14
|
+
Add this line to your application's Gemfile:
|
15
|
+
|
16
|
+
gem 'srbc'
|
17
|
+
|
18
|
+
And then execute:
|
19
|
+
|
20
|
+
$ bundle
|
21
|
+
|
22
|
+
Or install it yourself as:
|
23
|
+
|
24
|
+
$ gem install srbc
|
25
|
+
|
26
|
+
## Usage
|
27
|
+
|
28
|
+
Arguments:
|
29
|
+
|
30
|
+
-add:<exexutor> add executor
|
31
|
+
-<executor> run with executor
|
32
|
+
-help for this help
|
33
|
+
-list list of executors
|
34
|
+
no arguments run ruby executor
|
35
|
+
|
36
|
+
|
37
|
+
Comands:
|
38
|
+
|
39
|
+
shortcut command description
|
40
|
+
_________________________________________________
|
41
|
+
| @h | @help | this help |
|
42
|
+
| @l | @list | extension list |
|
43
|
+
| @e | @exit | exit from app |
|
44
|
+
| -- | @add "*.rb" | add extension |
|
45
|
+
| @c | @current | current executor |
|
46
|
+
| -- | @#<executor> | hot change executor |
|
47
|
+
| | | if executor not exits |
|
48
|
+
| | | will created new |
|
49
|
+
| -- | @delete <exc>| delete executor |
|
50
|
+
| -- | !<command> | run program. use when |
|
51
|
+
| | | have same name programm |
|
52
|
+
| | | and file, like pnig.rb |
|
53
|
+
__________________________________________________
|
54
|
+
|
55
|
+
|
56
|
+
## Contributing
|
57
|
+
|
58
|
+
1. Fork it ( https://github.com/[my-github-username]/srbc/fork )
|
59
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
60
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
61
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
62
|
+
5. Create a new Pull Request
|
data/lib/srbc.rb
CHANGED
data/lib/srbc/srbc_cli.rb
CHANGED
@@ -1,117 +1,116 @@
|
|
1
|
-
#-*- coding:utf-8 -*-
|
2
|
-
|
3
|
-
module SRBC_cli
|
4
|
-
# contain commandline inetfeice
|
5
|
-
# and detect SRBC command execute, file or system programm
|
6
|
-
|
7
|
-
def run()
|
8
|
-
|
9
|
-
if @settings[@executor].nil?
|
10
|
-
puts "\n Executor not defined. Run srbc with -add:<executor> options "
|
11
|
-
self.runed = false
|
12
|
-
else
|
13
|
-
@ext = @settings[@executor]
|
14
|
-
end
|
15
|
-
|
16
|
-
while self.lunched do
|
17
|
-
#get current path
|
18
|
-
path = Dir.pwd
|
19
|
-
#wait command and realise history of command
|
20
|
-
command = Readline.readline("#{@executor.chr.upcase}# #{path.gsub "/", "\\"}~ ", true)
|
21
|
-
command = nil if command.nil?
|
22
|
-
if command =~ /^\s*$/ or Readline::HISTORY.to_a[-2] == command
|
23
|
-
Readline::HISTORY.pop
|
24
|
-
end
|
25
|
-
|
26
|
-
cmd = command.gsub("#{path}~ ", '')
|
27
|
-
|
28
|
-
|
29
|
-
#if user type command start with @ - run srbc command
|
30
|
-
if cmd =~ /^@/
|
31
|
-
self.srbc_command cmd.gsub "@", ""
|
32
|
-
elsif cmd == ''
|
33
|
-
cmd = ' '
|
34
|
-
else
|
35
|
-
|
36
|
-
case cmd.downcase
|
37
|
-
|
38
|
-
# command cd - SRBC change current work dir
|
39
|
-
when /cd/
|
40
|
-
|
41
|
-
if cmd =~ /\.\./ || cmd =~/^cd$/
|
42
|
-
temp_path = Dir.pwd.split '/'
|
43
|
-
if temp_path.length > 1
|
44
|
-
temp_path.delete_at temp_path.length-1
|
45
|
-
if temp_path.length > 1
|
46
|
-
path = temp_path.join "\\"
|
47
|
-
Dir.chdir path
|
48
|
-
else
|
49
|
-
Dir.chdir "#{temp_path[0]}\\"
|
50
|
-
end
|
51
|
-
end
|
52
|
-
else
|
53
|
-
begin
|
54
|
-
Dir.chdir cmd.gsub 'cd ', ''
|
55
|
-
rescue
|
56
|
-
puts 'Wrong path'
|
57
|
-
end
|
58
|
-
end
|
59
|
-
|
60
|
-
# command X: change current work dir if user whant change volume
|
61
|
-
when /^\w:$/
|
62
|
-
begin
|
63
|
-
Dir.chdir cmd
|
64
|
-
rescue
|
65
|
-
puts "Path not found"
|
66
|
-
end
|
67
|
-
|
68
|
-
#run with skip executor.
|
69
|
-
# Use when you whant execute system command ping and have ping.rb un current folder
|
70
|
-
when /^\!/
|
71
|
-
run_program cmd.gsub '!',''
|
72
|
-
|
73
|
-
# run app or other program
|
74
|
-
when /^$|^ *$/
|
75
|
-
#skip when empty command
|
76
|
-
else
|
77
|
-
|
78
|
-
file_list = self.get_file_list cmd
|
79
|
-
|
80
|
-
#run file if find only one
|
81
|
-
if file_list.length == 1
|
82
|
-
file_list.each do |name, args|
|
83
|
-
run_file name, args
|
84
|
-
end
|
85
|
-
|
86
|
-
# не найдено фалов - значит команда
|
87
|
-
elsif file_list.length == 0
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
i
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
num_file
|
105
|
-
|
106
|
-
|
107
|
-
num_file
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
end
|
1
|
+
#-*- coding:utf-8 -*-
|
2
|
+
|
3
|
+
module SRBC_cli
|
4
|
+
# contain commandline inetfeice
|
5
|
+
# and detect SRBC command execute, file or system programm
|
6
|
+
|
7
|
+
def run()
|
8
|
+
|
9
|
+
if @settings[@executor].nil?
|
10
|
+
puts "\n Executor not defined. Run srbc with -add:<executor> options "
|
11
|
+
self.runed = false
|
12
|
+
else
|
13
|
+
@ext = @settings[@executor]
|
14
|
+
end
|
15
|
+
|
16
|
+
while self.lunched do
|
17
|
+
#get current path
|
18
|
+
path = Dir.pwd
|
19
|
+
#wait command and realise history of command
|
20
|
+
command = Readline.readline("#{@executor.chr.upcase}# #{path.gsub "/", "\\"}~ ", true)
|
21
|
+
command = nil if command.nil?
|
22
|
+
if command =~ /^\s*$/ or Readline::HISTORY.to_a[-2] == command
|
23
|
+
Readline::HISTORY.pop
|
24
|
+
end
|
25
|
+
|
26
|
+
cmd = command.gsub("#{path}~ ", '')
|
27
|
+
|
28
|
+
|
29
|
+
#if user type command start with @ - run srbc command
|
30
|
+
if cmd =~ /^@/
|
31
|
+
self.srbc_command cmd.gsub "@", ""
|
32
|
+
elsif cmd == ''
|
33
|
+
cmd = ' '
|
34
|
+
else
|
35
|
+
|
36
|
+
case cmd.downcase
|
37
|
+
|
38
|
+
# command cd - SRBC change current work dir
|
39
|
+
when /cd/
|
40
|
+
|
41
|
+
if cmd =~ /\.\./ || cmd =~/^cd$/
|
42
|
+
temp_path = Dir.pwd.split '/'
|
43
|
+
if temp_path.length > 1
|
44
|
+
temp_path.delete_at temp_path.length-1
|
45
|
+
if temp_path.length > 1
|
46
|
+
path = temp_path.join "\\"
|
47
|
+
Dir.chdir path
|
48
|
+
else
|
49
|
+
Dir.chdir "#{temp_path[0]}\\"
|
50
|
+
end
|
51
|
+
end
|
52
|
+
else
|
53
|
+
begin
|
54
|
+
Dir.chdir cmd.gsub 'cd ', ''
|
55
|
+
rescue
|
56
|
+
puts 'Wrong path'
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
60
|
+
# command X: change current work dir if user whant change volume
|
61
|
+
when /^\w:$/
|
62
|
+
begin
|
63
|
+
Dir.chdir cmd
|
64
|
+
rescue
|
65
|
+
puts "Path not found"
|
66
|
+
end
|
67
|
+
|
68
|
+
#run with skip executor.
|
69
|
+
# Use when you whant execute system command ping and have ping.rb un current folder
|
70
|
+
when /^\!/
|
71
|
+
run_program cmd.gsub '!',''
|
72
|
+
|
73
|
+
# run app or other program
|
74
|
+
when /^$|^ *$/
|
75
|
+
#skip when empty command
|
76
|
+
else
|
77
|
+
|
78
|
+
file_list = self.get_file_list cmd
|
79
|
+
|
80
|
+
#run file if find only one
|
81
|
+
if file_list.length == 1
|
82
|
+
file_list.each do |name, args|
|
83
|
+
run_file name, args
|
84
|
+
end
|
85
|
+
|
86
|
+
# не найдено фалов - значит команда
|
87
|
+
elsif file_list.length == 0
|
88
|
+
run_program cmd
|
89
|
+
|
90
|
+
# в остальных случаях файлов > 1
|
91
|
+
else
|
92
|
+
|
93
|
+
puts 'We find, more than one file:'
|
94
|
+
|
95
|
+
i = 0
|
96
|
+
numbered_files = {}
|
97
|
+
puts " 0 | Cancel "
|
98
|
+
file_list.each do |file|
|
99
|
+
i += 1
|
100
|
+
puts " #{i} | #{file[0]}"
|
101
|
+
numbered_files[i] = file[0]
|
102
|
+
end
|
103
|
+
num_file = -1
|
104
|
+
while num_file < 0
|
105
|
+
puts "Choose file to run (type @ and number of file)"
|
106
|
+
num_file = gets.chomp.gsub("@", "").to_i
|
107
|
+
if num_file > 0
|
108
|
+
run_file numbered_files[num_file], file_list[numbered_files[num_file]]
|
109
|
+
end
|
110
|
+
end
|
111
|
+
end
|
112
|
+
end
|
113
|
+
end
|
114
|
+
end
|
115
|
+
end
|
117
116
|
end
|
data/lib/srbc/srbc_command.rb
CHANGED
@@ -1,76 +1,79 @@
|
|
1
|
-
require_relative 'version'
|
2
|
-
module SrbcCommand
|
3
|
-
|
4
|
-
|
5
|
-
#method to execute command sterst with @
|
6
|
-
def srbc_command(command)
|
7
|
-
|
8
|
-
case command.downcase
|
9
|
-
when 'e','exit'
|
10
|
-
self.lunched = false
|
11
|
-
puts 'Exiting Smart Ruby Console'
|
12
|
-
|
13
|
-
when 'h','help'
|
14
|
-
puts "Smart Ruby Console help SRBC #{SrbcVersion::VERSION}"
|
15
|
-
File.open("#{@gem_root}/help", 'r') do |helpfile|
|
16
|
-
while line=helpfile.gets
|
17
|
-
puts line
|
18
|
-
end
|
19
|
-
end
|
20
|
-
|
21
|
-
#hot change executor
|
22
|
-
when /^#/
|
23
|
-
@executor = command.gsub(' ','').gsub '#', ''
|
24
|
-
@ext = @settings[@executor]
|
25
|
-
if @ext.nil?
|
26
|
-
puts "You use #{@executor} first time. Please add extension!"
|
27
|
-
ext = gets.chomp
|
28
|
-
set_settings @executor, ext
|
29
|
-
end
|
30
|
-
|
31
|
-
when 'l','list'
|
32
|
-
puts "Current [#{@executor}]:"
|
33
|
-
puts @ext
|
34
|
-
@settings.each do |executor, extensions|
|
35
|
-
unless executor == @executor
|
36
|
-
puts "\n"
|
37
|
-
puts "[#{executor}]"
|
38
|
-
puts extensions
|
39
|
-
end
|
40
|
-
end
|
41
|
-
|
42
|
-
when /^add/
|
43
|
-
new_ext = command.gsub 'add ', ''
|
44
|
-
|
45
|
-
set_settings @executor, new_ext
|
46
|
-
when 'c','current'
|
47
|
-
puts "\nCurrent executor: #{@executor}"
|
48
|
-
|
49
|
-
when /^delete/
|
50
|
-
executor_to_delete = command.gsub 'delete ', ''
|
51
|
-
if @settings[executor_to_delete].nil?
|
52
|
-
puts "Can't find #{executor_to_delete}"
|
53
|
-
else
|
54
|
-
if @executor == executor_to_delete
|
55
|
-
@executor = 'ruby'
|
56
|
-
end
|
57
|
-
@settings.delete (executor_to_delete)
|
58
|
-
save_settings
|
59
|
-
puts "#{executor_to_delete} deleted"
|
60
|
-
end
|
61
|
-
|
62
|
-
else
|
63
|
-
puts "Unknow SRBC command. Use @help for help"
|
64
|
-
end
|
65
|
-
|
66
|
-
end
|
67
|
-
|
68
|
-
def run_program(name)
|
69
|
-
system "#{name}"
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
1
|
+
require_relative 'version'
|
2
|
+
module SrbcCommand
|
3
|
+
|
4
|
+
|
5
|
+
#method to execute command sterst with @
|
6
|
+
def srbc_command(command)
|
7
|
+
|
8
|
+
case command.downcase
|
9
|
+
when 'e','exit'
|
10
|
+
self.lunched = false
|
11
|
+
puts 'Exiting Smart Ruby Console'
|
12
|
+
|
13
|
+
when 'h','help'
|
14
|
+
puts "Smart Ruby Console help SRBC #{SrbcVersion::VERSION}"
|
15
|
+
File.open("#{@gem_root}/help", 'r') do |helpfile|
|
16
|
+
while line=helpfile.gets
|
17
|
+
puts line
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
#hot change executor
|
22
|
+
when /^#/
|
23
|
+
@executor = command.gsub(' ','').gsub '#', ''
|
24
|
+
@ext = @settings[@executor]
|
25
|
+
if @ext.nil?
|
26
|
+
puts "You use #{@executor} first time. Please add extension!"
|
27
|
+
ext = gets.chomp
|
28
|
+
set_settings @executor, ext
|
29
|
+
end
|
30
|
+
|
31
|
+
when 'l','list'
|
32
|
+
puts "Current [#{@executor}]:"
|
33
|
+
puts @ext
|
34
|
+
@settings.each do |executor, extensions|
|
35
|
+
unless executor == @executor
|
36
|
+
puts "\n"
|
37
|
+
puts "[#{executor}]"
|
38
|
+
puts extensions
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
when /^add/
|
43
|
+
new_ext = command.gsub 'add ', ''
|
44
|
+
|
45
|
+
set_settings @executor, new_ext
|
46
|
+
when 'c','current'
|
47
|
+
puts "\nCurrent executor: #{@executor}"
|
48
|
+
|
49
|
+
when /^delete/
|
50
|
+
executor_to_delete = command.gsub 'delete ', ''
|
51
|
+
if @settings[executor_to_delete].nil?
|
52
|
+
puts "Can't find #{executor_to_delete}"
|
53
|
+
else
|
54
|
+
if @executor == executor_to_delete
|
55
|
+
@executor = 'ruby'
|
56
|
+
end
|
57
|
+
@settings.delete (executor_to_delete)
|
58
|
+
save_settings
|
59
|
+
puts "#{executor_to_delete} deleted"
|
60
|
+
end
|
61
|
+
|
62
|
+
else
|
63
|
+
puts "Unknow SRBC command. Use @help for help"
|
64
|
+
end
|
65
|
+
|
66
|
+
end
|
67
|
+
|
68
|
+
def run_program(name)
|
69
|
+
system "#{name}"
|
70
|
+
if $?.pid == 0
|
71
|
+
puts "#{name} not found"
|
72
|
+
end
|
73
|
+
end
|
74
|
+
|
75
|
+
def run_file(name, args="")
|
76
|
+
#puts "RUNN: ruby #{name} #{args}"
|
77
|
+
system "#{@executor} #{name} #{args}"
|
78
|
+
end
|
76
79
|
end
|
data/lib/srbc/version.rb
CHANGED
@@ -1,3 +1,3 @@
|
|
1
|
-
module SrbcVersion
|
2
|
-
VERSION = "0.0.
|
3
|
-
end
|
1
|
+
module SrbcVersion
|
2
|
+
VERSION = "0.0.10"
|
3
|
+
end
|
data/srbc.gemspec
CHANGED
@@ -10,7 +10,7 @@ Gem::Specification.new do |spec|
|
|
10
10
|
spec.email = ["bondarenko.ik@gmail.com"]
|
11
11
|
spec.summary = %q{SRBC extend windows comand line. Provide easy way to run ruby scripts}
|
12
12
|
spec.description = %q{Start ruby Console with extend features. Let execute ruby files without type "ruby" and "rb" extention.For exmple: type "main" to execute "runy main.rb". Also you can add custom executor: cucumber, python, ping or what you want.}
|
13
|
-
spec.homepage = ""
|
13
|
+
spec.homepage = "https://github.com/sedx/srbc"
|
14
14
|
spec.license = "MIT"
|
15
15
|
|
16
16
|
spec.files = `git ls-files -z`.split("\x0")
|
data/test/srbc_command_spec.rb
CHANGED
@@ -1,16 +1,16 @@
|
|
1
|
-
require 'rspec'
|
2
|
-
require_relative '../lib/srbc/srbc_command'
|
3
|
-
|
4
|
-
describe SrbcCommand do
|
5
|
-
include SrbcCommand
|
6
|
-
|
7
|
-
it 'srbc should exit when command e or exit' do
|
8
|
-
command ="e"
|
9
|
-
srbc_command(command)
|
10
|
-
$x.should eq false
|
11
|
-
$x = true
|
12
|
-
command = 'exit'
|
13
|
-
srbc_command command
|
14
|
-
$x.should eq false
|
15
|
-
end
|
1
|
+
require 'rspec'
|
2
|
+
require_relative '../lib/srbc/srbc_command'
|
3
|
+
|
4
|
+
describe SrbcCommand do
|
5
|
+
include SrbcCommand
|
6
|
+
|
7
|
+
it 'srbc should exit when command e or exit' do
|
8
|
+
command ="e"
|
9
|
+
srbc_command(command)
|
10
|
+
$x.should eq false
|
11
|
+
$x = true
|
12
|
+
command = 'exit'
|
13
|
+
srbc_command command
|
14
|
+
$x.should eq false
|
15
|
+
end
|
16
16
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: srbc
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.10
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ilya Bondarenko
|
@@ -63,7 +63,7 @@ files:
|
|
63
63
|
- settings.yml
|
64
64
|
- srbc.gemspec
|
65
65
|
- test/srbc_command_spec.rb
|
66
|
-
homepage:
|
66
|
+
homepage: https://github.com/sedx/srbc
|
67
67
|
licenses:
|
68
68
|
- MIT
|
69
69
|
metadata: {}
|