sixcore 0.3.3

Sign up to get free protection for your applications and to get access to all the features.
data/LICENSE ADDED
@@ -0,0 +1,167 @@
1
+ == sixcore
2
+
3
+ GNU LESSER GENERAL PUBLIC LICENSE
4
+ Version 3, 29 June 2007
5
+
6
+ Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
7
+ Everyone is permitted to copy and distribute verbatim copies
8
+ of this license document, but changing it is not allowed.
9
+
10
+
11
+ This version of the GNU Lesser General Public License incorporates
12
+ the terms and conditions of version 3 of the GNU General Public
13
+ License, supplemented by the additional permissions listed below.
14
+
15
+ 0. Additional Definitions.
16
+
17
+ As used herein, "this License" refers to version 3 of the GNU Lesser
18
+ General Public License, and the "GNU GPL" refers to version 3 of the GNU
19
+ General Public License.
20
+
21
+ "The Library" refers to a covered work governed by this License,
22
+ other than an Application or a Combined Work as defined below.
23
+
24
+ An "Application" is any work that makes use of an interface provided
25
+ by the Library, but which is not otherwise based on the Library.
26
+ Defining a subclass of a class defined by the Library is deemed a mode
27
+ of using an interface provided by the Library.
28
+
29
+ A "Combined Work" is a work produced by combining or linking an
30
+ Application with the Library. The particular version of the Library
31
+ with which the Combined Work was made is also called the "Linked
32
+ Version".
33
+
34
+ The "Minimal Corresponding Source" for a Combined Work means the
35
+ Corresponding Source for the Combined Work, excluding any source code
36
+ for portions of the Combined Work that, considered in isolation, are
37
+ based on the Application, and not on the Linked Version.
38
+
39
+ The "Corresponding Application Code" for a Combined Work means the
40
+ object code and/or source code for the Application, including any data
41
+ and utility programs needed for reproducing the Combined Work from the
42
+ Application, but excluding the System Libraries of the Combined Work.
43
+
44
+ 1. Exception to Section 3 of the GNU GPL.
45
+
46
+ You may convey a covered work under sections 3 and 4 of this License
47
+ without being bound by section 3 of the GNU GPL.
48
+
49
+ 2. Conveying Modified Versions.
50
+
51
+ If you modify a copy of the Library, and, in your modifications, a
52
+ facility refers to a function or data to be supplied by an Application
53
+ that uses the facility (other than as an argument passed when the
54
+ facility is invoked), then you may convey a copy of the modified
55
+ version:
56
+
57
+ a) under this License, provided that you make a good faith effort to
58
+ ensure that, in the event an Application does not supply the
59
+ function or data, the facility still operates, and performs
60
+ whatever part of its purpose remains meaningful, or
61
+
62
+ b) under the GNU GPL, with none of the additional permissions of
63
+ this License applicable to that copy.
64
+
65
+ 3. Object Code Incorporating Material from Library Header Files.
66
+
67
+ The object code form of an Application may incorporate material from
68
+ a header file that is part of the Library. You may convey such object
69
+ code under terms of your choice, provided that, if the incorporated
70
+ material is not limited to numerical parameters, data structure
71
+ layouts and accessors, or small macros, inline functions and templates
72
+ (ten or fewer lines in length), you do both of the following:
73
+
74
+ a) Give prominent notice with each copy of the object code that the
75
+ Library is used in it and that the Library and its use are
76
+ covered by this License.
77
+
78
+ b) Accompany the object code with a copy of the GNU GPL and this license
79
+ document.
80
+
81
+ 4. Combined Works.
82
+
83
+ You may convey a Combined Work under terms of your choice that,
84
+ taken together, effectively do not restrict modification of the
85
+ portions of the Library contained in the Combined Work and reverse
86
+ engineering for debugging such modifications, if you also do each of
87
+ the following:
88
+
89
+ a) Give prominent notice with each copy of the Combined Work that
90
+ the Library is used in it and that the Library and its use are
91
+ covered by this License.
92
+
93
+ b) Accompany the Combined Work with a copy of the GNU GPL and this license
94
+ document.
95
+
96
+ c) For a Combined Work that displays copyright notices during
97
+ execution, include the copyright notice for the Library among
98
+ these notices, as well as a reference directing the user to the
99
+ copies of the GNU GPL and this license document.
100
+
101
+ d) Do one of the following:
102
+
103
+ 0) Convey the Minimal Corresponding Source under the terms of this
104
+ License, and the Corresponding Application Code in a form
105
+ suitable for, and under terms that permit, the user to
106
+ recombine or relink the Application with a modified version of
107
+ the Linked Version to produce a modified Combined Work, in the
108
+ manner specified by section 6 of the GNU GPL for conveying
109
+ Corresponding Source.
110
+
111
+ 1) Use a suitable shared library mechanism for linking with the
112
+ Library. A suitable mechanism is one that (a) uses at run time
113
+ a copy of the Library already present on the user's computer
114
+ system, and (b) will operate properly with a modified version
115
+ of the Library that is interface-compatible with the Linked
116
+ Version.
117
+
118
+ e) Provide Installation Information, but only if you would otherwise
119
+ be required to provide such information under section 6 of the
120
+ GNU GPL, and only to the extent that such information is
121
+ necessary to install and execute a modified version of the
122
+ Combined Work produced by recombining or relinking the
123
+ Application with a modified version of the Linked Version. (If
124
+ you use option 4d0, the Installation Information must accompany
125
+ the Minimal Corresponding Source and Corresponding Application
126
+ Code. If you use option 4d1, you must provide the Installation
127
+ Information in the manner specified by section 6 of the GNU GPL
128
+ for conveying Corresponding Source.)
129
+
130
+ 5. Combined Libraries.
131
+
132
+ You may place library facilities that are a work based on the
133
+ Library side by side in a single library together with other library
134
+ facilities that are not Applications and are not covered by this
135
+ License, and convey such a combined library under terms of your
136
+ choice, if you do both of the following:
137
+
138
+ a) Accompany the combined library with a copy of the same work based
139
+ on the Library, uncombined with any other library facilities,
140
+ conveyed under the terms of this License.
141
+
142
+ b) Give prominent notice with the combined library that part of it
143
+ is a work based on the Library, and explaining where to find the
144
+ accompanying uncombined form of the same work.
145
+
146
+ 6. Revised Versions of the GNU Lesser General Public License.
147
+
148
+ The Free Software Foundation may publish revised and/or new versions
149
+ of the GNU Lesser General Public License from time to time. Such new
150
+ versions will be similar in spirit to the present version, but may
151
+ differ in detail to address new problems or concerns.
152
+
153
+ Each version is given a distinguishing version number. If the
154
+ Library as you received it specifies that a certain numbered version
155
+ of the GNU Lesser General Public License "or any later version"
156
+ applies to it, you have the option of following the terms and
157
+ conditions either of that published version or of any later version
158
+ published by the Free Software Foundation. If the Library as you
159
+ received it does not specify a version number of the GNU Lesser
160
+ General Public License, you may choose any version of the GNU Lesser
161
+ General Public License ever published by the Free Software Foundation.
162
+
163
+ If the Library as you received it specifies that a proxy can decide
164
+ whether future versions of the GNU Lesser General Public License shall
165
+ apply, that proxy's public statement of acceptance of any version is
166
+ permanent authorization for you to choose that version for the
167
+ Library.
data/README ADDED
@@ -0,0 +1,3 @@
1
+ == sixcore
2
+
3
+ Core modules and classes for 6thSense.eu Projects
data/Rakefile ADDED
@@ -0,0 +1,47 @@
1
+ #
2
+ # To change this template, choose Tools | Templates
3
+ # and open the template in the editor.
4
+
5
+
6
+ require 'rubygems'
7
+ require 'rake'
8
+ require 'rake/clean'
9
+ require 'rake/gempackagetask'
10
+ require 'rake/rdoctask'
11
+ require 'rake/testtask'
12
+
13
+ spec = Gem::Specification.new do |s|
14
+ s.name = 'sixcore'
15
+ s.rubyforge_project = s.name
16
+ s.version = '0.3.3'
17
+ s.has_rdoc = true
18
+ s.extra_rdoc_files = ['README', 'LICENSE']
19
+ s.summary = 'Basic Function Library for other six projects'
20
+ s.description = 'The library is primaraily designed for sixarma and sixarma-bt projects, to supply a basic set of core functions that can be used throughout the other (and future) six*** projects'
21
+ s.author = 'Sickboy'
22
+ s.email = 'sb@6thsense.eu'
23
+ s.homepage = 'http://6thsense.eu'
24
+ # s.executables = ['your_executable_here']
25
+ s.files = %w(LICENSE README Rakefile) + Dir.glob("{bin,lib,spec}/**/*.rb") + Dir.glob("{bin,lib,spec}/**/*.yaml")
26
+ s.require_path = "lib"
27
+ s.bindir = "bin"
28
+ end
29
+
30
+ Rake::GemPackageTask.new(spec) do |p|
31
+ p.gem_spec = spec
32
+ p.need_tar = true
33
+ p.need_zip = true
34
+ end
35
+
36
+ Rake::RDocTask.new do |rdoc|
37
+ files =['README', 'LICENSE', 'lib/**/*.rb']
38
+ rdoc.rdoc_files.add(files)
39
+ rdoc.main = "README" # page to start on
40
+ rdoc.title = "sixcore Docs"
41
+ rdoc.rdoc_dir = 'doc/rdoc' # rdoc output folder
42
+ rdoc.options << '--line-numbers'
43
+ end
44
+
45
+ Rake::TestTask.new do |t|
46
+ t.test_files = FileList['test/**/*.rb']
47
+ end
@@ -0,0 +1 @@
1
+ PROGRAM_NSIS = "C:\\Program Files (x86)\\NSIS\\makensis.exe"
@@ -0,0 +1,6 @@
1
+ INFO = true
2
+ DEBUG = false
3
+ LOG = true
4
+ VERBOSE = false
5
+ CLEAN_LOG = true
6
+ LOGFILE = "temp.log"
@@ -0,0 +1 @@
1
+ SVN_BIN = "svn"
@@ -0,0 +1,56 @@
1
+ =begin
2
+ 6thSense.eu Core (Ftp), by Sickboy (sb_at_6thSense.eu)
3
+ =end
4
+ require 'sixcore'
5
+ module SixCore
6
+ # Core FTP Class
7
+ class Ftp
8
+ attr :ftp
9
+ COMPONENT = 'SixCore::Ftp'
10
+
11
+ require 'net/ftp'
12
+ # host:: String, Hostname
13
+ # user:: String, Username
14
+ # pass:: String, Password
15
+ def initialize(host, user = "", pass = "")
16
+ SixCore::debugs "#{COMPONENT} Initialize"
17
+ SixCore::debug "Creating connection to ftp://#{user}:#{pass}@#{host} ..."
18
+ @host = host
19
+ @user = user
20
+ @pass = pass
21
+ @ftp = Net::FTP.new(@host)
22
+ @ftp.login(user=@user, passwd=@pass)
23
+ end
24
+
25
+ # Gets file from FTP
26
+ # filename:: String, Filename
27
+ # localpath:: String, Localpath
28
+ # remotepath:: String, Remotepath
29
+ def get(filename = "", localpath = "", remotepath = "")
30
+ SixCore::debug "Downloading #{filename} from #{@host}#{remotepath} ..."
31
+ @ftp.getbinaryfile("#{remotepath}#{filename}", "#{localpath}#{filename}", 1024) unless filename == ""
32
+ end
33
+
34
+ # Renames file on FTP
35
+ # filename:: String, Filename
36
+ # newfn:: String, New Filename
37
+ # remotepath:: String, Remotepath
38
+ def rename(filename = "", newfn = "", remotepath = "")
39
+ @ftp.rename("#{remotepath}#{filename}", "#{remotepath}#{newfn}")
40
+ end
41
+
42
+ # Puts file on FTP
43
+ # filename:: String, Filename
44
+ # localpath:: String, Localpath
45
+ # remotepath:: String, Remotepath
46
+ # temp:: Boolean, When true, Uploads file as #{filename}_tmp
47
+ # staytemp:: Boolean, When true, Uploaded file will remain as _tmp even after finishing
48
+ def put(filename = "", localpath = "", remotepath = "", temp = false, staytemp = false)
49
+ file = filename
50
+ file = "#{file}_tmp" if temp
51
+ SixCore::debug "Uploading #{filename} to #{@host}#{remotepath} ..."
52
+ @ftp.putbinaryfile("#{localpath}#{filename}", "#{remotepath}#{file}", 1024) unless filename == ""
53
+ @ftp.rename("#{remotepath}#{file}", "#{remotepath}#{filename}") if temp && !staytemp
54
+ end
55
+ end
56
+ end
@@ -0,0 +1,53 @@
1
+ =begin
2
+ 6thSense.eu Core (Nsis), by Sickboy (sb_at_6thSense.eu)
3
+ =end
4
+ require 'sixcore'
5
+ module SixCore
6
+ # Core Class for the Nullsoft Scriptable Install System
7
+ class Nsis
8
+ attr_reader(:template, :output)
9
+ COMPONENT = 'SixCore::nsis'
10
+
11
+ require 'sixcore/config/nsis'
12
+ # template:: Name of template to use
13
+ # output:: Name of output file to use
14
+ def initialize(template, output)
15
+ @template = template
16
+ @output = output
17
+ SixCore::debug("Initialize", COMPONENT, [template, output])
18
+ end
19
+
20
+ # Creates the NSIS Setup output file
21
+ # replace:: Array, Per Entry: [Search, Replace]
22
+ def create_output(replace = [])
23
+ SixCore::debug("Build", COMPONENT, replace)
24
+
25
+ # Read NSIS template file
26
+ nsis = File.open("#{@template}") do |file|
27
+ file.read
28
+ end
29
+
30
+ # exchange regex for new strings
31
+ SixCore::debug("Replacing regex...", COMPONENT, [@output, replace])
32
+ nsis = SixCore::gsub_ar(nsis, replace) unless replace.empty?
33
+
34
+ # write new nsis file
35
+ SixCore::debug("Creating new nsis file...", COMPONENT, @output)
36
+ newfile = File.new("#{@output}", "w")
37
+ newfile.write nsis
38
+ newfile.close
39
+
40
+ # compile new nsis file
41
+ SixCore::debug("Creating output exe...", COMPONENT)
42
+ r = SixCore::proc_cmd("\"#{PROGRAM_NSIS}\" \"#{@output}\"")
43
+ r.each do |l|
44
+ # TODO: Regex?
45
+ if l.gsub("Error - aborting creation process", "") != l
46
+ raise "Failed creating NSIS Installed"
47
+ end
48
+ end
49
+
50
+ return @output
51
+ end
52
+ end
53
+ end
@@ -0,0 +1,157 @@
1
+ =begin
2
+ 6thSense.eu Core (Svn), by Sickboy (sb_at_6thSense.eu)
3
+ =end
4
+ require 'sixcore'
5
+ module SixCore
6
+ # Core module for Subversion
7
+ class Svn
8
+ attr_accessor(:repos, :user, :pass)
9
+ COMPONENT = 'SixCore::Svn'
10
+
11
+ require 'sixcore/config/svn'
12
+ # repos:: String, Repository folder or URL
13
+ # user:: String, Username
14
+ # pass:: String, Password
15
+ def initialize(repos = "", user = "", pass = "")
16
+ @repos = repos
17
+ @user = user
18
+ @pass = pass
19
+ end
20
+
21
+ # Command Execution function
22
+ # cmd:: Command to execute, excl repositor, username, password
23
+ def cmd(cmd)
24
+ SixCore::debug("Command", COMPONENT, cmd)
25
+ cmd = "#{cmd} #{@repos}" unless @repos.empty?
26
+ cmd = "#{cmd} --username #{@user}" unless @user.empty?
27
+ cmd = "#{cmd} --password #{@pass}" unless @pass.empty?
28
+ r = SixCore::proc_cmd("#{SVN_BIN} #{cmd}")
29
+ return r
30
+ end
31
+
32
+ # Generates diff list between revisions
33
+ # Returns diff list
34
+ # old:: String or Integer, start revision number
35
+ # new:: String or Integer, end revision number
36
+ def diff(old, new)
37
+ r = cmd("diff -r #{old}:#{new} --summarize").split("\n")
38
+ return r
39
+ end
40
+
41
+ # Fetches SVN info
42
+ def info()
43
+ r = cmd("info").split("\n")
44
+ return r
45
+ end
46
+
47
+ # Fetches SVN List
48
+ def list()
49
+ r = cmd("list").split("/\n")
50
+ return r
51
+ end
52
+
53
+ # Executes SVN Update
54
+ # Returns Array of Strings
55
+ def update()
56
+ r = cmd("update").split("\n")
57
+ return r
58
+ end
59
+
60
+ # Generates log between revisions
61
+ # old:: String or Integer, start revision number
62
+ # new:: String or Integer, end revision number
63
+ # Returns Array of Strings (log)
64
+ def log(old, new)
65
+ r = cmd("log -r#{old}:#{new}").split("\n")
66
+ return r
67
+ end
68
+
69
+ # Generates array list of log entry information
70
+ # old:: String or Integer, start revision number
71
+ # new:: String or Integer, end revision number
72
+ # Returns Array of log, split between revision number, committer, log, etc
73
+ def log_split(old, new)
74
+ ar = log(old,new)
75
+ log = []
76
+ i = -1
77
+ entry = []
78
+ com = []
79
+ ar.each do |l|
80
+ if /------------------------------------------------------------------------/.match(l) != nil
81
+ unless i == -1
82
+ entry << com
83
+ log << entry
84
+ end
85
+ entry = []
86
+ com = []
87
+ i = 0
88
+ else
89
+ i += 1
90
+ if i == 1
91
+ m = /r(.*) \| (.*) \| (.*) \| (.*) line/.match(l)
92
+ if m != nil
93
+ entry << [m[1], m[2], m[3], m[4]]
94
+ end
95
+ elsif i > 2
96
+ com << l unless l.size == 0
97
+ end
98
+ end
99
+ end
100
+ return log
101
+ end
102
+
103
+ # Reads current revision number from repository
104
+ # Returns revision number
105
+ def read_rev()
106
+ inf = info()
107
+ r = [nil, nil]
108
+ inf.each do |l|
109
+ r = /Revision\: (.*)/.match(l) if /Revision\: (.*)/.match(l) != nil
110
+ end
111
+ return r[1]
112
+ end
113
+
114
+
115
+ # Parses log entry and returns type of change
116
+ # entry:: String, line of svn log
117
+ # folders:: Boolean, include folders?
118
+ # slash:: String, what type of file system / \ should be used
119
+ # Returns Array, Per Entry format: [integer, formatted entry string]
120
+ def parse_entry(entry, folders = true, slash = "\\")
121
+ # TODO: slash!
122
+ # substract everything after first \
123
+ if folders
124
+ entrymod = entry.gsub(/\\(.*)/, "")
125
+ else
126
+ entrymod = entry
127
+ end
128
+
129
+ case entrymod
130
+ when /A /
131
+ entrymod.gsub!(/A /, "")
132
+ if folders and entry =~ /(.*)\\(.*)/
133
+ # subfolder, so it's a change
134
+ return [1, entrymod]
135
+ else
136
+ return [0, entrymod]
137
+ end
138
+ when /M /
139
+ entrymod.gsub!(/M /, "")
140
+ return [1, entrymod]
141
+ when /D /
142
+ entrymod.gsub!(/D /, "")
143
+ if folders and entry =~ /(.*)\\(.*)/
144
+ # subfolder, so it's a change
145
+ if entry =~ /(.*)\.pbo(.*)/
146
+ return [2, entrymod]
147
+ else
148
+ return [1, entrymod]
149
+ end
150
+ else
151
+ return [2, entrymod]
152
+ end
153
+ end
154
+ return [-1, nil]
155
+ end
156
+ end
157
+ end
data/lib/sixcore.rb ADDED
@@ -0,0 +1,196 @@
1
+ =begin
2
+ 6thSense.eu Core Module, by Sickboy (sb_at_6thSense.eu)
3
+ =end
4
+ require 'sixcore/config/sixcore'
5
+
6
+ gem 'log4r'
7
+ require 'log4r'
8
+
9
+ # Core Module
10
+ module SixCore
11
+ MAINDIR = Dir.pwd
12
+ COMPONENT = 'SixCore'
13
+ @@log = Log4r::Logger.new(COMPONENT)
14
+
15
+ # Create Outputters
16
+ if LOG
17
+ o_file = Log4r::FileOutputter.new 'sixcore-file',
18
+ 'level' => 0, # All
19
+ :filename => "#{COMPONENT}.log"
20
+ #:maxsize => 1024
21
+ @@log.outputters << o_file
22
+ end
23
+
24
+ o_out = Log4r::StdoutOutputter.new 'sixcore-stdout',
25
+ 'level' => 2 # no DEBUG
26
+
27
+ o_err = Log4r::StderrOutputter.new 'sixcore-stderr',
28
+ 'level' => 4 # Error and Up
29
+
30
+ @@log.outputters << o_out << o_err
31
+
32
+ # @@log = File.new(LOGFILE, "a")
33
+ # @@log.sync = true
34
+
35
+ module_function
36
+
37
+ def log()
38
+ @@log
39
+ end
40
+
41
+ # Halts operation waiting for user input <enter>
42
+ def halt()
43
+ puts
44
+ puts "Press enter to continue"
45
+ gets
46
+ end
47
+
48
+ # Cleans string (chomp and strip)
49
+ # Returns: Cleaned string
50
+ # str:: String, Input
51
+ def clean(str)
52
+ str.chomp!
53
+ str.strip!
54
+ return str
55
+ end
56
+
57
+ # Prepares string for output to logger
58
+ # str:: String, Input
59
+ # component:: String, Component
60
+ # verbose:: String, Verbose (Only displayed when VERBOSE is true)
61
+ # type:: Integer, format types 0 or 1
62
+ def prep_msg(str, component, verbose, type = 0)
63
+ str = "#{component} - #{str}" unless component.empty?
64
+ case type
65
+ when 0
66
+ str += " - " + verbose.to_s if VERBOSE and verbose != ""
67
+ when 1
68
+ str = "(#{Time.now().strftime('%H:%M:%S')}) #{str}"
69
+ str += " - " + verbose.to_s if VERBOSE and verbose != ""
70
+ str = "=== #{str} ==="
71
+ end
72
+ return str
73
+ end
74
+
75
+ # Outputs string to info logger
76
+ # str:: String, Input
77
+ # component:: String, Component
78
+ # verbose:: String, Verbose (Only displayed when VERBOSE is true)
79
+ def info(str, component = "", verbose = "")
80
+ unless str.empty?
81
+ @@log.info prep_msg(str, component, verbose, 0)
82
+ end
83
+ end
84
+
85
+ # Outputs string to info logger with extra formatting
86
+ # str:: String, Input
87
+ # component:: String, Component
88
+ # verbose:: String, Verbose (Only displayed when VERBOSE is true)
89
+ def infos(str, component = "", verbose = "")
90
+ unless str.empty?
91
+ puts
92
+ @@log.info prep_msg(str, component, verbose, 1)
93
+ end
94
+ end
95
+
96
+ # Outputs string to debug logger
97
+ # str:: String, Input
98
+ # component:: String, Component
99
+ # verbose:: String, Verbose (Only displayed when VERBOSE is true)
100
+ def debug(str, component = "", verbose = "")
101
+ unless str.empty? || !DEBUG
102
+ puts
103
+ @@log.debug prep_msg(str, component, verbose, 0)
104
+ end
105
+ end
106
+
107
+ # Outputs string to debug logger with extra formatting
108
+ # str:: String, Input
109
+ # component:: String, Component
110
+ # verbose:: String, Verbose (Only displayed when VERBOSE is true)
111
+ def debugs(str, component = "", verbose = "")
112
+ unless str.empty? || !DEBUG
113
+ puts
114
+ @@log.debug prep_msg(str, component, verbose, 1)
115
+ end
116
+ end
117
+
118
+ # Replaces all search strings with replace strings from replace array
119
+ # string:: String, Input
120
+ # replace:: Array, per entry: [Search, Replace]
121
+ def gsub_ar(string, replace)
122
+ replace.each do |r|
123
+ string.gsub!(r[0], r[1])
124
+ end
125
+ return string
126
+ end
127
+
128
+ # Put quotes around string
129
+ # Returns quoted string
130
+ # str:: String, Input
131
+ def quote(str)
132
+ return "\"#{str}\""
133
+ end
134
+
135
+ # Evals command and logs to debug if enabled
136
+ # cmd:: String, command to eval
137
+ def eval_cmd(cmd)
138
+ eval cmd unless DEBUG or cmd.empty?
139
+ SixCore::debug("Eval Command", COMPONENT, cmd)
140
+ end
141
+
142
+ # Executes system command and logs to debug if enabled
143
+ # cmd:: String, command to execute
144
+ def proc_cmd(cmd)
145
+ unless DEBUG or cmd.empty?
146
+ r = (%x[#{cmd}])
147
+ SixCore::debug("Proc Command", COMPONENT, [cmd, r])
148
+ return r
149
+ end
150
+ end
151
+
152
+ # Uses Roboycopy to update folders from source to destination
153
+ # source:: String, Source folder
154
+ # destination:: String, Destination folder
155
+ # extra:: Extra parameters to supply to Robocopy
156
+ def fileupdate(source, destination, extra = "")
157
+ debug("Updating Files...", COMPONENT, [source, destination, extra])
158
+ proc_cmd("robocopy #{source} #{destination} /S /TIMFIX /ZB /R:5 /W:5 #{extra}")
159
+ end
160
+
161
+ # Uses Roboycopy to mirror folders from source to destination
162
+ # source:: String, Source folder
163
+ # destination:: String, Destination folder
164
+ # extra:: Extra parameters to supply to Robocopy
165
+ def filemirror(source, destination, extra = "")
166
+ debug("Mirroring Files...", COMPONENT, [source, destination, extra])
167
+ proc_cmd("robocopy #{source} #{destination} /MIR /TIMFIX /ZB /R:5 /W:5 #{extra}")
168
+ end
169
+
170
+ # Copies files from source to destination
171
+ # source:: String, Source folder
172
+ # destination:: String, Destination folder
173
+ def filecopy(source, destination)
174
+ debug("Copying Files...", COMPONENT, [source, destination])
175
+ proc_cmd("copy /y \"#{source}\" \"#{destination}\\\"")
176
+ end
177
+
178
+ # Moves files from source to destination
179
+ # source:: String, Source folder
180
+ # destination:: String, Destination folder
181
+ def filemove(source, destination)
182
+ debug("Moving Files...", COMPONENT, [source, destination])
183
+ proc_cmd("move /y \"#{source}\" \"#{destination}\"")
184
+ end
185
+
186
+ # Deletes files from source
187
+ # source:: String, Source folder
188
+ def filedel(source)
189
+ debug("Deleting Files...", COMPONENT, [source])
190
+ proc_cmd("del /f /q #{source}")
191
+ end
192
+ end
193
+
194
+ component = '6thSense.eu Core'
195
+ version = '0.3.3'
196
+ SixCore::debugs "#{component} #{version} loaded"
metadata ADDED
@@ -0,0 +1,63 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: sixcore
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.3.3
5
+ platform: ruby
6
+ authors:
7
+ - Sickboy
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+
12
+ date: 2008-11-29 00:00:00 +01:00
13
+ default_executable:
14
+ dependencies: []
15
+
16
+ description: The library is primaraily designed for sixarma and sixarma-bt projects, to supply a basic set of core functions that can be used throughout the other (and future) six*** projects
17
+ email: sb@6thsense.eu
18
+ executables: []
19
+
20
+ extensions: []
21
+
22
+ extra_rdoc_files:
23
+ - README
24
+ - LICENSE
25
+ files:
26
+ - LICENSE
27
+ - README
28
+ - Rakefile
29
+ - lib/sixcore/config/nsis.rb
30
+ - lib/sixcore/config/sixcore.rb
31
+ - lib/sixcore/config/svn.rb
32
+ - lib/sixcore/ftp.rb
33
+ - lib/sixcore/nsis.rb
34
+ - lib/sixcore/svn.rb
35
+ - lib/sixcore.rb
36
+ has_rdoc: true
37
+ homepage: http://6thsense.eu
38
+ post_install_message:
39
+ rdoc_options: []
40
+
41
+ require_paths:
42
+ - lib
43
+ required_ruby_version: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: "0"
48
+ version:
49
+ required_rubygems_version: !ruby/object:Gem::Requirement
50
+ requirements:
51
+ - - ">="
52
+ - !ruby/object:Gem::Version
53
+ version: "0"
54
+ version:
55
+ requirements: []
56
+
57
+ rubyforge_project: sixcore
58
+ rubygems_version: 1.3.1
59
+ signing_key:
60
+ specification_version: 2
61
+ summary: Basic Function Library for other six projects
62
+ test_files: []
63
+