duck_test 0.1.4

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.
Files changed (45) hide show
  1. data/bin/ducktest +29 -0
  2. data/lib/duck_test/autoload_config.rb +103 -0
  3. data/lib/duck_test/base.rb +41 -0
  4. data/lib/duck_test/commands.rb +208 -0
  5. data/lib/duck_test/config.rb +675 -0
  6. data/lib/duck_test/config_helper.rb +99 -0
  7. data/lib/duck_test/console.rb +18 -0
  8. data/lib/duck_test/default_config.rb +48 -0
  9. data/lib/duck_test/frame_work/base.rb +587 -0
  10. data/lib/duck_test/frame_work/file_manager.rb +511 -0
  11. data/lib/duck_test/frame_work/filter_set.rb +233 -0
  12. data/lib/duck_test/frame_work/map.rb +331 -0
  13. data/lib/duck_test/frame_work/queue.rb +221 -0
  14. data/lib/duck_test/frame_work/queue_event.rb +29 -0
  15. data/lib/duck_test/frame_work/rspec/base.rb +17 -0
  16. data/lib/duck_test/frame_work/rspec/frame_work.rb +30 -0
  17. data/lib/duck_test/frame_work/test_unit/base.rb +14 -0
  18. data/lib/duck_test/frame_work/test_unit/frame_work.rb +33 -0
  19. data/lib/duck_test/frame_work/watch_config.rb +69 -0
  20. data/lib/duck_test/gem/helper.rb +107 -0
  21. data/lib/duck_test/logger.rb +127 -0
  22. data/lib/duck_test/option_parser.rb +30 -0
  23. data/lib/duck_test/platforms/base.rb +18 -0
  24. data/lib/duck_test/platforms/dependencies.rb +18 -0
  25. data/lib/duck_test/platforms/generic/base.rb +15 -0
  26. data/lib/duck_test/platforms/generic/listener.rb +104 -0
  27. data/lib/duck_test/platforms/linux/base.rb +15 -0
  28. data/lib/duck_test/platforms/linux/listener.rb +76 -0
  29. data/lib/duck_test/platforms/listener.rb +303 -0
  30. data/lib/duck_test/platforms/mac/base.rb +15 -0
  31. data/lib/duck_test/platforms/mac/listener.rb +79 -0
  32. data/lib/duck_test/platforms/mac/listener.rb.orig +147 -0
  33. data/lib/duck_test/platforms/os_helper.rb +102 -0
  34. data/lib/duck_test/platforms/watch_event.rb +47 -0
  35. data/lib/duck_test/platforms/windows/base.rb +15 -0
  36. data/lib/duck_test/platforms/windows/listener.rb +123 -0
  37. data/lib/duck_test/railtie.rb +29 -0
  38. data/lib/duck_test/usage.rb +34 -0
  39. data/lib/duck_test/usage.yml +112 -0
  40. data/lib/duck_test/version.rb +3 -0
  41. data/lib/duck_test.rb +6 -0
  42. data/lib/notes.txt +215 -0
  43. data/lib/tasks/duck_tests.rake +35 -0
  44. data/lib/tasks/gem_tasks.rake +18 -0
  45. metadata +92 -0
@@ -0,0 +1,99 @@
1
+ module DuckTest
2
+
3
+ # For inclusion in classes that need the standard attributes
4
+ module ConfigHelper
5
+
6
+ ##################################################################################
7
+ # Root directory for all files to watch. Typically, this will equate to Rails.root
8
+ # The default value is the current directory '.'
9
+ #
10
+ # puts DuckTest::Config.root # '.'
11
+ #
12
+ # @return [String]
13
+ def root
14
+ return @root ||= "."
15
+ end
16
+
17
+ ##################################################################################
18
+ # Sets the root directory for all files to watch. Typically, this will equate to Rails.root
19
+ # The default value is the current directory '.', however, DuckTest::Config will set this value
20
+ # to the Rails.root directory if being loaded in a Rails environment. The purpose of this attribute
21
+ # is to account for the event that a development environment might deviate slightly from the standard
22
+ # to compensate for an unknown requirement.
23
+ #
24
+ # DuckTest::Config.root = "/my_directory"
25
+ # puts DuckTest::Config.root # => '/my_directory'
26
+ #
27
+ # @return [String]
28
+ def root=(value)
29
+ @root = value.to_s unless value.blank?
30
+ @root = File.expand_path(@root) unless @root.blank?
31
+ return @root
32
+ end
33
+
34
+ ##################################################################################
35
+ # @note See {file:README.md#base_directories} for details and examples
36
+ # The watch_basedir is used when evaluating directories and files and it's main purpose is to provide
37
+ # the conveinence of not having to specify full directory paths in watch definitions.
38
+ #
39
+ # @return [String] Returns the current value of watch_basedir
40
+ def watch_basedir
41
+ return @watch_basedir ||= ""
42
+ end
43
+
44
+ ##################################################################################
45
+ # Sets the current of watch_basedir.
46
+ # @return [String]
47
+ def watch_basedir=(value)
48
+ @watch_basedir = value.to_s unless value.blank?
49
+ end
50
+
51
+ ##################################################################################
52
+ # @note See {file:README.md#base_directories} for details and examples
53
+ # The runnable_basedir is used when evaluating directories and files and it's main purpose is to provide
54
+ # the conveinence of not having to specify full directory paths in runnable definitions.
55
+ #
56
+ # @return [String] Returns the current value of runnable_basedir
57
+ def runnable_basedir
58
+ return @runnable_basedir ||= ""
59
+ end
60
+
61
+ ##################################################################################
62
+ # Sets the current of runnable_basedir.
63
+ # @return [String]
64
+ def runnable_basedir=(value)
65
+ @runnable_basedir = value.to_s unless value.blank?
66
+ end
67
+
68
+ ##################################################################################
69
+ # Controls if tests/specs should be run automatically when changed.
70
+ # @return [Boolean]
71
+ def autorun
72
+ @autorun = true unless defined? @autorun
73
+ @autorun
74
+ end
75
+
76
+ ##################################################################################
77
+ # Returns true is autorun is enabled, otherwise, returns false.
78
+ # @return [Boolean]
79
+ def autorun?
80
+ @autorun
81
+ end
82
+
83
+ ##################################################################################
84
+ # Sets if tests/specs should be run automatically when changed. A value of true
85
+ # means test will be automatically run, otherwise, tests have to be run manually.
86
+ # @return [Boolean]
87
+ def autorun=(value)
88
+ @autorun = value
89
+ end
90
+
91
+ ##################################################################################
92
+ # Constructs a message indicating the current status of autorun.
93
+ # @return [String] Current autorun status message.
94
+ def autorun_status
95
+ return "Autorun is #{self.autorun ? 'ON' : 'OFF'}"
96
+ end
97
+
98
+ end
99
+ end
@@ -0,0 +1,18 @@
1
+ module DuckTest
2
+
3
+ # Module to include in the standard IRB class to provide a reference to DuckTest {Commands commands}.
4
+ module Console
5
+ include DuckTest::LoggerHelper
6
+
7
+ ##################################################################################
8
+ # Returns an instance of {Commands} class to allow a user to perform tasks like the following directly in the Rails console.
9
+ #
10
+ # duck.speed 1 # sets the queue speed
11
+ # duck.latency 2 # sets the queue latency
12
+ #
13
+ def duck
14
+ return DuckTest::Commands.new
15
+ end
16
+
17
+ end
18
+ end
@@ -0,0 +1,48 @@
1
+ module DuckTest
2
+
3
+ class DefaultConfig
4
+
5
+ ##################################################################################
6
+ # Runs a default configuration for a target testing framework.
7
+ def self.config(target)
8
+
9
+ puts "Autoloading configuration for framework: #{target}"
10
+ case target
11
+ when :testunit
12
+
13
+ DuckTest.config do
14
+ excluded [/.gitkeep$/, /kate-swp$/, /.yml$/, /test_helper/, /^.goutputstream/]
15
+ excluded_dirs [/^assets/, /^fixtures/]
16
+
17
+ watch_basedir :app
18
+
19
+ runnable "**/*"
20
+ watch "**/*" do
21
+ standard_maps
22
+ end
23
+ end
24
+
25
+ when :rspec
26
+
27
+ DuckTest.config do
28
+
29
+ excluded [/.gitkeep$/, /kate-swp$/, /.yml$/, /spec_helper/, /^.goutputstream/]
30
+ excluded_dirs [/^assets/, /^fixtures/]
31
+
32
+ runnable_basedir :spec
33
+ watch_basedir :app
34
+
35
+ runnable "**/*"
36
+ watch "**/*" do
37
+ standard_maps
38
+ end
39
+
40
+ end
41
+
42
+ end
43
+
44
+ end
45
+
46
+ end
47
+
48
+ end