cgialib 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
data/History.txt ADDED
@@ -0,0 +1,4 @@
1
+ == 0.0.1 2008-11-17
2
+
3
+ * 1 major enhancement:
4
+ * Initial release
data/Manifest.txt ADDED
@@ -0,0 +1,35 @@
1
+ History.txt
2
+ Manifest.txt
3
+ PostInstall.txt
4
+ README.rdoc
5
+ Rakefile
6
+ bin/testgen
7
+ config/website.yml.sample
8
+ features/development.feature
9
+ features/steps/common.rb
10
+ features/steps/env.rb
11
+ lib/cgialib.rb
12
+ lib/testgen/cli.rb
13
+ lib/cgialib/lp.rb
14
+ lib/cgialib/template.rb
15
+ lib/cgialib/lp/Language.rb
16
+ lib/cgialib/lp/Tokenizer.rb
17
+ lib/cgialib/lp/CLanguageScanner.rb
18
+ lib/cgialib/lp/CPPLanguageScanner.rb
19
+ lib/cgialib/lp/CTokenizer.rb
20
+ lib/cgialib/template/ut.rb
21
+ lib/cgialib/template/ut/c.rb
22
+ script/console
23
+ script/destroy
24
+ script/generate
25
+ script/txt2html
26
+ spec/cgialib_spec.rb
27
+ spec/spec.opts
28
+ spec/spec_helper.rb
29
+ spec/testgen_cli_spec.rb
30
+ tasks/rspec.rake
31
+ website/index.html
32
+ website/index.txt
33
+ website/javascripts/rounded_corners_lite.inc.js
34
+ website/stylesheets/screen.css
35
+ website/template.html.erb
data/PostInstall.txt ADDED
@@ -0,0 +1,7 @@
1
+
2
+ For more information on cgialib, see http://cgialib.rubyforge.org
3
+
4
+ NOTE: Change this information in PostInstall.txt
5
+ You can also delete it if you don't want it.
6
+
7
+
data/README.rdoc ADDED
@@ -0,0 +1,49 @@
1
+ = cgialib
2
+
3
+ * cgialib.rubyforge.org
4
+
5
+ == DESCRIPTION:
6
+
7
+ Import the examples in Code Generation In Action
8
+
9
+ == FEATURES/PROBLEMS:
10
+
11
+ * language parsers
12
+ * unit test generators
13
+
14
+ == SYNOPSIS:
15
+
16
+ testgen test.c
17
+
18
+ == REQUIREMENTS:
19
+
20
+ * NA
21
+
22
+ == INSTALL:
23
+
24
+ * sudo gem install cgialib
25
+
26
+ == LICENSE:
27
+
28
+ (The MIT License)
29
+
30
+ Copyright (c) 2008 FIXME full name
31
+
32
+ Permission is hereby granted, free of charge, to any person obtaining
33
+ a copy of this software and associated documentation files (the
34
+ 'Software'), to deal in the Software without restriction, including
35
+ without limitation the rights to use, copy, modify, merge, publish,
36
+ distribute, sublicense, and/or sell copies of the Software, and to
37
+ permit persons to whom the Software is furnished to do so, subject to
38
+ the following conditions:
39
+
40
+ The above copyright notice and this permission notice shall be
41
+ included in all copies or substantial portions of the Software.
42
+
43
+ THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
44
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
45
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
46
+ IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
47
+ CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
48
+ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
49
+ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/Rakefile ADDED
@@ -0,0 +1,28 @@
1
+ %w[rubygems rake rake/clean fileutils newgem rubigen].each { |f| require f }
2
+ require File.dirname(__FILE__) + '/lib/cgialib'
3
+
4
+ # Generate all the Rake tasks
5
+ # Run 'rake -T' to see list of generated tasks (from gem root directory)
6
+ $hoe = Hoe.new('cgialib', Cgialib::VERSION) do |p|
7
+ p.developer('David Ruan', 'ruanwz@gmail.com')
8
+ p.changes = p.paragraphs_of("History.txt", 0..1).join("\n\n")
9
+ p.post_install_message = 'PostInstall.txt' # TODO remove if post-install message not required
10
+ p.rubyforge_name = p.name # TODO this is default value
11
+ # p.extra_deps = [
12
+ # ['activesupport','>= 2.0.2'],
13
+ # ]
14
+ p.extra_dev_deps = [
15
+ ['newgem', ">= #{::Newgem::VERSION}"]
16
+ ]
17
+
18
+ p.clean_globs |= %w[**/.DS_Store tmp *.log]
19
+ path = (p.rubyforge_name == p.name) ? p.rubyforge_name : "\#{p.rubyforge_name}/\#{p.name}"
20
+ p.remote_rdoc_dir = File.join(path.gsub(/^#{p.rubyforge_name}\/?/,''), 'rdoc')
21
+ p.rsync_args = '-av --delete --ignore-errors'
22
+ end
23
+
24
+ require 'newgem/tasks' # load /tasks/*.rake
25
+ Dir['tasks/**/*.rake'].each { |t| load t }
26
+
27
+ # TODO - want other tests/tasks run by default? Add them to the list
28
+ # task :default => [:spec, :features]
data/bin/testgen ADDED
@@ -0,0 +1,10 @@
1
+ #!/usr/bin/env ruby
2
+ #
3
+ # Created on 2008-11-17.
4
+ # Copyright (c) 2008. All rights reserved.
5
+
6
+ require File.expand_path(File.dirname(__FILE__) + "/../lib/cgialib")
7
+
8
+ require "testgen/cli"
9
+
10
+ Testgen::CLI.execute(STDOUT, ARGV)
@@ -0,0 +1,2 @@
1
+ host: unknown@rubyforge.org
2
+ remote_dir: /var/www/gforge-projects/cgialib
@@ -0,0 +1,13 @@
1
+ Feature: Development processes of newgem itself (rake tasks)
2
+
3
+ As a Newgem maintainer or contributor
4
+ I want rake tasks to maintain and release the gem
5
+ So that I can spend time on the tests and code, and not excessive time on maintenance processes
6
+
7
+ Scenario: Generate RubyGem
8
+ Given this project is active project folder
9
+ And 'pkg' folder is deleted
10
+ When task 'rake gem' is invoked
11
+ Then folder 'pkg' is created
12
+ And file with name matching 'pkg/*.gem' is created else you should run "rake manifest" to fix this
13
+ And gem spec key 'rdoc_options' contains /--mainREADME.rdoc/
@@ -0,0 +1,174 @@
1
+ def in_project_folder(&block)
2
+ project_folder = @active_project_folder || @tmp_root
3
+ FileUtils.chdir(project_folder, &block)
4
+ end
5
+
6
+ def in_home_folder(&block)
7
+ FileUtils.chdir(@home_path, &block)
8
+ end
9
+
10
+ Given %r{^a safe folder} do
11
+ FileUtils.rm_rf @tmp_root = File.dirname(__FILE__) + "/../../tmp"
12
+ FileUtils.mkdir_p @tmp_root
13
+ FileUtils.mkdir_p @home_path = File.expand_path(File.join(@tmp_root, "home"))
14
+ @lib_path = File.expand_path(File.dirname(__FILE__) + '/../../lib')
15
+ Given "env variable $HOME set to '#{@home_path}'"
16
+ end
17
+
18
+ Given %r{^this project is active project folder} do
19
+ Given "a safe folder"
20
+ @active_project_folder = File.expand_path(File.dirname(__FILE__) + "/../..")
21
+ end
22
+
23
+ Given %r{^env variable \$([\w_]+) set to '(.*)'} do |env_var, value|
24
+ ENV[env_var] = value
25
+ end
26
+
27
+ def force_local_lib_override(project_name = @project_name)
28
+ rakefile = File.read(File.join(project_name, 'Rakefile'))
29
+ File.open(File.join(project_name, 'Rakefile'), "w+") do |f|
30
+ f << "$:.unshift('#{@lib_path}')\n"
31
+ f << rakefile
32
+ end
33
+ end
34
+
35
+ def setup_active_project_folder project_name
36
+ @active_project_folder = File.join(@tmp_root, project_name)
37
+ @project_name = project_name
38
+ end
39
+
40
+ Given %r{'(.*)' folder is deleted} do |folder|
41
+ in_project_folder do
42
+ FileUtils.rm_rf folder
43
+ end
44
+ end
45
+
46
+ When %r{^'(.*)' generator is invoked with arguments '(.*)'$} do |generator, arguments|
47
+ FileUtils.chdir(@active_project_folder) do
48
+ if Object.const_defined?("APP_ROOT")
49
+ APP_ROOT.replace(FileUtils.pwd)
50
+ else
51
+ APP_ROOT = FileUtils.pwd
52
+ end
53
+ run_generator(generator, arguments.split(' '), SOURCES)
54
+ end
55
+ end
56
+
57
+ When %r{run executable '(.*)' with arguments '(.*)'} do |executable, arguments|
58
+ @stdout = File.expand_path(File.join(@tmp_root, "executable.out"))
59
+ FileUtils.chdir(@active_project_folder) do
60
+ system "ruby #{executable} #{arguments} > #{@stdout}"
61
+ end
62
+ end
63
+
64
+ When %r{^task 'rake (.*)' is invoked$} do |task|
65
+ @stdout = File.expand_path(File.join(@tmp_root, "tests.out"))
66
+ FileUtils.chdir(@active_project_folder) do
67
+ system "rake #{task} --trace > #{@stdout} 2> #{@stdout}"
68
+ end
69
+ end
70
+
71
+ Then %r{^folder '(.*)' is created} do |folder|
72
+ in_project_folder do
73
+ File.exists?(folder).should be_true
74
+ end
75
+ end
76
+
77
+ Then %r{^file '(.*)' (is|is not) created} do |file, is|
78
+ in_project_folder do
79
+ File.exists?(file).should(is == 'is' ? be_true : be_false)
80
+ end
81
+ end
82
+
83
+ Then %r{^file with name matching '(.*)' is created} do |pattern|
84
+ in_project_folder do
85
+ Dir[pattern].should_not be_empty
86
+ end
87
+ end
88
+
89
+ Then %r{gem file '(.*)' and generated file '(.*)' should be the same} do |gem_file, project_file|
90
+ File.exists?(gem_file).should be_true
91
+ File.exists?(project_file).should be_true
92
+ gem_file_contents = File.read(File.dirname(__FILE__) + "/../../#{gem_file}")
93
+ project_file_contents = File.read(File.join(@active_project_folder, project_file))
94
+ project_file_contents.should == gem_file_contents
95
+ end
96
+
97
+ Then %r{^output same as contents of '(.*)'$} do |file|
98
+ expected_output = File.read(File.join(File.dirname(__FILE__) + "/../expected_outputs", file))
99
+ actual_output = File.read(File.dirname(__FILE__) + "/../../tmp/#{@stdout}")
100
+ actual_output.should == expected_output
101
+ end
102
+
103
+ Then %r{^(does|does not) invoke generator '(.*)'$} do |does_invoke, generator|
104
+ actual_output = File.read(File.dirname(__FILE__) + "/../../tmp/#{@stdout}")
105
+ does_invoke == "does" ?
106
+ actual_output.should(match(/dependency\s+#{generator}/)) :
107
+ actual_output.should_not(match(/dependency\s+#{generator}/))
108
+ end
109
+
110
+ Then %r{help options '(.*)' and '(.*)' are displayed} do |opt1, opt2|
111
+ actual_output = File.read(@stdout)
112
+ actual_output.should match(/#{opt1}/)
113
+ actual_output.should match(/#{opt2}/)
114
+ end
115
+
116
+ Then %r{^output (does|does not) match \/(.*)\/} do |does, regex|
117
+ actual_output = File.read(@stdout)
118
+ (does == 'does') ?
119
+ actual_output.should(match(/#{regex}/)) :
120
+ actual_output.should_not(match(/#{regex}/))
121
+ end
122
+
123
+ Then %r{^contents of file '(.*)' (does|does not) match \/(.*)\/} do |file, does, regex|
124
+ in_project_folder do
125
+ actual_output = File.read(file)
126
+ (does == 'does') ?
127
+ actual_output.should(match(/#{regex}/)) :
128
+ actual_output.should_not(match(/#{regex}/))
129
+ end
130
+ end
131
+
132
+ Then %r{^all (\d+) tests pass} do |expected_test_count|
133
+ expected = %r{^#{expected_test_count} tests, \d+ assertions, 0 failures, 0 errors}
134
+ actual_output = File.read(@stdout)
135
+ actual_output.should match(expected)
136
+ end
137
+
138
+ Then %r{^all (\d+) examples pass} do |expected_test_count|
139
+ expected = %r{^#{expected_test_count} examples?, 0 failures}
140
+ actual_output = File.read(@stdout)
141
+ actual_output.should match(expected)
142
+ end
143
+
144
+ Then %r{^yaml file '(.*)' contains (\{.*\})} do |file, yaml|
145
+ in_project_folder do
146
+ yaml = eval yaml
147
+ YAML.load(File.read(file)).should == yaml
148
+ end
149
+ end
150
+
151
+ Then %r{^Rakefile can display tasks successfully} do
152
+ @stdout = File.expand_path(File.join(@tmp_root, "rakefile.out"))
153
+ FileUtils.chdir(@active_project_folder) do
154
+ system "rake -T > #{@stdout} 2> #{@stdout}"
155
+ end
156
+ actual_output = File.read(@stdout)
157
+ actual_output.should match(/^rake\s+\w+\s+#\s.*/)
158
+ end
159
+
160
+ Then %r{^task 'rake (.*)' is executed successfully} do |task|
161
+ @stdout.should_not be_nil
162
+ actual_output = File.read(@stdout)
163
+ actual_output.should_not match(/^Don't know how to build task '#{task}'/)
164
+ actual_output.should_not match(/Error/i)
165
+ end
166
+
167
+ Then %r{^gem spec key '(.*)' contains \/(.*)\/} do |key, regex|
168
+ in_project_folder do
169
+ gem_file = Dir["pkg/*.gem"].first
170
+ gem_spec = Gem::Specification.from_yaml(`gem spec #{gem_file}`)
171
+ spec_value = gem_spec.send(key.to_sym)
172
+ spec_value.to_s.should match(/#{regex}/)
173
+ end
174
+ end
@@ -0,0 +1,6 @@
1
+ require File.dirname(__FILE__) + "/../../lib/cgialib"
2
+
3
+ gem 'cucumber'
4
+ require 'cucumber'
5
+ gem 'rspec'
6
+ require 'spec'