scout-essentials 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (107) hide show
  1. checksums.yaml +7 -0
  2. data/.document +5 -0
  3. data/.vimproject +78 -0
  4. data/Gemfile +14 -0
  5. data/LICENSE.txt +20 -0
  6. data/README.rdoc +18 -0
  7. data/Rakefile +47 -0
  8. data/VERSION +1 -0
  9. data/lib/scout/cmd.rb +348 -0
  10. data/lib/scout/concurrent_stream.rb +284 -0
  11. data/lib/scout/config.rb +168 -0
  12. data/lib/scout/exceptions.rb +77 -0
  13. data/lib/scout/indiferent_hash/case_insensitive.rb +30 -0
  14. data/lib/scout/indiferent_hash/options.rb +115 -0
  15. data/lib/scout/indiferent_hash.rb +96 -0
  16. data/lib/scout/log/color.rb +224 -0
  17. data/lib/scout/log/color_class.rb +269 -0
  18. data/lib/scout/log/fingerprint.rb +69 -0
  19. data/lib/scout/log/progress/report.rb +244 -0
  20. data/lib/scout/log/progress/util.rb +173 -0
  21. data/lib/scout/log/progress.rb +106 -0
  22. data/lib/scout/log/trap.rb +107 -0
  23. data/lib/scout/log.rb +441 -0
  24. data/lib/scout/meta_extension.rb +100 -0
  25. data/lib/scout/misc/digest.rb +63 -0
  26. data/lib/scout/misc/filesystem.rb +25 -0
  27. data/lib/scout/misc/format.rb +255 -0
  28. data/lib/scout/misc/helper.rb +31 -0
  29. data/lib/scout/misc/insist.rb +56 -0
  30. data/lib/scout/misc/monitor.rb +66 -0
  31. data/lib/scout/misc/system.rb +73 -0
  32. data/lib/scout/misc.rb +10 -0
  33. data/lib/scout/named_array.rb +138 -0
  34. data/lib/scout/open/lock/lockfile.rb +587 -0
  35. data/lib/scout/open/lock.rb +68 -0
  36. data/lib/scout/open/remote.rb +135 -0
  37. data/lib/scout/open/stream.rb +491 -0
  38. data/lib/scout/open/util.rb +244 -0
  39. data/lib/scout/open.rb +170 -0
  40. data/lib/scout/path/find.rb +204 -0
  41. data/lib/scout/path/tmpfile.rb +8 -0
  42. data/lib/scout/path/util.rb +127 -0
  43. data/lib/scout/path.rb +51 -0
  44. data/lib/scout/persist/open.rb +17 -0
  45. data/lib/scout/persist/path.rb +15 -0
  46. data/lib/scout/persist/serialize.rb +157 -0
  47. data/lib/scout/persist.rb +104 -0
  48. data/lib/scout/resource/open.rb +8 -0
  49. data/lib/scout/resource/path.rb +80 -0
  50. data/lib/scout/resource/produce/rake.rb +69 -0
  51. data/lib/scout/resource/produce.rb +151 -0
  52. data/lib/scout/resource/scout.rb +3 -0
  53. data/lib/scout/resource/software.rb +178 -0
  54. data/lib/scout/resource/util.rb +59 -0
  55. data/lib/scout/resource.rb +40 -0
  56. data/lib/scout/simple_opt/accessor.rb +54 -0
  57. data/lib/scout/simple_opt/doc.rb +126 -0
  58. data/lib/scout/simple_opt/get.rb +57 -0
  59. data/lib/scout/simple_opt/parse.rb +67 -0
  60. data/lib/scout/simple_opt/setup.rb +26 -0
  61. data/lib/scout/simple_opt.rb +5 -0
  62. data/lib/scout/tmpfile.rb +129 -0
  63. data/lib/scout-essentials.rb +10 -0
  64. data/scout-essentials.gemspec +143 -0
  65. data/share/color/color_names +507 -0
  66. data/share/color/diverging_colors.hex +12 -0
  67. data/share/software/install_helpers +523 -0
  68. data/test/scout/indiferent_hash/test_case_insensitive.rb +16 -0
  69. data/test/scout/indiferent_hash/test_options.rb +46 -0
  70. data/test/scout/log/test_color.rb +0 -0
  71. data/test/scout/log/test_progress.rb +108 -0
  72. data/test/scout/misc/test_digest.rb +30 -0
  73. data/test/scout/misc/test_filesystem.rb +30 -0
  74. data/test/scout/misc/test_insist.rb +13 -0
  75. data/test/scout/misc/test_system.rb +21 -0
  76. data/test/scout/open/test_lock.rb +52 -0
  77. data/test/scout/open/test_remote.rb +25 -0
  78. data/test/scout/open/test_stream.rb +676 -0
  79. data/test/scout/open/test_util.rb +73 -0
  80. data/test/scout/path/test_find.rb +110 -0
  81. data/test/scout/path/test_util.rb +22 -0
  82. data/test/scout/persist/test_open.rb +37 -0
  83. data/test/scout/persist/test_path.rb +37 -0
  84. data/test/scout/persist/test_serialize.rb +114 -0
  85. data/test/scout/resource/test_path.rb +58 -0
  86. data/test/scout/resource/test_produce.rb +94 -0
  87. data/test/scout/resource/test_software.rb +24 -0
  88. data/test/scout/resource/test_util.rb +38 -0
  89. data/test/scout/simple_opt/test_doc.rb +16 -0
  90. data/test/scout/simple_opt/test_get.rb +11 -0
  91. data/test/scout/simple_opt/test_parse.rb +10 -0
  92. data/test/scout/simple_opt/test_setup.rb +77 -0
  93. data/test/scout/test_cmd.rb +85 -0
  94. data/test/scout/test_concurrent_stream.rb +29 -0
  95. data/test/scout/test_config.rb +66 -0
  96. data/test/scout/test_indiferent_hash.rb +26 -0
  97. data/test/scout/test_log.rb +32 -0
  98. data/test/scout/test_meta_extension.rb +80 -0
  99. data/test/scout/test_misc.rb +6 -0
  100. data/test/scout/test_named_array.rb +43 -0
  101. data/test/scout/test_open.rb +146 -0
  102. data/test/scout/test_path.rb +54 -0
  103. data/test/scout/test_persist.rb +186 -0
  104. data/test/scout/test_resource.rb +26 -0
  105. data/test/scout/test_tmpfile.rb +53 -0
  106. data/test/test_helper.rb +50 -0
  107. metadata +247 -0
@@ -0,0 +1,30 @@
1
+ require File.expand_path(__FILE__).sub(%r(/test/.*), '/test/test_helper.rb')
2
+ require File.expand_path(__FILE__).sub(%r(.*/test/), '').sub(/test_(.*)\.rb/,'\1')
3
+
4
+ class TestMiscDigest < Test::Unit::TestCase
5
+ def test_digest_str
6
+ o = {:a => [1,2,3], :b => [1.1, 0.00001, 'hola']}
7
+ assert Misc.digest_str(o).include? "hola"
8
+ end
9
+
10
+ def test_digest_stream_located
11
+ TmpFile.with_file("TEST") do |filename|
12
+ Open.open(filename) do |f|
13
+ assert_equal 32, Misc.digest_str(f).length
14
+ end
15
+ end
16
+ end
17
+
18
+ def test_digest_stream_unlocated
19
+ TmpFile.with_file do |directory|
20
+ Path.setup(directory)
21
+ Open.write(directory.share.file, "TEST")
22
+ Misc.in_dir directory do
23
+ Open.open(Path.setup('share/file')) do |f|
24
+ assert_equal '\'share/file\'', Misc.digest_str(Path.setup('share/file'))
25
+ end
26
+ end
27
+ end
28
+ end
29
+ end
30
+
@@ -0,0 +1,30 @@
1
+ require File.expand_path(__FILE__).sub(%r(/test/.*), '/test/test_helper.rb')
2
+ require File.expand_path(__FILE__).sub(%r(.*/test/), '').sub(/test_(.*)\.rb/,'\1')
3
+
4
+ class TestFilesystem < Test::Unit::TestCase
5
+ def test_in_dir
6
+ TmpFile.with_file do |tmpdir|
7
+ Misc.in_dir tmpdir do
8
+ assert_equal tmpdir, FileUtils.pwd
9
+ end
10
+ end
11
+ end
12
+
13
+ def test_relative
14
+ assert_equal 'bar', Misc.path_relative_to("/tmp/foo", "/tmp/foo/bar")
15
+ assert_equal 'bar/other', Misc.path_relative_to("/tmp/foo", "/tmp/foo/bar/other")
16
+
17
+ refute Misc.path_relative_to("/tmp/bar", "/tmp/foo/bar/other")
18
+ refute Misc.path_relative_to("/tmp/foo", "tmp/foo/bar/other")
19
+
20
+ TmpFile.with_file do |tmpdir|
21
+ Misc.in_dir tmpdir do
22
+ assert Misc.path_relative_to(tmpdir, "foo")
23
+ assert Misc.path_relative_to(tmpdir, File.join(tmpdir, "foo"))
24
+ end
25
+ assert Misc.path_relative_to(tmpdir, File.join(tmpdir, "foo"))
26
+ assert Misc.path_relative_to(File.dirname(tmpdir), File.join(tmpdir, "foo"))
27
+ end
28
+ end
29
+ end
30
+
@@ -0,0 +1,13 @@
1
+ require File.expand_path(__FILE__).sub(%r(/test/.*), '/test/test_helper.rb')
2
+ require File.expand_path(__FILE__).sub(%r(.*/test/), '').sub(/test_(.*)\.rb/,'\1')
3
+
4
+ class TestMiscInsist < Test::Unit::TestCase
5
+ def test_insist
6
+ i = 0
7
+ Misc.insist do
8
+ i += 1
9
+ raise "Not yet" if i < 3
10
+ end
11
+ end
12
+ end
13
+
@@ -0,0 +1,21 @@
1
+ require File.expand_path(__FILE__).sub(%r(/test/.*), '/test/test_helper.rb')
2
+ require File.expand_path(__FILE__).sub(%r(.*/test/), '').sub(/test_(.*)\.rb/,'\1')
3
+
4
+ class TestMiscSystem < Test::Unit::TestCase
5
+ setup do
6
+ ENV.delete "TEST_VAR"
7
+ end
8
+
9
+ def test_env_add
10
+ Misc.env_add "TEST_VAR", "test_value1"
11
+ Misc.env_add "TEST_VAR", "test_value2"
12
+ assert_equal "test_value2:test_value1", ENV["TEST_VAR"]
13
+ end
14
+
15
+ def test_env_add_prepend
16
+ Misc.env_add "TEST_VAR", "test_value1", ":", false
17
+ Misc.env_add "TEST_VAR", "test_value2", ":", false
18
+ assert_equal "test_value1:test_value2", ENV["TEST_VAR"]
19
+ end
20
+ end
21
+
@@ -0,0 +1,52 @@
1
+ require File.expand_path(__FILE__).sub(%r(/test/.*), '/test/test_helper.rb')
2
+ require File.expand_path(__FILE__).sub(%r(.*/test/), '').sub(/test_(.*)\.rb/,'\1')
3
+
4
+ require 'scout/tmpfile'
5
+
6
+ class TestLock < Test::Unit::TestCase
7
+ def test_locks
8
+ num = 10
9
+ TmpFile.with_file do |lockfile|
10
+ TmpFile.with_file do |output|
11
+ f = File.open(output, 'w')
12
+ thrs = num.times.collect do
13
+ Thread.new do
14
+ Open.lock lockfile, true, min_sleep: 0.01, max_sleep: 0.05, sleep_inc: 0.001 do
15
+ f.write "["
16
+ sleep 0.01
17
+ f.write "]"
18
+ end
19
+ end
20
+ end
21
+ thrs.each{|t| t.join }
22
+ f.close
23
+ assert_equal "[]" * num, File.open(output).read
24
+ end
25
+ end
26
+ end
27
+
28
+ def test_keep_locked
29
+ num = 10
30
+ TmpFile.with_file do |lockfile|
31
+ TmpFile.with_file do |output|
32
+ f = File.open(output, 'w')
33
+ thrs = num.times.collect do
34
+ Thread.new do
35
+ lock = Lockfile.new(lockfile, min_sleep: 0.01, max_sleep: 0.05, sleep_inc: 0.001)
36
+ res = Open.lock lock do
37
+ f.write "["
38
+ raise KeepLocked, "1"
39
+ end
40
+ f.write res
41
+ f.write "]"
42
+ lock.unlock
43
+ end
44
+ end
45
+ thrs.each{|t| t.join }
46
+ f.close
47
+ assert_equal "[1]" * num, File.open(output).read
48
+ end
49
+ end
50
+ end
51
+ end
52
+
@@ -0,0 +1,25 @@
1
+ require File.expand_path(__FILE__).sub(%r(/test/.*), '/test/test_helper.rb')
2
+ require File.expand_path(__FILE__).sub(%r(.*/test/), '').sub(/test_(.*)\.rb/,'\1')
3
+
4
+ require 'scout/open'
5
+
6
+ class TestOpenRemote < Test::Unit::TestCase
7
+ def test_wget
8
+ teardown
9
+ 5.times do
10
+ assert(Misc.fixutf8(Open.wget('http://google.com', :quiet => true, :nocache => true).read) =~ /html/)
11
+ assert(Misc.fixutf8(Open.wget('http://google.com', :quiet => true).read) =~ /html/)
12
+ end
13
+ end
14
+
15
+ def test_ssh
16
+ TmpFile.with_file("TEST") do |f|
17
+ begin
18
+ assert_equal "TEST", Open.ssh("ssh://localhost:#{f}").read
19
+ rescue ConcurrentStreamProcessFailed
20
+ raise $! unless $!.message.include? "Connection refused"
21
+ end
22
+ end if false
23
+ end
24
+ end
25
+