oneis 1.1.0-java → 1.2.0-java

Sign up to get free protection for your applications and to get access to all the features.
data/lib/js.jar CHANGED
Binary file
@@ -38,13 +38,15 @@
38
38
  optionsBrowser.browser = true;
39
39
 
40
40
  // Predefined globals
41
- var makeGlobalsServer = function() {
42
- return {O:false, SCHEMA:false, HTTP:false, DBTime:false, console:false, JSON:false, '_':false, Handlebars:false, oForms:false, moment:false, XDate:false};
43
- };
44
- var globalsServer = makeGlobalsServer();
45
- var globalsBrowser = {ONEIS:false, jQuery:false, '_':false};
46
- var globalsTest = makeGlobalsServer();
47
- globalsTest.T = false; // Add in the test global
41
+ var globalsServer = [
42
+ 'O',
43
+ 'SCHEMA', 'TYPE', 'ATTR', 'ALIASED_ATTR', 'QUAL', 'LABEL', 'GROUP',
44
+ 'HTTP', 'DBTime',
45
+ 'console', 'JSON',
46
+ '_', 'Handlebars', 'oForms', 'moment', 'XDate'
47
+ ];
48
+ var globalsBrowser = ['ONEIS', 'jQuery', '_'];
49
+ var globalsTest = globalsServer.concat('T');
48
50
 
49
51
  // Set globals
50
52
  root.syntax_tester_globals = function(string) {
@@ -52,14 +54,19 @@
52
54
  };
53
55
 
54
56
  // Syntax tester function
55
- root.syntax_tester = function(source, kind) {
56
- var globals;
57
+ root.syntax_tester = function(source, kind, extraGlobals) {
58
+ var globalList;
57
59
  switch(kind) {
58
- case "js": globals = globalsServer; break;
59
- case "static": globals = globalsBrowser; break;
60
- case "test": globals = globalsTest; break;
60
+ case "js": globalList = globalsServer; break;
61
+ case "static": globalList = globalsBrowser; break;
62
+ case "test": globalList = globalsTest; break;
63
+ }
64
+ if(!globalList) { return "Wrong kind of file"; }
65
+ var globals = {}, addGlobal = function(g) { globals[g] = false; };
66
+ globalList.forEach(addGlobal);
67
+ if(extraGlobals) {
68
+ JSON.parse(extraGlobals).forEach(addGlobal);
61
69
  }
62
- if(!globals) { return "Wrong kind of file"; }
63
70
  var result = JSHINT(source,
64
71
  (kind !== 'static') ? optionsServer : optionsBrowser,
65
72
  globals
data/lib/new_plugin.rb CHANGED
@@ -26,7 +26,7 @@ module PluginTool
26
26
  "displayName": "#{plugin_name.split('_').map {|e| e.capitalize} .join(' ')}",
27
27
  "displayDescription": "TODO Longer description of plugin",
28
28
  "installSecret": "#{install_secret}",
29
- "apiVersion": 2,
29
+ "apiVersion": 3,
30
30
  "load": [
31
31
  "js/#{plugin_name}.js"
32
32
  ],
@@ -37,18 +37,12 @@ __E
37
37
  File.open("#{plugin_name}/js/#{plugin_name}.js",'w') do |file|
38
38
  file.write(<<__E)
39
39
 
40
- var #{plugin_name} = O.plugin("#{plugin_name}");
41
-
42
- (function(P) {
43
-
44
- P.respond("GET", "/do/#{plugin_url_fragment}/example", [
45
- ], function(E) {
46
- E.render({
47
- pageTitle: "Example page"
48
- });
40
+ P.respond("GET", "/do/#{plugin_url_fragment}/example", [
41
+ ], function(E) {
42
+ E.render({
43
+ pageTitle: "Example page"
49
44
  });
50
-
51
- })(#{plugin_name});
45
+ });
52
46
 
53
47
  __E
54
48
  end
@@ -35,23 +35,37 @@ module PluginTool
35
35
  # Load the plugin.json file
36
36
  plugin_dir = plugin.plugin_dir
37
37
  plugin_json = File.open("#{plugin_dir}/plugin.json") { |f| JSON.parse(f.read) }
38
+ api_version = (plugin_json["apiVersion"] || '0').to_i
38
39
  # Determine kind of file
39
- file =~ /\A(\w+)\//
40
- kind = $1
40
+ kind = (file =~ /\A(\w+)\//) ? $1 : file
41
41
  # Is this file referenced?
42
42
  report = nil
43
+ extra_globals = []
43
44
  unless kind != 'js' || plugin_json['load'].include?(file)
44
45
  puts "\nWARNING: #{plugin_dir}/plugin.json doesn't mention #{file} in the load directive.\n"
45
46
  report = "Couldn't check file - not mentioned in plugin.json"
46
47
  else
47
48
  # Load the file
48
49
  js = File.open("#{plugin_dir}/#{file}") { |f| f.read }
49
- # If it's not the first the file, need to tell JSHint about the extra var
50
- unless plugin_json['load'].first == file
51
- js = "/*global #{plugin_json["pluginName"]}: false */#{js}"
50
+ if api_version < 3
51
+ # If it's not the first file, need to tell JSHint about the extra var
52
+ unless plugin_json['load'].first == file
53
+ extra_globals << plugin_json["pluginName"];
54
+ end
55
+ else
56
+ if kind == 'js'
57
+ extra_globals << plugin_json["pluginName"]
58
+ extra_globals << 'P'
59
+ locals = plugin_json["locals"]
60
+ if locals
61
+ locals.each_key { |local| extra_globals << local }
62
+ end
63
+ end
64
+ # global.js requires server side syntax checking, but doesn't have any extra globals, not even the plugin name.
65
+ kind = 'js' if kind == 'global.js'
52
66
  end
53
67
  # Do syntax checking
54
- report = @@syntax_tester.call(@@cx, @@javascript_scope, @@javascript_scope, [js, kind])
68
+ report = @@syntax_tester.call(@@cx, @@javascript_scope, @@javascript_scope, [js, kind, JSON.generate(extra_globals)])
55
69
  end
56
70
  report
57
71
  end
data/lib/version.txt CHANGED
@@ -1 +1 @@
1
- ef06a9244e
1
+ 2a2fcaef6e
data/oneis.gemspec CHANGED
@@ -3,8 +3,8 @@ Gem::Specification.new do |s|
3
3
  files = Dir.glob("#{root_dir}/**/*.*").map { |x| x[root_dir.length + 1, x.length]}
4
4
 
5
5
  s.name = 'oneis'
6
- s.version = '1.1.0'
7
- s.date = '2014-10-03'
6
+ s.version = '1.2.0'
7
+ s.date = '2014-11-20'
8
8
  s.summary = "ONEIS Tools"
9
9
  s.description = "ONEIS Developer Tools"
10
10
  s.authors = ["ONEIS"]
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: oneis
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 1.1.0
5
+ version: 1.2.0
6
6
  platform: java
7
7
  authors:
8
8
  - ONEIS
@@ -10,7 +10,7 @@ autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
12
 
13
- date: 2014-10-03 00:00:00 Z
13
+ date: 2014-11-20 00:00:00 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: jruby-openssl