dr_nic_magic_models 0.8.1 → 0.9.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/History.txt ADDED
@@ -0,0 +1,10 @@
1
+ *** 0.9.0 / 2007-4-9
2
+
3
+ + 1 major enhancement:
4
+ + Support for dynamic loading of classes again
5
+ + 2 new DB supported:
6
+ + Tests run on sqlite (no fk support)
7
+ + Tests run on postgresql (fk support)
8
+ + Many fixes that I've lost track of
9
+ + History.txt to keep track of changes like these
10
+ + Using Hoe for Rakefile
data/Manifest.txt ADDED
@@ -0,0 +1,55 @@
1
+ CHANGELOG
2
+ History.txt
3
+ Manifest.txt
4
+ README
5
+ Rakefile
6
+ install.rb
7
+ lib/base.rb
8
+ lib/connection_adapters/abstract/schema_statements.rb
9
+ lib/connection_adapters/abstract_adapter.rb
10
+ lib/connection_adapters/mysql_adapter.rb
11
+ lib/connection_adapters/postgresql_adapter.rb
12
+ lib/dr_nic_magic_models.rb
13
+ lib/dr_nic_magic_models/inflector.rb
14
+ lib/dr_nic_magic_models/magic_model.rb
15
+ lib/dr_nic_magic_models/schema.rb
16
+ lib/dr_nic_magic_models/validations.rb
17
+ lib/dr_nic_magic_models/version.rb
18
+ lib/module.rb
19
+ lib/rails.rb
20
+ scripts/txt2html
21
+ scripts/txt2js
22
+ test.db
23
+ test/abstract_unit.rb
24
+ test/connections/native_mysql/connection.rb
25
+ test/connections/native_postgresql/connection.rb
26
+ test/connections/native_sqlite/connection.rb
27
+ test/dummy_test.rb
28
+ test/env_test.rb
29
+ test/fixtures/.DS_Store
30
+ test/fixtures/adjectives.yml
31
+ test/fixtures/adjectives_fun_users.yml
32
+ test/fixtures/db_definitions/mysql.drop.sql
33
+ test/fixtures/db_definitions/mysql.sql
34
+ test/fixtures/db_definitions/postgresql.sql
35
+ test/fixtures/db_definitions/sqlite.sql
36
+ test/fixtures/fun_users.yml
37
+ test/fixtures/group_memberships.yml
38
+ test/fixtures/group_tag.yml
39
+ test/fixtures/groups.yml
40
+ test/foreign_keys_test.rb
41
+ test/fun_user_plus.rb
42
+ test/invisible_model_access_test.rb
43
+ test/invisible_model_assoc_test.rb
44
+ test/invisible_model_classes_test.rb
45
+ test/magic_module_test.rb
46
+ website/index.html
47
+ website/index.txt
48
+ website/javascripts/rounded_corners_lite.inc.js
49
+ website/stylesheets/screen.css
50
+ website/template.js
51
+ website/template.rhtml
52
+ website/version-raw.js
53
+ website/version-raw.txt
54
+ website/version.js
55
+ website/version.txt
data/README CHANGED
@@ -0,0 +1,268 @@
1
+ See http://magicmodels.rubyforge.org/dr_nic_magic_models for pretty README
2
+
3
+ Ugly README (from website/index.txt in Textile format):
4
+
5
+ h1. Dr Nic's Magic Models
6
+
7
+ If you've used Ruby on Rails you'll have written at least one model class like this:
8
+
9
+ <pre syntax='ruby'>
10
+ class Person < ActiveRecord::Base
11
+ has_many :memberships
12
+ has_many :groups, :through => :memberships
13
+ belongs_to :family
14
+ validates_presence_of :firstname, :lastname, :email
15
+ end
16
+ </pre>
17
+
18
+ A few minutes later you'll have wondered to yourself,
19
+
20
+ <blockquote>
21
+ Why do I have write my own <code>has_many</code>, <code>belongs_to</code>, and <code>validates_presence_of</code>
22
+ commands if all the data is in the database schema?
23
+ </blockquote>
24
+
25
+ Now, for the very first time, your classes can look like this:
26
+
27
+ <pre syntax='ruby'>
28
+ class Person < ActiveRecord::Base
29
+ end
30
+ </pre>
31
+
32
+ or, if you are lazy...
33
+
34
+ <pre syntax='ruby'>
35
+ class Person < ActiveRecord::Base; end
36
+ </pre>
37
+
38
+ or, if you read right to the end of this page, this...
39
+
40
+ <pre syntax='ruby'>
41
+ # Go fish.
42
+ </pre>
43
+
44
+ Magic and mystery abound. All for you. Impress your friends, amaze your mother.
45
+
46
+ NOTE: The gratuitous use of *Dr Nic's* in the name should only enhance the mystical magikery,
47
+ for magic needs a magician; and I love magic. I always wanted to create my own magic trick.
48
+ So I shall be the magician for the sake of magic itself. I look a bit like Harry Potter too,
49
+ if Harry were 32 and better dressed.
50
+
51
+ h2. Installation
52
+
53
+ To install the Dr Nic's Magic Models gem you can run the following command to
54
+ fetch the gem remotely from RubyForge:
55
+ <pre>
56
+ gem install dr_nic_magic_models
57
+ </pre>
58
+
59
+ or "download the gem manually":http://rubyforge.org/projects/magicmodels and
60
+ run the above command in the download directory.
61
+
62
+ Now you need to <code>require</code> the gem into your Ruby/Rails app. Insert the following
63
+ line into your script (use <code>config/environment.rb</code> for your Rails apps):
64
+
65
+ <pre>
66
+ require 'dr_nic_magic_models'
67
+ </pre>
68
+
69
+ Your application is now blessed with magical mystery.
70
+
71
+ h2. David Copperfield eat your Ruby-crusted heart out
72
+
73
+ Let's demonstrate the magical mystery in all its full-stage glory. Create a Ruby on Rails app:
74
+
75
+ <pre syntax="ruby">
76
+ rails magic_show
77
+ cd magic_show
78
+ ruby script/generate model Person
79
+ ruby script/generate model Group
80
+ ruby script/generate model Membership
81
+ </pre>
82
+
83
+ Update the migration <code>001_create_people.rb</code> with:
84
+ <pre syntax="ruby">
85
+ class CreatePeople < ActiveRecord::Migration
86
+ def self.up
87
+ create_table :people do |t|
88
+ t.column :firstname, :string, :null => false
89
+ t.column :lastname, :string, :null => false
90
+ t.column :email, :string, :null => false
91
+ end
92
+ end
93
+
94
+ def self.down
95
+ drop_table :people
96
+ end
97
+ end
98
+ </pre>
99
+
100
+ Similarly, update the <code>def self.up</code> method of <code>002_create_groups.rb</code>
101
+ with:
102
+ <pre syntax="ruby">
103
+ create_table :groups do |t|
104
+ t.column :name, :string, :null => false
105
+ t.column :description, :string
106
+ end
107
+ </pre>
108
+
109
+ and <code>003_create_memberships.rb</code> with:
110
+ <pre syntax="ruby">
111
+ create_table :memberships do |t|
112
+ t.column :person_id, :integer, :null => false
113
+ t.column :group_id, :integer, :null => false
114
+ end
115
+ </pre>
116
+
117
+ Now create your database. For MySql:
118
+ <pre>
119
+ mysqladmin -u root create magic_show_development
120
+ mysqladmin -u root create magic_show_test
121
+ </pre>
122
+
123
+ And run your migrations to create the three tables:
124
+ <pre>
125
+ rake migrate
126
+ </pre>
127
+
128
+ h2. And now for some "woofle dust":http://en.wikipedia.org/wiki/List_of_conjuring_terms ...
129
+
130
+ At the end of <code>config/environment.rb</code> add the following line:
131
+
132
+ <pre>
133
+ require 'dr_nic_magic_models'
134
+ </pre>
135
+
136
+ Now, let's do a magic trick. First, let's check our model classes (<code>app/models/person.rb</code> etc):
137
+
138
+ <pre syntax="ruby">
139
+ class Person < ActiveRecord::Base
140
+ end
141
+ class Group < ActiveRecord::Base
142
+ end
143
+ class Membership < ActiveRecord::Base
144
+ end
145
+ </pre>
146
+
147
+ Nothing suspicious here. We have no validations and no associations. Just some plain old model classes.
148
+
149
+ For this trick, we'll need an ordinary console session. Any old one lying around the house will do.
150
+
151
+ <pre>
152
+ ruby script/console
153
+ </pre>
154
+
155
+ Now a normal model class is valid until you explicitly add <code>validates_xxx</code> commands.
156
+ With Dr Nic's Magic Models:
157
+
158
+ <pre syntax="ruby">
159
+ >> person = Person.new
160
+ => #<Person:0x393e0f8 @attributes={"lastname"=>"", "firstname"=>"", "email"=>""}, @new_record=true>
161
+ >> person.valid?
162
+ => false
163
+ >> person.errors
164
+ => <ActiveRecord::Errors:0x3938b18 @errors={"firstname"=>["can't be blank"],
165
+ "lastname"=>["can't be blank"], "email"=>["can't be blank"]},
166
+ @base=<Person:0x393e0f8 @errors=<ActiveRecord::Errors:0x3938b18 ...>,
167
+ @attributes={"lastname"=>"", "firstname"=>"", "email"=>""}, @new_record=true>>
168
+ </pre>
169
+
170
+ *Kapoow!* Instant validation!
171
+
172
+ Because you specified the three columns as <code>:null => false</code>,
173
+ your ActiveRecord models will now automatically generated <code>validates_presence_of</code>
174
+ for each non-null field.
175
+
176
+ Ok, we're just warming up.
177
+
178
+ Your models normally require association commands (<code>has_many</code>, <code>belongs_to</code>, etc, as
179
+ demonstrated above) to have the brilliantly simple support that Rails/ActiveRecords are known for.
180
+
181
+ Let's just watch what Dr Nic's Magic Models can do without any effort at all...
182
+
183
+ <pre syntax="ruby">
184
+ >> person = Person.create(:firstname => "Nic", :lastname => "Williams", :email => "drnicwilliams@gmail.com")
185
+ >> group = Group.create(:name => "Magic Models Forum", :description => "http://groups.google.com/magicmodels")
186
+ >> membership = Membership.create(:person_id => person, :group_id => group)
187
+ >> person.memberships.length
188
+ => 1
189
+ >> membership.person
190
+ => <Person:0x38898e8 @attributes={"lastname"=>"Williams", "firstname"=>"Nic",
191
+ "id"=>"1", "email"=>"drnicwilliams@gmail.com"}>
192
+ >> group.memberships
193
+ => [<Membership:0x3c8cd70 @attributes={"group_id"=>"1", "id"=>"1", "person_id"=>"1"}>]
194
+ </pre>
195
+
196
+
197
+ The final association trick is a ripper. Automatic generation of <code>has_many :through</code> associations...
198
+
199
+ <pre syntax="ruby">
200
+ >> person.groups
201
+ => [<Group:0x39047e0 @attributes={"name"=>"Magic Models Forum", "id"=>"1", "description"=>nil}>]
202
+ >> group.people
203
+ => [<Person:0x3c33580 @attributes={"lastname"=>"Williams", "firstname"=>"Nic",
204
+ "id"=>"1", "email"=>"drnicwilliams@gmail.com"}>]
205
+ </pre>
206
+
207
+ h2. Drum roll...
208
+
209
+ Ladies and gentlemen. For my final feat of magical mastery, I'll ask you to do
210
+ something you've never done before. This illusion is akin to the "floating lady":http://www.toytent.com/Posters/985.html
211
+ illusion that has been passed down through generations of magicians.
212
+
213
+ Exit your console session.
214
+
215
+ DELETE your three model classes: <code>person.rb, group.rb, and membership.rb</code> from the
216
+ <code>app/models</code> folder. (You can always get them back via the model generator... be fearless!)
217
+
218
+ Re-launch your console.
219
+
220
+ *drums are still rolling...*
221
+
222
+ Be prepared to applaud loudly...
223
+
224
+ <pre syntax="ruby">
225
+ >> Person
226
+ => Person
227
+ </pre>
228
+
229
+ You applaud loudly, but watch for more...
230
+
231
+ <pre syntax="ruby">
232
+ >> person = Person.find(1)
233
+ => <Person:0x3958930 @attributes={"lastname"=>"Williams", "firstname"=>"Nic",
234
+ "id"=>"1", "email"=>"drnicwilliams@gmail.com"}>
235
+ >> person.memberships
236
+ => [<Membership:0x393a000 @attributes={"group_id"=>"1", "id"=>"1", "person_id"=>"1"}>]
237
+ >> person.groups
238
+ => [<Group:0x390df60 @attributes={"name"=>"Magic Models Forum", "id"=>"1", "description"=>nil}>]
239
+ </pre>
240
+
241
+ h2. Tada!
242
+
243
+ The end.
244
+
245
+ h2. Dr Nic's Blog
246
+
247
+ "http://www.drnicwilliams.com":http://www.drnicwilliams.com - for future announcements and
248
+ other stories and things.
249
+
250
+ h2. Articles about Magic Models
251
+
252
+ * "Announcement":http://drnicwilliams.com/2006/08/07/ann-dr-nics-magic-models/
253
+ * "BTS - Class creation":http://drnicwilliams.com/2006/08/10/bts-magic-models-class-creation/
254
+
255
+
256
+ h2. Forum
257
+
258
+ "http://groups.google.com/group/magicmodels":http://groups.google.com/group/magicmodels
259
+
260
+ h2. Licence
261
+
262
+ This code is free to use under the terms of the MIT licence.
263
+
264
+ h2. Contact
265
+
266
+ Comments are welcome. Send an email to "Dr Nic Williams":mailto:drnicwilliams@gmail.com
267
+ or via his blog at "http://www.drnicwilliams.com":http://www.drnicwilliams.com
268
+
data/Rakefile CHANGED
@@ -1,34 +1,60 @@
1
1
  require 'rubygems'
2
2
  require 'rake'
3
+ require 'rake/clean'
3
4
  require 'rake/testtask'
4
5
  require 'rake/rdoctask'
5
6
  require 'rake/packagetask'
6
7
  require 'rake/gempackagetask'
7
8
  require 'rake/contrib/rubyforgepublisher'
9
+ require 'hoe'
8
10
  require File.join(File.dirname(__FILE__), 'lib', 'dr_nic_magic_models', 'version')
9
11
 
10
- PKG_BUILD = ENV['PKG_BUILD'] ? '.' + ENV['PKG_BUILD'] : ''
11
- PKG_NAME = 'dr_nic_magic_models'
12
- PKG_VERSION = DrNicMagicModels::VERSION::STRING + PKG_BUILD
13
- PKG_FILE_NAME = "#{PKG_NAME}-#{PKG_VERSION}"
14
-
15
- RELEASE_NAME = "REL #{PKG_VERSION}"
16
-
17
- RUBY_FORGE_PROJECT = "magicmodels"
18
- RUBY_FORGE_USER = "nicwilliams"
19
-
20
- PKG_FILES = FileList[
21
- "lib/**/*", "test/**/*", "examples/**/*", "doc/**/*", "website/**/*", "scripts/**/*", "[A-Z]*", "install.rb", "Rakefile"
22
- ].exclude(/\bCVS\b|~$/)
23
-
12
+ AUTHOR = "nicwilliams" # can also be an array of Authors
13
+ EMAIL = "drnicwilliams@gmail.com"
14
+ DESCRIPTION = "Dr Nic's Magic Models - Invisible validations, assocations and Active Record models themselves!"
15
+ GEM_NAME = "dr_nic_magic_models" # what ppl will type to install your gem
16
+ RUBYFORGE_PROJECT = "magicmodels" # The unix name for your project
17
+ HOMEPATH = "http://#{RUBYFORGE_PROJECT}.rubyforge.org"
18
+
19
+
20
+ NAME = "magic_multi_connections"
21
+ REV = nil # UNCOMMENT IF REQUIRED: File.read(".svn/entries")[/committed-rev="(d+)"/, 1] rescue nil
22
+ VERS = ENV['VERSION'] || (DrNicMagicModels::VERSION::STRING + (REV ? ".#{REV}" : ""))
23
+ CLEAN.include ['**/.*.sw?', '*.gem', '.config']
24
+ RDOC_OPTS = ['--quiet', '--title', "dr_nic_magic_models documentation",
25
+ "--opname", "index.html",
26
+ "--line-numbers",
27
+ "--main", "README",
28
+ "--inline-source"]
29
+
30
+ class Hoe
31
+ def extra_deps
32
+ @extra_deps.reject { |x| Array(x).first == 'hoe' }
33
+ end
34
+ end
24
35
 
25
- desc "Default Task"
26
- task :default => [ :test_mysql ] # UNTESTED =, :test_sqlite, :test_postgresql ]
27
- task :test => [ :test_mysql ]
36
+ # Generate all the Rake tasks
37
+ # Run 'rake -T' to see list of generated tasks (from gem root directory)
38
+ hoe = Hoe.new(GEM_NAME, VERS) do |p|
39
+ p.author = AUTHOR
40
+ p.description = DESCRIPTION
41
+ p.email = EMAIL
42
+ p.summary = DESCRIPTION
43
+ p.url = HOMEPATH
44
+ p.rubyforge_name = RUBYFORGE_PROJECT if RUBYFORGE_PROJECT
45
+ p.test_globs = ["test/**/test_*.rb"]
46
+ p.clean_globs = CLEAN #An array of file patterns to delete on clean.
47
+
48
+ # == Optional
49
+ p.changes = p.paragraphs_of("History.txt", 0..1).join("\n\n")
50
+
51
+ #p.extra_deps - An array of rubygem dependencies.
52
+ #p.spec_extras - A hash of extra values to set in the gemspec.
53
+ end
28
54
 
29
55
  # Run the unit tests
30
56
 
31
- for adapter in %w( mysql postgresql ) # UNTESTED - postgresql sqlite sqlite3 firebird sqlserver sqlserver_odbc db2 oracle sybase openbase )
57
+ for adapter in %w( sqlite mysql postgresql ) # UNTESTED - postgresql sqlite sqlite3 firebird sqlserver sqlserver_odbc db2 oracle sybase openbase )
32
58
  Rake::TestTask.new("test_#{adapter}") { |t|
33
59
  t.libs << "test" << "test/connections/native_#{adapter}"
34
60
  t.pattern = "test/*_test{,_#{adapter}}.rb"
@@ -41,119 +67,68 @@ SCHEMA_PATH = File.join(File.dirname(__FILE__), *%w(test fixtures db_definitions
41
67
  desc 'Build the MySQL test databases'
42
68
  task :build_mysql_databases do
43
69
  puts File.join(SCHEMA_PATH, 'mysql.sql')
44
- %x( mysqladmin -u root create "#{PKG_NAME}_unittest" )
45
- cmd = "mysql -u root #{PKG_NAME}_unittest < \"#{File.join(SCHEMA_PATH, 'mysql.sql')}\""
70
+ %x( mysqladmin -u root create "#{GEM_NAME}_unittest" )
71
+ cmd = "mysql -u root #{GEM_NAME}_unittest < \"#{File.join(SCHEMA_PATH, 'mysql.sql')}\""
46
72
  puts "#{cmd}\n"
47
73
  %x( #{cmd} )
48
74
  end
49
75
 
50
76
  desc 'Drop the MySQL test databases'
51
77
  task :drop_mysql_databases do
52
- %x( mysqladmin -u root -f drop "#{PKG_NAME}_unittest" )
78
+ %x( mysqladmin -u root -f drop "#{GEM_NAME}_unittest" )
53
79
  end
54
80
 
55
81
  desc 'Rebuild the MySQL test databases'
56
82
  task :rebuild_mysql_databases => [:drop_mysql_databases, :build_mysql_databases]
57
83
 
84
+ desc 'Build the sqlite test databases'
85
+ task :build_sqlite_databases do
86
+ # puts File.join(SCHEMA_PATH, 'sqlite.sql')
87
+ # %x( sqlite3 test.db < test/fixtures/db_definitions/sqlite.sql )
88
+ file = File.join(SCHEMA_PATH, 'sqlite.sql')
89
+ cmd = "sqlite3 test.db < #{file}"
90
+ puts cmd
91
+ %x( #{cmd} )
92
+ end
93
+
94
+ desc 'Drop the sqlite test databases'
95
+ task :drop_sqlite_databases do
96
+ %x( rm -f test.db )
97
+ end
98
+
99
+ desc 'Rebuild the sqlite test databases'
100
+ task :rebuild_sqlite_databases => [:drop_sqlite_databases, :build_sqlite_databases]
101
+
58
102
  desc 'Build the PostgreSQL test databases'
59
103
  task :build_postgresql_databases do
60
- %x( createdb -U postgres "#{PKG_NAME}_unittest" )
61
- %x( psql "#{PKG_NAME}_unittest" postgres -f "#{File.join(SCHEMA_PATH, 'postgresql.sql')}" )
104
+ %x( createdb "#{GEM_NAME}_unittest" )
105
+ %x( psql "#{GEM_NAME}_unittest" -f "#{File.join(SCHEMA_PATH, 'postgresql.sql')}" )
62
106
  end
63
107
 
64
108
  desc 'Drop the PostgreSQL test databases'
65
109
  task :drop_postgresql_databases do
66
- %x( dropdb -U postgres "#{PKG_NAME}_unittest" )
110
+ %x( dropdb "#{GEM_NAME}_unittest" )
67
111
  end
68
112
 
69
113
  desc 'Rebuild the PostgreSQL test databases'
70
114
  task :rebuild_postgresql_databases => [:drop_postgresql_databases, :build_postgresql_databases]
71
115
 
72
- # Generate the RDoc documentation
73
-
74
- Rake::RDocTask.new { |rdoc|
75
- rdoc.rdoc_dir = 'doc'
76
- rdoc.title = "Dr Nic's Magic Models - Invisible validations, assocations and Active Record models themselves!"
77
- rdoc.options << '--line-numbers' << '--inline-source' << '-A cattr_accessor=object'
78
- rdoc.template = "#{ENV['template']}.rb" if ENV['template']
79
- rdoc.rdoc_files.include('README', 'CHANGELOG')
80
- rdoc.rdoc_files.include('lib/**/*.rb')
81
- }
82
116
 
83
- # Enhance rdoc task to copy referenced images also
84
- task :rdoc do
85
- FileUtils.mkdir_p "doc/files/examples/"
117
+ desc 'Generate website files'
118
+ task :website_generate do
119
+ sh %{ ruby scripts/txt2html website/index.txt > website/index.html }
120
+ sh %{ ruby scripts/txt2js website/version.txt > website/version.js }
121
+ sh %{ ruby scripts/txt2js website/version-raw.txt > website/version-raw.js }
86
122
  end
87
123
 
88
-
89
- # Create compressed packages
90
-
91
- dist_dirs = [ "lib", "test", "examples", "website", "scripts"]
92
-
93
- spec = Gem::Specification.new do |s|
94
- s.name = PKG_NAME
95
- s.version = PKG_VERSION
96
- s.summary = "Invisible validations, assocations and Active Record models themselves!"
97
- s.description = %q{Associations and validations are automagically available to your ActiveRecord models. Model classes themselves are automagically generated if you haven't defined them already!}
98
-
99
- s.files = [ "Rakefile", "install.rb", "README", "CHANGELOG" ]
100
- dist_dirs.each do |dir|
101
- s.files = s.files + Dir.glob( "#{dir}/**/*" ).delete_if { |item| item.include?( "\.svn" ) }
102
- end
103
-
104
- s.require_path = 'lib'
105
- s.autorequire = 'dr_nic_magic_models'
106
-
107
- s.has_rdoc = true
108
- s.extra_rdoc_files = %w( README )
109
- s.rdoc_options.concat ['--main', 'README']
110
-
111
- s.author = "Dr Nic Williams"
112
- s.email = "drnicwilliams@gmail.com"
113
- s.homepage = "http://magicmodels.rubyforge.org"
114
- s.rubyforge_project = "magicmodels"
124
+ desc 'Upload website files to rubyforge'
125
+ task :website_upload do
126
+ config = YAML.load(File.read(File.expand_path("~/.rubyforge/user-config.yml")))
127
+ host = "#{config["username"]}@rubyforge.org"
128
+ remote_dir = "/var/www/gforge-projects/#{RUBYFORGE_PROJECT}/#{GEM_NAME}"
129
+ local_dir = 'website'
130
+ sh %{rsync -av --delete #{local_dir}/ #{host}:#{remote_dir}}
115
131
  end
116
-
117
- Rake::GemPackageTask.new(spec) do |p|
118
- p.gem_spec = spec
119
- p.need_tar = false
120
- p.need_zip = false
121
- end
122
-
123
- task :lines do
124
- lines, codelines, total_lines, total_codelines = 0, 0, 0, 0
125
-
126
- for file_name in FileList["lib/**/*.rb"]
127
- next if file_name =~ /vendor/
128
- f = File.open(file_name)
129
-
130
- while line = f.gets
131
- lines += 1
132
- next if line =~ /^\s*$/
133
- next if line =~ /^\s*#/
134
- codelines += 1
135
- end
136
- puts "L: #{sprintf("%4d", lines)}, LOC #{sprintf("%4d", codelines)} | #{file_name}"
137
-
138
- total_lines += lines
139
- total_codelines += codelines
140
-
141
- lines, codelines = 0, 0
142
- end
143
-
144
- puts "Total: Lines #{total_lines}, LOC #{total_codelines}"
145
- end
146
-
147
132
 
148
- # Publishing ------------------------------------------------------
149
-
150
- desc "Publish the release files to RubyForge."
151
- task :release => [ :package ] do
152
- `ruby scripts/rubyforge login`
153
-
154
- for ext in %w( gem tgz zip )
155
- release_command = "ruby scripts/rubyforge add_release #{PKG_NAME} #{PKG_NAME} 'REL #{PKG_VERSION}' pkg/#{PKG_NAME}-#{PKG_VERSION}.#{ext}"
156
- puts release_command
157
- system(release_command)
158
- end
159
- end
133
+ desc 'Generate and upload website files'
134
+ task :website => [:website_generate, :website_upload]