maiha-mjs 0.0.2
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 +20 -0
- data/README +89 -0
- data/Rakefile +55 -0
- data/TODO +15 -0
- data/app/controllers/application.rb +5 -0
- data/app/controllers/main.rb +7 -0
- data/app/helpers/application_helper.rb +63 -0
- data/app/views/layout/mjs.html.erb +16 -0
- data/app/views/main/index.html.erb +1 -0
- data/lib/mjs.rb +86 -0
- data/lib/mjs/helper.rb +40 -0
- data/lib/mjs/java_script_context.rb +478 -0
- data/lib/mjs/merbtasks.rb +103 -0
- data/lib/mjs/page_object.rb +16 -0
- data/lib/mjs/slicetasks.rb +20 -0
- data/lib/mjs/spectasks.rb +53 -0
- data/lib/mjs/utils.rb +13 -0
- data/public/javascripts/master.js +0 -0
- data/public/stylesheets/master.css +2 -0
- data/spec/mjs_spec.rb +20 -0
- data/spec/requests/main_spec.rb +30 -0
- data/spec/spec_helper.rb +58 -0
- data/stubs/app/controllers/application.rb +2 -0
- data/stubs/app/controllers/main.rb +2 -0
- metadata +97 -0
@@ -0,0 +1,103 @@
|
|
1
|
+
namespace :slices do
|
2
|
+
namespace :mjs do
|
3
|
+
|
4
|
+
desc "Install Mjs"
|
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
|
+
Mjs.mirrored_components.each do |type|
|
15
|
+
if File.directory?(Mjs.dir_for(type))
|
16
|
+
if !File.directory?(dst_path = Mjs.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 Mjs - resolves any collisions"
|
28
|
+
# copied, preserved = Mjs.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 Mjs - resolves any collisions"
|
40
|
+
copied, preserved = Mjs.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 Mjs into your app (only mjs/app)"
|
51
|
+
task :freeze => [ "freeze:app" ]
|
52
|
+
|
53
|
+
namespace :freeze do
|
54
|
+
|
55
|
+
# desc "Freezes Mjs by installing the gem into application/gems"
|
56
|
+
# task :gem do
|
57
|
+
# ENV["GEM"] ||= "mjs"
|
58
|
+
# Rake::Task['slices:install_as_gem'].invoke
|
59
|
+
# end
|
60
|
+
|
61
|
+
desc "Freezes Mjs by copying all files from mjs/app to your application"
|
62
|
+
task :app do
|
63
|
+
puts "Copying all mjs/app files to your application - resolves any collisions"
|
64
|
+
copied, preserved = Mjs.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 = Mjs.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 = Mjs.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 Mjs as a gem and copies over mjs/app"
|
89
|
+
task :app_with_gem => [:gem, :app]
|
90
|
+
|
91
|
+
desc "Freezes Mjs by unpacking all files into your application"
|
92
|
+
task :unpack do
|
93
|
+
puts "Unpacking Mjs files to your application - resolves any collisions"
|
94
|
+
copied, preserved = Mjs.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 :mjs do
|
3
|
+
|
4
|
+
# add your own mjs 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 :mjs 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 Mjs 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
|
data/lib/mjs/utils.rb
ADDED
@@ -0,0 +1,13 @@
|
|
1
|
+
module Mjs
|
2
|
+
module Utils
|
3
|
+
def self.camelize(lower_case_and_underscored_word, first_letter = :upper)
|
4
|
+
lower_case_and_underscored_word = lower_case_and_underscored_word.to_s
|
5
|
+
first_letter_in_uppercase = (first_letter == :upper)
|
6
|
+
if first_letter_in_uppercase
|
7
|
+
lower_case_and_underscored_word.to_s.gsub(/\/(.?)/) { "::#{$1.upcase}" }.gsub(/(?:^|_)(.)/) { $1.upcase }
|
8
|
+
else
|
9
|
+
lower_case_and_underscored_word[0,1].downcase + camelize(lower_case_and_underscored_word)[1..-1]
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
File without changes
|
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
|
data/spec/spec_helper.rb
ADDED
@@ -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
|
metadata
ADDED
@@ -0,0 +1,97 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: maiha-mjs
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.2
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- maiha
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
|
12
|
+
date: 2009-01-12 00:00:00 -08:00
|
13
|
+
default_executable:
|
14
|
+
dependencies:
|
15
|
+
- !ruby/object:Gem::Dependency
|
16
|
+
name: merb-slices
|
17
|
+
version_requirement:
|
18
|
+
version_requirements: !ruby/object:Gem::Requirement
|
19
|
+
requirements:
|
20
|
+
- - ">="
|
21
|
+
- !ruby/object:Gem::Version
|
22
|
+
version: 1.0.7.1
|
23
|
+
version:
|
24
|
+
description: A slice for the Merb framework that offers Ajax actions like RJS with jQuery
|
25
|
+
email: maiha@wota.jp
|
26
|
+
executables: []
|
27
|
+
|
28
|
+
extensions: []
|
29
|
+
|
30
|
+
extra_rdoc_files:
|
31
|
+
- README
|
32
|
+
- LICENSE
|
33
|
+
- TODO
|
34
|
+
files:
|
35
|
+
- LICENSE
|
36
|
+
- README
|
37
|
+
- Rakefile
|
38
|
+
- TODO
|
39
|
+
- lib/mjs.rb
|
40
|
+
- lib/mjs
|
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
|
51
|
+
- spec/requests/main_spec.rb
|
52
|
+
- app/views
|
53
|
+
- app/views/layout
|
54
|
+
- app/views/layout/mjs.html.erb
|
55
|
+
- app/views/main
|
56
|
+
- app/views/main/index.html.erb
|
57
|
+
- app/controllers
|
58
|
+
- app/controllers/main.rb
|
59
|
+
- app/controllers/application.rb
|
60
|
+
- app/helpers
|
61
|
+
- app/helpers/application_helper.rb
|
62
|
+
- public/stylesheets
|
63
|
+
- public/stylesheets/master.css
|
64
|
+
- public/javascripts
|
65
|
+
- public/javascripts/master.js
|
66
|
+
- stubs/app
|
67
|
+
- stubs/app/controllers
|
68
|
+
- stubs/app/controllers/main.rb
|
69
|
+
- stubs/app/controllers/application.rb
|
70
|
+
has_rdoc: true
|
71
|
+
homepage: http://github.com/maiha/mjs
|
72
|
+
post_install_message:
|
73
|
+
rdoc_options: []
|
74
|
+
|
75
|
+
require_paths:
|
76
|
+
- lib
|
77
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
78
|
+
requirements:
|
79
|
+
- - ">="
|
80
|
+
- !ruby/object:Gem::Version
|
81
|
+
version: "0"
|
82
|
+
version:
|
83
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
84
|
+
requirements:
|
85
|
+
- - ">="
|
86
|
+
- !ruby/object:Gem::Version
|
87
|
+
version: "0"
|
88
|
+
version:
|
89
|
+
requirements: []
|
90
|
+
|
91
|
+
rubyforge_project: merb
|
92
|
+
rubygems_version: 1.2.0
|
93
|
+
signing_key:
|
94
|
+
specification_version: 2
|
95
|
+
summary: A slice for the Merb framework that offers Ajax actions like RJS with jQuery
|
96
|
+
test_files: []
|
97
|
+
|