cplusplus 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- data/History.txt +4 -0
- data/License.txt +20 -0
- data/Manifest.txt +41 -0
- data/PostInstall.txt +5 -0
- data/README.txt +55 -0
- data/Rakefile +4 -0
- data/app_generators/cplusplus/USAGE +5 -0
- data/app_generators/cplusplus/cplusplus_generator.rb +74 -0
- data/app_generators/cplusplus/templates/Rakefile +69 -0
- data/app_generators/cplusplus/templates/main.cpp +16 -0
- data/app_generators/cplusplus/templates/makefile +5 -0
- data/bin/cplusplus +17 -0
- data/config/hoe.rb +73 -0
- data/config/requirements.rb +15 -0
- data/generators/class/USAGE +5 -0
- data/generators/class/class_generator.rb +57 -0
- data/generators/class/templates/class.cpp +18 -0
- data/generators/class/templates/class.h +31 -0
- data/generators/class/templates/test.cpp +55 -0
- data/generators/file/USAGE +5 -0
- data/generators/file/file_generator.rb +57 -0
- data/generators/file/templates/file.cpp +10 -0
- data/generators/file/templates/file.h +13 -0
- data/generators/file/templates/test.cpp +55 -0
- data/lib/cplusplus.rb +6 -0
- data/lib/cplusplus/version.rb +9 -0
- data/script/console +10 -0
- data/script/destroy +14 -0
- data/script/generate +14 -0
- data/script/txt2html +82 -0
- data/setup.rb +1585 -0
- data/tasks/deployment.rake +34 -0
- data/tasks/environment.rake +7 -0
- data/tasks/website.rake +17 -0
- data/test/test_class_generator.rb +45 -0
- data/test/test_cplusplus.rb +11 -0
- data/test/test_cplusplus_generator.rb +45 -0
- data/test/test_file_generator.rb +46 -0
- data/test/test_generator_helper.rb +29 -0
- data/test/test_helper.rb +2 -0
- data/website/index.html +11 -0
- data/website/index.txt +83 -0
- data/website/javascripts/rounded_corners_lite.inc.js +285 -0
- data/website/stylesheets/screen.css +138 -0
- data/website/template.html.erb +48 -0
- metadata +119 -0
data/History.txt
ADDED
data/License.txt
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) 2008 FIXME full name
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/Manifest.txt
ADDED
@@ -0,0 +1,41 @@
|
|
1
|
+
History.txt
|
2
|
+
License.txt
|
3
|
+
Manifest.txt
|
4
|
+
PostInstall.txt
|
5
|
+
README.txt
|
6
|
+
Rakefile
|
7
|
+
config/hoe.rb
|
8
|
+
config/requirements.rb
|
9
|
+
lib/cplusplus.rb
|
10
|
+
lib/cplusplus/version.rb
|
11
|
+
script/console
|
12
|
+
script/destroy
|
13
|
+
script/generate
|
14
|
+
script/txt2html
|
15
|
+
setup.rb
|
16
|
+
tasks/deployment.rake
|
17
|
+
tasks/environment.rake
|
18
|
+
tasks/website.rake
|
19
|
+
test/test_cplusplus.rb
|
20
|
+
test/test_helper.rb
|
21
|
+
website/index.html
|
22
|
+
website/index.txt
|
23
|
+
website/javascripts/rounded_corners_lite.inc.js
|
24
|
+
website/stylesheets/screen.css
|
25
|
+
website/template.html.erb
|
26
|
+
bin/cplusplus
|
27
|
+
app_generators/cplusplus/cplusplus_generator.rb
|
28
|
+
app_generators/cplusplus/USAGE
|
29
|
+
app_generators/cplusplus/templates/main.cpp
|
30
|
+
app_generators/cplusplus/templates/makefile
|
31
|
+
app_generators/cplusplus/templates/Rakefile
|
32
|
+
generators/class/class_generator.rb
|
33
|
+
generators/class/USAGE
|
34
|
+
generators/class/templates/class.cpp
|
35
|
+
generators/class/templates/class.h
|
36
|
+
generators/class/templates/test.cpp
|
37
|
+
generators/file/file_generator.rb
|
38
|
+
generators/file/USAGE
|
39
|
+
generators/file/templates/file.cpp
|
40
|
+
generators/file/templates/file.h
|
41
|
+
generators/file/templates/test.cpp
|
data/PostInstall.txt
ADDED
data/README.txt
ADDED
@@ -0,0 +1,55 @@
|
|
1
|
+
= cplusplus
|
2
|
+
|
3
|
+
* http://github.com/guitsaru/cplusplus
|
4
|
+
|
5
|
+
== DESCRIPTION:
|
6
|
+
|
7
|
+
Generators for C++ files.
|
8
|
+
|
9
|
+
== FEATURES/PROBLEMS:
|
10
|
+
|
11
|
+
* Generates C++ files and class files.
|
12
|
+
* Includes tests via cppunit.
|
13
|
+
|
14
|
+
Note, the makefile generated is very generic and will more than likely need to be changed to to use with any sufficiently sized project.
|
15
|
+
|
16
|
+
== SYNOPSIS:
|
17
|
+
|
18
|
+
cplusplus project_name
|
19
|
+
script/generate class class_name
|
20
|
+
script/generate file file_name
|
21
|
+
|
22
|
+
Build the project with Rake or generate a makefile with rake makefile.
|
23
|
+
|
24
|
+
== REQUIREMENTS:
|
25
|
+
|
26
|
+
* Need to have cppunit installed for unit tests
|
27
|
+
|
28
|
+
== INSTALL:
|
29
|
+
|
30
|
+
* sudo gem install cplusplus
|
31
|
+
|
32
|
+
== LICENSE:
|
33
|
+
|
34
|
+
(The MIT License)
|
35
|
+
|
36
|
+
Copyright (c) 2008 FIXME full name
|
37
|
+
|
38
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
39
|
+
a copy of this software and associated documentation files (the
|
40
|
+
'Software'), to deal in the Software without restriction, including
|
41
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
42
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
43
|
+
permit persons to whom the Software is furnished to do so, subject to
|
44
|
+
the following conditions:
|
45
|
+
|
46
|
+
The above copyright notice and this permission notice shall be
|
47
|
+
included in all copies or substantial portions of the Software.
|
48
|
+
|
49
|
+
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
|
50
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
51
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
52
|
+
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
53
|
+
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
54
|
+
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
55
|
+
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/Rakefile
ADDED
@@ -0,0 +1,74 @@
|
|
1
|
+
class CplusplusGenerator < RubiGen::Base
|
2
|
+
DEFAULT_SHEBANG = File.join(Config::CONFIG['bindir'],
|
3
|
+
Config::CONFIG['ruby_install_name'])
|
4
|
+
|
5
|
+
default_options :author => nil
|
6
|
+
|
7
|
+
attr_reader :name
|
8
|
+
|
9
|
+
def initialize(runtime_args, runtime_options = {})
|
10
|
+
super
|
11
|
+
usage if args.empty?
|
12
|
+
@destination_root = File.expand_path(args.shift)
|
13
|
+
@name = base_name
|
14
|
+
extract_options
|
15
|
+
end
|
16
|
+
|
17
|
+
def manifest
|
18
|
+
record do |m|
|
19
|
+
# Ensure appropriate folder(s) exists
|
20
|
+
m.directory ''
|
21
|
+
|
22
|
+
BASEDIRS.each { |path| m.directory path }
|
23
|
+
|
24
|
+
# Create stubs
|
25
|
+
# m.template "template.rb", "some_file_after_erb.rb"
|
26
|
+
# m.template_copy_each ["template.rb", "template2.rb"]
|
27
|
+
# m.file "file", "some_file_copied"
|
28
|
+
# m.file_copy_each ["path/to/file", "path/to/file2"]
|
29
|
+
|
30
|
+
# Makefiles
|
31
|
+
m.file "makefile", "makefile"
|
32
|
+
m.template "Rakefile", "Rakefile"
|
33
|
+
m.template "main.cpp", "src/main.cpp"
|
34
|
+
|
35
|
+
m.dependency "install_rubigen_scripts", [destination_root, 'cplusplus'],
|
36
|
+
:shebang => options[:shebang], :collision => :force
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
protected
|
41
|
+
def banner
|
42
|
+
<<-EOS
|
43
|
+
Creates a ...
|
44
|
+
|
45
|
+
USAGE: #{spec.name} name
|
46
|
+
EOS
|
47
|
+
end
|
48
|
+
|
49
|
+
def add_options!(opts)
|
50
|
+
opts.separator ''
|
51
|
+
opts.separator 'Options:'
|
52
|
+
# For each option below, place the default
|
53
|
+
# at the top of the file next to "default_options"
|
54
|
+
# opts.on("-a", "--author=\"Your Name\"", String,
|
55
|
+
# "Some comment about this option",
|
56
|
+
# "Default: none") { |options[:author]| }
|
57
|
+
opts.on("-v", "--version", "Show the #{File.basename($0)} version number and quit.")
|
58
|
+
end
|
59
|
+
|
60
|
+
def extract_options
|
61
|
+
# for each option, extract it into a local variable (and create an "attr_reader :author" at the top)
|
62
|
+
# Templates can access these value via the attr_reader-generated methods, but not the
|
63
|
+
# raw instance variable value.
|
64
|
+
# @author = options[:author]
|
65
|
+
end
|
66
|
+
|
67
|
+
# Installation skeleton. Intermediate directories are automatically
|
68
|
+
# created so don't sweat their absence here.
|
69
|
+
BASEDIRS = %w(
|
70
|
+
src
|
71
|
+
script
|
72
|
+
test
|
73
|
+
)
|
74
|
+
end
|
@@ -0,0 +1,69 @@
|
|
1
|
+
NAME = "<%= name %>"
|
2
|
+
|
3
|
+
desc "Build the Project"
|
4
|
+
task :default => :classes do
|
5
|
+
compile = "g++ -g "
|
6
|
+
Dir.glob("*.o").map {|file| compile += "#{file} "}
|
7
|
+
compile += "-o #{NAME}"
|
8
|
+
|
9
|
+
puts compile
|
10
|
+
system(compile)
|
11
|
+
end
|
12
|
+
|
13
|
+
desc "Build Classes"
|
14
|
+
task :classes do
|
15
|
+
Dir.glob("src/*.cpp").map do |file|
|
16
|
+
compile = "g++ -c -g #{file}"
|
17
|
+
puts compile
|
18
|
+
system(compile)
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
desc "Clean"
|
23
|
+
task :clean do
|
24
|
+
Dir.glob("{*.o,*~,#{NAME},test/test}").map {|file| puts "Removing #{file}."}
|
25
|
+
|
26
|
+
remove = "rm -f *.o *~ ._* src/._* #{NAME} test/test"
|
27
|
+
system(remove)
|
28
|
+
end
|
29
|
+
|
30
|
+
desc "Test"
|
31
|
+
task :test => :build_tests do
|
32
|
+
puts `test/test`
|
33
|
+
end
|
34
|
+
|
35
|
+
desc "Build Tests"
|
36
|
+
task :build_tests => [:classes] do
|
37
|
+
# g++ tests.cpp -o test/test -lcppunit
|
38
|
+
compile = "g++ "
|
39
|
+
Dir.glob("*.o").map {|file| compile += "#{file} " unless file == "main.o"}
|
40
|
+
Dir.glob("test/*.cpp").map {|file| compile += "#{file} "}
|
41
|
+
compile += "-o test/test -lcppunit"
|
42
|
+
system(compile)
|
43
|
+
end
|
44
|
+
|
45
|
+
desc "Generate Makefile"
|
46
|
+
task :makefile do
|
47
|
+
makefile = ""
|
48
|
+
dependencies = ""
|
49
|
+
|
50
|
+
#Define Classes
|
51
|
+
Dir.glob("src/*.cpp").map do |file|
|
52
|
+
compile = "g++ -c -g #{file}"
|
53
|
+
task = "#{file.gsub('.cpp', '.o').gsub('src/', '')}"
|
54
|
+
dependencies += "#{task} "
|
55
|
+
makefile += "#{task}:\n\t#{compile}\n\n"
|
56
|
+
end
|
57
|
+
|
58
|
+
makefile = "all:#{dependencies}\n\tg++ -g #{dependencies}-o #{NAME}\n\n" + makefile
|
59
|
+
makefile += "clean:\n\trm -f *.o *~ ._* src/._* #{NAME} test/test"
|
60
|
+
puts "Writing makefile."
|
61
|
+
File.open("makefile", "w+") {|file| file.syswrite(makefile)}
|
62
|
+
end
|
63
|
+
|
64
|
+
desc "Tar files"
|
65
|
+
task :tar => [:clean, :makefile] do
|
66
|
+
puts `tar cvf #{NAME}.tar ../#{NAME}/makefile ../#{NAME}/src/*`
|
67
|
+
remove = `tar -tf #{NAME}.tar | grep ._`.gsub("\n", ' ')
|
68
|
+
system("tar --delete -f #{NAME}.tar #{remove}")
|
69
|
+
end
|
data/bin/cplusplus
ADDED
@@ -0,0 +1,17 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require 'rubygems'
|
4
|
+
require 'rubigen'
|
5
|
+
|
6
|
+
if %w(-v --version).include? ARGV.first
|
7
|
+
require 'cplusplus/version'
|
8
|
+
puts "#{File.basename($0)} #{Cplusplus::VERSION::STRING}"
|
9
|
+
exit(0)
|
10
|
+
end
|
11
|
+
|
12
|
+
require 'rubigen/scripts/generate'
|
13
|
+
source = RubiGen::PathSource.new(:application,
|
14
|
+
File.join(File.dirname(__FILE__), "../app_generators"))
|
15
|
+
RubiGen::Base.reset_sources
|
16
|
+
RubiGen::Base.append_sources source
|
17
|
+
RubiGen::Scripts::Generate.new.run(ARGV, :generator => 'cplusplus')
|
data/config/hoe.rb
ADDED
@@ -0,0 +1,73 @@
|
|
1
|
+
require 'cplusplus/version'
|
2
|
+
|
3
|
+
AUTHOR = 'Matt Pruitt' # can also be an array of Authors
|
4
|
+
EMAIL = "guitsaru@gmail.com"
|
5
|
+
DESCRIPTION = "Generators for c++ projects."
|
6
|
+
GEM_NAME = 'cplusplus' # what ppl will type to install your gem
|
7
|
+
RUBYFORGE_PROJECT = 'cplusplus' # The unix name for your project
|
8
|
+
HOMEPATH = "http://#{RUBYFORGE_PROJECT}.rubyforge.org"
|
9
|
+
DOWNLOAD_PATH = "http://rubyforge.org/projects/#{RUBYFORGE_PROJECT}"
|
10
|
+
EXTRA_DEPENDENCIES = [
|
11
|
+
# ['activesupport', '>= 1.3.1']
|
12
|
+
] # An array of rubygem dependencies [name, version]
|
13
|
+
|
14
|
+
@config_file = "~/.rubyforge/user-config.yml"
|
15
|
+
@config = nil
|
16
|
+
RUBYFORGE_USERNAME = "unknown"
|
17
|
+
def rubyforge_username
|
18
|
+
unless @config
|
19
|
+
begin
|
20
|
+
@config = YAML.load(File.read(File.expand_path(@config_file)))
|
21
|
+
rescue
|
22
|
+
puts <<-EOS
|
23
|
+
ERROR: No rubyforge config file found: #{@config_file}
|
24
|
+
Run 'rubyforge setup' to prepare your env for access to Rubyforge
|
25
|
+
- See http://newgem.rubyforge.org/rubyforge.html for more details
|
26
|
+
EOS
|
27
|
+
exit
|
28
|
+
end
|
29
|
+
end
|
30
|
+
RUBYFORGE_USERNAME.replace @config["username"]
|
31
|
+
end
|
32
|
+
|
33
|
+
|
34
|
+
REV = nil
|
35
|
+
# UNCOMMENT IF REQUIRED:
|
36
|
+
# REV = YAML.load(`svn info`)['Revision']
|
37
|
+
VERS = Cplusplus::VERSION::STRING + (REV ? ".#{REV}" : "")
|
38
|
+
RDOC_OPTS = ['--quiet', '--title', 'cplusplus documentation',
|
39
|
+
"--opname", "index.html",
|
40
|
+
"--line-numbers",
|
41
|
+
"--main", "README",
|
42
|
+
"--inline-source"]
|
43
|
+
|
44
|
+
class Hoe
|
45
|
+
def extra_deps
|
46
|
+
@extra_deps.reject! { |x| Array(x).first == 'hoe' }
|
47
|
+
@extra_deps
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
# Generate all the Rake tasks
|
52
|
+
# Run 'rake -T' to see list of generated tasks (from gem root directory)
|
53
|
+
$hoe = Hoe.new(GEM_NAME, VERS) do |p|
|
54
|
+
p.developer(AUTHOR, EMAIL)
|
55
|
+
p.description = DESCRIPTION
|
56
|
+
p.summary = DESCRIPTION
|
57
|
+
p.url = HOMEPATH
|
58
|
+
p.rubyforge_name = RUBYFORGE_PROJECT if RUBYFORGE_PROJECT
|
59
|
+
p.test_globs = ["test/**/test_*.rb"]
|
60
|
+
p.clean_globs |= ['**/.*.sw?', '*.gem', '.config', '**/.DS_Store'] #An array of file patterns to delete on clean.
|
61
|
+
|
62
|
+
# == Optional
|
63
|
+
p.changes = p.paragraphs_of("History.txt", 0..1).join("\n\n")
|
64
|
+
#p.extra_deps = EXTRA_DEPENDENCIES
|
65
|
+
|
66
|
+
#p.spec_extras = {} # A hash of extra values to set in the gemspec.
|
67
|
+
end
|
68
|
+
|
69
|
+
CHANGES = $hoe.paragraphs_of('History.txt', 0..1).join("\\n\\n")
|
70
|
+
PATH = (RUBYFORGE_PROJECT == GEM_NAME) ? RUBYFORGE_PROJECT : "#{RUBYFORGE_PROJECT}/#{GEM_NAME}"
|
71
|
+
$hoe.remote_rdoc_dir = File.join(PATH.gsub(/^#{RUBYFORGE_PROJECT}\/?/,''), 'rdoc')
|
72
|
+
$hoe.rsync_args = '-av --delete --ignore-errors'
|
73
|
+
$hoe.spec.post_install_message = File.open(File.dirname(__FILE__) + "/../PostInstall.txt").read rescue ""
|
@@ -0,0 +1,15 @@
|
|
1
|
+
require 'fileutils'
|
2
|
+
include FileUtils
|
3
|
+
|
4
|
+
require 'rubygems'
|
5
|
+
%w[rake hoe newgem rubigen].each do |req_gem|
|
6
|
+
begin
|
7
|
+
require req_gem
|
8
|
+
rescue LoadError
|
9
|
+
puts "This Rakefile requires the '#{req_gem}' RubyGem."
|
10
|
+
puts "Installation: gem install #{req_gem} -y"
|
11
|
+
exit
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
$:.unshift(File.join(File.dirname(__FILE__), %w[.. lib]))
|
@@ -0,0 +1,57 @@
|
|
1
|
+
class ClassGenerator < RubiGen::Base
|
2
|
+
|
3
|
+
default_options :author => nil
|
4
|
+
|
5
|
+
attr_reader :name
|
6
|
+
|
7
|
+
def initialize(runtime_args, runtime_options = {})
|
8
|
+
super
|
9
|
+
usage if args.empty?
|
10
|
+
@name = args.shift
|
11
|
+
extract_options
|
12
|
+
end
|
13
|
+
|
14
|
+
def manifest
|
15
|
+
record do |m|
|
16
|
+
# Ensure appropriate folder(s) exists
|
17
|
+
m.directory 'src'
|
18
|
+
m.directory 'test'
|
19
|
+
|
20
|
+
# Create stubs
|
21
|
+
# m.template "template.rb", "some_file_after_erb.rb"
|
22
|
+
# m.template_copy_each ["template.rb", "template2.rb"]
|
23
|
+
# m.file "file", "some_file_copied"
|
24
|
+
# m.file_copy_each ["path/to/file", "path/to/file2"]
|
25
|
+
m.template "class.cpp", "src/#{name}.cpp"
|
26
|
+
m.template "class.h", "src/#{name}.h"
|
27
|
+
m.template "test.cpp", "test/test_#{name}.cpp"
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
protected
|
32
|
+
def banner
|
33
|
+
<<-EOS
|
34
|
+
Creates a ...
|
35
|
+
|
36
|
+
USAGE: #{$0} #{spec.name} name
|
37
|
+
EOS
|
38
|
+
end
|
39
|
+
|
40
|
+
def add_options!(opts)
|
41
|
+
# opts.separator ''
|
42
|
+
# opts.separator 'Options:'
|
43
|
+
# For each option below, place the default
|
44
|
+
# at the top of the file next to "default_options"
|
45
|
+
# opts.on("-a", "--author=\"Your Name\"", String,
|
46
|
+
# "Some comment about this option",
|
47
|
+
# "Default: none") { |options[:author]| }
|
48
|
+
# opts.on("-v", "--version", "Show the #{File.basename($0)} version number and quit.")
|
49
|
+
end
|
50
|
+
|
51
|
+
def extract_options
|
52
|
+
# for each option, extract it into a local variable (and create an "attr_reader :author" at the top)
|
53
|
+
# Templates can access these value via the attr_reader-generated methods, but not the
|
54
|
+
# raw instance variable value.
|
55
|
+
# @author = options[:author]
|
56
|
+
end
|
57
|
+
end
|