slickrun 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/slickrun.rb +67 -0
- metadata +45 -0
data/lib/slickrun.rb
ADDED
@@ -0,0 +1,67 @@
|
|
1
|
+
require 'securerandom'
|
2
|
+
|
3
|
+
class SlickRun
|
4
|
+
|
5
|
+
def self.srl_path_set?
|
6
|
+
!!@@srl_path
|
7
|
+
end
|
8
|
+
|
9
|
+
def self.set_srl_path(srl_path)
|
10
|
+
@@srl_path = srl_path
|
11
|
+
end
|
12
|
+
|
13
|
+
def self.add_magic_word(name, filename, params='', start_mode=1, use_run_as=0, disable_32bit_redir=0)
|
14
|
+
throw "SlickRun.srl file could not be found automatically. Use set_srl_path to set it implicitly." unless @@srl_path
|
15
|
+
magic_word_string = generate_magic_word_string(name, filename, params, start_mode, use_run_as, disable_32bit_redir)
|
16
|
+
insert_magic_word_to_srl(magic_word_string, name)
|
17
|
+
end
|
18
|
+
|
19
|
+
private
|
20
|
+
def self.generate_magic_word_string(name, filename, params, start_mode, use_run_as, disable_32bit_redir)
|
21
|
+
name.gsub!(/[^A-Za-z]/, '') # Strip the name off invalid chars
|
22
|
+
%Q{[#{name}]
|
23
|
+
Filename="#{filename}"
|
24
|
+
Params="#{params}"
|
25
|
+
GUID={#{SecureRandom.uuid.upcase}}
|
26
|
+
StartMode=#{start_mode}
|
27
|
+
UseRunAs=#{use_run_as}
|
28
|
+
Disable32BitRedir=#{disable_32bit_redir}
|
29
|
+
}
|
30
|
+
end
|
31
|
+
|
32
|
+
def self.insert_magic_word_to_srl(magic_word, name)
|
33
|
+
new_srl = ""
|
34
|
+
magic_word_added = false
|
35
|
+
File.open(@@srl_path, 'r') do |file|
|
36
|
+
file.readlines.each do |line|
|
37
|
+
|
38
|
+
# Shove the magic_word after the first magic word that is alphabetically bigger
|
39
|
+
if not magic_word_added and match = line.match(/\[(.+)\]/)
|
40
|
+
if name < match[1]
|
41
|
+
new_srl += magic_word
|
42
|
+
magic_word_added = true
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
new_srl += line
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
!!File.open(@@srl_path, "w") { |file| file.write(new_srl) }
|
51
|
+
end
|
52
|
+
|
53
|
+
# Searches for SlickRun.srl file in default locations
|
54
|
+
def self.search_srl_path
|
55
|
+
vista_path = File.join(ENV["USERPROFILE"], 'AppData\Roaming\Slickrun\SlickRun.srl')
|
56
|
+
return vista_path if File.exists?(vista_path)
|
57
|
+
|
58
|
+
xp_path = File.join(ENV["USERPROFILE"], 'Application Data\SlickRun\SlickRun.srl')
|
59
|
+
return xp_path if File.exists?(xp_path)
|
60
|
+
|
61
|
+
warn "[WARNING] Could not find SlickRun.srl file. Use set_srl_path to set it implicitly."
|
62
|
+
nil
|
63
|
+
end
|
64
|
+
|
65
|
+
@@srl_path = self.search_srl_path
|
66
|
+
|
67
|
+
end
|
metadata
ADDED
@@ -0,0 +1,45 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: slickrun
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Guy Zisman
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2012-05-10 00:00:00.000000000 Z
|
13
|
+
dependencies: []
|
14
|
+
description: Allows adding magic words to SlickRun using ruby.
|
15
|
+
email: Vall3y@gmail.com
|
16
|
+
executables: []
|
17
|
+
extensions: []
|
18
|
+
extra_rdoc_files: []
|
19
|
+
files:
|
20
|
+
- lib/slickrun.rb
|
21
|
+
homepage: http://rubygems.org/gems/slickrun
|
22
|
+
licenses: []
|
23
|
+
post_install_message:
|
24
|
+
rdoc_options: []
|
25
|
+
require_paths:
|
26
|
+
- lib
|
27
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
28
|
+
none: false
|
29
|
+
requirements:
|
30
|
+
- - ! '>='
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: '0'
|
33
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
34
|
+
none: false
|
35
|
+
requirements:
|
36
|
+
- - ! '>='
|
37
|
+
- !ruby/object:Gem::Version
|
38
|
+
version: '0'
|
39
|
+
requirements: []
|
40
|
+
rubyforge_project:
|
41
|
+
rubygems_version: 1.8.13
|
42
|
+
signing_key:
|
43
|
+
specification_version: 3
|
44
|
+
summary: Bayden's SlickRun gem.
|
45
|
+
test_files: []
|