qa_robusta 0.1.3
Sign up to get free protection for your applications and to get access to all the features.
- data/.autotest +23 -0
- data/.gemtest +0 -0
- data/History.txt +6 -0
- data/Manifest.txt +101 -0
- data/README.txt +48 -0
- data/Rakefile +18 -0
- data/bin/qa_robusta +14 -0
- data/common/Rakefile +95 -0
- data/common/conf/monkey_patch.yaml +8 -0
- data/common/conf/monkey_patch.yaml.ex +10 -0
- data/common/lib/array.rb +9 -0
- data/common/lib/cache.rb +12 -0
- data/common/lib/constants.rb +35 -0
- data/common/lib/error_defns.rb +13 -0
- data/common/lib/format_html_tmp.html +34 -0
- data/common/lib/formatters.rb +18 -0
- data/common/lib/gem_helpers.rb +29 -0
- data/common/lib/gems/.svn/entries +43 -0
- data/common/lib/gems/cache/.svn/entries +28 -0
- data/common/lib/gems/doc/.svn/entries +28 -0
- data/common/lib/gems/gems/.svn/entries +28 -0
- data/common/lib/gems/installed/.svn/entries +40 -0
- data/common/lib/gems/installed/cache/.svn/entries +28 -0
- data/common/lib/gems/installed/doc/.svn/entries +28 -0
- data/common/lib/gems/installed/gems/.svn/entries +28 -0
- data/common/lib/gems/installed/specifications/.svn/entries +28 -0
- data/common/lib/gems/specifications/.svn/entries +28 -0
- data/common/lib/gen_suite_doc.rb +52 -0
- data/common/lib/load_test_data.rb +18 -0
- data/common/lib/monkey_patch.rb +149 -0
- data/common/lib/navigate_mech.rb +79 -0
- data/common/lib/update_element.rb +12 -0
- data/common/monkey_patches/mechanize.rb +589 -0
- data/common/monkey_patches/table.rb +363 -0
- data/common/monkey_patches/telnet.rb +420 -0
- data/common/monkey_patches/unit.rb +538 -0
- data/demo/demo_site.rb +38 -0
- data/demo/public/javascripts/jquery-1.6.2.min.js +18 -0
- data/demo/views/index.erb +35 -0
- data/lib/monkey_patch.rb +26 -0
- data/lib/qa_robusta.rb +3 -0
- data/mechanize_interface/conf/app.yaml +10 -0
- data/mechanize_interface/lib/agent.rb +18 -0
- data/mechanize_interface/lib/app_require.rb +19 -0
- data/mechanize_interface/lib/get_page.rb +20 -0
- data/mechanize_interface/lib/login.rb +30 -0
- data/mechanize_interface/lib/navigation_paths.rb +12 -0
- data/mechanize_interface/test/lib/mech_unit_test.rb +19 -0
- data/qa_observer/conf/dev_users.yaml +9 -0
- data/qa_observer/conf/development.yaml +3 -0
- data/qa_observer/conf/qa_observer_links.yaml +10 -0
- data/qa_observer/generators/site/site_generator.rb +61 -0
- data/qa_observer/generators/site/templates/base_urls.yaml.erb +6 -0
- data/qa_observer/generators/site/templates/create_flow.rb.erb +54 -0
- data/qa_observer/generators/site/templates/elements.rb.erb +61 -0
- data/qa_observer/generators/site/templates/html_elements.yaml +22 -0
- data/qa_observer/generators/site/templates/navigate.rb +32 -0
- data/qa_observer/generators/site/templates/reports.rb +7 -0
- data/qa_observer/generators/site/templates/users_list.yaml +21 -0
- data/qa_observer/generators/test_case/templates/test_case.rb.erb +62 -0
- data/qa_observer/generators/test_case/test_case_generator.rb +29 -0
- data/qa_observer/lib/doc.rb +103 -0
- data/qa_observer/lib/env_details.rb +2 -0
- data/qa_observer/lib/error_defns.rb +3 -0
- data/qa_observer/lib/form_helpers.rb +52 -0
- data/qa_observer/lib/reports.rb +7 -0
- data/qa_observer/lib/requires.rb +23 -0
- data/qa_observer/lib/system_test.rb +146 -0
- data/qa_observer/lib/test_extention.rb +29 -0
- data/qa_observer/lib/update_element.rb +12 -0
- data/qa_observer/lib/watir.rb +42 -0
- data/qa_observer/script/destroy +14 -0
- data/qa_observer/script/generate +14 -0
- data/qa_observer/sites/demo/conf/base_urls.yaml +6 -0
- data/qa_observer/sites/demo/conf/html_elements.yaml +22 -0
- data/qa_observer/sites/demo/conf/remote_machine.yaml +12 -0
- data/qa_observer/sites/demo/conf/users_list.yaml +21 -0
- data/qa_observer/sites/demo/elements/demo_elements.rb +9 -0
- data/qa_observer/sites/demo/flows/demo_flows.rb +37 -0
- data/qa_observer/sites/demo/helpers/.placeholder +0 -0
- data/qa_observer/sites/demo/lib/navigate.rb +32 -0
- data/qa_observer/sites/demo/lib/reports.rb +7 -0
- data/qa_observer/sites/demo/results/.placeholder +0 -0
- data/qa_observer/sites/demo/results/images/.placeholder +0 -0
- data/qa_observer/sites/demo/test_cases/home_page.rb +106 -0
- data/qa_observer/suites/demo_lg_chrome/lg.yaml +11 -0
- data/qa_observer/suites/demo_md_chrome/md.yaml +11 -0
- data/qa_observer/suites/demo_sm_chrome/sm.yaml +11 -0
- data/qa_observer/suites/init.rb +41 -0
- data/qa_observer/test_runner.rb +125 -0
- data/remote_unix/helpers/constants.rb +8 -0
- data/remote_unix/helpers/out_xforms.rb +48 -0
- data/remote_unix/lib/common.rb +52 -0
- data/remote_unix/lib/error_defn.rb +4 -0
- data/remote_unix/lib/general_unix.rb +308 -0
- data/remote_unix/lib/network_commands.rb +41 -0
- data/remote_unix/lib/network_info.rb +98 -0
- data/remote_unix/lib/postfix_commands.rb +87 -0
- data/remote_unix/lib/postfix_info.rb +30 -0
- data/remote_unix/lib/requires.rb +25 -0
- data/remote_unix/lib/scp.rb +22 -0
- data/remote_unix/lib/ssh.rb +46 -0
- data/test/test_qa_robusta.rb +8 -0
- metadata +219 -0
@@ -0,0 +1,18 @@
|
|
1
|
+
module Format
|
2
|
+
module HTML
|
3
|
+
def self.to_txt(html)
|
4
|
+
base = File.expand_path(File.dirname(__FILE__))
|
5
|
+
lynx_path = "#{base}/../../windows_bin/lynx"
|
6
|
+
tmp_file = "#{base}/format_html_tmp.html"
|
7
|
+
fd = File.open(tmp_file, 'w+')
|
8
|
+
fd.puts html
|
9
|
+
fd.close
|
10
|
+
if RUBY_PLATFORM =~ /win32/i
|
11
|
+
cmd = "#{lynx_path}/lynx.exe -cfg=#{lynx_path}/lynx.cfg"
|
12
|
+
else
|
13
|
+
cmd = '/usr/bin/lynx'
|
14
|
+
end
|
15
|
+
`#{cmd} -dump #{tmp_file}`
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'find'
|
3
|
+
require 'fileutils'
|
4
|
+
|
5
|
+
module GemHelpers
|
6
|
+
def self.update_gem_path(path)
|
7
|
+
Gem.clear_paths
|
8
|
+
ENV['GEM_HOME'] = File.expand_path(path)
|
9
|
+
ENV['GEM_PATH'] = File.expand_path(path)
|
10
|
+
end
|
11
|
+
|
12
|
+
# FIXME: update to handle version
|
13
|
+
def self.is_installed?(gem_install_dir, gem_name)
|
14
|
+
spec = File.basename(gem_name.gsub(/\.gem$/, '.gemspec'))
|
15
|
+
dir = File.expand_path(gem_install_dir)
|
16
|
+
File.exists?("#{dir}/specifications/#{spec}")
|
17
|
+
end
|
18
|
+
|
19
|
+
# TODO once the cross platform gem install is working as expected
|
20
|
+
# copy over to other projects
|
21
|
+
def self.install(gem, install_dir)
|
22
|
+
#unless GemHelpers.is_installed?(install_dir, gem)
|
23
|
+
fork { exec("gem install #{gem} --no-rdoc --no-ri -i #{install_dir}") }
|
24
|
+
Process.wait2
|
25
|
+
FileUtils.chmod_R 0777, install_dir
|
26
|
+
#end
|
27
|
+
end
|
28
|
+
|
29
|
+
end
|
@@ -0,0 +1,43 @@
|
|
1
|
+
10
|
2
|
+
|
3
|
+
dir
|
4
|
+
410
|
5
|
+
file:///home/cliff/l_bkup/svn/repos/trunk/cyberconnect/qa_robusta/common/lib/gems
|
6
|
+
file:///home/cliff/l_bkup/svn/repos
|
7
|
+
|
8
|
+
|
9
|
+
|
10
|
+
2011-10-02T00:31:06.266671Z
|
11
|
+
366
|
12
|
+
cliff
|
13
|
+
|
14
|
+
|
15
|
+
|
16
|
+
|
17
|
+
|
18
|
+
|
19
|
+
|
20
|
+
|
21
|
+
|
22
|
+
|
23
|
+
|
24
|
+
|
25
|
+
|
26
|
+
|
27
|
+
b2aa1ad8-1ad5-46c2-9d55-a5a97d169f3f
|
28
|
+
|
29
|
+
installed
|
30
|
+
dir
|
31
|
+
|
32
|
+
cache
|
33
|
+
dir
|
34
|
+
|
35
|
+
specifications
|
36
|
+
dir
|
37
|
+
|
38
|
+
doc
|
39
|
+
dir
|
40
|
+
|
41
|
+
gems
|
42
|
+
dir
|
43
|
+
|
@@ -0,0 +1,28 @@
|
|
1
|
+
10
|
2
|
+
|
3
|
+
dir
|
4
|
+
410
|
5
|
+
file:///home/cliff/l_bkup/svn/repos/trunk/cyberconnect/qa_robusta/common/lib/gems/cache
|
6
|
+
file:///home/cliff/l_bkup/svn/repos
|
7
|
+
|
8
|
+
|
9
|
+
|
10
|
+
2011-10-02T00:31:06.266671Z
|
11
|
+
366
|
12
|
+
cliff
|
13
|
+
|
14
|
+
|
15
|
+
|
16
|
+
|
17
|
+
|
18
|
+
|
19
|
+
|
20
|
+
|
21
|
+
|
22
|
+
|
23
|
+
|
24
|
+
|
25
|
+
|
26
|
+
|
27
|
+
b2aa1ad8-1ad5-46c2-9d55-a5a97d169f3f
|
28
|
+
|
@@ -0,0 +1,28 @@
|
|
1
|
+
10
|
2
|
+
|
3
|
+
dir
|
4
|
+
410
|
5
|
+
file:///home/cliff/l_bkup/svn/repos/trunk/cyberconnect/qa_robusta/common/lib/gems/doc
|
6
|
+
file:///home/cliff/l_bkup/svn/repos
|
7
|
+
|
8
|
+
|
9
|
+
|
10
|
+
2011-10-02T00:31:06.266671Z
|
11
|
+
366
|
12
|
+
cliff
|
13
|
+
|
14
|
+
|
15
|
+
|
16
|
+
|
17
|
+
|
18
|
+
|
19
|
+
|
20
|
+
|
21
|
+
|
22
|
+
|
23
|
+
|
24
|
+
|
25
|
+
|
26
|
+
|
27
|
+
b2aa1ad8-1ad5-46c2-9d55-a5a97d169f3f
|
28
|
+
|
@@ -0,0 +1,28 @@
|
|
1
|
+
10
|
2
|
+
|
3
|
+
dir
|
4
|
+
410
|
5
|
+
file:///home/cliff/l_bkup/svn/repos/trunk/cyberconnect/qa_robusta/common/lib/gems/gems
|
6
|
+
file:///home/cliff/l_bkup/svn/repos
|
7
|
+
|
8
|
+
|
9
|
+
|
10
|
+
2011-10-02T00:31:06.266671Z
|
11
|
+
366
|
12
|
+
cliff
|
13
|
+
|
14
|
+
|
15
|
+
|
16
|
+
|
17
|
+
|
18
|
+
|
19
|
+
|
20
|
+
|
21
|
+
|
22
|
+
|
23
|
+
|
24
|
+
|
25
|
+
|
26
|
+
|
27
|
+
b2aa1ad8-1ad5-46c2-9d55-a5a97d169f3f
|
28
|
+
|
@@ -0,0 +1,40 @@
|
|
1
|
+
10
|
2
|
+
|
3
|
+
dir
|
4
|
+
410
|
5
|
+
file:///home/cliff/l_bkup/svn/repos/trunk/cyberconnect/qa_robusta/common/lib/gems/installed
|
6
|
+
file:///home/cliff/l_bkup/svn/repos
|
7
|
+
|
8
|
+
|
9
|
+
|
10
|
+
2011-10-02T00:31:06.266671Z
|
11
|
+
366
|
12
|
+
cliff
|
13
|
+
|
14
|
+
|
15
|
+
|
16
|
+
|
17
|
+
|
18
|
+
|
19
|
+
|
20
|
+
|
21
|
+
|
22
|
+
|
23
|
+
|
24
|
+
|
25
|
+
|
26
|
+
|
27
|
+
b2aa1ad8-1ad5-46c2-9d55-a5a97d169f3f
|
28
|
+
|
29
|
+
cache
|
30
|
+
dir
|
31
|
+
|
32
|
+
specifications
|
33
|
+
dir
|
34
|
+
|
35
|
+
doc
|
36
|
+
dir
|
37
|
+
|
38
|
+
gems
|
39
|
+
dir
|
40
|
+
|
@@ -0,0 +1,28 @@
|
|
1
|
+
10
|
2
|
+
|
3
|
+
dir
|
4
|
+
410
|
5
|
+
file:///home/cliff/l_bkup/svn/repos/trunk/cyberconnect/qa_robusta/common/lib/gems/installed/cache
|
6
|
+
file:///home/cliff/l_bkup/svn/repos
|
7
|
+
|
8
|
+
|
9
|
+
|
10
|
+
2011-10-02T00:31:06.266671Z
|
11
|
+
366
|
12
|
+
cliff
|
13
|
+
|
14
|
+
|
15
|
+
|
16
|
+
|
17
|
+
|
18
|
+
|
19
|
+
|
20
|
+
|
21
|
+
|
22
|
+
|
23
|
+
|
24
|
+
|
25
|
+
|
26
|
+
|
27
|
+
b2aa1ad8-1ad5-46c2-9d55-a5a97d169f3f
|
28
|
+
|
@@ -0,0 +1,28 @@
|
|
1
|
+
10
|
2
|
+
|
3
|
+
dir
|
4
|
+
410
|
5
|
+
file:///home/cliff/l_bkup/svn/repos/trunk/cyberconnect/qa_robusta/common/lib/gems/installed/doc
|
6
|
+
file:///home/cliff/l_bkup/svn/repos
|
7
|
+
|
8
|
+
|
9
|
+
|
10
|
+
2011-10-02T00:31:06.266671Z
|
11
|
+
366
|
12
|
+
cliff
|
13
|
+
|
14
|
+
|
15
|
+
|
16
|
+
|
17
|
+
|
18
|
+
|
19
|
+
|
20
|
+
|
21
|
+
|
22
|
+
|
23
|
+
|
24
|
+
|
25
|
+
|
26
|
+
|
27
|
+
b2aa1ad8-1ad5-46c2-9d55-a5a97d169f3f
|
28
|
+
|
@@ -0,0 +1,28 @@
|
|
1
|
+
10
|
2
|
+
|
3
|
+
dir
|
4
|
+
410
|
5
|
+
file:///home/cliff/l_bkup/svn/repos/trunk/cyberconnect/qa_robusta/common/lib/gems/installed/gems
|
6
|
+
file:///home/cliff/l_bkup/svn/repos
|
7
|
+
|
8
|
+
|
9
|
+
|
10
|
+
2011-10-02T00:31:06.266671Z
|
11
|
+
366
|
12
|
+
cliff
|
13
|
+
|
14
|
+
|
15
|
+
|
16
|
+
|
17
|
+
|
18
|
+
|
19
|
+
|
20
|
+
|
21
|
+
|
22
|
+
|
23
|
+
|
24
|
+
|
25
|
+
|
26
|
+
|
27
|
+
b2aa1ad8-1ad5-46c2-9d55-a5a97d169f3f
|
28
|
+
|
@@ -0,0 +1,28 @@
|
|
1
|
+
10
|
2
|
+
|
3
|
+
dir
|
4
|
+
410
|
5
|
+
file:///home/cliff/l_bkup/svn/repos/trunk/cyberconnect/qa_robusta/common/lib/gems/installed/specifications
|
6
|
+
file:///home/cliff/l_bkup/svn/repos
|
7
|
+
|
8
|
+
|
9
|
+
|
10
|
+
2011-10-02T00:31:06.266671Z
|
11
|
+
366
|
12
|
+
cliff
|
13
|
+
|
14
|
+
|
15
|
+
|
16
|
+
|
17
|
+
|
18
|
+
|
19
|
+
|
20
|
+
|
21
|
+
|
22
|
+
|
23
|
+
|
24
|
+
|
25
|
+
|
26
|
+
|
27
|
+
b2aa1ad8-1ad5-46c2-9d55-a5a97d169f3f
|
28
|
+
|
@@ -0,0 +1,28 @@
|
|
1
|
+
10
|
2
|
+
|
3
|
+
dir
|
4
|
+
410
|
5
|
+
file:///home/cliff/l_bkup/svn/repos/trunk/cyberconnect/qa_robusta/common/lib/gems/specifications
|
6
|
+
file:///home/cliff/l_bkup/svn/repos
|
7
|
+
|
8
|
+
|
9
|
+
|
10
|
+
2011-10-02T00:31:06.266671Z
|
11
|
+
366
|
12
|
+
cliff
|
13
|
+
|
14
|
+
|
15
|
+
|
16
|
+
|
17
|
+
|
18
|
+
|
19
|
+
|
20
|
+
|
21
|
+
|
22
|
+
|
23
|
+
|
24
|
+
|
25
|
+
|
26
|
+
|
27
|
+
b2aa1ad8-1ad5-46c2-9d55-a5a97d169f3f
|
28
|
+
|
@@ -0,0 +1,52 @@
|
|
1
|
+
GEN_BASE_DIR = File.expand_path(File.dirname(__FILE__))
|
2
|
+
|
3
|
+
require "#{GEN_BASE_DIR}/../../qa_observer/lib/doc"
|
4
|
+
require "#{GEN_BASE_DIR}/gem_helpers"
|
5
|
+
GemHelpers.update_gem_path "#{GEN_BASE_DIR}/../gems/installed"
|
6
|
+
require 'faster_csv'
|
7
|
+
require 'hpricot'
|
8
|
+
require 'ruby-debug'
|
9
|
+
require 'fileutils'
|
10
|
+
|
11
|
+
module Suite
|
12
|
+
# given a base :suite_dir create doc based on
|
13
|
+
# suite definition from each yaml within desired :suites
|
14
|
+
def self.create_doc(params={})
|
15
|
+
raise ArgumentError unless params.has_key?(:suite_dir) &&
|
16
|
+
params.has_key?(:suites)
|
17
|
+
|
18
|
+
doc_dir = "#{params[:suite_dir]}/doc"
|
19
|
+
FileUtils.mkdir_p doc_dir unless File.directory?(doc_dir)
|
20
|
+
|
21
|
+
params[:suites].each { |suite|
|
22
|
+
csv = []
|
23
|
+
|
24
|
+
header = ['Test File', 'Test Method', 'Documentation']
|
25
|
+
csv << FasterCSV.generate_line(header)
|
26
|
+
|
27
|
+
fd = File.open("#{doc_dir}/#{suite}.csv", 'w+')
|
28
|
+
|
29
|
+
Dir.entries("#{params[:suite_dir]}/#{suite}").each { |entry|
|
30
|
+
next unless entry =~ /\.yaml$/
|
31
|
+
|
32
|
+
suite_cfg = YAML::load_file("#{params[:suite_dir]}/#{suite}/#{entry}")
|
33
|
+
|
34
|
+
suite_cfg[:suites].each { |test_class|
|
35
|
+
$test_case_dir = "#{GEN_BASE_DIR}/../../qa_observer/sites/#{test_class[:site]}/test_cases"
|
36
|
+
test_class_file = "#{$test_case_dir}/#{test_class[:test_case_file]}"
|
37
|
+
|
38
|
+
TCDoc.process_test_class_file(test_class_file).each_pair { |method, doc|
|
39
|
+
record = [test_class[:test_case_file], method, doc]
|
40
|
+
csv << FasterCSV.generate_line(record)
|
41
|
+
}
|
42
|
+
}
|
43
|
+
}
|
44
|
+
fd.puts csv
|
45
|
+
fd.close
|
46
|
+
}
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
|
51
|
+
|
52
|
+
|
@@ -0,0 +1,18 @@
|
|
1
|
+
module LoadTestConfig
|
2
|
+
def self.stuff(conf_dir)
|
3
|
+
$test_data = {}
|
4
|
+
# lazily load all conf data without call to load_fixture
|
5
|
+
path=File.expand_path(conf_dir)
|
6
|
+
Dir.entries("#{conf_dir}/../conf").each { |i|
|
7
|
+
next if File.directory?("#{path}/#{i}") || i.to_s == "." || i.to_s == ".." ||
|
8
|
+
i.to_s !~ /[\.yml$|\.yaml$]/i
|
9
|
+
key=i.gsub(/\..*$/, '').to_sym
|
10
|
+
puts "LOADING CONF: #{TEST_CASE_DIR}/../conf/#{i}}"
|
11
|
+
begin
|
12
|
+
$test_data[key] = YAML::load_file(File.expand_path("#{TEST_CASE_DIR}/../conf/#{i}"))
|
13
|
+
rescue => e
|
14
|
+
raise StandardError, "Couldn't load config #{TEST_CASE_DIR}/../conf/#{i}\n\n#{e}\n\n"
|
15
|
+
end
|
16
|
+
}
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,149 @@
|
|
1
|
+
base = File.expand_path(File.dirname(__FILE__))
|
2
|
+
#require 'rubygems'
|
3
|
+
#require 'archive/tar/minitar'
|
4
|
+
require "#{base}/../lib/gem_helpers"
|
5
|
+
GemHelpers.update_gem_path "#{base}/gems/installed"
|
6
|
+
require 'yaml'
|
7
|
+
require 'fileutils'
|
8
|
+
require 'find'
|
9
|
+
|
10
|
+
module Build
|
11
|
+
|
12
|
+
|
13
|
+
def self.monkey_patch
|
14
|
+
patch_cfg = YAML::load_file("#{File.expand_path(File.dirname(__FILE__))}/../conf/monkey_patch.yaml")
|
15
|
+
|
16
|
+
patch_cfg.each { |monkey_item|
|
17
|
+
if monkey_item.has_key?(:patch)
|
18
|
+
if Kernel.const_defined?('DEBUG')
|
19
|
+
puts "copying #{monkey_item[:patch][:source]} to #{monkey_item[:patch][:destination]}" if DEBUG
|
20
|
+
end
|
21
|
+
|
22
|
+
FileUtils.cp monkey_item[:patch][:source], monkey_item[:patch][:destination]
|
23
|
+
elsif monkey_item.has_key?(:update_text)
|
24
|
+
unless File.exists?(monkey_item[:update_text][:file])
|
25
|
+
raise "no file found for #{monkey_item[:update_text][:file]}"
|
26
|
+
end
|
27
|
+
if monkey_item[:update_text].has_key?(:search_eval)
|
28
|
+
search = eval(monkey_item[:update_text][:search_eval])
|
29
|
+
elsif monkey_item[:update_text].has_key?(:search)
|
30
|
+
search = monkey_item[:update_text][:search]
|
31
|
+
end
|
32
|
+
if monkey_item[:update_text].has_key?(:replace_eval)
|
33
|
+
replace = eval(monkey_item[:update_text][:replace_eval])
|
34
|
+
if monkey_item[:update_text].has_key?(:string_wrap)
|
35
|
+
replace = "\"#{replace}\""
|
36
|
+
end
|
37
|
+
|
38
|
+
elsif monkey_item[:update_text].has_key?(:replace)
|
39
|
+
replace = monkey_item[:update_text][:replace]
|
40
|
+
end
|
41
|
+
|
42
|
+
puts "REPLACE: #{replace}"
|
43
|
+
file = monkey_item[:update_text][:file]
|
44
|
+
backup_file = "#{file}.#{Time.now.usec}"
|
45
|
+
updated_file = File.readlines(file).to_s.gsub("#{search}", "#{replace}")
|
46
|
+
begin
|
47
|
+
FileUtils.mv(file, backup_file)
|
48
|
+
fd=File.open(file, 'w+')
|
49
|
+
fd.puts updated_file
|
50
|
+
FileUtils.rm_f backup_file
|
51
|
+
rescue => e
|
52
|
+
puts e.inspect
|
53
|
+
FileUtils.mv(backup_file, file)
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
}
|
58
|
+
end
|
59
|
+
|
60
|
+
def self.update_bin
|
61
|
+
base_dir = "#{File.expand_path(File.dirname(__FILE__))}/.."
|
62
|
+
Find.find("#{base_dir}/gems/installed/bin") { |entry|
|
63
|
+
next if File.directory?(entry)
|
64
|
+
file = File.readlines(entry).to_s
|
65
|
+
next if file.grep(/GemHelpers\.update_gem_path/).nitems > 0
|
66
|
+
|
67
|
+
if Kernel.const_defined?('DEBUG')
|
68
|
+
puts "Adding GemHelpers.update_gem_path to #{entry}" if DEBUG
|
69
|
+
end
|
70
|
+
|
71
|
+
file = file.gsub("require 'rubygems'", "require 'rubygems'\nrequire \'#{base_dir}/lib/gem_helpers\'\nGemHelpers.update_gem_path \'#{base_dir}/gems/installed\'")
|
72
|
+
FileUtils.rm_f entry
|
73
|
+
fd=File.open(entry, 'w+')
|
74
|
+
fd.puts file
|
75
|
+
fd.close
|
76
|
+
}
|
77
|
+
end
|
78
|
+
|
79
|
+
def self.update_firewatir
|
80
|
+
base = "#{File.expand_path(File.dirname(__FILE__))}/../gems/installed/gems/firewatir-1.6.2/lib/firewatir"
|
81
|
+
|
82
|
+
if Kernel.const_defined?('DEBUG')
|
83
|
+
puts "modifying firewatir: replacing all instances of '< Element' with '< Tmp::Element'" if DEBUG
|
84
|
+
end
|
85
|
+
|
86
|
+
Dir.open(base).each { |i|
|
87
|
+
file = "#{base}/#{i}"
|
88
|
+
next if File.directory?(file)
|
89
|
+
f = File.read(file)
|
90
|
+
f = f.gsub("< Element", "< Tmp::Element")
|
91
|
+
fd=File.open(file, 'w+')
|
92
|
+
fd.puts f
|
93
|
+
fd.close
|
94
|
+
}
|
95
|
+
end
|
96
|
+
|
97
|
+
|
98
|
+
def self.files_include?(dir, match=[])
|
99
|
+
raise ArgumentError unless File.directory?(dir) || match.nitems < 1
|
100
|
+
Find.find(dir) { |i|
|
101
|
+
next if File.directory?(i) || i =~ /\.svn-base$/
|
102
|
+
file = File.readlines(i).to_s
|
103
|
+
match.each { |search|
|
104
|
+
if file.grep(/#{search}/).nitems > 0
|
105
|
+
puts "FOUND #{search.upcase}: #{i}"
|
106
|
+
end
|
107
|
+
}
|
108
|
+
}
|
109
|
+
end
|
110
|
+
|
111
|
+
def self.copy_skeletons_to_project
|
112
|
+
project_name = File.basename(Dir.pwd)
|
113
|
+
if File.directory?("#{project_name}_client")
|
114
|
+
Dir.entries('ruby_skeleton').each { |i|
|
115
|
+
next if i == '.' || i == '..' || i =~ /\.svn/
|
116
|
+
FileUtils.cp_r "ruby_skeleton/#{i}", "#{project_name}_client"
|
117
|
+
}
|
118
|
+
end
|
119
|
+
if File.directory?("#{project_name}_web")
|
120
|
+
Dir.entries('rails_skeleton').each { |i|
|
121
|
+
puts "copying rails_skeleton/#{i} to #{project_name}_web"
|
122
|
+
next if i == '.' || i == '..' || i =~ /^\.svn/
|
123
|
+
begin
|
124
|
+
FileUtils.cp_r "rails_skeleton/#{i}", "#{project_name}_web"
|
125
|
+
rescue
|
126
|
+
end
|
127
|
+
Find.find("rails_skeleton/#{i}") { |i|
|
128
|
+
FileUtils.rm_rf i if i =~ /\.svn$/
|
129
|
+
}
|
130
|
+
}
|
131
|
+
end
|
132
|
+
end
|
133
|
+
|
134
|
+
def self.package
|
135
|
+
pwd = Dir.pwd
|
136
|
+
project_name = File.basename(pwd)
|
137
|
+
File.open("#{project_name}.tar", 'wb') { |tar| Archive::Tar::Minitar.pack("#{project_name}", tar) }
|
138
|
+
end
|
139
|
+
|
140
|
+
def self.clean
|
141
|
+
pwd = Dir.pwd
|
142
|
+
project_name = File.basename(pwd)
|
143
|
+
#File.open("#{project_name}.tar", 'wb') { |tar| Archive::Tar::Minitar.pack("#{project_name}", tar) }
|
144
|
+
FileUtils.rm_rf "#{project_name}/common/gems/installed/"
|
145
|
+
FileUtils.mkdir "#{project_name}/common/gems/installed/"
|
146
|
+
end
|
147
|
+
|
148
|
+
end
|
149
|
+
|