zendesk_apps_support 1.14.4 → 1.15.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 42facf839227ec97b70c5ddb1777a8fc35750da2
4
- data.tar.gz: d8e73edd9f09a0db0894fe701ce63ac742e2f221
3
+ metadata.gz: 804155523a694d349fe6c9d511539158a019b989
4
+ data.tar.gz: d910659f19c622b0035c88fd2cee2b124d24634c
5
5
  SHA512:
6
- metadata.gz: 8c4de5166b970b0b8e1c01bffab99e38f62da6602899934e23ec6d26d7bb22b40139de64870e63e99c94e12da8385d20eff9c098054bc6cb92632a5b838c28b7
7
- data.tar.gz: 3c8e1d7b0044c330457881e3050e24f6932f26d08d648fceda214e22405ad209942a0194b0487df55e90e2ae71cf40cb56926952ad2cfb3fa420b7c7b478df45
6
+ metadata.gz: 0864c1dc53ae21a6b774e7ce67f95391cb4be00b8cb1edfb58acd9a24e4118e43ce88eec516b2db5e116d12e729ba405428f4f0ad1ad87c05f674ce2c442347c
7
+ data.tar.gz: abb37387907268112b38391ad0e02d65364db3e536d698dfb72c2e612ab49f75a735a702c042eb3a3fb1f755545c3f157ea62ed9f022ff1681585dc3a3350486
@@ -1,26 +1,36 @@
1
1
  (function() {
2
- with( require('apps/framework/app_scope') ) {
2
+ with( ZendeskApps.AppScope.create() ) {
3
+ <% unless modules.nil? %>
4
+ require.modules = {
5
+ <% modules.each do |path, content| %>
6
+ '<%= path %>': function(exports, require, module) {
7
+ <%= content %>
8
+ },
9
+ <% end %>
10
+ eom: undefined
11
+ };
12
+ <% end %>
3
13
 
4
- var source = <%= source %>;
14
+ var source = <%= source %>;
5
15
 
6
- ZendeskApps[<%= name.to_json %>] = ZendeskApps.defineApp(source)
7
- .reopenClass({ location: <%= location.to_json %> })
8
- .reopen({
9
- assetUrlPrefix: <%= asset_url_prefix.to_json %>,
10
- appClassName: <%= app_class_name.to_json %>,
11
- author: {
12
- name: <%= author[:name].to_json %>,
13
- email: <%= author[:email].to_json %>
14
- },
15
- translations: <%= translations.to_json %>,
16
- templates: <%= templates.to_json %>,
17
- frameworkVersion: <%= framework_version.to_json %>
18
- });
16
+ var app = ZendeskApps.defineApp(source)
17
+ .reopenClass({ location: <%= location.to_json %> })
18
+ .reopen({
19
+ assetUrlPrefix: <%= asset_url_prefix.to_json %>,
20
+ appClassName: <%= app_class_name.to_json %>,
21
+ author: {
22
+ name: <%= author[:name].to_json %>,
23
+ email: <%= author[:email].to_json %>
24
+ },
25
+ translations: <%= translations.to_json %>,
26
+ templates: <%= templates.to_json %>,
27
+ frameworkVersion: <%= framework_version.to_json %>,
28
+ });
19
29
 
20
- }
21
-
22
- ZendeskApps[<%= name.to_json %>].install({"id": <%= app_id %>, "app_id": <%= app_id %>, "settings": <%= settings.to_json %>});
30
+ ZendeskApps[<%= name.to_json %>] = app;
31
+ }
23
32
 
33
+ ZendeskApps[<%= name.to_json %>].install({"id": <%= app_id %>, "app_id": <%= app_id %>, "settings": <%= settings.to_json %>});
24
34
  }());
25
35
 
26
36
  ZendeskApps.trigger && ZendeskApps.trigger('ready');
@@ -10,11 +10,12 @@ module ZendeskAppsSupport
10
10
  DEFAULT_SCSS = File.read(File.expand_path('../assets/default_styles.scss', __FILE__))
11
11
  SRC_TEMPLATE = Erubis::Eruby.new( File.read(File.expand_path('../assets/src.js.erb', __FILE__)) )
12
12
 
13
- attr_reader :root, :warnings
13
+ attr_reader :lib_root, :root, :warnings
14
14
  attr_accessor :requirements_only
15
15
 
16
16
  def initialize(dir)
17
17
  @root = Pathname.new(File.expand_path(dir))
18
+ @lib_root = Pathname.new(File.join(@root, 'lib'))
18
19
  @warnings = []
19
20
  @requirements_only = false
20
21
  end
@@ -46,10 +47,28 @@ module ZendeskAppsSupport
46
47
  end
47
48
  end
48
49
 
50
+ def app_js
51
+ read_file("app.js")
52
+ end
53
+
54
+ def commonjs_modules
55
+ return unless has_lib_js?
56
+
57
+ lib_files.each_with_object({}) do |file, modules|
58
+ name = file.relative_path.gsub!(/^lib\//, '')
59
+ content = file.read
60
+ modules[name] = content
61
+ end
62
+ end
63
+
49
64
  def files
50
65
  non_tmp_files
51
66
  end
52
67
 
68
+ def lib_files
69
+ @lib_files ||= files.select { |f| f =~ /^lib\/.*\.js$/ }
70
+ end
71
+
53
72
  def template_files
54
73
  files.select { |f| f =~ /^templates\/.*\.hdbs$/ }
55
74
  end
@@ -76,7 +95,7 @@ module ZendeskAppsSupport
76
95
 
77
96
  def readified_js(app_name, app_id, asset_url_prefix, settings={})
78
97
  manifest = manifest_json
79
- source = read_file("app.js")
98
+ source = app_js
80
99
  name = app_name || manifest[:name] || 'Local App'
81
100
  location = manifest[:location]
82
101
  app_class_name = "app-#{app_id}"
@@ -97,7 +116,8 @@ module ZendeskAppsSupport
97
116
  :framework_version => framework_version,
98
117
  :templates => templates,
99
118
  :settings => settings,
100
- :app_id => app_id
119
+ :app_id => app_id,
120
+ :modules => commonjs_modules
101
121
  )
102
122
  end
103
123
 
@@ -110,6 +130,10 @@ module ZendeskAppsSupport
110
130
  file_exists?("app.js")
111
131
  end
112
132
 
133
+ def has_lib_js?
134
+ lib_files.any?
135
+ end
136
+
113
137
  def has_manifest?
114
138
  file_exists?("manifest.json")
115
139
  end
@@ -15,29 +15,38 @@ module ZendeskAppsSupport
15
15
 
16
16
  # predefined globals:
17
17
  :predef => %w(_ console services helpers alert window document self
18
- JSON Base64 clearInterval clearTimeout setInterval setTimeout)
18
+ JSON Base64 clearInterval clearTimeout setInterval setTimeout
19
+ require module exports top frames parent)
19
20
  }.freeze
20
21
 
21
22
  class <<self
22
23
  def call(package)
23
- source = package.files.find { |f| f.relative_path == 'app.js' }
24
+ app = package.files.find { |file| file.relative_path == 'app.js' }
25
+ files = package.lib_files << app
24
26
 
25
27
  if package.requirements_only
26
- return source ? [ ValidationError.new(:no_app_js_required) ] : []
28
+ return app ? [ ValidationError.new(:no_app_js_required) ] : []
27
29
  end
28
30
 
29
- return [ ValidationError.new(:missing_source) ] unless source
31
+ return [ ValidationError.new(:missing_source) ] unless app
30
32
 
31
- jshint_errors = linter.lint(source.read)
32
- if jshint_errors.any?
33
- [ JSHintValidationError.new(source.relative_path, jshint_errors) ]
34
- else
35
- []
36
- end
33
+ jshint_errors(files).flatten!
37
34
  end
38
35
 
39
36
  private
40
37
 
38
+ def jshint_error(file)
39
+ errors = linter.lint(file.read)
40
+ [ JSHintValidationError.new(file.relative_path, errors) ] if errors.any?
41
+ end
42
+
43
+ def jshint_errors(files)
44
+ files.each_with_object([]) do |file, errors|
45
+ error = jshint_error(file)
46
+ errors << error unless error.nil?
47
+ end
48
+ end
49
+
41
50
  def linter
42
51
  Jshintrb::Lint.new(LINTER_OPTIONS)
43
52
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: zendesk_apps_support
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.14.4
4
+ version: 1.15.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - James A. Rosen
@@ -11,104 +11,104 @@ authors:
11
11
  autorequire:
12
12
  bindir: bin
13
13
  cert_chain: []
14
- date: 2014-04-15 00:00:00.000000000 Z
14
+ date: 2014-05-09 00:00:00.000000000 Z
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
17
17
  name: i18n
18
18
  requirement: !ruby/object:Gem::Requirement
19
19
  requirements:
20
- - - '>='
20
+ - - ">="
21
21
  - !ruby/object:Gem::Version
22
22
  version: '0'
23
23
  type: :runtime
24
24
  prerelease: false
25
25
  version_requirements: !ruby/object:Gem::Requirement
26
26
  requirements:
27
- - - '>='
27
+ - - ">="
28
28
  - !ruby/object:Gem::Version
29
29
  version: '0'
30
30
  - !ruby/object:Gem::Dependency
31
31
  name: multi_json
32
32
  requirement: !ruby/object:Gem::Requirement
33
33
  requirements:
34
- - - '>='
34
+ - - ">="
35
35
  - !ruby/object:Gem::Version
36
36
  version: '0'
37
37
  type: :runtime
38
38
  prerelease: false
39
39
  version_requirements: !ruby/object:Gem::Requirement
40
40
  requirements:
41
- - - '>='
41
+ - - ">="
42
42
  - !ruby/object:Gem::Version
43
43
  version: '0'
44
44
  - !ruby/object:Gem::Dependency
45
45
  name: sass
46
46
  requirement: !ruby/object:Gem::Requirement
47
47
  requirements:
48
- - - '>='
48
+ - - ">="
49
49
  - !ruby/object:Gem::Version
50
50
  version: '0'
51
51
  type: :runtime
52
52
  prerelease: false
53
53
  version_requirements: !ruby/object:Gem::Requirement
54
54
  requirements:
55
- - - '>='
55
+ - - ">="
56
56
  - !ruby/object:Gem::Version
57
57
  version: '0'
58
58
  - !ruby/object:Gem::Dependency
59
59
  name: json
60
60
  requirement: !ruby/object:Gem::Requirement
61
61
  requirements:
62
- - - '>='
62
+ - - ">="
63
63
  - !ruby/object:Gem::Version
64
64
  version: '0'
65
65
  type: :runtime
66
66
  prerelease: false
67
67
  version_requirements: !ruby/object:Gem::Requirement
68
68
  requirements:
69
- - - '>='
69
+ - - ">="
70
70
  - !ruby/object:Gem::Version
71
71
  version: '0'
72
72
  - !ruby/object:Gem::Dependency
73
73
  name: json-stream
74
74
  requirement: !ruby/object:Gem::Requirement
75
75
  requirements:
76
- - - '>='
76
+ - - ">="
77
77
  - !ruby/object:Gem::Version
78
78
  version: '0'
79
79
  type: :runtime
80
80
  prerelease: false
81
81
  version_requirements: !ruby/object:Gem::Requirement
82
82
  requirements:
83
- - - '>='
83
+ - - ">="
84
84
  - !ruby/object:Gem::Version
85
85
  version: '0'
86
86
  - !ruby/object:Gem::Dependency
87
87
  name: image_size
88
88
  requirement: !ruby/object:Gem::Requirement
89
89
  requirements:
90
- - - '>='
90
+ - - ">="
91
91
  - !ruby/object:Gem::Version
92
92
  version: '0'
93
93
  type: :runtime
94
94
  prerelease: false
95
95
  version_requirements: !ruby/object:Gem::Requirement
96
96
  requirements:
97
- - - '>='
97
+ - - ">="
98
98
  - !ruby/object:Gem::Version
99
99
  version: '0'
100
100
  - !ruby/object:Gem::Dependency
101
101
  name: erubis
102
102
  requirement: !ruby/object:Gem::Requirement
103
103
  requirements:
104
- - - '>='
104
+ - - ">="
105
105
  - !ruby/object:Gem::Version
106
106
  version: '0'
107
107
  type: :runtime
108
108
  prerelease: false
109
109
  version_requirements: !ruby/object:Gem::Requirement
110
110
  requirements:
111
- - - '>='
111
+ - - ">="
112
112
  - !ruby/object:Gem::Version
113
113
  version: '0'
114
114
  - !ruby/object:Gem::Dependency
@@ -129,28 +129,28 @@ dependencies:
129
129
  name: rspec
130
130
  requirement: !ruby/object:Gem::Requirement
131
131
  requirements:
132
- - - '>='
132
+ - - ">="
133
133
  - !ruby/object:Gem::Version
134
134
  version: '0'
135
135
  type: :development
136
136
  prerelease: false
137
137
  version_requirements: !ruby/object:Gem::Requirement
138
138
  requirements:
139
- - - '>='
139
+ - - ">="
140
140
  - !ruby/object:Gem::Version
141
141
  version: '0'
142
142
  - !ruby/object:Gem::Dependency
143
143
  name: bump
144
144
  requirement: !ruby/object:Gem::Requirement
145
145
  requirements:
146
- - - ~>
146
+ - - "~>"
147
147
  - !ruby/object:Gem::Version
148
148
  version: 0.4.0
149
149
  type: :development
150
150
  prerelease: false
151
151
  version_requirements: !ruby/object:Gem::Requirement
152
152
  requirements:
153
- - - ~>
153
+ - - "~>"
154
154
  - !ruby/object:Gem::Version
155
155
  version: 0.4.0
156
156
  description: Support to help you develop Zendesk Apps.
@@ -160,6 +160,11 @@ executables: []
160
160
  extensions: []
161
161
  extra_rdoc_files: []
162
162
  files:
163
+ - LICENSE
164
+ - README.md
165
+ - config/locales/en.yml
166
+ - config/locales/translations/zendesk_apps_support.yml
167
+ - lib/zendesk_apps_support.rb
163
168
  - lib/zendesk_apps_support/app_file.rb
164
169
  - lib/zendesk_apps_support/app_requirement.rb
165
170
  - lib/zendesk_apps_support/app_version.rb
@@ -180,11 +185,6 @@ files:
180
185
  - lib/zendesk_apps_support/validations/templates.rb
181
186
  - lib/zendesk_apps_support/validations/translations.rb
182
187
  - lib/zendesk_apps_support/validations/validation_error.rb
183
- - lib/zendesk_apps_support.rb
184
- - config/locales/en.yml
185
- - config/locales/translations/zendesk_apps_support.yml
186
- - README.md
187
- - LICENSE
188
188
  homepage: http://github.com/zendesk/zendesk_apps_support
189
189
  licenses:
190
190
  - Apache License Version 2.0
@@ -195,17 +195,17 @@ require_paths:
195
195
  - lib
196
196
  required_ruby_version: !ruby/object:Gem::Requirement
197
197
  requirements:
198
- - - '>='
198
+ - - ">="
199
199
  - !ruby/object:Gem::Version
200
200
  version: '0'
201
201
  required_rubygems_version: !ruby/object:Gem::Requirement
202
202
  requirements:
203
- - - '>='
203
+ - - ">="
204
204
  - !ruby/object:Gem::Version
205
205
  version: 1.3.6
206
206
  requirements: []
207
207
  rubyforge_project:
208
- rubygems_version: 2.0.14
208
+ rubygems_version: 2.2.2
209
209
  signing_key:
210
210
  specification_version: 4
211
211
  summary: Support to help you develop Zendesk Apps.