srbc 0.0.9 → 0.0.10

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: dbd310003777e939ce2100c0b7ea9fe6d83e421a
4
- data.tar.gz: 4fe63b776630b705bb6738ea54575c61feb21fb7
3
+ metadata.gz: 31a55f421d86435e6abcf0cab465ec9415c02c3b
4
+ data.tar.gz: e89a7b022205a789d549cd2ec0a76676476bb689
5
5
  SHA512:
6
- metadata.gz: e2fd9e9ed9f47ab3a544bfa6164375036ee5f3a00cd4d88b009f2701df272420dd0676dd72e74885d6bc00a078d591b993a8fff329421479e29ad65e2e5a50f2
7
- data.tar.gz: 1557c13d3cf742defc035e05fd21d697ddb0ebe21aa4a810e2e9a138239c0861fb23acc78edd2134d421233a6c0ddf8df15f8d701e0c168a5119cd5ca69db52a
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
- TODO: Write a gem description
4
-
5
- ## Installation
6
-
7
- Add this line to your application's Gemfile:
8
-
9
- gem 'srbc'
10
-
11
- And then execute:
12
-
13
- $ bundle
14
-
15
- Or install it yourself as:
16
-
17
- $ gem install srbc
18
-
19
- ## Usage
20
-
21
- Usage: You can run *.rb files, or
22
- other in ruby, just print "main"
23
- to execute "ruby main.rb".
24
-
25
- If in folder same files contains
26
- "main" (for example foo_main.rb,
27
- bar_main.rb and main.rb) SRBC ask
28
- you what file run.
29
-
30
- When SRBC run default MS symbol
31
- in console > replace with ~
32
-
33
- You can use other executor.
34
- Run "srbc -add:cucumber"
35
- to add new executor.
36
- Then run "srbc -cucumber" to start
37
- Smart Ruby Console with cucumber executor.
38
-
39
-
40
- Arguments:
41
- -add:<exexutor> add executor
42
- -<executor> run with executor
43
- -help for this help
44
- -list list of executors
45
- no arguments run ruby executor
46
-
47
-
48
- Comands:
49
-
50
- | @help | this help |
51
- | @list | extension list |
52
- | @exit | exit from app |
53
- | @add "*.rb" | add extension |
54
-
55
- You can shortcut commands.
56
- Example: @h for help
57
-
58
- ## Contributing
59
-
60
- 1. Fork it ( https://github.com/[my-github-username]/srbc/fork )
61
- 2. Create your feature branch (`git checkout -b my-new-feature`)
62
- 3. Commit your changes (`git commit -am 'Add some feature'`)
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
@@ -29,7 +29,7 @@ class SRBC
29
29
  @settings[executor] = @ext
30
30
  save_settings
31
31
  else
32
- puts 'Wrong format! You muts type "@add *.extenssion"'
32
+ puts 'Wrong format! You muts type "@add *.extension"'
33
33
  end
34
34
  end
35
35
 
@@ -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
- p "run command #{cmd}"
89
- run_program cmd
90
-
91
- # в остальных случаях файлов > 1
92
- else
93
-
94
- puts 'We find, more than one file:'
95
-
96
- i = 0
97
- numbered_files = {}
98
- puts " 0 | Cancel "
99
- file_list.each do |file|
100
- i += 1
101
- puts " #{i} | #{file[0]}"
102
- numbered_files[i] = file[0]
103
- end
104
- num_file = -1
105
- while num_file < 0
106
- puts "Choose file to run (type @ and number of file)"
107
- num_file = gets.chomp.gsub("@", "").to_i
108
- if num_file > 0
109
- run_file numbered_files[num_file], file_list[numbered_files[num_file]]
110
- end
111
- end
112
- end
113
- end
114
- end
115
- end
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
@@ -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
- end
71
-
72
- def run_file(name, args="")
73
- #puts "RUNN: ruby #{name} #{args}"
74
- system "#{@executor} #{name} #{args}"
75
- end
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
@@ -1,3 +1,3 @@
1
- module SrbcVersion
2
- VERSION = "0.0.9"
3
- end
1
+ module SrbcVersion
2
+ VERSION = "0.0.10"
3
+ end
@@ -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")
@@ -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.9
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: {}