lockdown 1.3.1 → 1.3.2

Sign up to get free protection for your applications and to get access to all the features.
data/.gitignore ADDED
@@ -0,0 +1,6 @@
1
+ *.DS_Store
2
+ *.swp
3
+ pkg/**
4
+ doc/**
5
+ email.txt
6
+ coverage/**
data/Rakefile CHANGED
@@ -1,16 +1,7 @@
1
- # Look in the tasks/setup.rb file for the various options that can be
2
- # configured in this Rakefile. The .rake files in the tasks directory
3
- # are where the options are used.
4
-
5
- begin
6
- require 'bones'
7
- Bones.setup
8
- rescue LoadError
9
- load 'tasks/setup.rb'
10
- end
11
-
12
- ensure_in_path 'lib'
13
- require 'lockdown'
1
+ require 'rubygems'
2
+ require 'rake'
3
+ require 'rcov'
4
+ require 'spec/rake/spectask'
14
5
 
15
6
  task :default => 'rcov'
16
7
 
@@ -27,15 +18,19 @@ Spec::Rake::SpecTask.new(:rcov) do |t|
27
18
  t.rcov_opts = IO.readlines("spec/rcov.opts").map {|l| l.chomp.split " "}.flatten
28
19
  end
29
20
 
30
- PROJ.name = 'lockdown'
31
- PROJ.authors = 'Andrew Stone'
32
- PROJ.email = 'andy@stonean.com'
33
- PROJ.url = 'http://stonean.com/wiki/lockdown'
34
- PROJ.version = Lockdown::VERSION
35
- PROJ.rubyforge.name = 'lockdown'
36
-
37
- PROJ.spec.opts << '--color'
38
- PROJ.exclude << ".swp"
39
- PROJ.exclude << ".gitignore"
40
-
41
- # EOF
21
+ begin
22
+ require 'jeweler'
23
+ Jeweler::Tasks.new do |gemspec|
24
+ gemspec.name = "lockdown"
25
+ gemspec.rubyforge_project = "lockdown"
26
+ gemspec.summary = "Authorization system for Rails 2.x"
27
+ gemspec.description = "Restrict access to your controller actions. Supports basic model level restrictions as well"
28
+ gemspec.email = "andy@stonean.com"
29
+ gemspec.homepage = "http://stonean.com/wiki/lockdown"
30
+ gemspec.authors = ["Andrew Stone"]
31
+ gemspec.add_development_dependency('rspec')
32
+ end
33
+ Jeweler::GemcutterTasks.new
34
+ rescue LoadError
35
+ puts "Jeweler not available. Install it with: sudo gem install technicalpickles-jeweler -s http://gems.github.com"
36
+ end
data/VERSION ADDED
@@ -0,0 +1 @@
1
+ 1.3.2
@@ -11,7 +11,7 @@ module Lockdown
11
11
  @user_groups = Lockdown::System.get_user_groups
12
12
 
13
13
  unless ::Permission.table_exists? && Lockdown.user_group_class.table_exists?
14
- puts ">> Lockdown tables not found. Skipping database sync."
14
+ Lockdown.logger.info ">> Lockdown tables not found. Skipping database sync."
15
15
  return
16
16
  end
17
17
  create_new_permissions
@@ -20,7 +20,7 @@ module Lockdown
20
20
 
21
21
  maintain_user_groups
22
22
  rescue Exception => e
23
- puts ">> Lockdown sync failed: #{e}"
23
+ Lockdown.logger.error ">> Lockdown sync failed: #{e.backtrace.join("\n")}"
24
24
  end
25
25
 
26
26
  # Create permissions not found in the database
@@ -30,7 +30,7 @@ module Lockdown
30
30
  str = Lockdown.get_string(key)
31
31
  p = ::Permission.find(:first, :conditions => ["name = ?", str])
32
32
  unless p
33
- puts ">> Lockdown: Permission not found in db: #{str}, creating."
33
+ Lockdown.logger.info ">> Lockdown: Permission not found in db: #{str}, creating."
34
34
  ::Permission.create(:name => str)
35
35
  end
36
36
  end
@@ -41,7 +41,7 @@ module Lockdown
41
41
  db_perms = ::Permission.find(:all).dup
42
42
  db_perms.each do |dbp|
43
43
  unless @permissions.include?(Lockdown.get_symbol(dbp.name))
44
- puts ">> Lockdown: Permission no longer in init.rb: #{dbp.name}, deleting."
44
+ Lockdown.logger.info ">> Lockdown: Permission no longer in init.rb: #{dbp.name}, deleting."
45
45
  ug_table = Lockdown.user_groups_hbtm_reference.to_s
46
46
  if "permissions" < ug_table
47
47
  join_table = "permissions_#{ug_table}"
@@ -71,12 +71,18 @@ module Lockdown
71
71
  end
72
72
 
73
73
  def create_user_group(name_str, key)
74
- puts ">> Lockdown: #{Lockdown::System.fetch(:user_group_model)} not in the db: #{name_str}, creating."
74
+ Lockdown.logger.info ">> Lockdown: #{Lockdown::System.fetch(:user_group_model)} not in the db: #{name_str}, creating."
75
75
  ug = Lockdown.user_group_class.create(:name => name_str)
76
76
  #Inefficient, definitely, but shouldn't have any issues across orms.
77
+ #
77
78
  Lockdown::System.permissions_for_user_group(key).each do |perm|
78
- p = ::Permission.find(:first, :conditions => ["name = ?",
79
- Lockdown.get_string(perm)])
79
+
80
+ if Lockdown::System.permission_assigned_automatically?(perm)
81
+ Lockdown.logger.info ">> Permission #{perm} cannot be assigned to #{name_str}. Already belongs to built in user group (public or protected)."
82
+ raise InvalidPermissionAssignment, "Invalid permission assignment"
83
+ end
84
+
85
+ p = ::Permission.find(:first, :conditions => ["name = ?", Lockdown.get_string(perm)])
80
86
 
81
87
  ug_table = Lockdown.user_groups_hbtm_reference.to_s
82
88
  if "permissions" < ug_table
@@ -93,7 +99,7 @@ module Lockdown
93
99
  perm_sym = Lockdown.get_symbol(perm)
94
100
  perm_string = Lockdown.get_string(perm)
95
101
  unless Lockdown::System.permissions_for_user_group(key).include?(perm_sym)
96
- puts ">> Lockdown: Permission: #{perm_string} no longer associated to User Group: #{ug.name}, deleting."
102
+ Lockdown.logger.info ">> Lockdown: Permission: #{perm_string} no longer associated to User Group: #{ug.name}, deleting."
97
103
  ug.permissions.delete(perm)
98
104
  end
99
105
  end
@@ -109,7 +115,7 @@ module Lockdown
109
115
  end
110
116
  # if not found, add it
111
117
  unless found
112
- puts ">> Lockdown: Permission: #{perm_string} not found for User Group: #{ug.name}, adding it."
118
+ Lockdown.logger.info ">> Lockdown: Permission: #{perm_string} not found for User Group: #{ug.name}, adding it."
113
119
  p = ::Permission.find(:first, :conditions => ["name = ?", perm_string])
114
120
  ug.permissions << p
115
121
  end
@@ -4,4 +4,6 @@ module Lockdown
4
4
  class InvalidRuleContext < StandardError; end
5
5
 
6
6
  class PermissionScopeCollision < StandardError; end
7
+
8
+ class InvalidPermissionAssignment < StandardError; end
7
9
  end
@@ -334,8 +334,6 @@ module Lockdown
334
334
 
335
335
  method_definition << "\n\tend"
336
336
 
337
- #puts "method_definition:\n #{method_definition}"
338
-
339
337
  Lockdown.add_controller_method method_definition
340
338
  end
341
339
 
data/lib/lockdown.rb CHANGED
@@ -1,7 +1,8 @@
1
1
  $:.unshift File.dirname(__FILE__)
2
2
 
3
- require File.join("lockdown", "errors")
3
+ require 'logger'
4
4
 
5
+ require File.join("lockdown", "errors")
5
6
  require File.join("lockdown", "helper")
6
7
  require File.join("lockdown", "session")
7
8
  require File.join("lockdown", "context")
@@ -9,69 +10,74 @@ require File.join("lockdown", "permission")
9
10
  require File.join("lockdown", "database")
10
11
  require File.join("lockdown", "rules")
11
12
  require File.join("lockdown", "system")
12
-
13
13
  require File.join("lockdown", "references")
14
14
 
15
15
  module Lockdown
16
16
  extend Lockdown::References
17
17
  extend Lockdown::Helper
18
18
 
19
- # current version is 1.3.0
20
- VERSION = '1.3.1'
19
+ VERSION = '1.3.2'
21
20
 
22
- # Returns the version string for the library.
23
- def self.version
24
- VERSION
25
- end
21
+ class << self
22
+ attr_accessor :logger
26
23
 
27
- def self.major_version
28
- version.split('.')[0].to_i
29
- end
24
+ # Returns the version string for the library.
25
+ def version
26
+ VERSION
27
+ end
30
28
 
31
- def self.minor_version
32
- version.split('.')[1].to_i
33
- end
29
+ def major_version
30
+ version.split('.')[0].to_i
31
+ end
34
32
 
35
- def self.patch_version
36
- version.split('.')[2].to_i
37
- end
33
+ def minor_version
34
+ version.split('.')[1].to_i
35
+ end
38
36
 
39
- # Mixin Lockdown code to the appropriate framework and ORM
40
- def self.mixin
41
- if mixin_resource?("frameworks")
42
- unless mixin_resource?("orms")
43
- raise NotImplementedError, "ORM unknown to Lockdown!"
44
- end
37
+ def patch_version
38
+ version.split('.')[2].to_i
39
+ end
45
40
 
46
- if File.exists?(Lockdown.init_file)
47
- puts "=> Requiring Lockdown rules engine: #{Lockdown.init_file} \n"
48
- require Lockdown.init_file
41
+ # Mixin Lockdown code to the appropriate framework and ORM
42
+ def mixin
43
+ if mixin_resource?("frameworks")
44
+ unless mixin_resource?("orms")
45
+ raise NotImplementedError, "ORM unknown to Lockdown!"
46
+ end
47
+
48
+ if File.exists?(Lockdown.init_file)
49
+ Lockdown.logger.info "=> Requiring Lockdown rules engine: #{Lockdown.init_file} \n"
50
+ require Lockdown.init_file
51
+ else
52
+ Lockdown.logger.info "=> Note:: Lockdown couldn't find init file: #{Lockdown.init_file}\n"
53
+ end
49
54
  else
50
- puts "=> Note:: Lockdown couldn't find init file: #{Lockdown.init_file}\n"
55
+ Lockdown.logger.info "=> Note:: Lockdown cannot determine framework and therefore is not active.\n"
51
56
  end
52
- else
53
- puts "=> Note:: Lockdown cannot determine framework and therefore is not active.\n"
54
- end
55
- end # mixin
56
-
57
- private
58
-
59
- def self.mixin_resource?(str)
60
- wildcard_path = File.join( File.dirname(__FILE__), 'lockdown', str , '*.rb' )
61
- Dir[wildcard_path].each do |f|
62
- require f
63
- module_name = File.basename(f).split(".")[0]
64
- module_class = eval("Lockdown::#{str.capitalize}::#{Lockdown.camelize(module_name)}")
65
- if module_class.use_me?
66
- include module_class
67
- return true
57
+ end # mixin
58
+
59
+ private
60
+
61
+ def mixin_resource?(str)
62
+ wildcard_path = File.join( File.dirname(__FILE__), 'lockdown', str , '*.rb' )
63
+ Dir[wildcard_path].each do |f|
64
+ require f
65
+ module_name = File.basename(f).split(".")[0]
66
+ module_class = eval("Lockdown::#{str.capitalize}::#{Lockdown.camelize(module_name)}")
67
+ if module_class.use_me?
68
+ include module_class
69
+ return true
70
+ end
68
71
  end
69
- end
70
- false
71
- end # mixin_resource?
72
+ false
73
+ end # mixin_resource?
74
+ end # class block
75
+
76
+ self.logger = Logger.new(STDOUT)
77
+
72
78
  end # Lockdown
73
79
 
74
- puts "=> Mixing in Lockdown version: #{Lockdown.version} \n"
80
+ Lockdown.logger.info "=> Mixing in Lockdown version: #{Lockdown.version} \n"
75
81
  Lockdown.mixin
76
82
 
77
83
 
data/lockdown.gemspec ADDED
@@ -0,0 +1,119 @@
1
+ # Generated by jeweler
2
+ # DO NOT EDIT THIS FILE
3
+ # Instead, edit Jeweler::Tasks in Rakefile, and run `rake gemspec`
4
+ # -*- encoding: utf-8 -*-
5
+
6
+ Gem::Specification.new do |s|
7
+ s.name = %q{lockdown}
8
+ s.version = "1.3.2"
9
+
10
+ s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
+ s.authors = ["Andrew Stone"]
12
+ s.date = %q{2009-10-17}
13
+ s.description = %q{Restrict access to your controller actions. Supports basic model level restrictions as well}
14
+ s.email = %q{andy@stonean.com}
15
+ s.extra_rdoc_files = [
16
+ "README.txt"
17
+ ]
18
+ s.files = [
19
+ ".gitignore",
20
+ "History.txt",
21
+ "README.txt",
22
+ "Rakefile",
23
+ "VERSION",
24
+ "lib/lockdown.rb",
25
+ "lib/lockdown/context.rb",
26
+ "lib/lockdown/database.rb",
27
+ "lib/lockdown/errors.rb",
28
+ "lib/lockdown/frameworks/rails.rb",
29
+ "lib/lockdown/frameworks/rails/controller.rb",
30
+ "lib/lockdown/frameworks/rails/view.rb",
31
+ "lib/lockdown/helper.rb",
32
+ "lib/lockdown/orms/active_record.rb",
33
+ "lib/lockdown/permission.rb",
34
+ "lib/lockdown/references.rb",
35
+ "lib/lockdown/rspec_helper.rb",
36
+ "lib/lockdown/rules.rb",
37
+ "lib/lockdown/session.rb",
38
+ "lib/lockdown/system.rb",
39
+ "lockdown.gemspec",
40
+ "rails_generators/lockdown/lockdown_generator.rb",
41
+ "rails_generators/lockdown/templates/app/controllers/permissions_controller.rb",
42
+ "rails_generators/lockdown/templates/app/controllers/sessions_controller.rb",
43
+ "rails_generators/lockdown/templates/app/controllers/user_groups_controller.rb",
44
+ "rails_generators/lockdown/templates/app/controllers/users_controller.rb",
45
+ "rails_generators/lockdown/templates/app/helpers/permissions_helper.rb",
46
+ "rails_generators/lockdown/templates/app/helpers/user_groups_helper.rb",
47
+ "rails_generators/lockdown/templates/app/helpers/users_helper.rb",
48
+ "rails_generators/lockdown/templates/app/models/permission.rb",
49
+ "rails_generators/lockdown/templates/app/models/profile.rb",
50
+ "rails_generators/lockdown/templates/app/models/user.rb",
51
+ "rails_generators/lockdown/templates/app/models/user_group.rb",
52
+ "rails_generators/lockdown/templates/app/views/permissions/index.html.erb",
53
+ "rails_generators/lockdown/templates/app/views/permissions/show.html.erb",
54
+ "rails_generators/lockdown/templates/app/views/sessions/new.html.erb",
55
+ "rails_generators/lockdown/templates/app/views/user_groups/edit.html.erb",
56
+ "rails_generators/lockdown/templates/app/views/user_groups/index.html.erb",
57
+ "rails_generators/lockdown/templates/app/views/user_groups/new.html.erb",
58
+ "rails_generators/lockdown/templates/app/views/user_groups/show.html.erb",
59
+ "rails_generators/lockdown/templates/app/views/users/edit.html.erb",
60
+ "rails_generators/lockdown/templates/app/views/users/index.html.erb",
61
+ "rails_generators/lockdown/templates/app/views/users/new.html.erb",
62
+ "rails_generators/lockdown/templates/app/views/users/show.html.erb",
63
+ "rails_generators/lockdown/templates/config/initializers/lockit.rb",
64
+ "rails_generators/lockdown/templates/db/migrate/create_admin_user.rb",
65
+ "rails_generators/lockdown/templates/db/migrate/create_permissions.rb",
66
+ "rails_generators/lockdown/templates/db/migrate/create_profiles.rb",
67
+ "rails_generators/lockdown/templates/db/migrate/create_user_groups.rb",
68
+ "rails_generators/lockdown/templates/db/migrate/create_users.rb",
69
+ "rails_generators/lockdown/templates/lib/lockdown/README",
70
+ "rails_generators/lockdown/templates/lib/lockdown/init.rb",
71
+ "spec/lockdown/context_spec.rb",
72
+ "spec/lockdown/database_spec.rb",
73
+ "spec/lockdown/frameworks/rails/controller_spec.rb",
74
+ "spec/lockdown/frameworks/rails/view_spec.rb",
75
+ "spec/lockdown/frameworks/rails_spec.rb",
76
+ "spec/lockdown/permission_spec.rb",
77
+ "spec/lockdown/rspec_helper_spec.rb",
78
+ "spec/lockdown/rules_spec.rb",
79
+ "spec/lockdown/session_spec.rb",
80
+ "spec/lockdown/system_spec.rb",
81
+ "spec/lockdown_spec.rb",
82
+ "spec/rcov.opts",
83
+ "spec/spec.opts",
84
+ "spec/spec_helper.rb"
85
+ ]
86
+ s.homepage = %q{http://stonean.com/wiki/lockdown}
87
+ s.rdoc_options = ["--charset=UTF-8"]
88
+ s.require_paths = ["lib"]
89
+ s.rubyforge_project = %q{lockdown}
90
+ s.rubygems_version = %q{1.3.5}
91
+ s.summary = %q{Authorization system for Rails 2.x}
92
+ s.test_files = [
93
+ "spec/lockdown/context_spec.rb",
94
+ "spec/lockdown/database_spec.rb",
95
+ "spec/lockdown/frameworks/rails/controller_spec.rb",
96
+ "spec/lockdown/frameworks/rails/view_spec.rb",
97
+ "spec/lockdown/frameworks/rails_spec.rb",
98
+ "spec/lockdown/permission_spec.rb",
99
+ "spec/lockdown/rspec_helper_spec.rb",
100
+ "spec/lockdown/rules_spec.rb",
101
+ "spec/lockdown/session_spec.rb",
102
+ "spec/lockdown/system_spec.rb",
103
+ "spec/lockdown_spec.rb",
104
+ "spec/spec_helper.rb"
105
+ ]
106
+
107
+ if s.respond_to? :specification_version then
108
+ current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
109
+ s.specification_version = 3
110
+
111
+ if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
112
+ s.add_development_dependency(%q<rspec>, [">= 0"])
113
+ else
114
+ s.add_dependency(%q<rspec>, [">= 0"])
115
+ end
116
+ else
117
+ s.add_dependency(%q<rspec>, [">= 0"])
118
+ end
119
+ end
@@ -68,7 +68,7 @@ describe Lockdown::Database do
68
68
  it "should sync user group permissions for existing user group" do
69
69
  ug = mock('user group')
70
70
 
71
- @user_group_class.should_receive(:find).
71
+ @user_group_class.should_receive(:find).
72
72
  with(:first, :conditions => ["name = ?", "User Group"]).
73
73
  and_return(ug)
74
74
 
@@ -94,6 +94,9 @@ describe Lockdown::Database do
94
94
  Lockdown::System.stub!(:permissions_for_user_group).
95
95
  and_return([:perm])
96
96
 
97
+ Lockdown::System.stub!(:permission_assigned_automatically?).
98
+ and_return(false)
99
+
97
100
  perm = mock('permission')
98
101
  perm.stub!(:id).and_return(3344)
99
102
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: lockdown
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.3.1
4
+ version: 1.3.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andrew Stone
@@ -9,32 +9,33 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-09-02 00:00:00 -04:00
12
+ date: 2009-10-17 00:00:00 -04:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
- name: bones
16
+ name: rspec
17
17
  type: :development
18
18
  version_requirement:
19
19
  version_requirements: !ruby/object:Gem::Requirement
20
20
  requirements:
21
21
  - - ">="
22
22
  - !ruby/object:Gem::Version
23
- version: 2.5.1
23
+ version: "0"
24
24
  version:
25
- description: Lockdown is an authorization system for RubyOnRails (ver >= 2.1).
25
+ description: Restrict access to your controller actions. Supports basic model level restrictions as well
26
26
  email: andy@stonean.com
27
27
  executables: []
28
28
 
29
29
  extensions: []
30
30
 
31
31
  extra_rdoc_files:
32
- - History.txt
33
32
  - README.txt
34
33
  files:
34
+ - .gitignore
35
35
  - History.txt
36
36
  - README.txt
37
37
  - Rakefile
38
+ - VERSION
38
39
  - lib/lockdown.rb
39
40
  - lib/lockdown/context.rb
40
41
  - lib/lockdown/database.rb
@@ -50,6 +51,7 @@ files:
50
51
  - lib/lockdown/rules.rb
51
52
  - lib/lockdown/session.rb
52
53
  - lib/lockdown/system.rb
54
+ - lockdown.gemspec
53
55
  - rails_generators/lockdown/lockdown_generator.rb
54
56
  - rails_generators/lockdown/templates/app/controllers/permissions_controller.rb
55
57
  - rails_generators/lockdown/templates/app/controllers/sessions_controller.rb
@@ -95,27 +97,13 @@ files:
95
97
  - spec/rcov.opts
96
98
  - spec/spec.opts
97
99
  - spec/spec_helper.rb
98
- - tasks/ann.rake
99
- - tasks/bones.rake
100
- - tasks/gem.rake
101
- - tasks/git.rake
102
- - tasks/notes.rake
103
- - tasks/post_load.rake
104
- - tasks/rdoc.rake
105
- - tasks/rubyforge.rake
106
- - tasks/setup.rb
107
- - tasks/spec.rake
108
- - tasks/svn.rake
109
- - tasks/test.rake
110
- - tasks/zentest.rake
111
100
  has_rdoc: true
112
101
  homepage: http://stonean.com/wiki/lockdown
113
102
  licenses: []
114
103
 
115
104
  post_install_message:
116
105
  rdoc_options:
117
- - --main
118
- - README.txt
106
+ - --charset=UTF-8
119
107
  require_paths:
120
108
  - lib
121
109
  required_ruby_version: !ruby/object:Gem::Requirement
@@ -136,6 +124,17 @@ rubyforge_project: lockdown
136
124
  rubygems_version: 1.3.5
137
125
  signing_key:
138
126
  specification_version: 3
139
- summary: Lockdown is an authorization system for RubyOnRails (ver >= 2
140
- test_files: []
141
-
127
+ summary: Authorization system for Rails 2.x
128
+ test_files:
129
+ - spec/lockdown/context_spec.rb
130
+ - spec/lockdown/database_spec.rb
131
+ - spec/lockdown/frameworks/rails/controller_spec.rb
132
+ - spec/lockdown/frameworks/rails/view_spec.rb
133
+ - spec/lockdown/frameworks/rails_spec.rb
134
+ - spec/lockdown/permission_spec.rb
135
+ - spec/lockdown/rspec_helper_spec.rb
136
+ - spec/lockdown/rules_spec.rb
137
+ - spec/lockdown/session_spec.rb
138
+ - spec/lockdown/system_spec.rb
139
+ - spec/lockdown_spec.rb
140
+ - spec/spec_helper.rb
data/tasks/ann.rake DELETED
@@ -1,80 +0,0 @@
1
-
2
- begin
3
- require 'bones/smtp_tls'
4
- rescue LoadError
5
- require 'net/smtp'
6
- end
7
- require 'time'
8
-
9
- namespace :ann do
10
-
11
- # A prerequisites task that all other tasks depend upon
12
- task :prereqs
13
-
14
- file PROJ.ann.file do
15
- ann = PROJ.ann
16
- puts "Generating #{ann.file}"
17
- File.open(ann.file,'w') do |fd|
18
- fd.puts("#{PROJ.name} version #{PROJ.version}")
19
- fd.puts(" by #{Array(PROJ.authors).first}") if PROJ.authors
20
- fd.puts(" #{PROJ.url}") if PROJ.url.valid?
21
- fd.puts(" (the \"#{PROJ.release_name}\" release)") if PROJ.release_name
22
- fd.puts
23
- fd.puts("== DESCRIPTION")
24
- fd.puts
25
- fd.puts(PROJ.description)
26
- fd.puts
27
- fd.puts(PROJ.changes.sub(%r/^.*$/, '== CHANGES'))
28
- fd.puts
29
- ann.paragraphs.each do |p|
30
- fd.puts "== #{p.upcase}"
31
- fd.puts
32
- fd.puts paragraphs_of(PROJ.readme_file, p).join("\n\n")
33
- fd.puts
34
- end
35
- fd.puts ann.text if ann.text
36
- end
37
- end
38
-
39
- desc "Create an announcement file"
40
- task :announcement => ['ann:prereqs', PROJ.ann.file]
41
-
42
- desc "Send an email announcement"
43
- task :email => ['ann:prereqs', PROJ.ann.file] do
44
- ann = PROJ.ann
45
- from = ann.email[:from] || Array(PROJ.authors).first || PROJ.email
46
- to = Array(ann.email[:to])
47
-
48
- ### build a mail header for RFC 822
49
- rfc822msg = "From: #{from}\n"
50
- rfc822msg << "To: #{to.join(',')}\n"
51
- rfc822msg << "Subject: [ANN] #{PROJ.name} #{PROJ.version}"
52
- rfc822msg << " (#{PROJ.release_name})" if PROJ.release_name
53
- rfc822msg << "\n"
54
- rfc822msg << "Date: #{Time.new.rfc822}\n"
55
- rfc822msg << "Message-Id: "
56
- rfc822msg << "<#{"%.8f" % Time.now.to_f}@#{ann.email[:domain]}>\n\n"
57
- rfc822msg << File.read(ann.file)
58
-
59
- params = [:server, :port, :domain, :acct, :passwd, :authtype].map do |key|
60
- ann.email[key]
61
- end
62
-
63
- params[3] = PROJ.email if params[3].nil?
64
-
65
- if params[4].nil?
66
- STDOUT.write "Please enter your e-mail password (#{params[3]}): "
67
- params[4] = STDIN.gets.chomp
68
- end
69
-
70
- ### send email
71
- Net::SMTP.start(*params) {|smtp| smtp.sendmail(rfc822msg, from, to)}
72
- end
73
- end # namespace :ann
74
-
75
- desc 'Alias to ann:announcement'
76
- task :ann => 'ann:announcement'
77
-
78
- CLOBBER << PROJ.ann.file
79
-
80
- # EOF
data/tasks/bones.rake DELETED
@@ -1,20 +0,0 @@
1
-
2
- if HAVE_BONES
3
-
4
- namespace :bones do
5
-
6
- desc 'Show the PROJ open struct'
7
- task :debug do |t|
8
- atr = if t.application.top_level_tasks.length == 2
9
- t.application.top_level_tasks.pop
10
- end
11
-
12
- if atr then Bones::Debug.show_attr(PROJ, atr)
13
- else Bones::Debug.show PROJ end
14
- end
15
-
16
- end # namespace :bones
17
-
18
- end # HAVE_BONES
19
-
20
- # EOF