mjs 0.0.6

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/lib/mjs.rb ADDED
@@ -0,0 +1,86 @@
1
+ if defined?(Merb::Plugins)
2
+
3
+ $:.unshift File.dirname(__FILE__)
4
+
5
+ dependency 'merb-slices', :immediate => true
6
+ Merb::Plugins.add_rakefiles "mjs/merbtasks", "mjs/slicetasks", "mjs/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 :mjs
17
+ # :mirror - which path component types to use on copy operations; defaults to all
18
+ Merb::Slices::config[:mjs][:layout] ||= :mjs
19
+
20
+ # All Slice code is expected to be namespaced inside a module
21
+ module Mjs
22
+
23
+ # Slice metadata
24
+ self.description = "A slice for the Merb framework that offers Ajax actions like RJS with jQuery"
25
+ self.version = "0.0.1"
26
+ self.author = "maiha"
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
+ require 'mjs/helper'
32
+ end
33
+
34
+ # Initialization hook - runs before AfterAppLoads BootLoader
35
+ def self.init
36
+ Merb::Controller.send(:include, ::Mjs::Helper)
37
+ end
38
+
39
+ # Activation hook - runs after AfterAppLoads BootLoader
40
+ def self.activate
41
+ end
42
+
43
+ # Deactivation hook - triggered by Merb::Slices.deactivate(Mjs)
44
+ def self.deactivate
45
+ end
46
+
47
+ # Setup routes inside the host application
48
+ #
49
+ # @param scope<Merb::Router::Behaviour>
50
+ # Routes will be added within this scope (namespace). In fact, any
51
+ # router behaviour is a valid namespace, so you can attach
52
+ # routes at any level of your router setup.
53
+ #
54
+ # @note prefix your named routes with :mjs_
55
+ # to avoid potential conflicts with global named routes.
56
+ def self.setup_router(scope)
57
+ # example of a named route
58
+ scope.match('/index(.:format)').to(:controller => 'main', :action => 'index').name(:index)
59
+ # the slice is mounted at /mjs - note that it comes before default_routes
60
+ scope.match('/').to(:controller => 'main', :action => 'index').name(:home)
61
+ # enable slice-level default routes by default
62
+ scope.default_routes
63
+ end
64
+
65
+ end
66
+
67
+ # Setup the slice layout for Mjs
68
+ #
69
+ # Use Mjs.push_path and Mjs.push_app_path
70
+ # to set paths to mjs-level and app-level paths. Example:
71
+ #
72
+ # Mjs.push_path(:application, Mjs.root)
73
+ # Mjs.push_app_path(:application, Merb.root / 'slices' / 'mjs')
74
+ # ...
75
+ #
76
+ # Any component path that hasn't been set will default to Mjs.root
77
+ #
78
+ # Or just call setup_default_structure! to setup a basic Merb MVC structure.
79
+ Mjs.setup_default_structure!
80
+
81
+ # Add dependencies for other Mjs classes below. Example:
82
+ # dependency "mjs/other"
83
+
84
+
85
+
86
+ end
File without changes
@@ -0,0 +1,2 @@
1
+ html, body { margin: 0; padding: 0; }
2
+ #container { width: 800px; margin: 4em auto; padding: 4em 4em 6em 4em; background: #DDDDDD; }
data/spec/mjs_spec.rb ADDED
@@ -0,0 +1,20 @@
1
+ require File.dirname(__FILE__) + '/spec_helper'
2
+
3
+ describe "Mjs (module)" do
4
+
5
+ # Implement your Mjs specs here
6
+
7
+ # To spec Mjs you need to hook it up to the router like this:
8
+
9
+ # before :all do
10
+ # Merb::Router.prepare { add_slice(:Mjs) } 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 "/mjs/" do
4
+
5
+ before(:all) do
6
+ mount_slice
7
+ end
8
+
9
+ describe "GET /" do
10
+
11
+ before(:each) do
12
+ @response = request("/mjs/")
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 => "Mjs 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 mjs.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', 'mjs.rb')
9
+
10
+ # Require mjs.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 == ::Mjs.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(:Mjs, "mjs") } if standalone?
53
+ end
54
+
55
+ def dismount_slice
56
+ Merb::Router.reset! if standalone?
57
+ end
58
+ end
@@ -0,0 +1,2 @@
1
+ class Mjs::Application < Merb::Controller
2
+ end
@@ -0,0 +1,2 @@
1
+ class Mjs::Main < Mjs::Application
2
+ end
metadata ADDED
@@ -0,0 +1,89 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: mjs
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.6
5
+ platform: ruby
6
+ authors:
7
+ - maiha
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+
12
+ date: 2009-12-18 00:00:00 +09:00
13
+ default_executable:
14
+ dependencies:
15
+ - !ruby/object:Gem::Dependency
16
+ name: merb-slices
17
+ type: :runtime
18
+ version_requirement:
19
+ version_requirements: !ruby/object:Gem::Requirement
20
+ requirements:
21
+ - - ">="
22
+ - !ruby/object:Gem::Version
23
+ version: 1.0.7.1
24
+ version:
25
+ description: A slice for the Merb framework that offers Ajax actions like RJS with jQuery
26
+ email: maiha@wota.jp
27
+ executables: []
28
+
29
+ extensions: []
30
+
31
+ extra_rdoc_files:
32
+ - README
33
+ - LICENSE
34
+ - TODO
35
+ files:
36
+ - LICENSE
37
+ - README
38
+ - Rakefile
39
+ - TODO
40
+ - lib/mjs.rb
41
+ - lib/mjs/spectasks.rb
42
+ - lib/mjs/helper.rb
43
+ - lib/mjs/utils.rb
44
+ - lib/mjs/page_object.rb
45
+ - lib/mjs/slicetasks.rb
46
+ - lib/mjs/merbtasks.rb
47
+ - lib/mjs/java_script_context.rb
48
+ - spec/mjs_spec.rb
49
+ - spec/spec_helper.rb
50
+ - spec/requests/main_spec.rb
51
+ - app/views/layout/mjs.html.erb
52
+ - app/views/main/index.html.erb
53
+ - app/controllers/main.rb
54
+ - app/controllers/application.rb
55
+ - app/helpers/application_helper.rb
56
+ - public/stylesheets/master.css
57
+ - public/javascripts/master.js
58
+ - stubs/app/controllers/main.rb
59
+ - stubs/app/controllers/application.rb
60
+ has_rdoc: true
61
+ homepage: http://github.com/maiha/mjs
62
+ licenses: []
63
+
64
+ post_install_message:
65
+ rdoc_options: []
66
+
67
+ require_paths:
68
+ - lib
69
+ required_ruby_version: !ruby/object:Gem::Requirement
70
+ requirements:
71
+ - - ">="
72
+ - !ruby/object:Gem::Version
73
+ version: "0"
74
+ version:
75
+ required_rubygems_version: !ruby/object:Gem::Requirement
76
+ requirements:
77
+ - - ">="
78
+ - !ruby/object:Gem::Version
79
+ version: "0"
80
+ version:
81
+ requirements: []
82
+
83
+ rubyforge_project: merb
84
+ rubygems_version: 1.3.5
85
+ signing_key:
86
+ specification_version: 3
87
+ summary: A slice for the Merb framework that offers Ajax actions like RJS with jQuery
88
+ test_files: []
89
+