dev 2.1.70 → 2.1.71

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.
data/lib/apps/svn.rb CHANGED
@@ -1,152 +1,152 @@
1
- require 'fileutils'
2
- require 'tmpdir'
3
- require_relative('../base/dir.rb')
4
- class Svn
5
-
6
- def self.latest_revision
7
- if(Dir.exists?(".svn"))
8
- `svn update`
9
- `svn info`.scan(/Last Changed Rev: ([\d]+)/).each{|m|
10
- return m.first.to_s
11
- }
12
- end
13
- "0"
14
- end
15
-
16
- def self.url
17
- if(Dir.exists?(".svn"))
18
- `svn info`.scan(/URL: ([:\/\.\-\d\w]+)/).each{|m|
19
- return m.first.to_s
20
- }
21
- end
22
- ''
23
- end
24
-
25
- def self.export url, destination
26
- if(!File.exists?(destination.chomp('@')))
27
- `svn export #{url} #{destination}`
28
- end
29
- end
30
-
31
- def self.has_changes? directory=''
32
- directory=Dir.pwd if directory.length==0
33
- Dir.chdir(directory) do
34
- if(File.exists?('.svn'))
35
- return true if `svn status`.scan(/^[MA]/).length>0
36
- end
37
- end
38
- false
39
- end
40
-
41
- def self.add source, directory=''
42
- directory=Dir.pwd if directory.length < 1
43
- Dir.chdir(directory) do
44
- source.each{|f|
45
- puts `svn add #{f} --parents` if `svn status #{f}`.include?('?')
46
- puts `svn add #{f} --parents` if !system("svn status #{f}")
47
- }
48
- end
49
- end
50
-
51
- def self.append_commit_message message,directory=''
52
- directory=Dir.pwd if directory.length < 1
53
- Dir.chdir(directory) do
54
-
55
- end
56
- end
57
-
58
- def self.commit message, directory=''
59
- directory=Dir.pwd if directory.length < 1
60
- Dir.chdir(directory) do
61
- # svn commit -F commit_message_filename
62
- puts `svn commit -m"commit all"`
63
- `svn update`
64
- end
65
- end
66
-
67
- # publish a directory to a new subversion path
68
- # source_dir is the directory with the files to be published
69
- # destination is the new subversion path URL
70
- # source_glob is a string or array of glob directives to specify files in source_dir to be publish
71
- # source_glob defaults to '**/*' to publish all files in the source_dir
72
- def self.publish destination, source_dir, source_filelist=FileList.new('**/*')
73
-
74
- # Support for legacy argument order
75
- if(source_dir.include?('svn:') || source_dir.include?('http:') || source_dir.include?('https:'))
76
- puts 'warning arguments are in legacy order' if Environment.default.debug?
77
- # swap arguments
78
- tmp=source_dir
79
- source_dir=destination
80
- destination=tmp
81
- end
82
-
83
- if(!source_filelist.kind_of?(FileList))
84
- puts 'converting files array into FileList' if Environment.default.debug?
85
- list=FileList.new
86
- source_filelist.each{|item|list.include(item)}
87
- source_fileList=list
88
- end
89
-
90
- output = "\n"
91
- if(`svn info #{destination} 2>&1`.include?('Revision:'))
92
- puts "Svn.publish: destination #{destination} already exists"
93
- else
94
- # create subversion directory
95
- output = output + "svn mkdir #{destination} --parents --message mkdir_for_publishing"
96
- if(!`svn mkdir #{destination} --parents --message mkdir_for_publishing`.include?('Committed'))
97
- raise "failure 'svn mkdir #{destination} --parents --message mkdir_for_publishing'"
98
- end
99
-
100
- Dir.chdir(source_dir) do
101
- files = source_filelist.to_a
102
- end
103
- files=source_filelist
104
- output = output + "\nfiles: "
105
- files.each{|f|
106
- output = output + f + " "
107
- }
108
- pwd=Dir.pwd
109
-
110
- dir="#{Environment.default.tmp_dir}/svn_publish"
111
- Dir.remove dir if File.exists? dir
112
- FileUtils.mkdir dir
113
- Dir.chdir(dir) do
114
- #Dir.mktmpdir{|dir|
115
-
116
- # checkout new subversion directory
117
- output = output + "\nsvn checkout #{destination} #{dir}/to_publish_checkout"
118
- if(!`svn checkout #{destination} #{dir}/to_publish_checkout`.include?('Checked out'))
119
- raise "failure 'svn checkout #{destination} #{dir}/to_publish_checkout'"
120
- end
121
-
122
- # copy files into the checkout out subversion directory to_publish
123
- raise "#{dir}/to_publish_checkout does not exist" if(!File.exists?("#{dir}/to_publish_checkout"))
124
- Dir.chdir("#{dir}/to_publish_checkout") do
125
- File.open('add.txt','w'){|add_file|
126
-
127
- files.each{|f|
128
- fdir=File.dirname(f)
129
- FileUtils.mkdir_p(fdir) if(fdir.length > 0 && !File.exists?(fdir))
130
- FileUtils.cp("#{source_dir}/#{f}","#{f}")
131
- add_file.puts f
132
- }
133
- add_file.close
134
- }
135
-
136
- output = output + "\nsvn add --parents --targets add.txt 2>&1"
137
- `svn add --parents --targets add.txt 2>&1`
138
- commit_output = `svn commit -m"add" 2>&1`
139
- output = output + "\n#{commit_output}"
140
- if(!commit_output.include?("Committed"))
141
- raise "failure 'svn commit -m'added files''" + output
142
- end
143
- end
144
-
145
- #begin
146
- #Dir.remove "#{dir}/to_publish_checkout"
147
- output
148
- end
149
- Dir.remove(dir)
150
- end
151
- end
1
+ require 'fileutils'
2
+ require 'tmpdir'
3
+ require_relative('../base/dir.rb')
4
+ class Svn
5
+
6
+ def self.latest_revision
7
+ if(Dir.exists?(".svn"))
8
+ `svn update`
9
+ `svn info`.scan(/Last Changed Rev: ([\d]+)/).each{|m|
10
+ return m.first.to_s
11
+ }
12
+ end
13
+ "0"
14
+ end
15
+
16
+ def self.url
17
+ if(Dir.exists?(".svn"))
18
+ `svn info`.scan(/URL: ([:\/\.\-\d\w]+)/).each{|m|
19
+ return m.first.to_s
20
+ }
21
+ end
22
+ ''
23
+ end
24
+
25
+ def self.export url, destination
26
+ if(!File.exists?(destination.chomp('@')))
27
+ `svn export #{url} #{destination}`
28
+ end
29
+ end
30
+
31
+ def self.has_changes? directory=''
32
+ directory=Dir.pwd if directory.length==0
33
+ Dir.chdir(directory) do
34
+ if(File.exists?('.svn'))
35
+ return true if `svn status`.scan(/^[MA]/).length>0
36
+ end
37
+ end
38
+ false
39
+ end
40
+
41
+ def self.add source, directory=''
42
+ directory=Dir.pwd if directory.length < 1
43
+ Dir.chdir(directory) do
44
+ source.each{|f|
45
+ puts `svn add #{f} --parents` if `svn status #{f}`.include?('?')
46
+ puts `svn add #{f} --parents` if !system("svn status #{f}")
47
+ }
48
+ end
49
+ end
50
+
51
+ def self.append_commit_message message,directory=''
52
+ directory=Dir.pwd if directory.length < 1
53
+ Dir.chdir(directory) do
54
+
55
+ end
56
+ end
57
+
58
+ def self.commit message, directory=''
59
+ directory=Dir.pwd if directory.length < 1
60
+ Dir.chdir(directory) do
61
+ # svn commit -F commit_message_filename
62
+ puts `svn commit -m"commit all"`
63
+ `svn update`
64
+ end
65
+ end
66
+
67
+ # publish a directory to a new subversion path
68
+ # source_dir is the directory with the files to be published
69
+ # destination is the new subversion path URL
70
+ # source_glob is a string or array of glob directives to specify files in source_dir to be publish
71
+ # source_glob defaults to '**/*' to publish all files in the source_dir
72
+ def self.publish destination, source_dir, source_filelist=FileList.new('**/*')
73
+
74
+ # Support for legacy argument order
75
+ if(source_dir.include?('svn:') || source_dir.include?('http:') || source_dir.include?('https:'))
76
+ puts 'warning arguments are in legacy order' if Environment.default.debug?
77
+ # swap arguments
78
+ tmp=source_dir
79
+ source_dir=destination
80
+ destination=tmp
81
+ end
82
+
83
+ if(!source_filelist.kind_of?(FileList))
84
+ puts 'converting files array into FileList' if Environment.default.debug?
85
+ list=FileList.new
86
+ source_filelist.each{|item|list.include(item)}
87
+ source_fileList=list
88
+ end
89
+
90
+ output = "\n"
91
+ if(`svn info #{destination} 2>&1`.include?('Revision:'))
92
+ puts "Svn.publish: destination #{destination} already exists"
93
+ else
94
+ # create subversion directory
95
+ output = output + "svn mkdir #{destination} --parents --message mkdir_for_publishing"
96
+ if(!`svn mkdir #{destination} --parents --message mkdir_for_publishing`.include?('Committed'))
97
+ raise "failure 'svn mkdir #{destination} --parents --message mkdir_for_publishing'"
98
+ end
99
+
100
+ Dir.chdir(source_dir) do
101
+ files = source_filelist.to_a
102
+ end
103
+ files=source_filelist
104
+ output = output + "\nfiles: "
105
+ files.each{|f|
106
+ output = output + f + " "
107
+ }
108
+ pwd=Dir.pwd
109
+
110
+ dir="#{Environment.default.tmp_dir}/svn_publish"
111
+ Dir.remove dir if File.exists? dir
112
+ FileUtils.mkdir dir
113
+ Dir.chdir(dir) do
114
+ #Dir.mktmpdir{|dir|
115
+
116
+ # checkout new subversion directory
117
+ output = output + "\nsvn checkout #{destination} #{dir}/to_publish_checkout"
118
+ if(!`svn checkout #{destination} #{dir}/to_publish_checkout`.include?('Checked out'))
119
+ raise "failure 'svn checkout #{destination} #{dir}/to_publish_checkout'"
120
+ end
121
+
122
+ # copy files into the checkout out subversion directory to_publish
123
+ raise "#{dir}/to_publish_checkout does not exist" if(!File.exists?("#{dir}/to_publish_checkout"))
124
+ Dir.chdir("#{dir}/to_publish_checkout") do
125
+ File.open('add.txt','w'){|add_file|
126
+
127
+ files.each{|f|
128
+ fdir=File.dirname(f)
129
+ FileUtils.mkdir_p(fdir) if(fdir.length > 0 && !File.exists?(fdir))
130
+ FileUtils.cp("#{source_dir}/#{f}","#{f}")
131
+ add_file.puts f
132
+ }
133
+ add_file.close
134
+ }
135
+
136
+ output = output + "\nsvn add --parents --targets add.txt 2>&1"
137
+ `svn add --parents --targets add.txt 2>&1`
138
+ commit_output = `svn commit -m"add" 2>&1`
139
+ output = output + "\n#{commit_output}"
140
+ if(!commit_output.include?("Committed"))
141
+ raise "failure 'svn commit -m'added files''" + output
142
+ end
143
+ end
144
+
145
+ #begin
146
+ #Dir.remove "#{dir}/to_publish_checkout"
147
+ output
148
+ end
149
+ Dir.remove(dir)
150
+ end
151
+ end
152
152
  end
@@ -1,16 +1,16 @@
1
- #COMMANDS[:build]=['xcodebuild clean -scheme Hydrogen -destination "name=iPhone 6"',
2
- # 'xcodebuild build -scheme Hydrogen -destination "name=iPhone 6"']
3
- # COMMANDS[:test]=['xcodebuild test -scheme Hydrogen -destination "name=iPhone 6"'] if RUBY_PLATFORM.include?('darwin')
4
-
5
- class XCodeBuild < Hash
6
- def self.get_build_commands xcodeproj_filename
7
- #build_commands=Array.new
8
- #build_command=Command.new('xcodebuild build')
9
- #build_command[:directory] = File.dirname(xcodeproj_filename)
10
-
11
- #name=xcodeproj_filename.gsub('.xcodeproj','')
12
- #build_commands << "xcodebuild clean -scheme #{name} -destination \"name=iPhone 6\""
13
- #build_commands << "xcodebuild build -scheme #{name} -destination \"name=iPhone 6\""
14
- #build_commands << build_command
15
- end
1
+ #COMMANDS[:build]=['xcodebuild clean -scheme Hydrogen -destination "name=iPhone 6"',
2
+ # 'xcodebuild build -scheme Hydrogen -destination "name=iPhone 6"']
3
+ # COMMANDS[:test]=['xcodebuild test -scheme Hydrogen -destination "name=iPhone 6"'] if RUBY_PLATFORM.include?('darwin')
4
+
5
+ class XCodeBuild < Hash
6
+ def self.get_build_commands xcodeproj_filename
7
+ #build_commands=Array.new
8
+ #build_command=Command.new('xcodebuild build')
9
+ #build_command[:directory] = File.dirname(xcodeproj_filename)
10
+
11
+ #name=xcodeproj_filename.gsub('.xcodeproj','')
12
+ #build_commands << "xcodebuild clean -scheme #{name} -destination \"name=iPhone 6\""
13
+ #build_commands << "xcodebuild build -scheme #{name} -destination \"name=iPhone 6\""
14
+ #build_commands << build_command
15
+ end
16
16
  end
data/lib/apps.rb CHANGED
@@ -1,3 +1,3 @@
1
- puts __FILE__ if defined?(DEBUG)
2
-
1
+ puts __FILE__ if defined?(DEBUG)
2
+
3
3
  ['git','msbuild','nuget','svn','wix','xcodebuild'].each{|name| require_relative("apps/#{name}.rb")}
data/lib/base/dir.rb CHANGED
@@ -1,99 +1,99 @@
1
- require 'fileutils'
2
-
3
- class Dir
4
- def self.make directory
5
- FileUtils.mkdir_p directory if !File.exists? directory
6
- end
7
- def self.remove directory, remove_empty_parents=false
8
- begin
9
- FileUtils.rm_rf directory if(!Dir.empty?(directory))
10
- FileUtils.rm_r directory if(File.exists?(directory))
11
- if(remove_empty_parents)
12
- parent_dir=File.dirname(directory)
13
- Dir.remove parent_dir, true if(Dir.empty?(parent_dir))
14
- end
15
- rescue
16
- end
17
- end
18
- def self.empty? directory
19
- if((Dir.entries(directory) - %w{ . .. }).empty?)
20
- return true
21
- end
22
- false
23
- end
24
-
25
- def self.get_latest_mtime directory
26
- mtime=Time.new(1980)
27
- Dir.chdir(directory) do
28
- latest_filename=''
29
- Dir.glob('**/*.*').each{|f|
30
- if mtime.nil? || File.mtime(f) > mtime
31
- mtime=File.mtime(f)
32
- latest_filename=f
33
- end
34
- }
35
- puts " latest_mtime #{mtime.to_s} #{latest_filename}" if Environment.default.debug?
36
- end
37
- mtime
38
- end
39
-
40
- def self.zip(directory,files,zipfilename)
41
- if Gem::Specification::find_all_by_name('rubyzip').any?
42
- require 'zip'
43
- File.delete(zipfilename) if(File.exists?(zipfilename))
44
- Zip::File.open(zipfilename,Zip::File::CREATE) do |zipfile|
45
- Dir.chdir(directory) do
46
- count = 0
47
- files.each{|source_file|
48
- zipfile.add(source_file,"#{directory}/#{source_file}")
49
- count = count + 1
50
- }
51
- puts "added #{count} files to #{zipfilename}"
52
- end
53
- end
54
- else
55
- puts "rubyzip gem is not installed 'gem install rubyzip'"
56
- end
57
- end
58
-
59
- def self.unzip(zipfilename,directory)
60
- if Gem::Specification::find_all_by_name('rubyzip').any?
61
- require 'zip'
62
- count = 0
63
- Zip::File.open(zipfilename) do |zip_file|
64
- zip_file.each do |entry|
65
- dest = "#{directory}/#{entry.to_s}"
66
- parent_dir=File.dirname(dest)
67
- FileUtils.mkdir_p parent_dir if(!Dir.exists?(parent_dir))
68
- entry.extract("#{directory}/#{entry.to_s}")
69
- count = count + 1
70
- end
71
- end
72
- puts "extracted #{count} files to #{directory}"
73
- else
74
- puts "rubyzip gem is not installed 'gem install rubyzip'"
75
- end
76
- end
77
-
78
- def self.copy_files(src_dir,glob_pattern,exclude_patterns,target_dir)
79
- if(Dir.exists?(src_dir))
80
- Dir.chdir(src_dir) do
81
- Dir.glob(glob_pattern).each{|f|
82
- if(File.file?(f))
83
- exclude = false
84
- if(!exclude_patterns.nil?)
85
- exclude_patterns.each{|p|
86
- exclude = true if(f.include?(p))
87
- }
88
- end
89
- if(!exclude)
90
- dest = "#{target_dir}/#{f}"
91
- FileUtils.mkdir_p(File.dirname(dest)) if(!Dir.exists?(File.dirname(dest)))
92
- FileUtils.cp(f,dest)
93
- end
94
- end
95
- }
96
- end
97
- end
98
- end
1
+ require 'fileutils'
2
+
3
+ class Dir
4
+ def self.make directory
5
+ FileUtils.mkdir_p directory if !File.exists? directory
6
+ end
7
+ def self.remove directory, remove_empty_parents=false
8
+ begin
9
+ FileUtils.rm_rf directory if(!Dir.empty?(directory))
10
+ FileUtils.rm_r directory if(File.exists?(directory))
11
+ if(remove_empty_parents)
12
+ parent_dir=File.dirname(directory)
13
+ Dir.remove parent_dir, true if(Dir.empty?(parent_dir))
14
+ end
15
+ rescue
16
+ end
17
+ end
18
+ def self.empty? directory
19
+ if((Dir.entries(directory) - %w{ . .. }).empty?)
20
+ return true
21
+ end
22
+ false
23
+ end
24
+
25
+ def self.get_latest_mtime directory
26
+ mtime=Time.new(1980)
27
+ Dir.chdir(directory) do
28
+ latest_filename=''
29
+ Dir.glob('**/*.*').each{|f|
30
+ if mtime.nil? || File.mtime(f) > mtime
31
+ mtime=File.mtime(f)
32
+ latest_filename=f
33
+ end
34
+ }
35
+ puts " latest_mtime #{mtime.to_s} #{latest_filename}" if Environment.default.debug?
36
+ end
37
+ mtime
38
+ end
39
+
40
+ def self.zip(directory,files,zipfilename)
41
+ if Gem::Specification::find_all_by_name('rubyzip').any?
42
+ require 'zip'
43
+ File.delete(zipfilename) if(File.exists?(zipfilename))
44
+ Zip::File.open(zipfilename,Zip::File::CREATE) do |zipfile|
45
+ Dir.chdir(directory) do
46
+ count = 0
47
+ files.each{|source_file|
48
+ zipfile.add(source_file,"#{directory}/#{source_file}")
49
+ count = count + 1
50
+ }
51
+ puts "added #{count} files to #{zipfilename}"
52
+ end
53
+ end
54
+ else
55
+ puts "rubyzip gem is not installed 'gem install rubyzip'"
56
+ end
57
+ end
58
+
59
+ def self.unzip(zipfilename,directory)
60
+ if Gem::Specification::find_all_by_name('rubyzip').any?
61
+ require 'zip'
62
+ count = 0
63
+ Zip::File.open(zipfilename) do |zip_file|
64
+ zip_file.each do |entry|
65
+ dest = "#{directory}/#{entry.to_s}"
66
+ parent_dir=File.dirname(dest)
67
+ FileUtils.mkdir_p parent_dir if(!Dir.exists?(parent_dir))
68
+ entry.extract("#{directory}/#{entry.to_s}")
69
+ count = count + 1
70
+ end
71
+ end
72
+ puts "extracted #{count} files to #{directory}"
73
+ else
74
+ puts "rubyzip gem is not installed 'gem install rubyzip'"
75
+ end
76
+ end
77
+
78
+ def self.copy_files(src_dir,glob_pattern,exclude_patterns,target_dir)
79
+ if(Dir.exists?(src_dir))
80
+ Dir.chdir(src_dir) do
81
+ Dir.glob(glob_pattern).each{|f|
82
+ if(File.file?(f))
83
+ exclude = false
84
+ if(!exclude_patterns.nil?)
85
+ exclude_patterns.each{|p|
86
+ exclude = true if(f.include?(p))
87
+ }
88
+ end
89
+ if(!exclude)
90
+ dest = "#{target_dir}/#{f}"
91
+ FileUtils.mkdir_p(File.dirname(dest)) if(!Dir.exists?(File.dirname(dest)))
92
+ FileUtils.cp(f,dest)
93
+ end
94
+ end
95
+ }
96
+ end
97
+ end
98
+ end
99
99
  end
data/lib/base/file.rb CHANGED
@@ -1,35 +1,35 @@
1
- puts __FILE__ if defined?(DEBUG)
2
-
3
- require 'fileutils'
4
-
5
- class File
6
- def self.amalgamate filename,source
7
- File.open(filename,'w'){|file|
8
- source.each{|source_file|
9
- file.puts IO.read(source_file)
10
- }
11
- }
12
- end
13
-
14
- def self.publish destination, source_dir, source_glob='**/*', overwrite_existing=false
15
-
16
- output = "\n"
17
- FileUtils.mkdir_p destination if !File.exists? destination
18
-
19
- files=nil
20
- Dir.chdir(source_dir) do
21
- files=FileList.new(source_glob).to_a
22
- end
23
- output = output + "\nfiles: #{files}.to_s"
24
-
25
- Dir.chdir(source_dir) do
26
- files.each{|f|
27
- file="#{destination}/#{f}"
28
- dirname=File.dirname(file)
29
- FileUtils.mkdir_p dirname if !File.exists? dirname
30
- FileUtils.cp(f,file) if !File.exists? file || overwrite_existing
31
- }
32
- end
33
- output
34
- end
1
+ puts __FILE__ if defined?(DEBUG)
2
+
3
+ require 'fileutils'
4
+
5
+ class File
6
+ def self.amalgamate filename,source
7
+ File.open(filename,'w'){|file|
8
+ source.each{|source_file|
9
+ file.puts IO.read(source_file)
10
+ }
11
+ }
12
+ end
13
+
14
+ def self.publish destination, source_dir, source_glob='**/*', overwrite_existing=false
15
+
16
+ output = "\n"
17
+ FileUtils.mkdir_p destination if !File.exists? destination
18
+
19
+ files=nil
20
+ Dir.chdir(source_dir) do
21
+ files=FileList.new(source_glob).to_a
22
+ end
23
+ output = output + "\nfiles: #{files}.to_s"
24
+
25
+ Dir.chdir(source_dir) do
26
+ files.each{|f|
27
+ file="#{destination}/#{f}"
28
+ dirname=File.dirname(file)
29
+ FileUtils.mkdir_p dirname if !File.exists? dirname
30
+ FileUtils.cp(f,file) if !File.exists? file || overwrite_existing
31
+ }
32
+ end
33
+ output
34
+ end
35
35
  end