appjs-rails 1.0.3 → 1.0.4

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -66,9 +66,21 @@ Now all Array object has got functions
66
66
 
67
67
  ```javascript
68
68
  [1, 2, 3].equal('2, 3'); // false
69
+
69
70
  [1, 2, 3].any(); // true
71
+
70
72
  [1, 2, 3].empty(); // false
73
+
71
74
  ['1', '2', '3'].each(function(item) {console.log('item: ' + item)} );
75
+
76
+ ['1', '2', '3'].erase(); // []
77
+
78
+ ['1', '2', '3'].first(); // 1
79
+
80
+ [].first(); // undefined
81
+
82
+ ['a', 'b'].last(); // 'b'
83
+
72
84
  ```
73
85
  # License
74
86
 
@@ -45,20 +45,38 @@ var app = (function() {
45
45
  },
46
46
  _config: {
47
47
  array: function(){
48
+
49
+ Array.prototype.any = function() {
50
+ return (this.length > 0);
51
+ }
48
52
  Array.prototype.each = function(fn) {
49
53
  for(var i=0; i<this.length; i++) {
50
54
  fn(this[i]);
51
55
  }
52
56
  }
53
- Array.prototype.any = function() {
54
- return (this.length > 0);
55
- }
56
57
  Array.prototype.empty = function() {
57
58
  return (this.length == 0);
58
59
  }
59
60
  Array.prototype.equal = function(nextArray) {
60
61
  return JSON.stringify(this) == JSON.stringify(nextArray);
61
62
  }
63
+ Array.prototype.erase = function() {
64
+ var length = this.length
65
+ for(var i=0; i<length; i++) {
66
+ this.pop();
67
+ }
68
+ return this;
69
+ }
70
+ Array.prototype.last = function() {
71
+ return this[this.length-1];
72
+ }
73
+ Array.prototype.first = function() {
74
+ return this[0];
75
+ }
76
+
77
+ },
78
+ debug: function(){
79
+ debugger;
62
80
  }
63
81
  },
64
82
  _uuid: function(){
@@ -1,5 +1,5 @@
1
1
  module Appjs
2
2
  module Rails
3
- VERSION = "1.0.3"
3
+ VERSION = "1.0.4"
4
4
  end
5
5
  end
@@ -1,4 +1,5 @@
1
1
  describe("app", function() {
2
+ document.write('<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.8.1/jquery.min.js" ></script>');
2
3
 
3
4
  describe("#_singleton", function() {
4
5
  it("should be able to create example singleton without initialize", function() {
@@ -43,11 +44,27 @@ describe("app", function() {
43
44
  expect([1, '2', 3].equal([1, '2', 3])).toEqual(true);
44
45
  })
45
46
 
47
+ it('#erase', function(){
48
+ expect([1, '2', 3].erase()).toEqual([]);
49
+ })
50
+
51
+ it('#last', function(){
52
+ expect([1, '2', 3].last()).toEqual(3);
53
+ expect([1].last()).toEqual(1);
54
+ expect([].last()).toEqual(undefined);
55
+ })
56
+
57
+ it('#first', function(){
58
+ expect([1, '2', 3].first()).toEqual(1);
59
+ expect([1].first()).toEqual(1);
60
+ expect([].first()).toEqual(undefined);
61
+ })
62
+
46
63
  });
47
64
 
48
65
  describe('#_ajax', function(){
49
66
  it('#addEvent', function(){
50
- //app._ajax.addEvent.lockAfterClick();
67
+ app._ajax.addEvent.lockAfterClick();
51
68
  })
52
69
  })
53
70
 
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.3
4
+ version: 1.0.4
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-27 00:00:00.000000000 Z
12
+ date: 2014-01-28 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: bundler