sumatra-rails 0.0.2 → 0.0.3.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +15 -0
- data/.gitignore +8 -0
- data/Gemfile +17 -0
- data/Gemfile.lock +107 -0
- data/lib/sumatra/rails/version.rb +1 -1
- data/script/rails +8 -0
- data/sumatra-rails.gemspec +22 -0
- data/test/dummy/app/mailers/.gitkeep +0 -0
- data/test/dummy/app/models/.gitkeep +0 -0
- data/test/dummy/lib/assets/.gitkeep +0 -0
- data/test/dummy/log/.gitkeep +0 -0
- data/vendor/assets/javascripts/sumatra.js.coffee +121 -0
- metadata +22 -26
checksums.yaml
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
---
|
2
|
+
!binary "U0hBMQ==":
|
3
|
+
metadata.gz: !binary |-
|
4
|
+
NmFmY2ZmN2IxMWU4NjJkNWQ0ZTExODEzNGZhYTE5NjQ0Mzc2ZWFjZQ==
|
5
|
+
data.tar.gz: !binary |-
|
6
|
+
ZTU2MzU3MmYxMzkzNWE3N2JhM2QxNThlZDA4MjE0YjJiZmQ5ODU2Nw==
|
7
|
+
!binary "U0hBNTEy":
|
8
|
+
metadata.gz: !binary |-
|
9
|
+
MDc4ZDRkZjdhZjBlYTQ1OTI4NjNmYzUzYjhjMTc3NWJkNWI3ZmY1N2IyNTg1
|
10
|
+
NGFkMWUxM2VmMzBlNGY2YjViMzI0MWQwYjhkNDRjZmY2ZjUxZGJiZmZmYTJj
|
11
|
+
OWU1Nzk2OWZhZGM4NzEyZGM3NTQ2YmY0YjkxODZhOGJlODYyODM=
|
12
|
+
data.tar.gz: !binary |-
|
13
|
+
Mjc4YmQ2MjdmZDU5NDY0NTRmMWE5NDQyZDVjNzU1ZWE0NGRjYjRlYmVkY2Rk
|
14
|
+
ZDJmOGVkNTYyNDlmOTg0MjZjYzM4YTc5YmUyNDBmMTU1OTJmYjZiNzAzYzMy
|
15
|
+
ZDhjOGM0ZjAxZGIyNDY1YTA1NDZjMmYxMjQ5ZDk1ZTA1YjFhMjY=
|
data/.gitignore
ADDED
data/Gemfile
ADDED
@@ -0,0 +1,17 @@
|
|
1
|
+
source "http://rubygems.org"
|
2
|
+
|
3
|
+
# Declare your gem's dependencies in sumatra.gemspec.
|
4
|
+
# Bundler will treat runtime dependencies like base dependencies, and
|
5
|
+
# development dependencies will be added by default to the :development group.
|
6
|
+
gemspec
|
7
|
+
|
8
|
+
# jquery-rails is used by the dummy application
|
9
|
+
gem "jquery-rails"
|
10
|
+
|
11
|
+
# Declare any dependencies that are still in development here instead of in
|
12
|
+
# your gemspec. These might include edge Rails or gems from your path or
|
13
|
+
# Git. Remember to move these dependencies to your gemspec before releasing
|
14
|
+
# your gem to rubygems.org.
|
15
|
+
|
16
|
+
# To use debugger
|
17
|
+
# gem 'debugger'
|
data/Gemfile.lock
ADDED
@@ -0,0 +1,107 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
sumatra-rails (0.0.3.1)
|
5
|
+
coffee-rails
|
6
|
+
jquery-rails
|
7
|
+
rails (~> 3.2.12)
|
8
|
+
|
9
|
+
GEM
|
10
|
+
remote: http://rubygems.org/
|
11
|
+
specs:
|
12
|
+
actionmailer (3.2.12)
|
13
|
+
actionpack (= 3.2.12)
|
14
|
+
mail (~> 2.4.4)
|
15
|
+
actionpack (3.2.12)
|
16
|
+
activemodel (= 3.2.12)
|
17
|
+
activesupport (= 3.2.12)
|
18
|
+
builder (~> 3.0.0)
|
19
|
+
erubis (~> 2.7.0)
|
20
|
+
journey (~> 1.0.4)
|
21
|
+
rack (~> 1.4.5)
|
22
|
+
rack-cache (~> 1.2)
|
23
|
+
rack-test (~> 0.6.1)
|
24
|
+
sprockets (~> 2.2.1)
|
25
|
+
activemodel (3.2.12)
|
26
|
+
activesupport (= 3.2.12)
|
27
|
+
builder (~> 3.0.0)
|
28
|
+
activerecord (3.2.12)
|
29
|
+
activemodel (= 3.2.12)
|
30
|
+
activesupport (= 3.2.12)
|
31
|
+
arel (~> 3.0.2)
|
32
|
+
tzinfo (~> 0.3.29)
|
33
|
+
activeresource (3.2.12)
|
34
|
+
activemodel (= 3.2.12)
|
35
|
+
activesupport (= 3.2.12)
|
36
|
+
activesupport (3.2.12)
|
37
|
+
i18n (~> 0.6)
|
38
|
+
multi_json (~> 1.0)
|
39
|
+
arel (3.0.2)
|
40
|
+
builder (3.0.4)
|
41
|
+
coffee-rails (3.2.2)
|
42
|
+
coffee-script (>= 2.2.0)
|
43
|
+
railties (~> 3.2.0)
|
44
|
+
coffee-script (2.2.0)
|
45
|
+
coffee-script-source
|
46
|
+
execjs
|
47
|
+
coffee-script-source (1.6.1)
|
48
|
+
erubis (2.7.0)
|
49
|
+
execjs (1.4.0)
|
50
|
+
multi_json (~> 1.0)
|
51
|
+
hike (1.2.1)
|
52
|
+
i18n (0.6.4)
|
53
|
+
journey (1.0.4)
|
54
|
+
jquery-rails (2.2.1)
|
55
|
+
railties (>= 3.0, < 5.0)
|
56
|
+
thor (>= 0.14, < 2.0)
|
57
|
+
json (1.7.7)
|
58
|
+
mail (2.4.4)
|
59
|
+
i18n (>= 0.4.0)
|
60
|
+
mime-types (~> 1.16)
|
61
|
+
treetop (~> 1.4.8)
|
62
|
+
mime-types (1.21)
|
63
|
+
multi_json (1.6.1)
|
64
|
+
polyglot (0.3.3)
|
65
|
+
rack (1.4.5)
|
66
|
+
rack-cache (1.2)
|
67
|
+
rack (>= 0.4)
|
68
|
+
rack-ssl (1.3.3)
|
69
|
+
rack
|
70
|
+
rack-test (0.6.2)
|
71
|
+
rack (>= 1.0)
|
72
|
+
rails (3.2.12)
|
73
|
+
actionmailer (= 3.2.12)
|
74
|
+
actionpack (= 3.2.12)
|
75
|
+
activerecord (= 3.2.12)
|
76
|
+
activeresource (= 3.2.12)
|
77
|
+
activesupport (= 3.2.12)
|
78
|
+
bundler (~> 1.0)
|
79
|
+
railties (= 3.2.12)
|
80
|
+
railties (3.2.12)
|
81
|
+
actionpack (= 3.2.12)
|
82
|
+
activesupport (= 3.2.12)
|
83
|
+
rack-ssl (~> 1.3.2)
|
84
|
+
rake (>= 0.8.7)
|
85
|
+
rdoc (~> 3.4)
|
86
|
+
thor (>= 0.14.6, < 2.0)
|
87
|
+
rake (10.0.3)
|
88
|
+
rdoc (3.12.2)
|
89
|
+
json (~> 1.4)
|
90
|
+
sprockets (2.2.2)
|
91
|
+
hike (~> 1.2)
|
92
|
+
multi_json (~> 1.0)
|
93
|
+
rack (~> 1.0)
|
94
|
+
tilt (~> 1.1, != 1.3.0)
|
95
|
+
thor (0.17.0)
|
96
|
+
tilt (1.3.5)
|
97
|
+
treetop (1.4.12)
|
98
|
+
polyglot
|
99
|
+
polyglot (>= 0.3.1)
|
100
|
+
tzinfo (0.3.37)
|
101
|
+
|
102
|
+
PLATFORMS
|
103
|
+
ruby
|
104
|
+
|
105
|
+
DEPENDENCIES
|
106
|
+
jquery-rails
|
107
|
+
sumatra-rails!
|
data/script/rails
ADDED
@@ -0,0 +1,8 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# This command will automatically be run when you run "rails" with Rails 3 gems installed from the root of your application.
|
3
|
+
|
4
|
+
ENGINE_ROOT = File.expand_path('../..', __FILE__)
|
5
|
+
ENGINE_PATH = File.expand_path('../../lib/sumatra/engine', __FILE__)
|
6
|
+
|
7
|
+
require 'rails/all'
|
8
|
+
require 'rails/engine/commands'
|
@@ -0,0 +1,22 @@
|
|
1
|
+
$:.push File.expand_path("../lib", __FILE__)
|
2
|
+
|
3
|
+
# Maintain your gem's version:
|
4
|
+
require "sumatra/rails/version"
|
5
|
+
|
6
|
+
# Describe your gem and declare its dependencies:
|
7
|
+
Gem::Specification.new do |s|
|
8
|
+
s.name = "sumatra-rails"
|
9
|
+
s.version = Sumatra::Rails::VERSION
|
10
|
+
s.authors = ["Tom Scott"]
|
11
|
+
s.email = ["tubbo@psychedeli.ca"]
|
12
|
+
s.homepage = "http://github.com/tubbo/sumatra-rails"
|
13
|
+
s.summary = "Sumatra is a CoffeeScript framework for writing beautiful jQuery plugins."
|
14
|
+
s.description = "Sumatra is a CoffeeScript framework for writing beautiful jQuery plugins."
|
15
|
+
|
16
|
+
s.files = `git ls-files`.split("\n")
|
17
|
+
s.test_files = Dir["test/**/*"]
|
18
|
+
|
19
|
+
s.add_dependency "rails", "~> 3.2.12"
|
20
|
+
s.add_dependency "jquery-rails"
|
21
|
+
s.add_dependency "coffee-rails"
|
22
|
+
end
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
@@ -0,0 +1,121 @@
|
|
1
|
+
# SumatraPlugin
|
2
|
+
# -------------
|
3
|
+
#
|
4
|
+
# A prototype object for common actions when defining jQuery plugins
|
5
|
+
# in the Sumatra framework. It is designed so that you never have to
|
6
|
+
# override the constructor. Instead, the constructor sets up a common
|
7
|
+
# method interface for both initialization (which would happen after
|
8
|
+
# construction) and the binding of events, a common task in jQuery
|
9
|
+
# plugins. This prototype even handles some of that for you, with
|
10
|
+
# the default `bindEvents()` being bound to call the `perform()`
|
11
|
+
# method (which must be defined by the object extending `SumatraPlugin`)
|
12
|
+
# whenever the element it was constructed with triggers the event
|
13
|
+
# defined by `action`.
|
14
|
+
#
|
15
|
+
# So essentially, you can define almost any jQuery plugin using this
|
16
|
+
# interface, even though the only thing binding it to the `sumatra`
|
17
|
+
# function is its constructor that takes 3 parameters.
|
18
|
+
#
|
19
|
+
# `SumatraPlugin` also has facilities for dealing with an options hash
|
20
|
+
# and merging said options with defaults. You can define the default
|
21
|
+
# options for your plugin like so:
|
22
|
+
#
|
23
|
+
# sumatra 'clickToGo', ->
|
24
|
+
# class ClickToGo extends SumatraPlugin
|
25
|
+
# action: 'click'
|
26
|
+
# defaults: { to: 'http://google.com' }
|
27
|
+
# perform: (event) =>
|
28
|
+
# if confirm "Are you sure you want to go to #{@options.goTo}?"
|
29
|
+
# window.location = @options.goTo
|
30
|
+
#
|
31
|
+
# Then, when instantiating, just override them.
|
32
|
+
#
|
33
|
+
# $('a').clickToGo(to: 'http://yahoo.com');
|
34
|
+
#
|
35
|
+
# This removes the need for writing that boilerplate options hash extend
|
36
|
+
# code every time you write a jQuery plugin that takes options. All
|
37
|
+
# plugins defined with `sumatra()` take an optional options hash, which is
|
38
|
+
# `{}` by default, in case your plugin doesn't require options.
|
39
|
+
class @SumatraPlugin
|
40
|
+
# The event to bind to if `perform()` is defined.
|
41
|
+
action: 'one'
|
42
|
+
|
43
|
+
# A hash of attributes that are extended with an options hash passed
|
44
|
+
# into the jQuery plugin upon instantiation. Useful for setting up
|
45
|
+
# data that is required.
|
46
|
+
defaults: {}
|
47
|
+
|
48
|
+
# Instantiate a `SumatraPlugin` and bind it to the current element
|
49
|
+
# with options. This also initiates the workflow.
|
50
|
+
#
|
51
|
+
# **DO NOT OVERRIDE!!**
|
52
|
+
constructor: (current_element, index_of_query, init_options) ->
|
53
|
+
@element = $(current_element)
|
54
|
+
@index = index_of_query
|
55
|
+
@options = @mergeDefaultsWith init_options
|
56
|
+
@initialize() and @bindEvents()
|
57
|
+
|
58
|
+
# Merge `options` hash with the `defaults` as set in the definition
|
59
|
+
# of this object.
|
60
|
+
mergeDefaultsWith: (options) ->
|
61
|
+
_.extend @defaults, @options
|
62
|
+
|
63
|
+
# Run custom constructor code, but blocks instantiation if this method
|
64
|
+
# returns `false`. This method was pretty much designed to be overridden.
|
65
|
+
initialize: ->
|
66
|
+
true
|
67
|
+
|
68
|
+
# Bind the `perform()` method to the `action` as set in the definition
|
69
|
+
# of this plugin. Overriding this method removes the guarantee that
|
70
|
+
# perform() will be called at all...
|
71
|
+
bindEvents: ->
|
72
|
+
if @action?
|
73
|
+
@element.on @action, @perform
|
74
|
+
|
75
|
+
# The event binding that handles `action`. Override this with your own
|
76
|
+
# method. You must override this method or the `bindEvents` method to
|
77
|
+
# get this plugin to do anything. It takes a single argument, `event`,
|
78
|
+
# which represents the given DOMEvent represented by `action` as passed
|
79
|
+
# in by `jQuery.on`.
|
80
|
+
perform: null
|
81
|
+
|
82
|
+
# SumatraRuntime
|
83
|
+
# --------------
|
84
|
+
#
|
85
|
+
# Defines a jQuery plugin using a service object with a nice,
|
86
|
+
# consistent, CoffeeScript-style interface. Plugins can extend
|
87
|
+
# `SumatraPlugin`, a prototype that makes defining plugins with
|
88
|
+
# Sumatra easier.
|
89
|
+
#
|
90
|
+
# The runtime function returns the generated jQuery plugin to the
|
91
|
+
# global scope so it can be used in your application code.
|
92
|
+
#
|
93
|
+
# Arguments:
|
94
|
+
#
|
95
|
+
# - **plugin_name:** The jQuery plugin name, called like `$('div').myPlugin();`
|
96
|
+
# - **plugin_code:** A function that will be executed immediately and must return
|
97
|
+
# a single object that takes 3 parameters in its constructor. These parameters
|
98
|
+
# are the `element` being targeted by jQuery, the `index` at which it appears
|
99
|
+
# in the query, and the `options` hash passed during the instantiation of the
|
100
|
+
# jQuery plugin.
|
101
|
+
#
|
102
|
+
# Example:
|
103
|
+
#
|
104
|
+
# sumatra 'myPlugin', ->
|
105
|
+
# class MyPlugin extends SumatraPlugin
|
106
|
+
# action: null
|
107
|
+
# initialize:
|
108
|
+
# alert 'loaded'
|
109
|
+
#
|
110
|
+
@sumatra = (plugin_name, plugin_code) ->
|
111
|
+
# Instantiate a PluginHelper and apply the current scope. This can
|
112
|
+
# be any object that responds to 3 parameters in its constructor
|
113
|
+
# and will be set to whatever is returned by `plugin_code()`.
|
114
|
+
PluginHelper = plugin_code.apply this
|
115
|
+
|
116
|
+
jQuery.fn[plugin_name] = (options={}) ->
|
117
|
+
@each (index, element) ->
|
118
|
+
# For each element, create a `PluginHelper` instance
|
119
|
+
# of the passed-in `plugin_code` and apply the jQuery
|
120
|
+
# plugin parameters to the constructor.
|
121
|
+
new PluginHelper(element, index, options)
|
metadata
CHANGED
@@ -1,20 +1,18 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sumatra-rails
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
5
|
-
prerelease:
|
4
|
+
version: 0.0.3.1
|
6
5
|
platform: ruby
|
7
6
|
authors:
|
8
7
|
- Tom Scott
|
9
8
|
autorequire:
|
10
9
|
bindir: bin
|
11
10
|
cert_chain: []
|
12
|
-
date: 2013-03-
|
11
|
+
date: 2013-03-18 00:00:00.000000000 Z
|
13
12
|
dependencies:
|
14
13
|
- !ruby/object:Gem::Dependency
|
15
14
|
name: rails
|
16
15
|
requirement: !ruby/object:Gem::Requirement
|
17
|
-
none: false
|
18
16
|
requirements:
|
19
17
|
- - ~>
|
20
18
|
- !ruby/object:Gem::Version
|
@@ -22,7 +20,6 @@ dependencies:
|
|
22
20
|
type: :runtime
|
23
21
|
prerelease: false
|
24
22
|
version_requirements: !ruby/object:Gem::Requirement
|
25
|
-
none: false
|
26
23
|
requirements:
|
27
24
|
- - ~>
|
28
25
|
- !ruby/object:Gem::Version
|
@@ -30,7 +27,6 @@ dependencies:
|
|
30
27
|
- !ruby/object:Gem::Dependency
|
31
28
|
name: jquery-rails
|
32
29
|
requirement: !ruby/object:Gem::Requirement
|
33
|
-
none: false
|
34
30
|
requirements:
|
35
31
|
- - ! '>='
|
36
32
|
- !ruby/object:Gem::Version
|
@@ -38,7 +34,6 @@ dependencies:
|
|
38
34
|
type: :runtime
|
39
35
|
prerelease: false
|
40
36
|
version_requirements: !ruby/object:Gem::Requirement
|
41
|
-
none: false
|
42
37
|
requirements:
|
43
38
|
- - ! '>='
|
44
39
|
- !ruby/object:Gem::Version
|
@@ -46,7 +41,6 @@ dependencies:
|
|
46
41
|
- !ruby/object:Gem::Dependency
|
47
42
|
name: coffee-rails
|
48
43
|
requirement: !ruby/object:Gem::Requirement
|
49
|
-
none: false
|
50
44
|
requirements:
|
51
45
|
- - ! '>='
|
52
46
|
- !ruby/object:Gem::Version
|
@@ -54,7 +48,6 @@ dependencies:
|
|
54
48
|
type: :runtime
|
55
49
|
prerelease: false
|
56
50
|
version_requirements: !ruby/object:Gem::Requirement
|
57
|
-
none: false
|
58
51
|
requirements:
|
59
52
|
- - ! '>='
|
60
53
|
- !ruby/object:Gem::Version
|
@@ -66,19 +59,29 @@ executables: []
|
|
66
59
|
extensions: []
|
67
60
|
extra_rdoc_files: []
|
68
61
|
files:
|
62
|
+
- .gitignore
|
63
|
+
- Gemfile
|
64
|
+
- Gemfile.lock
|
65
|
+
- LICENSE.md
|
66
|
+
- README.md
|
67
|
+
- Rakefile
|
69
68
|
- config/routes.rb
|
69
|
+
- lib/sumatra-rails.rb
|
70
70
|
- lib/sumatra/rails/engine.rb
|
71
71
|
- lib/sumatra/rails/version.rb
|
72
|
-
- lib/sumatra-rails.rb
|
73
72
|
- lib/tasks/sumatra_tasks.rake
|
74
|
-
-
|
75
|
-
-
|
76
|
-
- README.
|
73
|
+
- script/rails
|
74
|
+
- sumatra-rails.gemspec
|
75
|
+
- test/dummy/README.rdoc
|
76
|
+
- test/dummy/Rakefile
|
77
77
|
- test/dummy/app/assets/javascripts/application.js
|
78
78
|
- test/dummy/app/assets/stylesheets/application.css
|
79
79
|
- test/dummy/app/controllers/application_controller.rb
|
80
80
|
- test/dummy/app/helpers/application_helper.rb
|
81
|
+
- test/dummy/app/mailers/.gitkeep
|
82
|
+
- test/dummy/app/models/.gitkeep
|
81
83
|
- test/dummy/app/views/layouts/application.html.erb
|
84
|
+
- test/dummy/config.ru
|
82
85
|
- test/dummy/config/application.rb
|
83
86
|
- test/dummy/config/boot.rb
|
84
87
|
- test/dummy/config/database.yml
|
@@ -94,46 +97,39 @@ files:
|
|
94
97
|
- test/dummy/config/initializers/wrap_parameters.rb
|
95
98
|
- test/dummy/config/locales/en.yml
|
96
99
|
- test/dummy/config/routes.rb
|
97
|
-
- test/dummy/
|
100
|
+
- test/dummy/lib/assets/.gitkeep
|
101
|
+
- test/dummy/log/.gitkeep
|
98
102
|
- test/dummy/public/404.html
|
99
103
|
- test/dummy/public/422.html
|
100
104
|
- test/dummy/public/500.html
|
101
105
|
- test/dummy/public/favicon.ico
|
102
|
-
- test/dummy/Rakefile
|
103
|
-
- test/dummy/README.rdoc
|
104
106
|
- test/dummy/script/rails
|
105
107
|
- test/integration/navigation_test.rb
|
106
108
|
- test/sumatra_test.rb
|
107
109
|
- test/test_helper.rb
|
110
|
+
- vendor/assets/javascripts/sumatra.js.coffee
|
108
111
|
homepage: http://github.com/tubbo/sumatra-rails
|
109
112
|
licenses: []
|
113
|
+
metadata: {}
|
110
114
|
post_install_message:
|
111
115
|
rdoc_options: []
|
112
116
|
require_paths:
|
113
117
|
- lib
|
114
118
|
required_ruby_version: !ruby/object:Gem::Requirement
|
115
|
-
none: false
|
116
119
|
requirements:
|
117
120
|
- - ! '>='
|
118
121
|
- !ruby/object:Gem::Version
|
119
122
|
version: '0'
|
120
|
-
segments:
|
121
|
-
- 0
|
122
|
-
hash: 4448772707311110201
|
123
123
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
124
|
-
none: false
|
125
124
|
requirements:
|
126
125
|
- - ! '>='
|
127
126
|
- !ruby/object:Gem::Version
|
128
127
|
version: '0'
|
129
|
-
segments:
|
130
|
-
- 0
|
131
|
-
hash: 4448772707311110201
|
132
128
|
requirements: []
|
133
129
|
rubyforge_project:
|
134
|
-
rubygems_version:
|
130
|
+
rubygems_version: 2.0.0
|
135
131
|
signing_key:
|
136
|
-
specification_version:
|
132
|
+
specification_version: 4
|
137
133
|
summary: Sumatra is a CoffeeScript framework for writing beautiful jQuery plugins.
|
138
134
|
test_files:
|
139
135
|
- test/dummy/app/assets/javascripts/application.js
|