sudojs-rails 0.1.7 → 0.1.9
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/README.md +83 -3
- data/Rakefile +5 -3
- data/lib/sudojs/version.rb +1 -1
- data/vendor/assets/javascripts/es5-sham +25 -0
- data/vendor/assets/javascripts/es5-shim +948 -0
- data/vendor/assets/javascripts/sudo-x.js +341 -262
- data/vendor/assets/javascripts/sudo.js +222 -191
- metadata +6 -4
data/README.md
CHANGED
@@ -70,12 +70,92 @@ Before use, a few steps need to be followed to prepare your project for our pref
|
|
70
70
|
### In Practice
|
71
71
|
|
72
72
|
running the command `rails g` would reveal that a single `sudojs:install` command can be made. Execute the command
|
73
|
-
`rails g sudojs:install -h` to see the USAGE directives. Running `rails g sudojs:install Spam` will install the correct files
|
73
|
+
`rails g sudojs:install -h` (or see below) to see the USAGE directives. Running `rails g sudojs:install Spam` will install the correct files
|
74
74
|
and directories (with your shiny new `Spam` namespace).
|
75
75
|
|
76
|
+
#### sudojs:install USAGE
|
77
|
+
|
78
|
+
Description:
|
79
|
+
Install sudo.js along with it's particular directory hierarchy.
|
80
|
+
|
81
|
+
Example:
|
82
|
+
rails g sudojs:install namespace [which_sudo] [which_markup] [use_coffee]
|
83
|
+
|
84
|
+
The only mandatory argument is the initial `namespace`.
|
85
|
+
|
86
|
+
The install generator uses these optional arguments to expand the values in the sudo_js.yml file:
|
87
|
+
1. `which_sudo` => which version of sudo.js are you loading? As sudo.js can be rebuilt into any number
|
88
|
+
of custom configurations, indicate here what name should be placed into the application manifest.
|
89
|
+
Defaults to 'sudo-x' if omitted.
|
90
|
+
2. `which_markup` => defaults to `erb`.
|
91
|
+
3. `use_coffee` => defaults to `false` pass `true` if you are of the coffee persuasion.
|
92
|
+
|
93
|
+
This will create:
|
94
|
+
app/
|
95
|
+
assets/
|
96
|
+
javascripts/
|
97
|
+
application/
|
98
|
+
yourNamespace.js
|
99
|
+
model.js
|
100
|
+
manifests/
|
101
|
+
application.js
|
102
|
+
views/
|
103
|
+
config/
|
104
|
+
sudo_js.yml
|
105
|
+
|
106
|
+
#### sudojs:class USAGE
|
107
|
+
|
76
108
|
After installing a second generator becomes available, run `rails g` again and `sudojs:class` should now be an option.
|
77
|
-
The reason for this is that `:class` depends on a yaml file to be placed in `config/` to function.
|
78
|
-
`rails g sudojs:class -h`
|
109
|
+
The reason for this is that `:class` depends on a yaml file to be placed in `config/` to function. Executing the command
|
110
|
+
`rails g sudojs:class -h` would reveal this:
|
111
|
+
|
112
|
+
Description:
|
113
|
+
Create a skeletal sudo.js Class and place the files correctly for a given controller#name.
|
114
|
+
|
115
|
+
Example:
|
116
|
+
`rails g sudojs:class View foo#baz`
|
117
|
+
|
118
|
+
Where `View` is a Class Object that this new Object will inherit from. Sudo.js itself
|
119
|
+
will recognize 5 types:
|
120
|
+
|
121
|
+
1. 'Base'
|
122
|
+
2. 'Container'
|
123
|
+
3. 'View'
|
124
|
+
4. 'ViewController'
|
125
|
+
5. 'Dataview'
|
126
|
+
|
127
|
+
The inheritance for any of these will be set as `_.<Name>` as we assume sudo has taken the
|
128
|
+
global `_` char as an alias. If the argument is any other string we assume you are inheriting
|
129
|
+
from a custom class and pass it through as is.
|
130
|
+
|
131
|
+
|
132
|
+
Where `foo#baz` *can* match a controller#action (like `home#show`) it does not
|
133
|
+
have to. The controller argument (`foo`) allows the generator to place the file correctly and
|
134
|
+
create/modify the correct manifest file. The name argument will be the proper name of the
|
135
|
+
Class Object itself
|
136
|
+
|
137
|
+
If a corresponding views/controller/name.html.* is found, a skeletal instantiation of the newly
|
138
|
+
created View will be placed there
|
139
|
+
|
140
|
+
This will create:
|
141
|
+
app/
|
142
|
+
assests/
|
143
|
+
javascripts/
|
144
|
+
manifests/
|
145
|
+
foo.js
|
146
|
+
views/
|
147
|
+
foo/
|
148
|
+
baz.js
|
149
|
+
|
150
|
+
And modify (if found):
|
151
|
+
app/
|
152
|
+
views/
|
153
|
+
foo/
|
154
|
+
baz.html.*
|
155
|
+
|
156
|
+
Note:
|
157
|
+
If the `route` is application level (application#baz) the file will be placed
|
158
|
+
in the application level directory and the manifests/application file will be modified
|
79
159
|
|
80
160
|
## Contributing
|
81
161
|
|
data/Rakefile
CHANGED
@@ -8,11 +8,13 @@ end
|
|
8
8
|
require 'bundler/gem_tasks'
|
9
9
|
|
10
10
|
namespace :sudojs do
|
11
|
-
desc "Download the latest released versions sudo.js"
|
11
|
+
desc "Download the latest released versions sudo.js as well as Ecmascript-5 shims for non-standard browsers"
|
12
12
|
task :download_latest do
|
13
13
|
files = {
|
14
|
-
'sudo.js'=>'https://raw.github.com/robrobbins/sudo-js/
|
15
|
-
'sudo-x.js' => 'https://raw.github.com/robrobbins/sudo-js/
|
14
|
+
'sudo.js'=>'https://raw.github.com/robrobbins/sudo-js/master/build/debug/sudo.js',
|
15
|
+
'sudo-x.js' => 'https://raw.github.com/robrobbins/sudo-js/master/build/debug/sudo-x.js',
|
16
|
+
'es5-shim' => 'https://raw.github.com/robrobbins/sudo-js/master/lib/es5-shim/es5-shim.js',
|
17
|
+
'es5-sham' => 'https://raw.github.com/robrobbins/sudo-js/master/lib/es5-shim/es5-sham.js'
|
16
18
|
}
|
17
19
|
|
18
20
|
vendor_dir = "vendor/assets/javascripts"
|
data/lib/sudojs/version.rb
CHANGED
@@ -0,0 +1,25 @@
|
|
1
|
+
// Polyfills for non-std browsers that, while not attaining ES5 spec
|
2
|
+
// (hence `sham`), function correctly on a limited scope.
|
3
|
+
(function() {
|
4
|
+
if(!Object.create) {
|
5
|
+
Object.create = function(obj) {
|
6
|
+
var ret;
|
7
|
+
if (arguments.length > 1 ) {
|
8
|
+
// cannot support the multiple argument scenario for legacy browsers
|
9
|
+
throw new Error('This Object.create implementation only accepts a single argument');
|
10
|
+
}
|
11
|
+
function F(){}
|
12
|
+
F.prototype = obj;
|
13
|
+
ret = new F();
|
14
|
+
// Allows Object.getPrototypeOf to work in non-std browsers
|
15
|
+
ret.__proto__ = obj;
|
16
|
+
return ret;
|
17
|
+
};
|
18
|
+
}
|
19
|
+
// Will return the expected Object for all Objects created using the above `create` method
|
20
|
+
if(!Object.getPrototypeOf) {
|
21
|
+
Object.getPrototypeOf = function(object) {
|
22
|
+
return object.__proto__;
|
23
|
+
};
|
24
|
+
}
|
25
|
+
}());
|