scottmotte-merb_auth_slice_multisite 0.1.1

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/LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2009 scottmotte
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/README.rdoc ADDED
@@ -0,0 +1,7 @@
1
+ = merb_auth_slice_multisite
2
+
3
+ Description goes here.
4
+
5
+ == Copyright
6
+
7
+ Copyright (c) 2009 scottmotte. See LICENSE for details.
data/VERSION.yml ADDED
@@ -0,0 +1,4 @@
1
+ ---
2
+ :major: 0
3
+ :minor: 1
4
+ :patch: 1
@@ -0,0 +1,82 @@
1
+ if defined?(Merb::Plugins)
2
+
3
+ $:.unshift File.dirname(__FILE__)
4
+
5
+ dependency 'merb-slices', :immediate => true
6
+ Merb::Plugins.add_rakefiles "merb_auth_slice_multisite/merbtasks", "merb_auth_slice_multisite/slicetasks", "merb_auth_slice_multisite/spectasks"
7
+
8
+ # Register the Slice for the current host application
9
+ Merb::Slices::register(__FILE__)
10
+
11
+ # Slice configuration - set this in a before_app_loads callback.
12
+ # By default a Slice uses its own layout, so you can swicht to
13
+ # the main application layout or no layout at all if needed.
14
+ #
15
+ # Configuration options:
16
+ # :layout - the layout to use; defaults to :merb_auth_slice_multisite
17
+ # :mirror - which path component types to use on copy operations; defaults to all
18
+ Merb::Slices::config[:merb_auth_slice_multisite][:layout] ||= :merb_auth_slice_multisite
19
+
20
+ # All Slice code is expected to be namespaced inside a module
21
+ module MerbAuthSliceMultisite
22
+
23
+ # Slice metadata
24
+ self.description = "MerbAuthSliceMultisite is a chunky Merb slice!"
25
+ self.version = "0.0.1"
26
+ self.author = "Engine Yard"
27
+
28
+ # Stub classes loaded hook - runs before LoadClasses BootLoader
29
+ # right after a slice's classes have been loaded internally.
30
+ def self.loaded
31
+ end
32
+
33
+ # Initialization hook - runs before AfterAppLoads BootLoader
34
+ def self.init
35
+ end
36
+
37
+ # Activation hook - runs after AfterAppLoads BootLoader
38
+ def self.activate
39
+ end
40
+
41
+ # Deactivation hook - triggered by Merb::Slices.deactivate(MerbAuthSliceMultisite)
42
+ def self.deactivate
43
+ end
44
+
45
+ # Setup routes inside the host application
46
+ #
47
+ # @param scope<Merb::Router::Behaviour>
48
+ # Routes will be added within this scope (namespace). In fact, any
49
+ # router behaviour is a valid namespace, so you can attach
50
+ # routes at any level of your router setup.
51
+ #
52
+ # @note prefix your named routes with :merb_auth_slice_multisite_
53
+ # to avoid potential conflicts with global named routes.
54
+ def self.setup_router(scope)
55
+ # example of a named route
56
+ scope.match('/index(.:format)').to(:controller => 'main', :action => 'index').name(:index)
57
+ # the slice is mounted at /merb_auth_slice_multisite - note that it comes before default_routes
58
+ scope.match('/').to(:controller => 'main', :action => 'index').name(:home)
59
+ # enable slice-level default routes by default
60
+ scope.default_routes
61
+ end
62
+
63
+ end
64
+
65
+ # Setup the slice layout for MerbAuthSliceMultisite
66
+ #
67
+ # Use MerbAuthSliceMultisite.push_path and MerbAuthSliceMultisite.push_app_path
68
+ # to set paths to merb_auth_slice_multisite-level and app-level paths. Example:
69
+ #
70
+ # MerbAuthSliceMultisite.push_path(:application, MerbAuthSliceMultisite.root)
71
+ # MerbAuthSliceMultisite.push_app_path(:application, Merb.root / 'slices' / 'merb_auth_slice_multisite')
72
+ # ...
73
+ #
74
+ # Any component path that hasn't been set will default to MerbAuthSliceMultisite.root
75
+ #
76
+ # Or just call setup_default_structure! to setup a basic Merb MVC structure.
77
+ MerbAuthSliceMultisite.setup_default_structure!
78
+
79
+ # Add dependencies for other MerbAuthSliceMultisite classes below. Example:
80
+ # dependency "merb_auth_slice_multisite/other"
81
+
82
+ end
@@ -0,0 +1,103 @@
1
+ namespace :slices do
2
+ namespace :merb_auth_slice_multisite do
3
+
4
+ desc "Install MerbAuthSliceMultisite"
5
+ task :install => [:preflight, :setup_directories, :copy_assets, :migrate]
6
+
7
+ desc "Test for any dependencies"
8
+ task :preflight do # see slicetasks.rb
9
+ end
10
+
11
+ desc "Setup directories"
12
+ task :setup_directories do
13
+ puts "Creating directories for host application"
14
+ MerbAuthSliceMultisite.mirrored_components.each do |type|
15
+ if File.directory?(MerbAuthSliceMultisite.dir_for(type))
16
+ if !File.directory?(dst_path = MerbAuthSliceMultisite.app_dir_for(type))
17
+ relative_path = dst_path.relative_path_from(Merb.root)
18
+ puts "- creating directory :#{type} #{File.basename(Merb.root) / relative_path}"
19
+ mkdir_p(dst_path)
20
+ end
21
+ end
22
+ end
23
+ end
24
+
25
+ # desc "Copy stub files to host application"
26
+ # task :stubs do
27
+ # puts "Copying stubs for MerbAuthSliceMultisite - resolves any collisions"
28
+ # copied, preserved = MerbAuthSliceMultisite.mirror_stubs!
29
+ # puts "- no files to copy" if copied.empty? && preserved.empty?
30
+ # copied.each { |f| puts "- copied #{f}" }
31
+ # preserved.each { |f| puts "! preserved override as #{f}" }
32
+ # end
33
+
34
+ # desc "Copy stub files and views to host application"
35
+ # task :patch => [ "stubs", "freeze:views" ]
36
+
37
+ desc "Copy public assets to host application"
38
+ task :copy_assets do
39
+ puts "Copying assets for MerbAuthSliceMultisite - resolves any collisions"
40
+ copied, preserved = MerbAuthSliceMultisite.mirror_public!
41
+ puts "- no files to copy" if copied.empty? && preserved.empty?
42
+ copied.each { |f| puts "- copied #{f}" }
43
+ preserved.each { |f| puts "! preserved override as #{f}" }
44
+ end
45
+
46
+ desc "Migrate the database"
47
+ task :migrate do # see slicetasks.rb
48
+ end
49
+
50
+ desc "Freeze MerbAuthSliceMultisite into your app (only merb_auth_slice_multisite/app)"
51
+ task :freeze => [ "freeze:app" ]
52
+
53
+ namespace :freeze do
54
+
55
+ # desc "Freezes MerbAuthSliceMultisite by installing the gem into application/gems"
56
+ # task :gem do
57
+ # ENV["GEM"] ||= "merb_auth_slice_multisite"
58
+ # Rake::Task['slices:install_as_gem'].invoke
59
+ # end
60
+
61
+ desc "Freezes MerbAuthSliceMultisite by copying all files from merb_auth_slice_multisite/app to your application"
62
+ task :app do
63
+ puts "Copying all merb_auth_slice_multisite/app files to your application - resolves any collisions"
64
+ copied, preserved = MerbAuthSliceMultisite.mirror_app!
65
+ puts "- no files to copy" if copied.empty? && preserved.empty?
66
+ copied.each { |f| puts "- copied #{f}" }
67
+ preserved.each { |f| puts "! preserved override as #{f}" }
68
+ end
69
+
70
+ desc "Freeze all views into your application for easy modification"
71
+ task :views do
72
+ puts "Copying all view templates to your application - resolves any collisions"
73
+ copied, preserved = MerbAuthSliceMultisite.mirror_files_for :view
74
+ puts "- no files to copy" if copied.empty? && preserved.empty?
75
+ copied.each { |f| puts "- copied #{f}" }
76
+ preserved.each { |f| puts "! preserved override as #{f}" }
77
+ end
78
+
79
+ desc "Freeze all models into your application for easy modification"
80
+ task :models do
81
+ puts "Copying all models to your application - resolves any collisions"
82
+ copied, preserved = MerbAuthSliceMultisite.mirror_files_for :model
83
+ puts "- no files to copy" if copied.empty? && preserved.empty?
84
+ copied.each { |f| puts "- copied #{f}" }
85
+ preserved.each { |f| puts "! preserved override as #{f}" }
86
+ end
87
+
88
+ desc "Freezes MerbAuthSliceMultisite as a gem and copies over merb_auth_slice_multisite/app"
89
+ task :app_with_gem => [:gem, :app]
90
+
91
+ desc "Freezes MerbAuthSliceMultisite by unpacking all files into your application"
92
+ task :unpack do
93
+ puts "Unpacking MerbAuthSliceMultisite files to your application - resolves any collisions"
94
+ copied, preserved = MerbAuthSliceMultisite.unpack_slice!
95
+ puts "- no files to copy" if copied.empty? && preserved.empty?
96
+ copied.each { |f| puts "- copied #{f}" }
97
+ preserved.each { |f| puts "! preserved override as #{f}" }
98
+ end
99
+
100
+ end
101
+
102
+ end
103
+ end
@@ -0,0 +1,20 @@
1
+ namespace :slices do
2
+ namespace :merb_auth_slice_multisite do
3
+
4
+ # add your own merb_auth_slice_multisite tasks here
5
+
6
+ # # Uncomment the following lines and edit the pre defined tasks
7
+ #
8
+ # # implement this to test for structural/code dependencies
9
+ # # like certain directories or availability of other files
10
+ # desc "Test for any dependencies"
11
+ # task :preflight do
12
+ # end
13
+ #
14
+ # # implement this to perform any database related setup steps
15
+ # desc "Migrate the database"
16
+ # task :migrate do
17
+ # end
18
+
19
+ end
20
+ end
@@ -0,0 +1,53 @@
1
+ namespace :slices do
2
+ namespace :merb_auth_slice_multisite do
3
+
4
+ desc "Run slice specs within the host application context"
5
+ task :spec => [ "spec:explain", "spec:default" ]
6
+
7
+ namespace :spec do
8
+
9
+ slice_root = File.expand_path(File.join(File.dirname(__FILE__), '..', '..'))
10
+
11
+ task :explain do
12
+ puts "\nNote: By running MerbAuthSliceMultisite specs inside the application context any\n" +
13
+ "overrides could break existing specs. This isn't always a problem,\n" +
14
+ "especially in the case of views. Use these spec tasks to check how\n" +
15
+ "well your application conforms to the original slice implementation."
16
+ end
17
+
18
+ Spec::Rake::SpecTask.new('default') do |t|
19
+ t.spec_opts = ["--format", "specdoc", "--colour"]
20
+ t.spec_files = Dir["#{slice_root}/spec/**/*_spec.rb"].sort
21
+ end
22
+
23
+ desc "Run all model specs, run a spec for a specific Model with MODEL=MyModel"
24
+ Spec::Rake::SpecTask.new('model') do |t|
25
+ t.spec_opts = ["--format", "specdoc", "--colour"]
26
+ if(ENV['MODEL'])
27
+ t.spec_files = Dir["#{slice_root}/spec/models/**/#{ENV['MODEL']}_spec.rb"].sort
28
+ else
29
+ t.spec_files = Dir["#{slice_root}/spec/models/**/*_spec.rb"].sort
30
+ end
31
+ end
32
+
33
+ desc "Run all request specs, run a spec for a specific request with REQUEST=MyRequest"
34
+ Spec::Rake::SpecTask.new('request') do |t|
35
+ t.spec_opts = ["--format", "specdoc", "--colour"]
36
+ if(ENV['REQUEST'])
37
+ t.spec_files = Dir["#{slice_root}/spec/requests/**/#{ENV['REQUEST']}_spec.rb"].sort
38
+ else
39
+ t.spec_files = Dir["#{slice_root}/spec/requests/**/*_spec.rb"].sort
40
+ end
41
+ end
42
+
43
+ desc "Run all specs and output the result in html"
44
+ Spec::Rake::SpecTask.new('html') do |t|
45
+ t.spec_opts = ["--format", "html"]
46
+ t.libs = ['lib', 'server/lib' ]
47
+ t.spec_files = Dir["#{slice_root}/spec/**/*_spec.rb"].sort
48
+ end
49
+
50
+ end
51
+
52
+ end
53
+ end
@@ -0,0 +1,20 @@
1
+ require File.dirname(__FILE__) + '/spec_helper'
2
+
3
+ describe "MerbAuthSliceMultisite (module)" do
4
+
5
+ # Implement your MerbAuthSliceMultisite specs here
6
+
7
+ # To spec MerbAuthSliceMultisite you need to hook it up to the router like this:
8
+
9
+ # before :all do
10
+ # Merb::Router.prepare { add_slice(:MerbAuthSliceMultisite) } if standalone?
11
+ # end
12
+ #
13
+ # after :all do
14
+ # Merb::Router.reset! if standalone?
15
+ # end
16
+ #
17
+ #
18
+ # it "should have proper specs"
19
+
20
+ end
@@ -0,0 +1,30 @@
1
+ require File.join(File.dirname(__FILE__), '..', 'spec_helper.rb')
2
+
3
+ describe "/merb_auth_slice_multisite/" do
4
+
5
+ before(:all) do
6
+ mount_slice
7
+ end
8
+
9
+ describe "GET /" do
10
+
11
+ before(:each) do
12
+ @response = request("/merb_auth_slice_multisite/")
13
+ end
14
+
15
+ it "should be successful" do
16
+ @response.status.should be_successful
17
+ end
18
+
19
+ # This is just an example of what you can do
20
+ # You can also use the other webrat methods to click links,
21
+ # fill up forms etc...
22
+ it "should render the default slice layout" do
23
+ @response.should have_tag(:h1, :content => "MerbAuthSliceMultisite Slice")
24
+ @response.should have_selector("div#container div#main")
25
+ @response.should have_xpath("//div[@id='container']/div[@id='main']")
26
+ end
27
+
28
+ end
29
+
30
+ end
@@ -0,0 +1,58 @@
1
+ require 'rubygems'
2
+ require 'merb-core'
3
+ require 'merb-slices'
4
+ require 'spec'
5
+
6
+ # Add merb_auth_slice_multisite.rb to the search path
7
+ Merb::Plugins.config[:merb_slices][:auto_register] = true
8
+ Merb::Plugins.config[:merb_slices][:search_path] = File.join(File.dirname(__FILE__), '..', 'lib', 'merb_auth_slice_multisite.rb')
9
+
10
+ # Require merb_auth_slice_multisite.rb explicitly so any dependencies are loaded
11
+ require Merb::Plugins.config[:merb_slices][:search_path]
12
+
13
+ # Using Merb.root below makes sure that the correct root is set for
14
+ # - testing standalone, without being installed as a gem and no host application
15
+ # - testing from within the host application; its root will be used
16
+ Merb.start_environment(
17
+ :testing => true,
18
+ :adapter => 'runner',
19
+ :environment => ENV['MERB_ENV'] || 'test',
20
+ :session_store => 'memory'
21
+ )
22
+
23
+ module Merb
24
+ module Test
25
+ module SliceHelper
26
+
27
+ # The absolute path to the current slice
28
+ def current_slice_root
29
+ @current_slice_root ||= File.expand_path(File.join(File.dirname(__FILE__), '..'))
30
+ end
31
+
32
+ # Whether the specs are being run from a host application or standalone
33
+ def standalone?
34
+ Merb.root == ::MerbAuthSliceMultisite.root
35
+ end
36
+
37
+ end
38
+ end
39
+ end
40
+
41
+ Spec::Runner.configure do |config|
42
+ config.include(Merb::Test::ViewHelper)
43
+ config.include(Merb::Test::RouteHelper)
44
+ config.include(Merb::Test::ControllerHelper)
45
+ config.include(Merb::Test::SliceHelper)
46
+ end
47
+
48
+ # You can add your own helpers here
49
+ #
50
+ Merb::Test.add_helpers do
51
+ def mount_slice
52
+ Merb::Router.prepare { add_slice(:MerbAuthSliceMultisite, "merb_auth_slice_multisite") } if standalone?
53
+ end
54
+
55
+ def dismount_slice
56
+ Merb::Router.reset! if standalone?
57
+ end
58
+ end
@@ -0,0 +1,7 @@
1
+ require 'test_helper'
2
+
3
+ class MerbAuthSliceMultisiteTest < Test::Unit::TestCase
4
+ should "probably rename this file and start testing for real" do
5
+ flunk "hey buddy, you should probably rename this file and start testing for real"
6
+ end
7
+ end
@@ -0,0 +1,10 @@
1
+ require 'rubygems'
2
+ require 'test/unit'
3
+ require 'shoulda'
4
+
5
+ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
6
+ $LOAD_PATH.unshift(File.dirname(__FILE__))
7
+ require 'merb_auth_slice_multisite'
8
+
9
+ class Test::Unit::TestCase
10
+ end
metadata ADDED
@@ -0,0 +1,68 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: scottmotte-merb_auth_slice_multisite
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.1
5
+ platform: ruby
6
+ authors:
7
+ - scottmotte
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+
12
+ date: 2009-03-27 00:00:00 -07:00
13
+ default_executable:
14
+ dependencies: []
15
+
16
+ description:
17
+ email: scott@scottmotte.com
18
+ executables: []
19
+
20
+ extensions: []
21
+
22
+ extra_rdoc_files:
23
+ - README.rdoc
24
+ - LICENSE
25
+ files:
26
+ - README.rdoc
27
+ - VERSION.yml
28
+ - lib/merb_auth_slice_multisite
29
+ - lib/merb_auth_slice_multisite/merbtasks.rb
30
+ - lib/merb_auth_slice_multisite/slicetasks.rb
31
+ - lib/merb_auth_slice_multisite/spectasks.rb
32
+ - lib/merb_auth_slice_multisite.rb
33
+ - test/merb_auth_slice_multisite_test.rb
34
+ - test/test_helper.rb
35
+ - spec/merb_auth_slice_multisite_spec.rb
36
+ - spec/requests
37
+ - spec/requests/main_spec.rb
38
+ - spec/spec_helper.rb
39
+ - LICENSE
40
+ has_rdoc: true
41
+ homepage: http://github.com/scottmotte/merb_auth_slice_multisite
42
+ post_install_message:
43
+ rdoc_options:
44
+ - --inline-source
45
+ - --charset=UTF-8
46
+ require_paths:
47
+ - lib
48
+ required_ruby_version: !ruby/object:Gem::Requirement
49
+ requirements:
50
+ - - ">="
51
+ - !ruby/object:Gem::Version
52
+ version: "0"
53
+ version:
54
+ required_rubygems_version: !ruby/object:Gem::Requirement
55
+ requirements:
56
+ - - ">="
57
+ - !ruby/object:Gem::Version
58
+ version: "0"
59
+ version:
60
+ requirements: []
61
+
62
+ rubyforge_project:
63
+ rubygems_version: 1.2.0
64
+ signing_key:
65
+ specification_version: 2
66
+ summary: add multisite/subdomain functionality to your merb app on top of merb-auth
67
+ test_files: []
68
+