acpc_dealer 2.4.1 → 3.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (90) hide show
  1. checksums.yaml +4 -4
  2. data/Brickfile +6 -0
  3. data/README.md +7 -6
  4. data/Rakefile +30 -14
  5. data/acpc_dealer.gemspec +2 -1
  6. data/bin/acpc_dealer +4 -0
  7. data/ext/hand_evaluator/extconf.rb +10 -0
  8. data/lib/acpc_dealer/version.rb +1 -1
  9. data/lib/hand_evaluator.bundle +0 -0
  10. data/spec/dealer_runner_spec.rb +76 -72
  11. metadata +19 -82
  12. data/vendor/project_acpc_server/LICENCE +0 -23
  13. data/vendor/project_acpc_server/Makefile +0 -35
  14. data/vendor/project_acpc_server/README +0 -113
  15. data/vendor/project_acpc_server/README.submission +0 -42
  16. data/vendor/project_acpc_server/acpc_play_match.pl +0 -101
  17. data/vendor/project_acpc_server/bm_run_matches.c +0 -238
  18. data/vendor/project_acpc_server/bm_server.c +0 -1604
  19. data/vendor/project_acpc_server/bm_server.config +0 -78
  20. data/vendor/project_acpc_server/bm_widget.c +0 -230
  21. data/vendor/project_acpc_server/dealer.c +0 -1293
  22. data/vendor/project_acpc_server/evalHandTables +0 -4269
  23. data/vendor/project_acpc_server/example_player.c +0 -204
  24. data/vendor/project_acpc_server/example_player.limit.2p.sh +0 -3
  25. data/vendor/project_acpc_server/example_player.limit.3p.sh +0 -3
  26. data/vendor/project_acpc_server/example_player.nolimit.2p.sh +0 -3
  27. data/vendor/project_acpc_server/example_player.nolimit.3p.sh +0 -3
  28. data/vendor/project_acpc_server/game.c +0 -1792
  29. data/vendor/project_acpc_server/game.h +0 -253
  30. data/vendor/project_acpc_server/holdem.limit.2p.reverse_blinds.game +0 -13
  31. data/vendor/project_acpc_server/holdem.limit.3p.game +0 -13
  32. data/vendor/project_acpc_server/holdem.nolimit.2p.reverse_blinds.game +0 -12
  33. data/vendor/project_acpc_server/holdem.nolimit.3p.game +0 -12
  34. data/vendor/project_acpc_server/kuhn.limit.3p.game +0 -14
  35. data/vendor/project_acpc_server/kuhn_3p_equilibrium_player.sf1.sh +0 -3
  36. data/vendor/project_acpc_server/kuhn_3p_equilibrium_player.sf2.sh +0 -3
  37. data/vendor/project_acpc_server/kuhn_3p_equilibrium_player.sf3.sh +0 -3
  38. data/vendor/project_acpc_server/kuhn_3p_equilibrium_player/LICENCE +0 -23
  39. data/vendor/project_acpc_server/kuhn_3p_equilibrium_player/Makefile +0 -127
  40. data/vendor/project_acpc_server/kuhn_3p_equilibrium_player/README.md +0 -35
  41. data/vendor/project_acpc_server/kuhn_3p_equilibrium_player/src/CExceptionConfig.h +0 -12
  42. data/vendor/project_acpc_server/kuhn_3p_equilibrium_player/src/dealer_connection.c +0 -49
  43. data/vendor/project_acpc_server/kuhn_3p_equilibrium_player/src/dealer_connection.h +0 -22
  44. data/vendor/project_acpc_server/kuhn_3p_equilibrium_player/src/kuhn_3p_equilibrium_player.c +0 -483
  45. data/vendor/project_acpc_server/kuhn_3p_equilibrium_player/src/kuhn_3p_equilibrium_player.h +0 -108
  46. data/vendor/project_acpc_server/kuhn_3p_equilibrium_player/src/main.c +0 -84
  47. data/vendor/project_acpc_server/kuhn_3p_equilibrium_player/src/player_config.c +0 -253
  48. data/vendor/project_acpc_server/kuhn_3p_equilibrium_player/src/player_config.h +0 -21
  49. data/vendor/project_acpc_server/kuhn_3p_equilibrium_player/test/support/test_helper.c +0 -45
  50. data/vendor/project_acpc_server/kuhn_3p_equilibrium_player/test/support/test_helper.h +0 -27
  51. data/vendor/project_acpc_server/kuhn_3p_equilibrium_player/test/test_kuhn_3p_equilibrium_player.c +0 -698
  52. data/vendor/project_acpc_server/kuhn_3p_equilibrium_player/test/test_kuhn_3p_equilibrium_player_sub_family_1.c +0 -324
  53. data/vendor/project_acpc_server/kuhn_3p_equilibrium_player/test/test_kuhn_3p_equilibrium_player_sub_family_2.c +0 -262
  54. data/vendor/project_acpc_server/kuhn_3p_equilibrium_player/test/test_kuhn_3p_equilibrium_player_sub_family_3.c +0 -177
  55. data/vendor/project_acpc_server/kuhn_3p_equilibrium_player/vendor/cexception/docs/license.txt +0 -30
  56. data/vendor/project_acpc_server/kuhn_3p_equilibrium_player/vendor/cexception/docs/readme.txt +0 -242
  57. data/vendor/project_acpc_server/kuhn_3p_equilibrium_player/vendor/cexception/lib/CException.c +0 -43
  58. data/vendor/project_acpc_server/kuhn_3p_equilibrium_player/vendor/cexception/lib/CException.h +0 -86
  59. data/vendor/project_acpc_server/kuhn_3p_equilibrium_player/vendor/cexception/release/build.info +0 -2
  60. data/vendor/project_acpc_server/kuhn_3p_equilibrium_player/vendor/cexception/release/version.info +0 -2
  61. data/vendor/project_acpc_server/kuhn_3p_equilibrium_player/vendor/commander.c/History.md +0 -27
  62. data/vendor/project_acpc_server/kuhn_3p_equilibrium_player/vendor/commander.c/Makefile +0 -8
  63. data/vendor/project_acpc_server/kuhn_3p_equilibrium_player/vendor/commander.c/Readme.md +0 -103
  64. data/vendor/project_acpc_server/kuhn_3p_equilibrium_player/vendor/commander.c/package.json +0 -9
  65. data/vendor/project_acpc_server/kuhn_3p_equilibrium_player/vendor/commander.c/src/commander.c +0 -250
  66. data/vendor/project_acpc_server/kuhn_3p_equilibrium_player/vendor/commander.c/src/commander.h +0 -88
  67. data/vendor/project_acpc_server/kuhn_3p_equilibrium_player/vendor/commander.c/test.c +0 -34
  68. data/vendor/project_acpc_server/kuhn_3p_equilibrium_player/vendor/unity/auto/colour_prompt.rb +0 -94
  69. data/vendor/project_acpc_server/kuhn_3p_equilibrium_player/vendor/unity/auto/colour_reporter.rb +0 -39
  70. data/vendor/project_acpc_server/kuhn_3p_equilibrium_player/vendor/unity/auto/generate_config.yml +0 -36
  71. data/vendor/project_acpc_server/kuhn_3p_equilibrium_player/vendor/unity/auto/generate_module.rb +0 -202
  72. data/vendor/project_acpc_server/kuhn_3p_equilibrium_player/vendor/unity/auto/generate_test_runner.rb +0 -316
  73. data/vendor/project_acpc_server/kuhn_3p_equilibrium_player/vendor/unity/auto/test_file_filter.rb +0 -23
  74. data/vendor/project_acpc_server/kuhn_3p_equilibrium_player/vendor/unity/auto/unity_test_summary.rb +0 -139
  75. data/vendor/project_acpc_server/kuhn_3p_equilibrium_player/vendor/unity/docs/Unity Summary.txt +0 -216
  76. data/vendor/project_acpc_server/kuhn_3p_equilibrium_player/vendor/unity/docs/license.txt +0 -31
  77. data/vendor/project_acpc_server/kuhn_3p_equilibrium_player/vendor/unity/release/build.info +0 -2
  78. data/vendor/project_acpc_server/kuhn_3p_equilibrium_player/vendor/unity/release/version.info +0 -2
  79. data/vendor/project_acpc_server/kuhn_3p_equilibrium_player/vendor/unity/src/unity.c +0 -1146
  80. data/vendor/project_acpc_server/kuhn_3p_equilibrium_player/vendor/unity/src/unity.h +0 -245
  81. data/vendor/project_acpc_server/kuhn_3p_equilibrium_player/vendor/unity/src/unity_internals.h +0 -546
  82. data/vendor/project_acpc_server/net.c +0 -218
  83. data/vendor/project_acpc_server/net.h +0 -62
  84. data/vendor/project_acpc_server/play_match.pl +0 -99
  85. data/vendor/project_acpc_server/protocol.md +0 -239
  86. data/vendor/project_acpc_server/protocol.odt +0 -0
  87. data/vendor/project_acpc_server/protocol.pdf +0 -0
  88. data/vendor/project_acpc_server/rng.c +0 -139
  89. data/vendor/project_acpc_server/rng.h +0 -63
  90. data/vendor/project_acpc_server/validate_submission.pl +0 -546
@@ -1,88 +0,0 @@
1
-
2
- //
3
- // commander.h
4
- //
5
- // Copyright (c) 2012 TJ Holowaychuk <tj@vision-media.ca>
6
- //
7
-
8
- #ifndef COMMANDER_H
9
- #define COMMANDER_H
10
-
11
- /*
12
- * Max options that can be defined.
13
- */
14
-
15
- #ifndef COMMANDER_MAX_OPTIONS
16
- #define COMMANDER_MAX_OPTIONS 32
17
- #endif
18
-
19
- /*
20
- * Max arguments that can be passed.
21
- */
22
-
23
- #ifndef COMMANDER_MAX_ARGS
24
- #define COMMANDER_MAX_ARGS 32
25
- #endif
26
-
27
- /*
28
- * Command struct.
29
- */
30
-
31
- struct command;
32
-
33
- /*
34
- * Option callback.
35
- */
36
-
37
- typedef void (* command_callback_t)(struct command *self);
38
-
39
- /*
40
- * Command option.
41
- */
42
-
43
- typedef struct {
44
- int optional_arg;
45
- int required_arg;
46
- char *argname;
47
- char *large;
48
- const char *small;
49
- const char *large_with_arg;
50
- const char *description;
51
- command_callback_t cb;
52
- } command_option_t;
53
-
54
- /*
55
- * Command.
56
- */
57
-
58
- typedef struct command {
59
- void *data;
60
- const char *usage;
61
- const char *arg;
62
- const char *name;
63
- const char *version;
64
- int option_count;
65
- command_option_t options[COMMANDER_MAX_OPTIONS];
66
- int argc;
67
- char *argv[COMMANDER_MAX_ARGS];
68
- char **nargv;
69
- } command_t;
70
-
71
- // prototypes
72
-
73
- void
74
- command_init(command_t *self, const char *name, const char *version);
75
-
76
- void
77
- command_free(command_t *self);
78
-
79
- void
80
- command_help(command_t *self);
81
-
82
- void
83
- command_option(command_t *self, const char *small, const char *large, const char *desc, command_callback_t cb);
84
-
85
- void
86
- command_parse(command_t *self, int argc, char **argv);
87
-
88
- #endif /* COMMANDER_H */
@@ -1,34 +0,0 @@
1
-
2
- #include <stdio.h>
3
- #include "src/commander.h"
4
-
5
- static void
6
- verbose(command_t *self) {
7
- printf("verbose: enabled\n");
8
- }
9
-
10
- static void
11
- required(command_t *self) {
12
- printf("required: %s\n", self->arg);
13
- }
14
-
15
- static void
16
- optional(command_t *self) {
17
- printf("optional: %s\n", self->arg);
18
- }
19
-
20
- int
21
- main(int argc, char **argv){
22
- command_t cmd;
23
- command_init(&cmd, argv[0], "0.0.1");
24
- command_option(&cmd, "-v", "--verbose", "enable verbose stuff", verbose);
25
- command_option(&cmd, "-r", "--required <arg>", "required arg", required);
26
- command_option(&cmd, "-o", "--optional [arg]", "optional arg", optional);
27
- command_parse(&cmd, argc, argv);
28
- printf("additional args:\n");
29
- for (int i = 0; i < cmd.argc; ++i) {
30
- printf(" - '%s'\n", cmd.argv[i]);
31
- }
32
- command_free(&cmd);
33
- return 0;
34
- }
@@ -1,94 +0,0 @@
1
- # ==========================================
2
- # Unity Project - A Test Framework for C
3
- # Copyright (c) 2007 Mike Karlesky, Mark VanderVoord, Greg Williams
4
- # [Released under MIT License. Please refer to license.txt for details]
5
- # ==========================================
6
-
7
- if RUBY_PLATFORM =~/(win|w)32$/
8
- begin
9
- require 'Win32API'
10
- rescue LoadError
11
- puts "ERROR! \"Win32API\" library not found"
12
- puts "\"Win32API\" is required for colour on a windows machine"
13
- puts " try => \"gem install Win32API\" on the command line"
14
- puts
15
- end
16
- # puts
17
- # puts 'Windows Environment Detected...'
18
- # puts 'Win32API Library Found.'
19
- # puts
20
- end
21
-
22
- class ColourCommandLine
23
- def initialize
24
- if RUBY_PLATFORM =~/(win|w)32$/
25
- get_std_handle = Win32API.new("kernel32", "GetStdHandle", ['L'], 'L')
26
- @set_console_txt_attrb =
27
- Win32API.new("kernel32","SetConsoleTextAttribute",['L','N'], 'I')
28
- @hout = get_std_handle.call(-11)
29
- end
30
- end
31
-
32
- def change_to(new_colour)
33
- if RUBY_PLATFORM =~/(win|w)32$/
34
- @set_console_txt_attrb.call(@hout,self.win32_colour(new_colour))
35
- else
36
- "\033[30;#{posix_colour(new_colour)};22m"
37
- end
38
- end
39
-
40
- def win32_colour(colour)
41
- case colour
42
- when :black then 0
43
- when :dark_blue then 1
44
- when :dark_green then 2
45
- when :dark_cyan then 3
46
- when :dark_red then 4
47
- when :dark_purple then 5
48
- when :dark_yellow, :narrative then 6
49
- when :default_white, :default, :dark_white then 7
50
- when :silver then 8
51
- when :blue then 9
52
- when :green, :success then 10
53
- when :cyan, :output then 11
54
- when :red, :failure then 12
55
- when :purple then 13
56
- when :yellow then 14
57
- when :white then 15
58
- else
59
- 0
60
- end
61
- end
62
-
63
- def posix_colour(colour)
64
- case colour
65
- when :black then 30
66
- when :red, :failure then 31
67
- when :green, :success then 32
68
- when :yellow then 33
69
- when :blue, :narrative then 34
70
- when :purple, :magenta then 35
71
- when :cyan, :output then 36
72
- when :white, :default_white, :default then 37
73
- else
74
- 30
75
- end
76
- end
77
-
78
- def out_c(mode, colour, str)
79
- case RUBY_PLATFORM
80
- when /(win|w)32$/
81
- change_to(colour)
82
- $stdout.puts str if mode == :puts
83
- $stdout.print str if mode == :print
84
- change_to(:default_white)
85
- else
86
- $stdout.puts("#{change_to(colour)}#{str}\033[0m") if mode == :puts
87
- $stdout.print("#{change_to(colour)}#{str}\033[0m") if mode == :print
88
- end
89
- end
90
- end # ColourCommandLine
91
-
92
- def colour_puts(role,str) ColourCommandLine.new.out_c(:puts, role, str) end
93
- def colour_print(role,str) ColourCommandLine.new.out_c(:print, role, str) end
94
-
@@ -1,39 +0,0 @@
1
- # ==========================================
2
- # Unity Project - A Test Framework for C
3
- # Copyright (c) 2007 Mike Karlesky, Mark VanderVoord, Greg Williams
4
- # [Released under MIT License. Please refer to license.txt for details]
5
- # ==========================================
6
-
7
- require "#{File.expand_path(File.dirname(__FILE__))}/colour_prompt"
8
-
9
- $colour_output = true
10
-
11
- def report(message)
12
- if not $colour_output
13
- $stdout.puts(message)
14
- else
15
- message = message.join('\n') if (message.class == Array)
16
- message.each_line do |line|
17
- line.chomp!
18
- colour = case(line)
19
- when /(?:total\s+)?tests:?\s+(\d+)\s+(?:total\s+)?failures:?\s+\d+\s+Ignored:?/i
20
- ($1.to_i == 0) ? :green : :red
21
- when /PASS/
22
- :green
23
- when /^OK$/
24
- :green
25
- when /(?:FAIL|ERROR)/
26
- :red
27
- when /IGNORE/
28
- :yellow
29
- when /^(?:Creating|Compiling|Linking)/
30
- :white
31
- else
32
- :silver
33
- end
34
- colour_puts(colour, line)
35
- end
36
- end
37
- $stdout.flush
38
- $stderr.flush
39
- end
@@ -1,36 +0,0 @@
1
- #this is a sample configuration file for generate_module
2
- #you would use it by calling generate_module with the -ygenerate_config.yml option
3
- #files like this are useful for customizing generate_module to your environment
4
- :generate_module:
5
- :defaults:
6
- #these defaults are used in place of any missing options at the command line
7
- :path_src: ../src/
8
- :path_inc: ../src/
9
- :path_tst: ../test/
10
- :update_svn: true
11
- :includes:
12
- #use [] for no additional includes, otherwise list the includes on separate lines
13
- :src:
14
- - Defs.h
15
- - Board.h
16
- :inc: []
17
- :tst:
18
- - Defs.h
19
- - Board.h
20
- - Exception.h
21
- :boilerplates:
22
- #these are inserted at the top of generated files.
23
- #just comment out or remove if not desired.
24
- #use %1$s where you would like the file name to appear (path/extension not included)
25
- :src: |
26
- //-------------------------------------------
27
- // %1$s.c
28
- //-------------------------------------------
29
- :inc: |
30
- //-------------------------------------------
31
- // %1$s.h
32
- //-------------------------------------------
33
- :tst: |
34
- //-------------------------------------------
35
- // Test%1$s.c : Units tests for %1$s.c
36
- //-------------------------------------------
@@ -1,202 +0,0 @@
1
- # ==========================================
2
- # Unity Project - A Test Framework for C
3
- # Copyright (c) 2007 Mike Karlesky, Mark VanderVoord, Greg Williams
4
- # [Released under MIT License. Please refer to license.txt for details]
5
- # ==========================================
6
-
7
- # This script creates all the files with start code necessary for a new module.
8
- # A simple module only requires a source file, header file, and test file.
9
- # Triad modules require a source, header, and test file for each triad type (like model, conductor, and hardware).
10
-
11
- require 'rubygems'
12
- require 'fileutils'
13
-
14
- HERE = File.expand_path(File.dirname(__FILE__)) + '/'
15
-
16
- #help text when requested
17
- HELP_TEXT = [ "\nGENERATE MODULE\n-------- ------",
18
- "\nUsage: ruby generate_module [options] module_name",
19
- " -i\"include\" sets the path to output headers to 'include' (DEFAULT ../src)",
20
- " -s\"../src\" sets the path to output source to '../src' (DEFAULT ../src)",
21
- " -t\"C:/test\" sets the path to output source to 'C:/test' (DEFAULT ../test)",
22
- " -p\"MCH\" sets the output pattern to MCH.",
23
- " dh - driver hardware.",
24
- " dih - driver interrupt hardware.",
25
- " mch - model conductor hardware.",
26
- " mvp - model view presenter.",
27
- " src - just a single source module. (DEFAULT)",
28
- " -d destroy module instead of creating it.",
29
- " -u update subversion too (requires subversion command line)",
30
- " -y\"my.yml\" selects a different yaml config file for module generation",
31
- "" ].join("\n")
32
-
33
- #Built in patterns
34
- PATTERNS = { 'src' => {'' => { :inc => [] } },
35
- 'dh' => {'Driver' => { :inc => ['%1$sHardware.h'] },
36
- 'Hardware' => { :inc => [] }
37
- },
38
- 'dih' => {'Driver' => { :inc => ['%1$sHardware.h', '%1$sInterrupt.h'] },
39
- 'Interrupt'=> { :inc => ['%1$sHardware.h'] },
40
- 'Hardware' => { :inc => [] }
41
- },
42
- 'mch' => {'Model' => { :inc => [] },
43
- 'Conductor'=> { :inc => ['%1$sModel.h', '%1$sHardware.h'] },
44
- 'Hardware' => { :inc => [] }
45
- },
46
- 'mvp' => {'Model' => { :inc => [] },
47
- 'Presenter'=> { :inc => ['%1$sModel.h', '%1$sView.h'] },
48
- 'View' => { :inc => [] }
49
- }
50
- }
51
-
52
- #TEMPLATE_TST
53
- TEMPLATE_TST = %q[#include "unity.h"
54
- %2$s#include "%1$s.h"
55
-
56
- void setUp(void)
57
- {
58
- }
59
-
60
- void tearDown(void)
61
- {
62
- }
63
-
64
- void test_%1$s_NeedToImplement(void)
65
- {
66
- TEST_IGNORE();
67
- }
68
- ]
69
-
70
- #TEMPLATE_SRC
71
- TEMPLATE_SRC = %q[%2$s#include "%1$s.h"
72
- ]
73
-
74
- #TEMPLATE_INC
75
- TEMPLATE_INC = %q[#ifndef _%3$s_H
76
- #define _%3$s_H%2$s
77
-
78
- #endif // _%3$s_H
79
- ]
80
-
81
- # Parse the command line parameters.
82
- ARGV.each do |arg|
83
- case(arg)
84
- when /^-d/ then @destroy = true
85
- when /^-u/ then @update_svn = true
86
- when /^-p(\w+)/ then @pattern = $1
87
- when /^-s(.+)/ then @path_src = $1
88
- when /^-i(.+)/ then @path_inc = $1
89
- when /^-t(.+)/ then @path_tst = $1
90
- when /^-y(.+)/ then @yaml_config = $1
91
- when /^(\w+)/
92
- raise "ERROR: You can't have more than one Module name specified!" unless @module_name.nil?
93
- @module_name = arg
94
- when /^-(h|-help)/
95
- puts HELP_TEXT
96
- exit
97
- else
98
- raise "ERROR: Unknown option specified '#{arg}'"
99
- end
100
- end
101
- raise "ERROR: You must have a Module name specified! (use option -h for help)" if @module_name.nil?
102
-
103
- #load yaml file if one was requested
104
- if @yaml_config
105
- require 'yaml'
106
- cfg = YAML.load_file(HERE + @yaml_config)[:generate_module]
107
- @path_src = cfg[:defaults][:path_src] if @path_src.nil?
108
- @path_inc = cfg[:defaults][:path_inc] if @path_inc.nil?
109
- @path_tst = cfg[:defaults][:path_tst] if @path_tst.nil?
110
- @update_svn = cfg[:defaults][:update_svn] if @update_svn.nil?
111
- @extra_inc = cfg[:includes]
112
- @boilerplates = cfg[:boilerplates]
113
- else
114
- @boilerplates = {}
115
- end
116
-
117
- # Create default file paths if none were provided
118
- @path_src = HERE + "../src/" if @path_src.nil?
119
- @path_inc = @path_src if @path_inc.nil?
120
- @path_tst = HERE + "../test/" if @path_tst.nil?
121
- @path_src += '/' unless (@path_src[-1] == 47)
122
- @path_inc += '/' unless (@path_inc[-1] == 47)
123
- @path_tst += '/' unless (@path_tst[-1] == 47)
124
- @pattern = 'src' if @pattern.nil?
125
- @includes = { :src => [], :inc => [], :tst => [] }
126
- @includes.merge!(@extra_inc) unless @extra_inc.nil?
127
-
128
- #create triad definition
129
- TRIAD = [ { :ext => '.c', :path => @path_src, :template => TEMPLATE_SRC, :inc => :src, :boilerplate => @boilerplates[:src] },
130
- { :ext => '.h', :path => @path_inc, :template => TEMPLATE_INC, :inc => :inc, :boilerplate => @boilerplates[:inc] },
131
- { :ext => '.c', :path => @path_tst+'Test', :template => TEMPLATE_TST, :inc => :tst, :boilerplate => @boilerplates[:tst] },
132
- ]
133
-
134
- #prepare the pattern for use
135
- @patterns = PATTERNS[@pattern.downcase]
136
- raise "ERROR: The design pattern specified isn't one that I recognize!" if @patterns.nil?
137
-
138
- # Assemble the path/names of the files we need to work with.
139
- files = []
140
- TRIAD.each do |triad|
141
- @patterns.each_pair do |pattern_file, pattern_traits|
142
- files << {
143
- :path => "#{triad[:path]}#{@module_name}#{pattern_file}#{triad[:ext]}",
144
- :name => "#{@module_name}#{pattern_file}",
145
- :template => triad[:template],
146
- :boilerplate => triad[:boilerplate],
147
- :includes => case(triad[:inc])
148
- when :src then @includes[:src] | pattern_traits[:inc].map{|f| f % [@module_name]}
149
- when :inc then @includes[:inc]
150
- when :tst then @includes[:tst] | pattern_traits[:inc].map{|f| "Mock#{f}"% [@module_name]}
151
- end
152
- }
153
- end
154
- end
155
-
156
- # destroy files if that was what was requested
157
- if @destroy
158
- files.each do |filespec|
159
- file = filespec[:path]
160
- if File.exist?(file)
161
- if @update_svn
162
- `svn delete \"#{file}\" --force`
163
- puts "File #{file} deleted and removed from source control"
164
- else
165
- FileUtils.remove(file)
166
- puts "File #{file} deleted"
167
- end
168
- else
169
- puts "File #{file} does not exist so cannot be removed."
170
- end
171
- end
172
- puts "Destroy Complete"
173
- exit
174
- end
175
-
176
- #Abort if any module already exists
177
- files.each do |file|
178
- raise "ERROR: File #{file[:name]} already exists. Exiting." if File.exist?(file[:path])
179
- end
180
-
181
- # Create Source Modules
182
- files.each_with_index do |file, i|
183
- File.open(file[:path], 'w') do |f|
184
- f.write(file[:boilerplate] % [file[:name]]) unless file[:boilerplate].nil?
185
- f.write(file[:template] % [ file[:name],
186
- file[:includes].map{|f| "#include \"#{f}\"\n"}.join,
187
- file[:name].upcase ]
188
- )
189
- end
190
- if (@update_svn)
191
- `svn add \"#{file[:path]}\"`
192
- if $?.exitstatus == 0
193
- puts "File #{file[:path]} created and added to source control"
194
- else
195
- puts "File #{file[:path]} created but FAILED adding to source control!"
196
- end
197
- else
198
- puts "File #{file[:path]} created"
199
- end
200
- end
201
-
202
- puts 'Generate Complete'