webfontloader 1.4.2 → 1.4.3

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,180 @@
1
+ goog.provide('webfont.Version');
2
+
3
+ /**
4
+ * Represents a version as used in user agent strings. Note
5
+ * that this does not represent any sort of reliable versioning
6
+ * scheme (like Semantic Versioning) but merely a best effort
7
+ * at parsing a large amount of wildly different version strings.
8
+ *
9
+ * @constructor
10
+ * @param {?number=} opt_major
11
+ * @param {?number=} opt_minor
12
+ * @param {?number=} opt_patch
13
+ * @param {?(number|string)=} opt_build
14
+ */
15
+ webfont.Version = function(opt_major, opt_minor, opt_patch, opt_build) {
16
+ /**
17
+ * @type {?number}
18
+ */
19
+ this.major = goog.isDefAndNotNull(opt_major) ? opt_major : null;
20
+
21
+ /**
22
+ * @type {?number}
23
+ */
24
+ this.minor = goog.isDefAndNotNull(opt_minor) ? opt_minor : null;
25
+
26
+ /**
27
+ * @type {?number}
28
+ */
29
+ this.patch = goog.isDefAndNotNull(opt_patch) ? opt_patch : null;
30
+
31
+ /**
32
+ * @type {?(number|string)}
33
+ */
34
+ this.build = goog.isDefAndNotNull(opt_build) ? opt_build : null;
35
+ }
36
+
37
+ goog.scope(function () {
38
+ var Version = webfont.Version;
39
+
40
+ Version.TOKENIZER = new RegExp(
41
+ "^" +
42
+ "([0-9]+)" + // major
43
+ "(?:" +
44
+ "[\\._-]([0-9]+)" + // minor
45
+ ")?" +
46
+ "(?:" +
47
+ "[\\._-]([0-9]+)" + // patch
48
+ ")?" +
49
+ "(?:" +
50
+ "[\\._+-]?(.*)" + // build
51
+ ")?$"
52
+ );
53
+
54
+ /**
55
+ * Returns true if the version is valid. A
56
+ * version is considered valid if it has at
57
+ * least a major version number.
58
+ *
59
+ * @return {boolean}
60
+ */
61
+ Version.prototype.isValid = function () {
62
+ return !goog.isNull(this.major);
63
+ };
64
+
65
+ /**
66
+ * Compares two versions. Returns -1 if this
67
+ * is smaller than version. Returns 1 if this
68
+ * is greater than version. Returns 0 if this
69
+ * equals version.
70
+ *
71
+ * Build strings or numbers are ignored when
72
+ * comparing versions.
73
+ *
74
+ * @param {webfont.Version} version
75
+ * @return {number}
76
+ */
77
+ Version.prototype.compare = function (version) {
78
+ if (this.major > version.major ||
79
+ ((this.major === version.major && this.minor > version.minor) ||
80
+ (this.major === version.major && this.minor === version.minor && this.patch > version.patch))) {
81
+ return 1;
82
+ } else if (this.major < version.major ||
83
+ ((this.major === version.major && this.minor < version.minor) ||
84
+ (this.major === version.major && this.minor === version.minor && this.patch < version.patch))) {
85
+ return -1;
86
+ }
87
+ return 0;
88
+ };
89
+
90
+ /**
91
+ * @param {webfont.Version} version
92
+ * @return {boolean}
93
+ */
94
+ Version.prototype.gt = function (version) {
95
+ return this.compare(version) === 1;
96
+ };
97
+
98
+ /**
99
+ * @param {webfont.Version} version
100
+ * @return {boolean}
101
+ */
102
+ Version.prototype.lt = function (version) {
103
+ return this.compare(version) === -1;
104
+ };
105
+
106
+ /**
107
+ * @param {webfont.Version} version
108
+ * @return {boolean}
109
+ */
110
+ Version.prototype.ge = function (version) {
111
+ return this.compare(version) === 0 || this.compare(version) === 1;
112
+ };
113
+
114
+ /**
115
+ * @param {webfont.Version} version
116
+ * @return {boolean}
117
+ */
118
+ Version.prototype.le = function (version) {
119
+ return this.compare(version) === 0 || this.compare(version) === -1;
120
+ };
121
+
122
+ /**
123
+ * @param {webfont.Version} version
124
+ * @return {boolean}
125
+ */
126
+ Version.prototype.eq = function (version) {
127
+ return this.compare(version) === 0;
128
+ };
129
+
130
+ /**
131
+ * @param {webfont.Version} version
132
+ * @return {boolean}
133
+ */
134
+ Version.prototype.ne = function (version) {
135
+ return this.compare(version) !== 0;
136
+ };
137
+
138
+ /**
139
+ * @return {string}
140
+ */
141
+ Version.prototype.toString = function () {
142
+ return [this.major, this.minor || '', this.patch || '', this.build || ''].join('');
143
+ };
144
+
145
+ /**
146
+ * @param {string} str
147
+ * @return {!webfont.Version}
148
+ */
149
+ Version.parse = function (str) {
150
+ var match = Version.TOKENIZER.exec(str),
151
+ major = null,
152
+ minor = null,
153
+ patch = null,
154
+ build = null;
155
+
156
+ if (match) {
157
+ if (!goog.isNull(match[1]) && !!match[1]) {
158
+ major = parseInt(match[1], 10);
159
+ }
160
+
161
+ if (!goog.isNull(match[2]) && !!match[2]) {
162
+ minor = parseInt(match[2], 10);
163
+ }
164
+
165
+ if (!goog.isNull(match[3]) && !!match[3]) {
166
+ patch = parseInt(match[3], 10);
167
+ }
168
+
169
+ if (!goog.isNull(match[4]) && !!match[4]) {
170
+ if (/^[0-9]+$/.test(match[4])) {
171
+ build = parseInt(match[4], 10);
172
+ } else {
173
+ build = match[4];
174
+ }
175
+ }
176
+ }
177
+
178
+ return new Version(major, minor, patch, build);
179
+ };
180
+ });
data/src/modules.yml CHANGED
@@ -2,6 +2,7 @@ core:
2
2
  - ../tools/compiler/base.js
3
3
  - core/domhelper.js
4
4
  - core/browserinfo.js
5
+ - core/version.js
5
6
  - core/useragent.js
6
7
  - core/useragentparser.js
7
8
  - core/cssclassname.js
@@ -13,8 +13,8 @@ Gem::Specification.new do |s|
13
13
  ## If your rubyforge_project name is different, then edit it and comment out
14
14
  ## the sub! line in the Rakefile
15
15
  s.name = 'webfontloader'
16
- s.version = '1.4.2'
17
- s.date = '2013-04-11'
16
+ s.version = '1.4.3'
17
+ s.date = '2013-05-16'
18
18
 
19
19
  ## Make sure your summary is short. The description may be as long
20
20
  ## as you like.
@@ -119,6 +119,7 @@ DESC
119
119
  spec/core/fontwatchrunner_spec.js
120
120
  spec/core/size_spec.js
121
121
  spec/core/useragentparser_spec.js
122
+ spec/core/version_spec.js
122
123
  spec/core/webfont_spec.js
123
124
  spec/custom/customcss_spec.js
124
125
  spec/deps.js
@@ -161,6 +162,7 @@ DESC
161
162
  src/core/namespace.js
162
163
  src/core/useragent.js
163
164
  src/core/useragentparser.js
165
+ src/core/version.js
164
166
  src/core/webfont.js
165
167
  src/custom/customcss.js
166
168
  src/fontdeck/fontdeck_script.js
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: webfontloader
3
3
  version: !ruby/object:Gem::Version
4
- hash: 3
4
+ hash: 1
5
5
  prerelease:
6
6
  segments:
7
7
  - 1
8
8
  - 4
9
- - 2
10
- version: 1.4.2
9
+ - 3
10
+ version: 1.4.3
11
11
  platform: ruby
12
12
  authors:
13
13
  - Ryan Carver
@@ -16,7 +16,7 @@ autorequire:
16
16
  bindir: bin
17
17
  cert_chain: []
18
18
 
19
- date: 2013-04-11 00:00:00 Z
19
+ date: 2013-05-16 00:00:00 Z
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency
22
22
  name: rake
@@ -150,6 +150,7 @@ files:
150
150
  - spec/core/fontwatchrunner_spec.js
151
151
  - spec/core/size_spec.js
152
152
  - spec/core/useragentparser_spec.js
153
+ - spec/core/version_spec.js
153
154
  - spec/core/webfont_spec.js
154
155
  - spec/custom/customcss_spec.js
155
156
  - spec/deps.js
@@ -192,6 +193,7 @@ files:
192
193
  - src/core/namespace.js
193
194
  - src/core/useragent.js
194
195
  - src/core/useragentparser.js
196
+ - src/core/version.js
195
197
  - src/core/webfont.js
196
198
  - src/custom/customcss.js
197
199
  - src/fontdeck/fontdeck_script.js