esphinx-loader-rails 0.0.1.alpha

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.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: d983fe0503e5229b49f1e872edf14630e90096c1
4
+ data.tar.gz: d17977e498f7fc944a39a294a98a1ceb6aa028c0
5
+ SHA512:
6
+ metadata.gz: 86b3590d26ed11e4378311a50c00460145d7426b63e39f65fec513843ef9da794509801417a6726f2c7055df75ff910e0df1055a03d896bd4a46ee6f005fcaff
7
+ data.tar.gz: 16bcac7918be2db840e05f807406e5e2eed0909213e660aab9e2f7366db5374e1acacff189bfe14de00f310b1aee82501ec3fc36786e6ba4ee4a27a6978155db
data/MIT-LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ Copyright 2015
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1 @@
1
+ # require_js-rails
data/Rakefile ADDED
@@ -0,0 +1,24 @@
1
+ begin
2
+ require 'bundler/setup'
3
+ rescue LoadError
4
+ puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
5
+ end
6
+
7
+ require 'rdoc/task'
8
+
9
+ RDoc::Task.new(:rdoc) do |rdoc|
10
+ rdoc.rdoc_dir = 'rdoc'
11
+ rdoc.title = 'RequireJSRails'
12
+ rdoc.options << '--line-numbers'
13
+ rdoc.rdoc_files.include('README.rdoc')
14
+ rdoc.rdoc_files.include('lib/**/*.rb')
15
+ end
16
+
17
+
18
+
19
+ load 'rails/tasks/statistics.rake'
20
+
21
+
22
+
23
+ Bundler::GemHelper.install_tasks
24
+
@@ -0,0 +1,181 @@
1
+ "use strict";
2
+
3
+ // fazer método reload
4
+
5
+ var esPhinxLoader;
6
+ esPhinxLoader = (function ($) {
7
+
8
+ var
9
+ loadPath = "",
10
+
11
+ resolvePath = function (path) {
12
+ // : (não captura grupo)
13
+ return path
14
+ .replace(/^\/*/, "/")
15
+ .replace(/\/+$/, "");
16
+ },
17
+
18
+ joinPaths = function () {
19
+ var
20
+ path = "",
21
+ args = Array.prototype.slice.call(arguments);
22
+
23
+ args.forEach(function (v) {
24
+ path += resolvePath(v);
25
+ });
26
+
27
+ return path;
28
+ };
29
+
30
+ return {
31
+ config: {
32
+ defaultPath: "/"
33
+ },
34
+
35
+ resolvePath: function (path) {
36
+ return resolvePath(path);
37
+ },
38
+
39
+ defaultPath: function () {
40
+ if (arguments.length) {
41
+ this.config.defaultPath = arguments[0];
42
+ }
43
+ return resolvePath(this.config.defaultPath);
44
+ },
45
+
46
+ loadPath: function () {
47
+ if (arguments.length) {
48
+ loadPath = arguments[0];
49
+ }
50
+
51
+ return joinPaths(this.config.defaultPath, loadPath);
52
+ }
53
+ };
54
+
55
+ })();
56
+
57
+ var require;
58
+ require = (function ($) {
59
+
60
+ var
61
+ promises = [],
62
+
63
+ resolveSrc = function (src) {
64
+ src = src.toLowerCase();
65
+ if (src.match(/(.js)$/g)) {
66
+ return src;
67
+ }
68
+
69
+ return src.replace() + ".js";
70
+ },
71
+
72
+ resetLoadPath = function () {
73
+ $.loadPath("");
74
+ },
75
+
76
+ promise = function (src) {
77
+ if (promises.indexOf(src) === -1) {
78
+ promises.unshift(src);
79
+ }
80
+ },
81
+
82
+ // accomplish = function (i) {
83
+ // i = arguments[0] || 0;
84
+
85
+ // var
86
+ // script,
87
+ // src;
88
+
89
+ // debugger;
90
+ // src = promises[i];
91
+ // if (!document
92
+ // .querySelector("head script[src=\"" + src + "\"]")
93
+ // ) {
94
+ // script = document.createElement("script");
95
+ // script.src = src;
96
+ // // script.async = true;
97
+
98
+ // // document.head.appendChild(script);
99
+ // // usar recursividade aqui. E pelo que parece, está dando ruim usando create. Talvez seja interessante usar fragment, ou document.writeln()
100
+ // script.addEventListener("load", function() {
101
+ // if (i < promises.length) {
102
+ // accomplish(i + 1);
103
+ // }
104
+ // });
105
+ // }
106
+
107
+ // },
108
+
109
+ loaded = false;
110
+
111
+ // return function (src, callback) {
112
+ return function (src) {
113
+ var
114
+ scripts = document.querySelectorAll("head script"),
115
+ script,
116
+ lastScript;
117
+
118
+ // let
119
+ // loaded = false;
120
+
121
+ // time = new Date().getTime()
122
+
123
+ //testar inserir sabosta no body também
124
+ src = resolveSrc($.loadPath() + $.resolvePath(src));
125
+
126
+ if (!document
127
+ .querySelector("head script[src^=\"" + src + "\"]")
128
+ ) {
129
+
130
+ script = document.createElement("script");
131
+ script.src = src;
132
+ script.async = true;
133
+ // script.defer = true;
134
+
135
+ debugger
136
+ if (promises.length) {
137
+ promises[0].removeEventListener("load");
138
+ document.head.removeChild(promises[0]);
139
+ }
140
+ debugger
141
+
142
+ promise(script);
143
+
144
+ // Ao ser carregado, o script pode sair do array, podendo passar para o próximo script, devendo ser adicionado ao DOM, e no evento load, o próximo poderá ser carregado, e assim suscessivamente. Mas, como saber que nenhum script mais precisou ser carregado?
145
+ script.addEventListener("load", function () {
146
+ loaded = true;
147
+ });
148
+
149
+ lastScript = scripts.item(scripts.length -1);
150
+ document.head.insertBefore(script, lastScript);
151
+
152
+ resetLoadPath();
153
+
154
+ promises[0].addEventListener("load", function () {
155
+ loaded = true;
156
+ //
157
+ });
158
+
159
+
160
+ // talvez haja um problema com o loading
161
+ (function loading () {
162
+ setTimeout(function () {
163
+ if (!loaded){
164
+ debugger
165
+ loading();
166
+ } else {
167
+ loaded = false;
168
+ }
169
+ // }, 10);
170
+ }, 0);
171
+ })();
172
+ }
173
+
174
+ // document.addEventListener("DOMContentLoaded", function () {
175
+ // window.addEventListener("load", function () {
176
+ // document.writeln('<script src=\"' + src + '\"></script>');
177
+ // // accomplish();
178
+ // });
179
+ };
180
+
181
+ })(esPhinxLoader);
@@ -0,0 +1,20 @@
1
+ (function () {
2
+ "use strict";
3
+
4
+ var
5
+ tag = <%= "\'#{javascript_include_tag('esphinx/loader/main')}\'" %>,
6
+ src,
7
+ script;
8
+
9
+ src = tag
10
+ .match(/(src=[\"\'])([\/\w])+(\.js)?/gi)[0]
11
+ .replace(/(src=)|([\"\']*)/g, "");
12
+
13
+ script = document.querySelector("head script[src=\"" + src + "\"]");
14
+
15
+ if (!script) {
16
+ window.onload = function () {};
17
+ document.writeln(tag);
18
+ }
19
+
20
+ })();
@@ -0,0 +1 @@
1
+ require "esphinx/loader/rails/engine"
@@ -0,0 +1,9 @@
1
+ module ESphinx
2
+ module Loader
3
+ module Rails
4
+ class Engine < ::Rails::Engine
5
+ # isolate_namespace RequireJSRails
6
+ end
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,7 @@
1
+ module ESphinx
2
+ module Loader
3
+ module Rails
4
+ VERSION = "0.0.1.alpha"
5
+ end
6
+ end
7
+ end
metadata ADDED
@@ -0,0 +1,52 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: esphinx-loader-rails
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1.alpha
5
+ platform: ruby
6
+ authors:
7
+ - Home Labs
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2015-12-16 00:00:00.000000000 Z
12
+ dependencies: []
13
+ description: Loader to scripts.
14
+ email:
15
+ - home-labs@outlook.com
16
+ executables: []
17
+ extensions: []
18
+ extra_rdoc_files: []
19
+ files:
20
+ - MIT-LICENSE
21
+ - README.md
22
+ - Rakefile
23
+ - lib/assets/javascripts/esphinx/loader/main.js
24
+ - lib/assets/javascripts/esphinx_loader.js.erb
25
+ - lib/esphinx-loader-rails.rb
26
+ - lib/esphinx/loader/rails/engine.rb
27
+ - lib/esphinx/loader/rails/version.rb
28
+ homepage: https://rubygems.org/gems/esphinx-loader-rails
29
+ licenses:
30
+ - MIT
31
+ metadata: {}
32
+ post_install_message:
33
+ rdoc_options: []
34
+ require_paths:
35
+ - lib
36
+ required_ruby_version: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ required_rubygems_version: !ruby/object:Gem::Requirement
42
+ requirements:
43
+ - - ">"
44
+ - !ruby/object:Gem::Version
45
+ version: 1.3.1
46
+ requirements: []
47
+ rubyforge_project:
48
+ rubygems_version: 2.4.5.1
49
+ signing_key:
50
+ specification_version: 4
51
+ summary: Summary of ESphinx.
52
+ test_files: []