gen 0.24.0

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/ProjectInfo ADDED
@@ -0,0 +1,56 @@
1
+ --- %YAML:1.0
2
+
3
+ TITLE : &title Gen
4
+ NAME : &pkg gen
5
+ VERSION : '0.24.0'
6
+ STATUS : beta
7
+
8
+ AUTHOR : George Moschovitis
9
+ EMAIL : &email gm@navel.gr
10
+ HOMEPAGE : "http://www.nitrohq.com"
11
+
12
+ SUMMARY: A simple code generation system.
13
+
14
+ DESCRIPTION: >
15
+ A simple code generation system.
16
+
17
+ DISTRIBUTE: [ gem, tgz, zip ]
18
+
19
+ DEPENDENCIES:
20
+ - [ glue, '= 0.24.0' ]
21
+
22
+ RUBYFORGE:
23
+ PROJECT: 'nitro'
24
+ USERNAME: 'gmosx'
25
+
26
+ # Anything to require upfront?
27
+ #TEST:
28
+ # fixture: ''
29
+
30
+ ANNOUNCE:
31
+ to: george.moschovitis@gmail.com
32
+ from: gm@navel.gr
33
+ domain: navel.gr
34
+ server: mail
35
+ port: 25 #587
36
+ account: gm@navel.gr
37
+ authtype: login #cram_md5 #plain
38
+ sectype: tls # ~, tls, ssl (tls is broke)
39
+ file: ANN
40
+ slogan: Gen
41
+
42
+
43
+
44
+ links:
45
+ - http://www.nitrohq.com
46
+
47
+
48
+
49
+
50
+
51
+
52
+
53
+
54
+
55
+
56
+
data/README ADDED
@@ -0,0 +1,30 @@
1
+ = Gen 0.24.0 README
2
+
3
+ A Ruby code generation framework.
4
+
5
+ Code generators can be implemented as standard Ruby Gems
6
+ for simple distribution.
7
+
8
+
9
+ == Support
10
+
11
+ For any questions regarding Gen, feel free to ask on the ruby-talk
12
+ mailing list (which is mirrored to comp.lang.ruby) or contact
13
+ mailto:gm@navel.gr.
14
+
15
+ A Gen specific mailing list is also available. Please subscribe
16
+ to nitro-general@rubyforge.com. The homepage for this list
17
+ is available here:
18
+
19
+ http://rubyforge.org/mailman/listinfo/nitro-general
20
+
21
+
22
+ == Licence
23
+
24
+ Copyright (c) 2005, Navel Ltd (http://www.navel.gr)
25
+ Copyright (c) 2005, George 'gmosx' Moschovitis (http://www.gmosx.com)
26
+
27
+ Gen (http://www.nitrohq.com) is copyrighted free software
28
+ created and maintained by George Moschovitis (mailto:gm@navel.gr)
29
+ and released under the standard BSD Licence. For details consult
30
+ the file LICENCE.
data/Rakefile ADDED
@@ -0,0 +1,220 @@
1
+ require 'rake/rdoctask'
2
+ require 'rake/testtask'
3
+ require 'rake/gempackagetask'
4
+
5
+ # Initialize some variables.
6
+
7
+ readme = File.read('README')
8
+ Release = (readme[/^= (.+) README$/, 1] || 'unknown').downcase.tr(" ", "-")
9
+ Name = Release[/\D+/].sub(/\-+$/, '') || 'unknown'
10
+ Version = Release[/[\d.]+/] || 'unknown'
11
+
12
+ AuthorName, AuthorMail = 'George Moschovitis', 'gm@navel.gr'
13
+ RubyVersion = '1.8.3'
14
+
15
+ # Description = (readme[/README\s+(.+?)\n\n/m, 1] || "unknown").gsub(/\s+/, " ")
16
+ # Summary = Description[/^.+?>/] || "unknown"
17
+
18
+ # DocFiles = %w(README NEWS TODO COPYING GPL)
19
+ # RDocFiles = DocFiles - %w(GPL)
20
+ RDocOpts = ["--inline-source", "--line-numbers","--title", Name ]
21
+ # AdditionalFiles = DocFiles + %w(setup.rb)
22
+ VersionFile = MainFile = File.join("lib", Name + '.rb')
23
+
24
+ RubyForgeProject = Name
25
+ RubyForgeUser = 'gmosx'
26
+ Homepage = "http://www.nitrohq.org/"
27
+
28
+ task :default => :package
29
+
30
+ # Run the tests.
31
+
32
+ Rake::TestTask.new do |t|
33
+ t.libs << 'test'
34
+ t.test_files = FileList['test/**/tc*.rb']
35
+ t.verbose = true
36
+ end
37
+
38
+ # Generate RDoc documentation.
39
+
40
+ Rake::RDocTask.new do |rd|
41
+ rd.main = 'README'
42
+ rd.rdoc_dir = 'rdoc'
43
+ rd.rdoc_files.include('README', 'INSTALL', 'doc/RELEASES', 'lib/**/*.rb')
44
+ rd.options << '--all --inline-source'
45
+ end
46
+
47
+ # Build gem.
48
+
49
+ spec = Gem::Specification.new do |s|
50
+ s.name = 'gen'
51
+ if File.read('lib/gen.rb') =~ /Version\s+=\s+'(\d+\.\d+\.\d+)'/
52
+ s.version = $1
53
+ else
54
+ raise 'No version found'
55
+ end
56
+ s.summary = 'Gen code generation framework'
57
+ s.description = 'A simple code generation framework.'
58
+
59
+ s.add_dependency 'glue', "= #{s.version}"
60
+ s.add_dependency 'og', "= #{s.version}"
61
+ s.add_dependency 'nitro', "= #{s.version}"
62
+
63
+ s.required_ruby_version = '= 1.8.3'
64
+
65
+ s.files = FileList[
66
+ '[A-Z]*', '{bin,doc,lib,test}/**/*'
67
+ ].exclude("_darcs").exclude("_darcs/**/*").exclude('*.og').exclude('**/*.log').to_a
68
+
69
+ s.require_path = 'lib'
70
+ s.autorequire = 'nitro'
71
+
72
+ s.has_rdoc = true
73
+ s.extra_rdoc_files = FileList['[A-Z]*'].to_a
74
+ s.rdoc_options << '--main' << 'README' << '--title' << 'Gen Documentation'
75
+ s.rdoc_options << '--all' << '--inline-source'
76
+
77
+ s.test_files = []
78
+
79
+ s.bindir = 'bin'
80
+ s.executables = ['gen']
81
+ s.default_executable = 'gen'
82
+
83
+ s.author = 'George Moschovitis'
84
+ s.email = 'gm@navel.gr'
85
+ s.homepage = 'http://www.nitrohq.com'
86
+ s.rubyforge_project = 'gen'
87
+ end
88
+
89
+ Rake::GemPackageTask.new(spec) do |pkg|
90
+ pkg.package_dir = 'dist'
91
+ pkg.need_zip = true
92
+ pkg.need_tar = true
93
+ end
94
+
95
+ # Manual install (not recommended).
96
+
97
+ task :install do
98
+ ruby 'install.rb'
99
+ end
100
+
101
+ # Release files to Rubyforge.
102
+ # The code for this task provided by Florian Gross.
103
+
104
+ desc "Publish the release files to RubyForge."
105
+ task :publish => [:package] do
106
+ files = ['gem', 'tgz', 'zip'].map { |ext| "dist/#{Release}.#{ext}" }
107
+
108
+ if RubyForgeProject then
109
+ require 'net/http'
110
+ require 'open-uri'
111
+
112
+ changes = ''
113
+ if File.exist?('doc/RELEASES') then
114
+ changes_re = /^== \s+ Version \s+ #{Regexp.quote(Version)} \s*
115
+ (.+?) (?:==|\Z)/mx
116
+ changes = File.read('doc/RELEASES')[changes_re, 1] || ''
117
+ end
118
+
119
+ project_uri = "http://rubyforge.org/projects/#{RubyForgeProject}/"
120
+ project_data = open(project_uri) { |data| data.read }
121
+ group_id = project_data[/[?&]group_id=(\d+)/, 1]
122
+ raise "Couldn't get group id" unless group_id
123
+
124
+ print "#{RubyForgeUser}@rubyforge.org's password: "
125
+ password = STDIN.gets.chomp
126
+
127
+ login_response = Net::HTTP.start('rubyforge.org', 80) do |http|
128
+ data = [
129
+ "login=1",
130
+ "form_loginname=#{RubyForgeUser}",
131
+ "form_pw=#{password}"
132
+ ].join("&")
133
+ http.post('/account/login.php', data)
134
+ end
135
+
136
+ cookie = login_response['set-cookie']
137
+ raise 'Login failed' unless cookie
138
+ headers = { 'Cookie' => cookie }
139
+
140
+ release_uri = "http://rubyforge.org/frs/admin/?group_id=#{group_id}"
141
+ release_data = open(release_uri, headers) { |data| data.read }
142
+ package_id = release_data[/[?&]package_id=(\d+)/, 1]
143
+ raise "Couldn't get package id" unless package_id
144
+
145
+ first_file = true
146
+ release_id = ""
147
+
148
+ files.each do |filename|
149
+ basename = File.basename(filename)
150
+ file_ext = File.extname(filename)
151
+ file_data = File.open(filename, "rb") { |file| file.read }
152
+
153
+ puts "Releasing #{basename}..."
154
+
155
+ release_response = Net::HTTP.start('rubyforge.org', 80) do |http|
156
+ release_date = Time.now.strftime('%Y-%m-%d %H:%M')
157
+ type_map = {
158
+ '.zip' => '3000',
159
+ '.tgz' => '3110',
160
+ '.gz' => '3110',
161
+ '.gem' => '1400',
162
+ '.md5sum' => '8100'
163
+ }; type_map.default = '9999'
164
+ type = type_map[file_ext]
165
+ boundary = 'rubyqMY6QN9bp6e4kS21H4y0zxcvoor'
166
+
167
+ query_hash = if first_file then
168
+ {
169
+ 'group_id' => group_id,
170
+ 'package_id' => package_id,
171
+ 'release_name' => Release,
172
+ 'release_date' => release_date,
173
+ 'type_id' => type,
174
+ 'processor_id' => '8000', # Any
175
+ 'release_notes' => '',
176
+ 'release_changes' => changes,
177
+ 'preformatted' => '1',
178
+ 'submit' => '1'
179
+ }
180
+ else
181
+ {
182
+ 'group_id' => group_id,
183
+ 'release_id' => release_id,
184
+ 'package_id' => package_id,
185
+ 'step2' => '1',
186
+ 'type_id' => type,
187
+ 'processor_id' => '8000', # Any
188
+ 'submit' => 'Add This File'
189
+ }
190
+ end
191
+
192
+ query = '?' + query_hash.map do |(name, value)|
193
+ [name, URI.encode(value)].join('=')
194
+ end.join('&')
195
+
196
+ data = [
197
+ "--" + boundary,
198
+ "Content-Disposition: form-data; name=\"userfile\"; filename=\"#{basename}\"",
199
+ "Content-Type: application/octet-stream",
200
+ "Content-Transfer-Encoding: binary",
201
+ "", file_data, ""
202
+ ].join("\x0D\x0A")
203
+
204
+ release_headers = headers.merge(
205
+ 'Content-Type' => "multipart/form-data; boundary=#{boundary}"
206
+ )
207
+
208
+ target = first_file ? '/frs/admin/qrs.php' : '/frs/admin/editrelease.php'
209
+ http.post(target + query, data, release_headers)
210
+ end
211
+
212
+ if first_file then
213
+ release_id = release_response.body[/release_id=(\d+)/, 1]
214
+ raise("Couldn't get release id") unless release_id
215
+ end
216
+
217
+ first_file = false
218
+ end
219
+ end
220
+ end
data/bin/gen ADDED
@@ -0,0 +1,43 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'gen'
4
+
5
+ def usage
6
+ puts <<-USAGE
7
+
8
+ NAME
9
+ gen - frontend for the Nitro generator mechanism.
10
+
11
+ SYNOPSIS
12
+ gen [generator] [generator options]
13
+
14
+ DESCRIPTION
15
+ This is a frontend to the Nitro generator mechanism. Nitro
16
+ generators are used to 'bootstrap' development by creating
17
+ a standard directory structure and files for common tasks.
18
+
19
+ app:
20
+ This will create some basic files to get you
21
+ started fleshing out your Nitro web application.
22
+
23
+ EXAMPLE
24
+ nitrogen app ~/my_application
25
+
26
+ This will generate a new Nitro application in the
27
+ ~/my_application folder.
28
+ USAGE
29
+ exit 1
30
+ end
31
+
32
+ generator = ARGV.shift || usage()
33
+
34
+ begin
35
+ require "gen/#{generator}/gen.rb"
36
+ rescue LoadError
37
+ puts 'Cannot load the specified generator!'
38
+ exit 1
39
+ end
40
+
41
+ $generator.generator_dir = File.join(Gen::LibPath, 'gen', generator)
42
+ $generator.setup
43
+ $generator.run
data/doc/AUTHORS ADDED
@@ -0,0 +1,9 @@
1
+ MAIN DEVELOPER:
2
+
3
+ * George Moschovitis <gm@navel.gr>
4
+ Project leader, architecture and design, main coder,
5
+ documentation, maintainer.
6
+
7
+
8
+ IDEAS, ADDITIONAL CODING, SUPPORT:
9
+
data/doc/LICENSE ADDED
@@ -0,0 +1,33 @@
1
+ The BSD License
2
+
3
+ Copyright (c) 2004-2005, George 'gmosx' Moschovitis. (http://www.gmosx.com)
4
+ Copyright (c) 2004-2005, Navel Ltd. (http://www.navel.gr)
5
+ All rights reserved.
6
+
7
+ Redistribution and use in source and binary forms, with or without
8
+ modification, are permitted provided that the following conditions are
9
+ met:
10
+
11
+ * Redistributions of source code must retain the above copyright
12
+ notice, this list of conditions and the following disclaimer.
13
+
14
+ * Redistributions in binary form must reproduce the above copyright
15
+ notice, this list of conditions and the following disclaimer in the
16
+ documentation and/or other materials provided with the distribution.
17
+
18
+ * Neither the name of Navel nor the names of its contributors may be
19
+ used to endorse or promote products derived from this software
20
+ without specific prior written permission.
21
+
22
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
23
+ "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
24
+ LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
25
+ A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
26
+ OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
27
+ SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
28
+ TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
29
+ PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
30
+ LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
31
+ NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
32
+ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
33
+
data/doc/RELEASES ADDED
@@ -0,0 +1,4 @@
1
+ == Version 0.24.0
2
+
3
+ First open release. The aim of this release is to gather
4
+ feedback from the community.
data/lib/gen/app/USAGE ADDED
@@ -0,0 +1,17 @@
1
+ NAME
2
+ gen app - Nitro application generator.
3
+
4
+ SYNOPSIS
5
+ gen app [generator options]
6
+
7
+ DESCRIPTION
8
+ This generator will create some basic files to get you
9
+ started fleshing out your Nitro web application.
10
+ The proto directory structure in the standard Nitro
11
+ distribution is used as reference.
12
+
13
+ EXAMPLE
14
+ nitrogen app ~/my_application
15
+
16
+ This will generate a new Nitro application in the
17
+ ~/my_application folder.
@@ -0,0 +1,32 @@
1
+ $NITRO_NO_ENVIRONMENT = true
2
+
3
+ require 'nano/dir/self/recurse'
4
+
5
+ require 'gen'
6
+ require 'nitro'
7
+
8
+ PROTO_DIR = File.join(Nitro::LibPath, '..', 'proto')
9
+
10
+ class AppGen < Gen
11
+
12
+ def setup
13
+ @path = ARGV[0] || usage()
14
+ @path = File.expand_path(@path)
15
+ end
16
+
17
+ def run
18
+ if File.exists? @path
19
+ STDERR.puts "ERROR: Path #{@path} already exists! Aborting!"
20
+ exit 1
21
+ end
22
+
23
+ FileUtils.cp_r(PROTO_DIR, @path)
24
+
25
+ Dir.recurse(@path) do |f|
26
+ FileUtils.rm_rf(f) if /\.svn$/ =~ f
27
+ end
28
+ end
29
+
30
+ end
31
+
32
+ $generator = AppGen.new
@@ -0,0 +1,14 @@
1
+ NAME
2
+ gen form - Nitro xhtml form generator.
3
+
4
+ SYNOPSIS
5
+ gen form [options]
6
+
7
+ DESCRIPTION
8
+ This generator will create some a complete xhtml
9
+ form for the given object. The scaffolding code
10
+ uses the object annotations to create a useful form.
11
+
12
+ EXAMPLE
13
+ gen form model/user User
14
+ gen form model/user
@@ -0,0 +1,37 @@
1
+ require 'nano/kernel/constant'
2
+ require 'nano/string/underscore'
3
+
4
+ require 'gen'
5
+ require 'nitro/mixin/form'
6
+ require 'og'
7
+
8
+ # This generator generates xhtml forms for Ruby objects.
9
+ #
10
+ # === Example
11
+ #
12
+ # gen form model/user User
13
+ # gen form model/user
14
+
15
+ class FormGen < Gen
16
+ include Nitro::FormMixin
17
+
18
+ def setup
19
+ @def_filename = ARGV[1] || usage()
20
+ @klass = ARGV[2]
21
+ @form_filename = ARGV[3] || "#{@klass.underscore}.html"
22
+ require @def_filename
23
+ rescue LoadError
24
+ puts "Cannot load ruby file '#@def_filename'!"
25
+ end
26
+
27
+ def run
28
+ @klass = constant(@klass)
29
+ @klass.send(:define_method, :oid) { -1 }
30
+ form = form_for(@klass.allocate, :skip_relations => true)
31
+ File.open(@form_filename, 'w') do |f|
32
+ f << form
33
+ end
34
+ end
35
+ end
36
+
37
+ $generator = FormGen.new
data/lib/gen.rb ADDED
@@ -0,0 +1,47 @@
1
+ # = Gen
2
+ #
3
+ # A flexible code generation system.
4
+ #
5
+ # Copyright (c) 2005, Navel Ltd (http://www.navel.gr)
6
+ # Copyright (c) 2005, George Moschovitis (http://www.gmosx.com)
7
+ #
8
+ # Gen (http://www.nitrohq.com) is copyrighted free software
9
+ # created and maintained by George Moschovitis (mailto:gm@navel.gr)
10
+ # and released under the standard BSD Licence. For details
11
+ # consult the file doc/LICENCE.
12
+
13
+ class Gen
14
+
15
+ # The version.
16
+
17
+ Version = '0.24.0'
18
+
19
+ # Library path.
20
+
21
+ LibPath = File.dirname(__FILE__)
22
+
23
+ end
24
+
25
+ # The base generator class.
26
+ #--
27
+ # TODO: add support for cmdparse.
28
+ #++
29
+
30
+ class Gen
31
+ attr_accessor :generator_dir
32
+
33
+ def usage
34
+ filename = File.join(@generator_dir, 'USAGE')
35
+ puts "\n#{File.read(filename)}"
36
+ exit 1
37
+ end
38
+
39
+ def setup
40
+ end
41
+
42
+ def run
43
+ end
44
+
45
+ def teardown
46
+ end
47
+ end
metadata ADDED
@@ -0,0 +1,64 @@
1
+ --- !ruby/object:Gem::Specification
2
+ rubygems_version: 0.8.10
3
+ specification_version: 1
4
+ name: gen
5
+ version: !ruby/object:Gem::Version
6
+ version: 0.24.0
7
+ date: 2005-10-28
8
+ summary: A simple code generation system.
9
+ require_paths:
10
+ - lib
11
+ email: gm@navel.gr
12
+ homepage: http://www.nitrohq.com
13
+ rubyforge_project: nitro
14
+ description:
15
+ autorequire:
16
+ default_executable:
17
+ bindir: bin
18
+ has_rdoc: false
19
+ required_ruby_version: !ruby/object:Gem::Version::Requirement
20
+ requirements:
21
+ -
22
+ - ">"
23
+ - !ruby/object:Gem::Version
24
+ version: 0.0.0
25
+ version:
26
+ platform: ruby
27
+ authors:
28
+ - George Moschovitis
29
+ files:
30
+ - bin
31
+ - doc
32
+ - lib
33
+ - ProjectInfo
34
+ - Rakefile
35
+ - README
36
+ - bin/gen
37
+ - doc/AUTHORS
38
+ - doc/LICENSE
39
+ - doc/RELEASES
40
+ - lib/gen
41
+ - lib/gen.rb
42
+ - lib/gen/app
43
+ - lib/gen/form
44
+ - lib/gen/app/gen.rb
45
+ - lib/gen/app/USAGE
46
+ - lib/gen/form/gen.rb
47
+ - lib/gen/form/USAGE
48
+ test_files: []
49
+ rdoc_options: []
50
+ extra_rdoc_files: []
51
+ executables: []
52
+ extensions: []
53
+ requirements: []
54
+ dependencies:
55
+ - !ruby/object:Gem::Dependency
56
+ name: glue
57
+ version_requirement:
58
+ version_requirements: !ruby/object:Gem::Version::Requirement
59
+ requirements:
60
+ -
61
+ - "="
62
+ - !ruby/object:Gem::Version
63
+ version: 0.24.0
64
+ version: