angular-html2js 0.0.1

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.
Files changed (48) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +17 -0
  3. data/.rspec +2 -0
  4. data/Gemfile +4 -0
  5. data/LICENSE +20 -0
  6. data/README.md +138 -0
  7. data/Rakefile +1 -0
  8. data/angular-html2js.gemspec +33 -0
  9. data/app/.gitignore +16 -0
  10. data/app/Gemfile +48 -0
  11. data/app/Rakefile +6 -0
  12. data/app/app/assets/javascripts/templates/test.js.ngt +1 -0
  13. data/app/bin/bundle +3 -0
  14. data/app/bin/rails +4 -0
  15. data/app/bin/rake +4 -0
  16. data/app/config.ru +4 -0
  17. data/app/config/application.rb +23 -0
  18. data/app/config/boot.rb +4 -0
  19. data/app/config/database.yml +25 -0
  20. data/app/config/environment.rb +5 -0
  21. data/app/config/environments/development.rb +29 -0
  22. data/app/config/environments/production.rb +80 -0
  23. data/app/config/environments/test.rb +36 -0
  24. data/app/config/initializers/backtrace_silencers.rb +7 -0
  25. data/app/config/initializers/filter_parameter_logging.rb +4 -0
  26. data/app/config/initializers/inflections.rb +16 -0
  27. data/app/config/initializers/mime_types.rb +5 -0
  28. data/app/config/initializers/secret_token.rb +12 -0
  29. data/app/config/initializers/session_store.rb +3 -0
  30. data/app/config/initializers/wrap_parameters.rb +14 -0
  31. data/app/config/locales/en.yml +23 -0
  32. data/app/config/routes.rb +56 -0
  33. data/app/db/seeds.rb +7 -0
  34. data/app/log/.keep +0 -0
  35. data/lib/angular/html2js.rb +3 -0
  36. data/lib/angular/html2js/configuration.rb +39 -0
  37. data/lib/angular/html2js/engine.rb +14 -0
  38. data/lib/angular/html2js/railtie.rb +18 -0
  39. data/lib/angular/html2js/template.rb +66 -0
  40. data/lib/angular/html2js/version.rb +5 -0
  41. data/spec/angular/html2js/engine_spec.rb +31 -0
  42. data/spec/angular/html2js/railtie_spec.rb +39 -0
  43. data/spec/angular/html2js/template_spec.rb +89 -0
  44. data/spec/assets/test.js.ngt +1 -0
  45. data/spec/spec_helper.rb +15 -0
  46. data/spec/support/template_cache.coffee +27 -0
  47. data/spec/support/template_matchers.rb +70 -0
  48. metadata +252 -0
@@ -0,0 +1 @@
1
+ <html></html>
@@ -0,0 +1,15 @@
1
+ require 'pry'
2
+
3
+ RSpec.configure do |config|
4
+ config.treat_symbols_as_metadata_keys_with_true_values = true
5
+ config.run_all_when_everything_filtered = true
6
+ config.filter_run :focus
7
+
8
+ # Run specs in random order to surface order dependencies. If you find an
9
+ # order dependency and want to debug it, you can fix the order by providing
10
+ # the seed, which is printed after each run.
11
+ # --seed 1234
12
+ config.order = 'random'
13
+
14
+ require 'support/template_matchers'
15
+ end
@@ -0,0 +1,27 @@
1
+ class AngularModule
2
+ constructor: (@name, @deps) ->
3
+ templates = @templates = {}
4
+
5
+ run: (block) ->
6
+ block
7
+ put: (id, content) =>
8
+ @templates[id] = content
9
+
10
+ # Evaluates generated js code fot the template cache
11
+ # processedContent - The String to be evaluated
12
+ # Returns an object with the following fields
13
+ # moduleName - generated module name `angular.module('myApp')...`
14
+ # templateId - generated template id `$templateCache.put('id', ...)`
15
+ # templateContent - template content `$templateCache.put(..., <div>cache me!</div>')`
16
+ @evaluateTemplate = (processedContent) ->
17
+ modules = {}
18
+
19
+ angular =
20
+ module: (name, deps) ->
21
+ if deps? then return modules[name] = new AngularModule name, deps
22
+ if modules[name] then return modules[name]
23
+ throw new Error "Module #{name} does not exists!"
24
+
25
+ eval processedContent
26
+
27
+ modules
@@ -0,0 +1,70 @@
1
+ require 'v8'
2
+ require 'coffee-script'
3
+
4
+ module Angular
5
+ module Html2js
6
+ TEMPLATE_HELPER = CoffeeScript.compile(File.read("spec/support/template_cache.coffee"))
7
+ end
8
+ end
9
+
10
+ RSpec::Matchers.define :define_module do |module_name|
11
+
12
+ match do |template|
13
+ @modules = modules_from(template)
14
+ @mod = @modules[module_name]
15
+ @content = @mod && @mod.templates[@template_id]
16
+ has_module && has_template_id && has_content
17
+ end
18
+
19
+ chain :with_template_id do |template_id|
20
+ @template_id = template_id
21
+ end
22
+
23
+ chain :and_content do |content|
24
+ @expected_content = content
25
+ end
26
+
27
+ def has_module
28
+ !!@mod
29
+ end
30
+
31
+ def has_template_id
32
+ return true unless @template_id
33
+ @template_id && @content
34
+ end
35
+
36
+ def has_content
37
+ return true unless @expected_content
38
+ @expected_content && (@content == @expected_content)
39
+ end
40
+
41
+ failure_message_for_should do |template|
42
+ failure_message
43
+ end
44
+
45
+ define_method :failure_message do |not_msg: nil|
46
+ msg = "Template expected"
47
+ msg += ' not' if not_msg
48
+
49
+ msg + if !has_module
50
+ " to define module '#{module_name}', found: #{@modules.keys}"
51
+ elsif !has_template_id
52
+ " to define template_id '#{@template_id}', found: #{@mod.templates.keys}"
53
+ elsif !has_content
54
+ " to have content #{@expected_content.inspect}, found: #{@content.inspect}"
55
+ else
56
+ "; Unknown reason"
57
+ end
58
+ end
59
+
60
+ failure_message_for_should_not do |template|
61
+ failure_message('not')
62
+ end
63
+
64
+ def modules_from(template)
65
+ cxt = V8::Context.new
66
+ cxt.eval(Angular::Html2js::TEMPLATE_HELPER, "spec/helpers/template_cache.coffee")
67
+ cxt['template'] = template
68
+ cxt.eval('evaluateTemplate(template)')
69
+ end
70
+ end
metadata ADDED
@@ -0,0 +1,252 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: angular-html2js
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Nicholas Clark
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2013-09-03 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: tilt
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ~>
18
+ - !ruby/object:Gem::Version
19
+ version: '1.0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ~>
25
+ - !ruby/object:Gem::Version
26
+ version: '1.0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: sprockets
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ~>
32
+ - !ruby/object:Gem::Version
33
+ version: '2.0'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ~>
39
+ - !ruby/object:Gem::Version
40
+ version: '2.0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: bundler
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ~>
46
+ - !ruby/object:Gem::Version
47
+ version: '1.3'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ~>
53
+ - !ruby/object:Gem::Version
54
+ version: '1.3'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rspec
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ~>
60
+ - !ruby/object:Gem::Version
61
+ version: '2.12'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ~>
67
+ - !ruby/object:Gem::Version
68
+ version: '2.12'
69
+ - !ruby/object:Gem::Dependency
70
+ name: rake
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ~>
74
+ - !ruby/object:Gem::Version
75
+ version: 10.1.0
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ~>
81
+ - !ruby/object:Gem::Version
82
+ version: 10.1.0
83
+ - !ruby/object:Gem::Dependency
84
+ name: pry
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - '>='
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - '>='
95
+ - !ruby/object:Gem::Version
96
+ version: '0'
97
+ - !ruby/object:Gem::Dependency
98
+ name: therubyracer
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - ~>
102
+ - !ruby/object:Gem::Version
103
+ version: 0.11.4
104
+ type: :development
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - ~>
109
+ - !ruby/object:Gem::Version
110
+ version: 0.11.4
111
+ - !ruby/object:Gem::Dependency
112
+ name: coffee-script
113
+ requirement: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - '='
116
+ - !ruby/object:Gem::Version
117
+ version: 2.2.0
118
+ type: :development
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - '='
123
+ - !ruby/object:Gem::Version
124
+ version: 2.2.0
125
+ - !ruby/object:Gem::Dependency
126
+ name: rails
127
+ requirement: !ruby/object:Gem::Requirement
128
+ requirements:
129
+ - - ~>
130
+ - !ruby/object:Gem::Version
131
+ version: 4.0.0
132
+ type: :development
133
+ prerelease: false
134
+ version_requirements: !ruby/object:Gem::Requirement
135
+ requirements:
136
+ - - ~>
137
+ - !ruby/object:Gem::Version
138
+ version: 4.0.0
139
+ - !ruby/object:Gem::Dependency
140
+ name: capybara
141
+ requirement: !ruby/object:Gem::Requirement
142
+ requirements:
143
+ - - ~>
144
+ - !ruby/object:Gem::Version
145
+ version: 2.1.0
146
+ type: :development
147
+ prerelease: false
148
+ version_requirements: !ruby/object:Gem::Requirement
149
+ requirements:
150
+ - - ~>
151
+ - !ruby/object:Gem::Version
152
+ version: 2.1.0
153
+ - !ruby/object:Gem::Dependency
154
+ name: sqlite3
155
+ requirement: !ruby/object:Gem::Requirement
156
+ requirements:
157
+ - - ~>
158
+ - !ruby/object:Gem::Version
159
+ version: 1.3.7
160
+ type: :development
161
+ prerelease: false
162
+ version_requirements: !ruby/object:Gem::Requirement
163
+ requirements:
164
+ - - ~>
165
+ - !ruby/object:Gem::Version
166
+ version: 1.3.7
167
+ description: Angular HTML2JS allows you to use ng templates as first class citizens
168
+ in the Rails/Sprockets world. Based on the karma-ng-html2js-preprocessor for Karma.
169
+ email:
170
+ - nick.clark@k3integrations.com
171
+ executables: []
172
+ extensions: []
173
+ extra_rdoc_files: []
174
+ files:
175
+ - .gitignore
176
+ - .rspec
177
+ - Gemfile
178
+ - LICENSE
179
+ - README.md
180
+ - Rakefile
181
+ - angular-html2js.gemspec
182
+ - app/.gitignore
183
+ - app/Gemfile
184
+ - app/Rakefile
185
+ - app/app/assets/javascripts/templates/test.js.ngt
186
+ - app/bin/bundle
187
+ - app/bin/rails
188
+ - app/bin/rake
189
+ - app/config.ru
190
+ - app/config/application.rb
191
+ - app/config/boot.rb
192
+ - app/config/database.yml
193
+ - app/config/environment.rb
194
+ - app/config/environments/development.rb
195
+ - app/config/environments/production.rb
196
+ - app/config/environments/test.rb
197
+ - app/config/initializers/backtrace_silencers.rb
198
+ - app/config/initializers/filter_parameter_logging.rb
199
+ - app/config/initializers/inflections.rb
200
+ - app/config/initializers/mime_types.rb
201
+ - app/config/initializers/secret_token.rb
202
+ - app/config/initializers/session_store.rb
203
+ - app/config/initializers/wrap_parameters.rb
204
+ - app/config/locales/en.yml
205
+ - app/config/routes.rb
206
+ - app/db/seeds.rb
207
+ - app/log/.keep
208
+ - lib/angular/html2js.rb
209
+ - lib/angular/html2js/configuration.rb
210
+ - lib/angular/html2js/engine.rb
211
+ - lib/angular/html2js/railtie.rb
212
+ - lib/angular/html2js/template.rb
213
+ - lib/angular/html2js/version.rb
214
+ - spec/angular/html2js/engine_spec.rb
215
+ - spec/angular/html2js/railtie_spec.rb
216
+ - spec/angular/html2js/template_spec.rb
217
+ - spec/assets/test.js.ngt
218
+ - spec/spec_helper.rb
219
+ - spec/support/template_cache.coffee
220
+ - spec/support/template_matchers.rb
221
+ homepage: http://www.k3integrations.com
222
+ licenses:
223
+ - MIT
224
+ metadata: {}
225
+ post_install_message:
226
+ rdoc_options: []
227
+ require_paths:
228
+ - lib
229
+ required_ruby_version: !ruby/object:Gem::Requirement
230
+ requirements:
231
+ - - '>='
232
+ - !ruby/object:Gem::Version
233
+ version: '0'
234
+ required_rubygems_version: !ruby/object:Gem::Requirement
235
+ requirements:
236
+ - - '>='
237
+ - !ruby/object:Gem::Version
238
+ version: '0'
239
+ requirements: []
240
+ rubyforge_project:
241
+ rubygems_version: 2.0.3
242
+ signing_key:
243
+ specification_version: 4
244
+ summary: AngularJS HTML templates in Sprockets and Rails
245
+ test_files:
246
+ - spec/angular/html2js/engine_spec.rb
247
+ - spec/angular/html2js/railtie_spec.rb
248
+ - spec/angular/html2js/template_spec.rb
249
+ - spec/assets/test.js.ngt
250
+ - spec/spec_helper.rb
251
+ - spec/support/template_cache.coffee
252
+ - spec/support/template_matchers.rb