flote 0.0.01

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/bin/flote ADDED
@@ -0,0 +1,6 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ flote_dir = File.expand_path(File.join(File.dirname(__FILE__), '..', 'lib'))
4
+ $LOAD_PATH.unshift(flote_dir) unless $LOAD_PATH.include?(flote_dir)
5
+ require 'flote/flote'
6
+ Flote.new(ARGV).run
@@ -0,0 +1,48 @@
1
+ class ConsoleView
2
+
3
+ def show_help
4
+ show <<-helptext
5
+ flote (Flow Tester), is a continuous testing tool.
6
+
7
+ helptext
8
+ show_usage
9
+ end
10
+
11
+ def show_usage
12
+ show <<-helptext
13
+ Usage: #{current_command_path} command [options]
14
+ start <shell_command> Watches all the files in the work dir (including subdirs) and runs the given shell command when a file was modified.
15
+
16
+ Report bugs to <codersdojo@it-agile.de>
17
+ helptext
18
+ end
19
+
20
+ def show_start command
21
+ show "Starting flow testing with flote with command #{command}. Use Ctrl+C to stop flote."
22
+ end
23
+
24
+ def show_run_once_message modified_file, modification_time
25
+ time = modification_time.strftime("%X")
26
+ date = modification_time.strftime("%x")
27
+ show "\nFile #{modified_file} was modified at #{time} on #{date}. Run tests."
28
+ end
29
+
30
+ def show_missing_command_argument_error command, missing_argument
31
+ show "Command <#{command}> recognized but argument <#{missing_argument}> was missing.\n"
32
+ show_detailed_help command
33
+ end
34
+
35
+ def show_unknwon_command_message command
36
+ show "Command #{command} not known.\n\n"
37
+ show_usage
38
+ end
39
+
40
+ def show text
41
+ puts text
42
+ end
43
+
44
+ def current_command_path
45
+ $0.gsub '/', '%/%'
46
+ end
47
+
48
+ end
@@ -0,0 +1,34 @@
1
+ require 'shellutils/shell_wrapper'
2
+ require 'shellutils/shell_argument_exception'
3
+ require 'shellutils/argument_parser'
4
+ require 'flote/console_view'
5
+ require 'flote/runner'
6
+ require 'flote/start_command'
7
+
8
+ class Flote
9
+
10
+ def initialize params
11
+ @params = params
12
+ end
13
+
14
+ def run
15
+ if called_from_spec? then return end
16
+ shell = ShellWrapper.new
17
+ view = ConsoleView.new
18
+ runner = Runner.new shell, view
19
+
20
+ begin
21
+ arg_parser = ArgumentParser.new [StartCommand.new runner, view]
22
+ command = arg_parser.parse @params
23
+ rescue ShellArgumentException => e
24
+ view.show_unknwon_command_message e.command
25
+ end
26
+ end
27
+
28
+ private
29
+
30
+ def called_from_spec?
31
+ @params and @params[0] == "spec"
32
+ end
33
+
34
+ end
@@ -0,0 +1,43 @@
1
+ require 'shellutils/progress'
2
+
3
+ class Runner
4
+
5
+ attr_accessor :source_files, :run_command, :init_session_callback, :execute_callback
6
+
7
+ WORKING_DIR = '.'
8
+
9
+ def initialize shell, view
10
+ @shell = shell
11
+ @view = view
12
+ end
13
+
14
+ def start
15
+ if @init_session_callback then @init_session_callback.call end
16
+ execute
17
+ end
18
+
19
+ def execute
20
+ files = @shell.files_in_dir_tree WORKING_DIR, @source_files
21
+ newest_dir_entry = @shell.newest_dir_entry WORKING_DIR, files
22
+ change_time = @shell.modification_time newest_dir_entry
23
+ if change_time == @previous_change_time then
24
+ Progress.next
25
+ return
26
+ end
27
+ Progress.end
28
+ @view.show_run_once_message newest_dir_entry, change_time
29
+ execute_once files
30
+ @previous_change_time = change_time
31
+ end
32
+
33
+ def execute_once files
34
+ process = @shell.execute @run_command
35
+ if @execute_callback then @execute_callback.call(files, process) end
36
+ end
37
+
38
+ def run_command= command
39
+ @run_command = @shell.expand_run_command command
40
+ end
41
+
42
+ end
43
+
@@ -0,0 +1,35 @@
1
+ class Scheduler
2
+
3
+ attr_accessor :interrupt_listener
4
+
5
+ def initialize runner
6
+ @runner = runner
7
+ end
8
+
9
+ def start
10
+ @continue = true
11
+ register_interrupt_listener
12
+ @runner.start
13
+ while @continue do
14
+ sleep 1
15
+ @runner.execute
16
+ end
17
+ end
18
+
19
+ private
20
+
21
+ def register_interrupt_listener
22
+ trap("INT") {
23
+ interrupt
24
+ }
25
+ end
26
+
27
+ def interrupt
28
+ if @interrupt_listener then
29
+ @continue = @interrupt_listener.interrupt
30
+ else
31
+ @continue = false
32
+ end
33
+ end
34
+
35
+ end
@@ -0,0 +1,29 @@
1
+ class SourceCodeSuffixes
2
+
3
+ def suffixes
4
+ [
5
+ '4th',
6
+ 'asm', 'asp',
7
+ 'bas', 'bat',
8
+ 'c', 'cbl', 'cl', 'clj', 'cmd', 'coffee', 'cpp', 'cs', 'css', 'cxx',
9
+ 'dtd',
10
+ 'e', 'erl',
11
+ 'f', 'fs',
12
+ 'go', 'groovy',
13
+ 'h', 'html', 'hs', 'hxx',
14
+ 'idl', 'inc',
15
+ 'java', 'js', 'json', 'jsp',
16
+ 'm', 'm2', 'm3',
17
+ 'lisp',
18
+ 'm', 'mod',
19
+ 'obn',
20
+ 'pas', 'php', 'pl', 'pm', 'py',
21
+ 'rb'
22
+ 's', 'scala', 'sh', 'sim', 'sm', 'sql',
23
+ 'txt',
24
+ 'xhtml', 'xml',
25
+ 'yml'
26
+ ]
27
+ end
28
+
29
+ end
@@ -0,0 +1,27 @@
1
+ require 'flote/scheduler'
2
+
3
+ class StartCommand
4
+
5
+ def initialize runner, view
6
+ @runner = runner
7
+ @view = view
8
+ end
9
+
10
+ def execute_from_shell params
11
+ start params[1]
12
+ end
13
+
14
+ def start command
15
+ unless command then @view.show_missing_command_argument_error "start", "shell_command"; return end
16
+ @view.show_start command
17
+ @runner.source_files = '.*'
18
+ @runner.run_command = command
19
+ scheduler = Scheduler.new @runner
20
+ scheduler.start
21
+ end
22
+
23
+ def accepts_shell_command? command
24
+ command == 'start'
25
+ end
26
+
27
+ end
metadata ADDED
@@ -0,0 +1,96 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: flote
3
+ version: !ruby/object:Gem::Version
4
+ prerelease: false
5
+ segments:
6
+ - 0
7
+ - 0
8
+ - 1
9
+ version: 0.0.01
10
+ platform: ruby
11
+ authors:
12
+ - CodersDojo-Team
13
+ autorequire:
14
+ bindir: bin
15
+ cert_chain: []
16
+
17
+ date: 2011-09-28 00:00:00 +02:00
18
+ default_executable:
19
+ dependencies:
20
+ - !ruby/object:Gem::Dependency
21
+ name: term-ansicolor
22
+ prerelease: false
23
+ requirement: &id001 !ruby/object:Gem::Requirement
24
+ requirements:
25
+ - - ">="
26
+ - !ruby/object:Gem::Version
27
+ segments:
28
+ - 1
29
+ - 0
30
+ - 5
31
+ version: 1.0.5
32
+ type: :runtime
33
+ version_requirements: *id001
34
+ - !ruby/object:Gem::Dependency
35
+ name: shell-utils
36
+ prerelease: false
37
+ requirement: &id002 !ruby/object:Gem::Requirement
38
+ requirements:
39
+ - - "="
40
+ - !ruby/object:Gem::Version
41
+ segments:
42
+ - 0
43
+ - 0
44
+ - 9
45
+ version: 0.0.9
46
+ type: :runtime
47
+ version_requirements: *id002
48
+ description: flote executes tests in an endless loop.
49
+ email: codersdojo@it-agile.de
50
+ executables:
51
+ - flote
52
+ extensions: []
53
+
54
+ extra_rdoc_files: []
55
+
56
+ files:
57
+ - lib/flote/console_view.rb
58
+ - lib/flote/flote.rb
59
+ - lib/flote/runner.rb
60
+ - lib/flote/scheduler.rb
61
+ - lib/flote/source_code_suffixes.rb
62
+ - lib/flote/start_command.rb
63
+ has_rdoc: true
64
+ homepage: http://www.codersdojo.org/
65
+ licenses: []
66
+
67
+ post_install_message:
68
+ rdoc_options: []
69
+
70
+ require_paths:
71
+ - lib
72
+ required_ruby_version: !ruby/object:Gem::Requirement
73
+ requirements:
74
+ - - ">="
75
+ - !ruby/object:Gem::Version
76
+ segments:
77
+ - 1
78
+ - 8
79
+ - 6
80
+ version: 1.8.6
81
+ required_rubygems_version: !ruby/object:Gem::Requirement
82
+ requirements:
83
+ - - ">="
84
+ - !ruby/object:Gem::Version
85
+ segments:
86
+ - 0
87
+ version: "0"
88
+ requirements: []
89
+
90
+ rubyforge_project: flote
91
+ rubygems_version: 1.3.6
92
+ signing_key:
93
+ specification_version: 3
94
+ summary: flote (Flow Tester) is a continuous testing tool for any programming language.
95
+ test_files: []
96
+