appjs-rails 1.0.1 → 1.0.2
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +18 -3
- data/app/assets/javascripts/app.js +5 -1
- data/lib/appjs/rails/version.rb +1 -1
- data/spec/javascripts/appSpec.js +9 -6
- metadata +2 -2
data/README.md
CHANGED
@@ -18,13 +18,15 @@ Or install it yourself as:
|
|
18
18
|
|
19
19
|
$ gem install appjs-rails
|
20
20
|
|
21
|
-
## Usage
|
22
|
-
|
23
21
|
The app file will be added to the asset pipeline when you in file ```app/assets/javascripts/application.js``` add this line:
|
24
22
|
|
23
|
+
```
|
25
24
|
//= require app
|
25
|
+
```
|
26
26
|
|
27
|
-
|
27
|
+
## Usage
|
28
|
+
|
29
|
+
Creation new singleton without initialize
|
28
30
|
|
29
31
|
```javascript
|
30
32
|
app._singleton.add('example', function() {
|
@@ -35,6 +37,19 @@ app._singleton.add('example', function() {
|
|
35
37
|
app.example.init();
|
36
38
|
app.example.toString; // 'Class Example'
|
37
39
|
```
|
40
|
+
|
41
|
+
Creation new singleton with initialize
|
42
|
+
|
43
|
+
|
44
|
+
```javascript
|
45
|
+
app._singleton.init('example', function() {
|
46
|
+
return {
|
47
|
+
toString: 'Class Example'
|
48
|
+
}
|
49
|
+
} );
|
50
|
+
app.example.toString; // 'Class Example'
|
51
|
+
```
|
52
|
+
|
38
53
|
Generation UUID
|
39
54
|
|
40
55
|
```javascript
|
@@ -23,7 +23,11 @@ var app = (function() {
|
|
23
23
|
return app[name];
|
24
24
|
};
|
25
25
|
},
|
26
|
-
|
26
|
+
init: function(name, fn) {
|
27
|
+
app._singleton.add(name, fn);
|
28
|
+
return app[name].init();
|
29
|
+
},
|
30
|
+
listAdded: singletons
|
27
31
|
},
|
28
32
|
// free generator http://ajaxload.info/
|
29
33
|
_ajax: {
|
data/lib/appjs/rails/version.rb
CHANGED
data/spec/javascripts/appSpec.js
CHANGED
@@ -1,15 +1,18 @@
|
|
1
1
|
describe("app", function() {
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
|
3
|
+
describe("#_singleton", function() {
|
4
|
+
it("should be able to create example singleton without initialize", function() {
|
5
|
+
app._singleton.add('singletonAdd', function(){});
|
6
|
+
expect(app.singletonAdd).not.toEqual(undefined);
|
7
|
+
});
|
6
8
|
|
7
|
-
|
8
|
-
|
9
|
+
it("should be able to create example singleton with initialize", function() {
|
10
|
+
app._singleton.init('singletonInit', function(){return {toString: "Init"}});
|
11
|
+
expect(app.singletonInit['toString']).toEqual('Init');
|
12
|
+
});
|
9
13
|
});
|
10
14
|
|
11
15
|
it("should generate an uuid", function() {
|
12
16
|
expect(app._uuid()).toMatch(/^\w{8}-\w{4}-\w{4}-\w{4}-\w{12}$/);
|
13
17
|
});
|
14
|
-
|
15
18
|
});
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: appjs-rails
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.2
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2014-01-
|
12
|
+
date: 2014-01-23 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: bundler
|