lockdown 0.6.3 → 0.7.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/.gitignore +5 -0
- data/History.txt +4 -0
- data/Manifest.txt +4 -31
- data/README.txt +6 -31
- data/Rakefile +26 -28
- data/lib/lockdown.rb +40 -10
- data/lib/lockdown/controller.rb +2 -5
- data/lib/lockdown/database.rb +1 -2
- data/lib/lockdown/frameworks/merb.rb +14 -4
- data/lib/lockdown/frameworks/merb/controller.rb +7 -3
- data/lib/lockdown/frameworks/merb/view.rb +5 -3
- data/lib/lockdown/frameworks/rails.rb +14 -4
- data/lib/lockdown/frameworks/rails/controller.rb +21 -20
- data/lib/lockdown/frameworks/rails/view.rb +20 -24
- data/lib/lockdown/orms/active_record.rb +4 -2
- data/lib/lockdown/orms/data_mapper.rb +4 -2
- data/lib/lockdown/rights.rb +1 -1
- data/lib/lockdown/system.rb +2 -3
- data/rails_generators/lockdown/lockdown_generator.rb +21 -11
- data/rails_generators/lockdown/templates/app/controllers/users_controller.rb +1 -4
- data/rails_generators/lockdown/templates/app/helpers/permissions_helper.rb +0 -11
- data/rails_generators/lockdown/templates/app/helpers/user_groups_helper.rb +0 -33
- data/rails_generators/lockdown/templates/app/helpers/users_helper.rb +0 -76
- data/rails_generators/lockdown/templates/app/models/user.rb +37 -11
- data/rails_generators/lockdown/templates/app/views/permissions/show.html.erb +24 -1
- data/rails_generators/lockdown/templates/app/views/user_groups/edit.html.erb +29 -2
- data/rails_generators/lockdown/templates/app/views/user_groups/new.html.erb +28 -2
- data/rails_generators/lockdown/templates/app/views/user_groups/show.html.erb +24 -1
- data/rails_generators/lockdown/templates/app/views/users/edit.html.erb +46 -1
- data/rails_generators/lockdown/templates/app/views/users/new.html.erb +46 -1
- data/rails_generators/lockdown/templates/app/views/users/show.html.erb +30 -1
- data/rails_generators/lockdown/templates/config/initializers/lockit.rb +1 -0
- data/{app_generators/lockdown/templates → rails_generators/lockdown/templates/lib/lockdown}/init.rb +0 -1
- data/{app_generators/lockdown/templates → rails_generators/lockdown/templates/lib/lockdown}/session.rb +13 -12
- data/tasks/ann.rake +80 -0
- data/tasks/bones.rake +20 -0
- data/tasks/gem.rake +192 -0
- data/tasks/git.rake +40 -0
- data/tasks/manifest.rake +48 -0
- data/tasks/notes.rake +27 -0
- data/tasks/post_load.rake +39 -0
- data/tasks/rdoc.rake +50 -0
- data/tasks/rubyforge.rake +55 -0
- data/tasks/setup.rb +279 -0
- data/tasks/spec.rake +54 -0
- data/tasks/svn.rake +47 -0
- data/tasks/test.rake +40 -0
- metadata +29 -73
- data/License.txt +0 -20
- data/PostInstall.txt +0 -3
- data/app_generators/lockdown/USAGE +0 -5
- data/app_generators/lockdown/lockdown_generator.rb +0 -25
- data/bin/lockdown +0 -132
- data/lib/lockdown/version.rb +0 -9
- data/rails_generators/lockdown/USAGE +0 -5
- data/rails_generators/lockdown/templates/app/views/permissions/_data.html.erb +0 -13
- data/rails_generators/lockdown/templates/app/views/user_groups/_data.html.erb +0 -68
- data/rails_generators/lockdown/templates/app/views/user_groups/_form.html.erb +0 -11
- data/rails_generators/lockdown/templates/app/views/users/_data.html.erb +0 -87
- data/rails_generators/lockdown/templates/app/views/users/_form.html.erb +0 -12
- data/script/console +0 -10
- data/script/destroy +0 -14
- data/script/generate +0 -14
- data/script/txt2html +0 -82
- data/setup.rb +0 -1585
- data/test/test_generator_helper.rb +0 -29
- data/test/test_helper.rb +0 -2
- data/test/test_lockdown.rb +0 -11
- data/test/test_lockdown_all_generator.rb +0 -43
- data/test/test_lockdown_generator.rb +0 -45
- data/test/test_lockdown_models_generator.rb +0 -43
- data/website/index.html +0 -62
- data/website/index.txt +0 -20
- data/website/javascripts/rounded_corners_lite.inc.js +0 -285
- data/website/model.jpg +0 -0
- data/website/stylesheets/screen.css +0 -138
- data/website/template.html.erb +0 -54
data/tasks/spec.rake
ADDED
@@ -0,0 +1,54 @@
|
|
1
|
+
|
2
|
+
if HAVE_SPEC_RAKE_SPECTASK and not PROJ.spec.files.to_a.empty?
|
3
|
+
require 'spec/rake/verify_rcov'
|
4
|
+
|
5
|
+
namespace :spec do
|
6
|
+
|
7
|
+
desc 'Run all specs with basic output'
|
8
|
+
Spec::Rake::SpecTask.new(:run) do |t|
|
9
|
+
t.ruby_opts = PROJ.ruby_opts
|
10
|
+
t.spec_opts = PROJ.spec.opts
|
11
|
+
t.spec_files = PROJ.spec.files
|
12
|
+
t.libs += PROJ.libs
|
13
|
+
end
|
14
|
+
|
15
|
+
desc 'Run all specs with text output'
|
16
|
+
Spec::Rake::SpecTask.new(:specdoc) do |t|
|
17
|
+
t.ruby_opts = PROJ.ruby_opts
|
18
|
+
t.spec_opts = PROJ.spec.opts + ['--format', 'specdoc']
|
19
|
+
t.spec_files = PROJ.spec.files
|
20
|
+
t.libs += PROJ.libs
|
21
|
+
end
|
22
|
+
|
23
|
+
if HAVE_RCOV
|
24
|
+
desc 'Run all specs with RCov'
|
25
|
+
Spec::Rake::SpecTask.new(:rcov) do |t|
|
26
|
+
t.ruby_opts = PROJ.ruby_opts
|
27
|
+
t.spec_opts = PROJ.spec.opts
|
28
|
+
t.spec_files = PROJ.spec.files
|
29
|
+
t.libs += PROJ.libs
|
30
|
+
t.rcov = true
|
31
|
+
t.rcov_dir = PROJ.rcov.dir
|
32
|
+
t.rcov_opts = PROJ.rcov.opts + ['--exclude', 'spec']
|
33
|
+
end
|
34
|
+
|
35
|
+
RCov::VerifyTask.new(:verify) do |t|
|
36
|
+
t.threshold = PROJ.rcov.threshold
|
37
|
+
t.index_html = File.join(PROJ.rcov.dir, 'index.html')
|
38
|
+
t.require_exact_threshold = PROJ.rcov.threshold_exact
|
39
|
+
end
|
40
|
+
|
41
|
+
task :verify => :rcov
|
42
|
+
remove_desc_for_task %w(spec:clobber_rcov)
|
43
|
+
end
|
44
|
+
|
45
|
+
end # namespace :spec
|
46
|
+
|
47
|
+
desc 'Alias to spec:run'
|
48
|
+
task :spec => 'spec:run'
|
49
|
+
|
50
|
+
task :clobber => 'spec:clobber_rcov' if HAVE_RCOV
|
51
|
+
|
52
|
+
end # if HAVE_SPEC_RAKE_SPECTASK
|
53
|
+
|
54
|
+
# EOF
|
data/tasks/svn.rake
ADDED
@@ -0,0 +1,47 @@
|
|
1
|
+
|
2
|
+
if HAVE_SVN
|
3
|
+
|
4
|
+
unless PROJ.svn.root
|
5
|
+
info = %x/svn info ./
|
6
|
+
m = %r/^Repository Root:\s+(.*)$/.match(info)
|
7
|
+
PROJ.svn.root = (m.nil? ? '' : m[1])
|
8
|
+
end
|
9
|
+
PROJ.svn.root = File.join(PROJ.svn.root, PROJ.svn.path) unless PROJ.svn.path.empty?
|
10
|
+
|
11
|
+
namespace :svn do
|
12
|
+
|
13
|
+
# A prerequisites task that all other tasks depend upon
|
14
|
+
task :prereqs
|
15
|
+
|
16
|
+
desc 'Show tags from the SVN repository'
|
17
|
+
task :show_tags => 'svn:prereqs' do |t|
|
18
|
+
tags = %x/svn list #{File.join(PROJ.svn.root, PROJ.svn.tags)}/
|
19
|
+
tags.gsub!(%r/\/$/, '')
|
20
|
+
tags = tags.split("\n").sort {|a,b| b <=> a}
|
21
|
+
puts tags
|
22
|
+
end
|
23
|
+
|
24
|
+
desc 'Create a new tag in the SVN repository'
|
25
|
+
task :create_tag => 'svn:prereqs' do |t|
|
26
|
+
v = ENV['VERSION'] or abort 'Must supply VERSION=x.y.z'
|
27
|
+
abort "Versions don't match #{v} vs #{PROJ.version}" if v != PROJ.version
|
28
|
+
|
29
|
+
svn = PROJ.svn
|
30
|
+
trunk = File.join(svn.root, svn.trunk)
|
31
|
+
tag = "%s-%s" % [PROJ.name, PROJ.version]
|
32
|
+
tag = File.join(svn.root, svn.tags, tag)
|
33
|
+
msg = "Creating tag for #{PROJ.name} version #{PROJ.version}"
|
34
|
+
|
35
|
+
puts "Creating SVN tag '#{tag}'"
|
36
|
+
unless system "svn cp -m '#{msg}' #{trunk} #{tag}"
|
37
|
+
abort "Tag creation failed"
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
end # namespace :svn
|
42
|
+
|
43
|
+
task 'gem:release' => 'svn:create_tag'
|
44
|
+
|
45
|
+
end # if PROJ.svn.path
|
46
|
+
|
47
|
+
# EOF
|
data/tasks/test.rake
ADDED
@@ -0,0 +1,40 @@
|
|
1
|
+
|
2
|
+
if test(?e, PROJ.test.file) or not PROJ.test.files.to_a.empty?
|
3
|
+
require 'rake/testtask'
|
4
|
+
|
5
|
+
namespace :test do
|
6
|
+
|
7
|
+
Rake::TestTask.new(:run) do |t|
|
8
|
+
t.libs = PROJ.libs
|
9
|
+
t.test_files = if test(?f, PROJ.test.file) then [PROJ.test.file]
|
10
|
+
else PROJ.test.files end
|
11
|
+
t.ruby_opts += PROJ.ruby_opts
|
12
|
+
t.ruby_opts += PROJ.test.opts
|
13
|
+
end
|
14
|
+
|
15
|
+
if HAVE_RCOV
|
16
|
+
desc 'Run rcov on the unit tests'
|
17
|
+
task :rcov => :clobber_rcov do
|
18
|
+
opts = PROJ.rcov.opts.dup << '-o' << PROJ.rcov.dir
|
19
|
+
opts = opts.join(' ')
|
20
|
+
files = if test(?f, PROJ.test.file) then [PROJ.test.file]
|
21
|
+
else PROJ.test.files end
|
22
|
+
files = files.join(' ')
|
23
|
+
sh "#{RCOV} #{files} #{opts}"
|
24
|
+
end
|
25
|
+
|
26
|
+
task :clobber_rcov do
|
27
|
+
rm_r 'coverage' rescue nil
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
end # namespace :test
|
32
|
+
|
33
|
+
desc 'Alias to test:run'
|
34
|
+
task :test => 'test:run'
|
35
|
+
|
36
|
+
task :clobber => 'test:clobber_rcov' if HAVE_RCOV
|
37
|
+
|
38
|
+
end
|
39
|
+
|
40
|
+
# EOF
|
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: 0.
|
4
|
+
version: 0.7.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Andrew Stone
|
@@ -9,65 +9,34 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date:
|
12
|
+
date: 2009-01-08 00:00:00 -05:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
|
-
name:
|
17
|
-
type: :runtime
|
18
|
-
version_requirement:
|
19
|
-
version_requirements: !ruby/object:Gem::Requirement
|
20
|
-
requirements:
|
21
|
-
- - ">="
|
22
|
-
- !ruby/object:Gem::Version
|
23
|
-
version: 0.6.2
|
24
|
-
version:
|
25
|
-
- !ruby/object:Gem::Dependency
|
26
|
-
name: newgem
|
27
|
-
type: :development
|
28
|
-
version_requirement:
|
29
|
-
version_requirements: !ruby/object:Gem::Requirement
|
30
|
-
requirements:
|
31
|
-
- - ">="
|
32
|
-
- !ruby/object:Gem::Version
|
33
|
-
version: 1.1.0
|
34
|
-
version:
|
35
|
-
- !ruby/object:Gem::Dependency
|
36
|
-
name: hoe
|
16
|
+
name: bones
|
37
17
|
type: :development
|
38
18
|
version_requirement:
|
39
19
|
version_requirements: !ruby/object:Gem::Requirement
|
40
20
|
requirements:
|
41
21
|
- - ">="
|
42
22
|
- !ruby/object:Gem::Version
|
43
|
-
version: 1.
|
23
|
+
version: 2.1.1
|
44
24
|
version:
|
45
|
-
description: Lockdown is a authentication/authorization system for RubyOnRails
|
46
|
-
email:
|
47
|
-
|
48
|
-
|
49
|
-
- lockdown
|
25
|
+
description: Lockdown is a authentication/authorization system for RubyOnRails (ver >= 2.1).
|
26
|
+
email: andy@stonean.com
|
27
|
+
executables: []
|
28
|
+
|
50
29
|
extensions: []
|
51
30
|
|
52
31
|
extra_rdoc_files:
|
53
32
|
- History.txt
|
54
|
-
- License.txt
|
55
|
-
- Manifest.txt
|
56
|
-
- PostInstall.txt
|
57
33
|
- README.txt
|
58
|
-
- website/index.txt
|
59
34
|
files:
|
35
|
+
- .gitignore
|
60
36
|
- History.txt
|
61
|
-
- License.txt
|
62
37
|
- Manifest.txt
|
63
|
-
- PostInstall.txt
|
64
38
|
- README.txt
|
65
39
|
- Rakefile
|
66
|
-
- app_generators/lockdown/USAGE
|
67
|
-
- app_generators/lockdown/lockdown_generator.rb
|
68
|
-
- app_generators/lockdown/templates/init.rb
|
69
|
-
- app_generators/lockdown/templates/session.rb
|
70
|
-
- bin/lockdown
|
71
40
|
- lib/lockdown.rb
|
72
41
|
- lib/lockdown/classy-inheritance.rb
|
73
42
|
- lib/lockdown/controller.rb
|
@@ -84,8 +53,6 @@ files:
|
|
84
53
|
- lib/lockdown/rights.rb
|
85
54
|
- lib/lockdown/session.rb
|
86
55
|
- lib/lockdown/system.rb
|
87
|
-
- lib/lockdown/version.rb
|
88
|
-
- rails_generators/lockdown/USAGE
|
89
56
|
- rails_generators/lockdown/lockdown_generator.rb
|
90
57
|
- rails_generators/lockdown/templates/app/controllers/permissions_controller.rb
|
91
58
|
- rails_generators/lockdown/templates/app/controllers/sessions_controller.rb
|
@@ -98,47 +65,41 @@ files:
|
|
98
65
|
- rails_generators/lockdown/templates/app/models/profile.rb
|
99
66
|
- rails_generators/lockdown/templates/app/models/user.rb
|
100
67
|
- rails_generators/lockdown/templates/app/models/user_group.rb
|
101
|
-
- rails_generators/lockdown/templates/app/views/permissions/_data.html.erb
|
102
68
|
- rails_generators/lockdown/templates/app/views/permissions/index.html.erb
|
103
69
|
- rails_generators/lockdown/templates/app/views/permissions/show.html.erb
|
104
70
|
- rails_generators/lockdown/templates/app/views/sessions/new.html.erb
|
105
|
-
- rails_generators/lockdown/templates/app/views/user_groups/_data.html.erb
|
106
|
-
- rails_generators/lockdown/templates/app/views/user_groups/_form.html.erb
|
107
71
|
- rails_generators/lockdown/templates/app/views/user_groups/edit.html.erb
|
108
72
|
- rails_generators/lockdown/templates/app/views/user_groups/index.html.erb
|
109
73
|
- rails_generators/lockdown/templates/app/views/user_groups/new.html.erb
|
110
74
|
- rails_generators/lockdown/templates/app/views/user_groups/show.html.erb
|
111
|
-
- rails_generators/lockdown/templates/app/views/users/_data.html.erb
|
112
|
-
- rails_generators/lockdown/templates/app/views/users/_form.html.erb
|
113
75
|
- rails_generators/lockdown/templates/app/views/users/edit.html.erb
|
114
76
|
- rails_generators/lockdown/templates/app/views/users/index.html.erb
|
115
77
|
- rails_generators/lockdown/templates/app/views/users/new.html.erb
|
116
78
|
- rails_generators/lockdown/templates/app/views/users/show.html.erb
|
79
|
+
- rails_generators/lockdown/templates/config/initializers/lockit.rb
|
117
80
|
- rails_generators/lockdown/templates/db/migrate/create_admin_user.rb
|
118
81
|
- rails_generators/lockdown/templates/db/migrate/create_permissions.rb
|
119
82
|
- rails_generators/lockdown/templates/db/migrate/create_profiles.rb
|
120
83
|
- rails_generators/lockdown/templates/db/migrate/create_user_groups.rb
|
121
84
|
- rails_generators/lockdown/templates/db/migrate/create_users.rb
|
122
|
-
-
|
123
|
-
-
|
124
|
-
-
|
125
|
-
-
|
126
|
-
-
|
127
|
-
-
|
128
|
-
-
|
129
|
-
-
|
130
|
-
-
|
131
|
-
-
|
132
|
-
-
|
133
|
-
-
|
134
|
-
-
|
135
|
-
-
|
136
|
-
-
|
137
|
-
- website/stylesheets/screen.css
|
138
|
-
- website/template.html.erb
|
85
|
+
- rails_generators/lockdown/templates/lib/lockdown/init.rb
|
86
|
+
- rails_generators/lockdown/templates/lib/lockdown/session.rb
|
87
|
+
- tasks/ann.rake
|
88
|
+
- tasks/bones.rake
|
89
|
+
- tasks/gem.rake
|
90
|
+
- tasks/git.rake
|
91
|
+
- tasks/manifest.rake
|
92
|
+
- tasks/notes.rake
|
93
|
+
- tasks/post_load.rake
|
94
|
+
- tasks/rdoc.rake
|
95
|
+
- tasks/rubyforge.rake
|
96
|
+
- tasks/setup.rb
|
97
|
+
- tasks/spec.rake
|
98
|
+
- tasks/svn.rake
|
99
|
+
- tasks/test.rake
|
139
100
|
has_rdoc: true
|
140
101
|
homepage: http://stonean.com/wiki/lockdown
|
141
|
-
post_install_message:
|
102
|
+
post_install_message:
|
142
103
|
rdoc_options:
|
143
104
|
- --main
|
144
105
|
- README.txt
|
@@ -162,11 +123,6 @@ rubyforge_project: lockdown
|
|
162
123
|
rubygems_version: 1.3.1
|
163
124
|
signing_key:
|
164
125
|
specification_version: 2
|
165
|
-
summary: Lockdown is a authentication/authorization system for RubyOnRails
|
166
|
-
test_files:
|
167
|
-
|
168
|
-
- test/test_helper.rb
|
169
|
-
- test/test_lockdown.rb
|
170
|
-
- test/test_lockdown_all_generator.rb
|
171
|
-
- test/test_lockdown_generator.rb
|
172
|
-
- test/test_lockdown_models_generator.rb
|
126
|
+
summary: Lockdown is a authentication/authorization system for RubyOnRails (ver >= 2
|
127
|
+
test_files: []
|
128
|
+
|
data/License.txt
DELETED
@@ -1,20 +0,0 @@
|
|
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/PostInstall.txt
DELETED
@@ -1,25 +0,0 @@
|
|
1
|
-
class LockdownGenerator < RubiGen::Base
|
2
|
-
|
3
|
-
DEFAULT_SHEBANG = File.join(Config::CONFIG['bindir'],
|
4
|
-
Config::CONFIG['ruby_install_name'])
|
5
|
-
|
6
|
-
default_options :author => "Andrew Stone"
|
7
|
-
|
8
|
-
attr_reader :name, :framework
|
9
|
-
|
10
|
-
def initialize(runtime_args, runtime_options = {})
|
11
|
-
super
|
12
|
-
usage if args.empty?
|
13
|
-
@destination_root = File.expand_path(args.shift)
|
14
|
-
@name = base_name
|
15
|
-
@framework = runtime_options[:framework]
|
16
|
-
end
|
17
|
-
|
18
|
-
def manifest
|
19
|
-
record do |m|
|
20
|
-
m.directory "lib/lockdown"
|
21
|
-
m.template "session.rb", "lib/lockdown/session.rb"
|
22
|
-
m.file "init.rb", "lib/lockdown/init.rb"
|
23
|
-
end
|
24
|
-
end
|
25
|
-
end
|
data/bin/lockdown
DELETED
@@ -1,132 +0,0 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
|
3
|
-
require "rubygems"
|
4
|
-
require "rubigen"
|
5
|
-
require "rubigen/scripts/generate"
|
6
|
-
require 'optparse'
|
7
|
-
|
8
|
-
if %w(-v --version).include? ARGV.first
|
9
|
-
require 'lockdown/version'
|
10
|
-
puts "#{File.basename($0)} #{Lockdown::VERSION::STRING}"
|
11
|
-
exit(0)
|
12
|
-
end
|
13
|
-
|
14
|
-
MERB_CONFIG = 'config/init.rb'
|
15
|
-
RAILS_CONFIG = 'config/environment.rb'
|
16
|
-
|
17
|
-
if File.exists?(MERB_CONFIG)
|
18
|
-
@framework = "merb"
|
19
|
-
elsif File.exists?(RAILS_CONFIG)
|
20
|
-
@framework = "rails"
|
21
|
-
else
|
22
|
-
raise NotImplementedError, "Configuration file not found. Looking for init.rb (Merb) or environment.rb (Rails)"
|
23
|
-
end
|
24
|
-
|
25
|
-
def merb_app?
|
26
|
-
@framework == "merb"
|
27
|
-
end
|
28
|
-
|
29
|
-
def rails_app?
|
30
|
-
@framework == "rails"
|
31
|
-
end
|
32
|
-
|
33
|
-
#
|
34
|
-
# Right now we only have the two and we raise an exception
|
35
|
-
# if we don't know prior to getting here..
|
36
|
-
#
|
37
|
-
def config_file
|
38
|
-
if merb_app?
|
39
|
-
MERB_CONFIG
|
40
|
-
else
|
41
|
-
RAILS_CONFIG
|
42
|
-
end
|
43
|
-
end
|
44
|
-
|
45
|
-
begin
|
46
|
-
require 'rubygems'
|
47
|
-
rescue LoadError
|
48
|
-
# no rubygems to load, so we fail silently
|
49
|
-
end
|
50
|
-
|
51
|
-
|
52
|
-
OPTIONS = {
|
53
|
-
:path => File.expand_path('.')
|
54
|
-
}
|
55
|
-
|
56
|
-
parser = OptionParser.new do |opts|
|
57
|
-
opts.banner = <<-BANNER
|
58
|
-
Lockdown will add init.rb and session.rb to the lib/lockdown directory and require them in #{config_file}.
|
59
|
-
|
60
|
-
Usage: #{File.basename($0)} [options]
|
61
|
-
|
62
|
-
Options are:
|
63
|
-
BANNER
|
64
|
-
|
65
|
-
opts.separator ""
|
66
|
-
opts.on("-p", "--path=PATH", String,
|
67
|
-
"The root path for selecting files",
|
68
|
-
"Default: [current directory]") { |OPTIONS[:path]| }
|
69
|
-
opts.on("-h", "--help",
|
70
|
-
"Show this help message.") { puts opts; exit }
|
71
|
-
opts.parse!(ARGV)
|
72
|
-
end
|
73
|
-
|
74
|
-
#
|
75
|
-
# Load up the config file contents
|
76
|
-
#
|
77
|
-
@configuration = File.open config_file do |f|
|
78
|
-
f.map {|line| line.chomp}
|
79
|
-
end
|
80
|
-
|
81
|
-
def configuration_file_has?(req)
|
82
|
-
@configuration.include?(req)
|
83
|
-
end
|
84
|
-
|
85
|
-
puts <<-MSG
|
86
|
-
\n------------------------------------------------------------
|
87
|
-
Installing Lockdown
|
88
|
-
MSG
|
89
|
-
|
90
|
-
begin
|
91
|
-
source = RubiGen::PathSource.new(:application,
|
92
|
-
File.join(File.dirname(__FILE__), "../app_generators"))
|
93
|
-
RubiGen::Base.reset_sources
|
94
|
-
RubiGen::Base.append_sources source
|
95
|
-
RubiGen::Scripts::Generate.new.run(ARGV, :generator => 'lockdown', :framework => @framework)
|
96
|
-
|
97
|
-
File.open(config_file, "a") do |f|
|
98
|
-
require_lockdown = %Q(require "lockdown/init")
|
99
|
-
|
100
|
-
f << %Q(\n#{require_lockdown}\n) unless configuration_file_has?(require_lockdown)
|
101
|
-
end
|
102
|
-
rescue Exception => e
|
103
|
-
puts e.backtrace.join("\n")
|
104
|
-
raise e
|
105
|
-
end
|
106
|
-
|
107
|
-
puts <<-MSG
|
108
|
-
------------------------------------------------------------\n
|
109
|
-
MSG
|
110
|
-
|
111
|
-
puts <<-MSG
|
112
|
-
\n------------------------------------------------------------
|
113
|
-
Modified #{config_file} by adding:
|
114
|
-
require "lockdown/init"
|
115
|
-
------------------------------------------------------------\n
|
116
|
-
MSG
|
117
|
-
|
118
|
-
puts <<-MSG
|
119
|
-
\n------------------------------------------------------------
|
120
|
-
You are now locked down. To open up access to your
|
121
|
-
application please modify lib/lockdown/init.rb. This is
|
122
|
-
where you'll add permissions and create user groups.
|
123
|
-
|
124
|
-
To modify the contents of your session and to add access
|
125
|
-
methods, modify lib/lockdown/session.rb.
|
126
|
-
|
127
|
-
For the wiki, news, forum and issue tracker please visit:
|
128
|
-
|
129
|
-
http://stonean.com/projects/show/lockdown
|
130
|
-
|
131
|
-
------------------------------------------------------------\n
|
132
|
-
MSG
|