angular-html2js 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
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
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 6a191bf51b42cad4c053d8ce6ad460c9624037bd
4
+ data.tar.gz: b7f1317aec4355fa183c155cad9f05b6968154d5
5
+ SHA512:
6
+ metadata.gz: 72986d613b0d3f79eee40c5e621797fa610949c97b5d5014199c5478a2b34e93cfb5c1be38a3a1b0ae90644b16b951519f822dda1e0d82babfcf50b3565ee357
7
+ data.tar.gz: 89c45b124a9ad329e2e37bb682d09006cd96d0a043978eb36f33d8b8ff01dfbbb9ba5c0a0857463bddceb7632526e0372b5931b4b74dcbae782b75d28e4bb254
data/.gitignore ADDED
@@ -0,0 +1,17 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --color
2
+ --format progress
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in angular-html2js.gemspec
4
+ gemspec
data/LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2013 K3 Integrations, LLC
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy of
6
+ this software and associated documentation files (the "Software"), to deal in
7
+ the Software without restriction, including without limitation the rights to
8
+ use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
9
+ the Software, and to permit persons to whom the Software is furnished to do so,
10
+ subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
17
+ FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
18
+ COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
19
+ IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
20
+ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,138 @@
1
+ # Angular-html2js
2
+
3
+ Angular-html2js is based off the Karma [preprocessor](https://github.com/karma-runner/karma-ng-html2js-preprocessor)
4
+ that many Angular folks use. This gem makes your templates available through the Rails asset pipeline, Sprockets,
5
+ or Tilt, while still acting like Karam's ng-html2js. So it should feel familiar to those already
6
+ using ng-html2js and should be less confusing for those following instructions in online
7
+ tutorials.
8
+
9
+ Look in the usage section below for examples.
10
+
11
+ ## Installation
12
+
13
+ Add this line to your application's Gemfile:
14
+
15
+ gem 'angular-html2js'
16
+
17
+ And then execute:
18
+
19
+ $ bundle
20
+
21
+ Or install it yourself as:
22
+
23
+ $ gem install angular-html2js
24
+
25
+ ## Usage
26
+
27
+ This gem adds support for AngularJS templates. Those familiar with the Karma
28
+ test runner will be able to use the familiar `beforeEach(module('myTemplateModule'))`
29
+ or `beforeEach(module('/your/template/file'))`. Additionally, you can now leverage
30
+ sprockets to help you. In Rails, this means that you can also inline your templates in
31
+ production!
32
+
33
+ ### Include in global module (recommended)
34
+
35
+ 1. Configure a top level shared module
36
+
37
+ ```ruby
38
+ # In Rails
39
+ MyApp::Application.configure do
40
+ config.angular_html2js.module_name = 'MyApp'
41
+ end
42
+
43
+ # or Any
44
+ Angular::Html2js.configure do |config|
45
+ config.angular_html2js.module_name = 'MyApp'
46
+ end
47
+ ```
48
+ 2. Now just require the template before the code needing it (perhaps a directive)
49
+
50
+ ```javascript
51
+ //= require my_template
52
+
53
+ angular.module('myApp').directive('myDirective', function($injectable){
54
+ { restrict: 'A'
55
+ templateUrl: 'my_template'
56
+ // Etc...
57
+ }
58
+ });
59
+ ```
60
+
61
+ ### Using auto-generated modules (No configuration needed)
62
+
63
+ * Just require your template, depend on the automatically generated module
64
+ (named after the template), and use the template path as your templateURL
65
+
66
+ ```javascript
67
+ //= require full/path/to/my_template
68
+
69
+ angular.module('myApp', ['/full/path/to/myTemplate.html']).directive('myDirective', function($injectable){
70
+ { restrict: 'A'
71
+ templateUrl: 'full/path/to/myTemplate'
72
+ // Etc...
73
+ }
74
+ });
75
+ ```
76
+
77
+ ### Use custom module
78
+
79
+ 1. Configure a top level shared module
80
+
81
+ ```ruby
82
+ # In Rails
83
+ MyApp::Application.configure do
84
+ config.angular_html2js.module_name = 'MyTemplates'
85
+ end
86
+ ```
87
+
88
+ 2. Depend on that module
89
+
90
+ ```javascript
91
+ //= require full/path/to/myTemplate
92
+
93
+ angular.module('myApp', ['MyTemplates']).directive('myDirective', function($injectable){
94
+ { restrict: 'A'
95
+ templateUrl: 'full/path/to/myTemplate'
96
+ // Etc...
97
+ }
98
+ });
99
+ ```
100
+
101
+ ### Use custom module and template ID
102
+
103
+ 1. Configure a top level shared module and custom cache ID
104
+
105
+ ```ruby
106
+ # In Rails
107
+ MyApp::Application.configure do
108
+ config.angular_html2js.module_name = 'MyTemplates'
109
+
110
+ # `file` is the full file path
111
+ # `scope` is the Sprockets scope. This has handy things like scope.logical_path
112
+ #
113
+ config.angular_html2js.cache_id {|file_path, scope|
114
+ "myTemplates-#{scope.logical_path}"
115
+ }
116
+ end
117
+ ```
118
+
119
+ 2. Depend on that module and use the cache ID you configured above for the templateUrl
120
+
121
+ ```javascript
122
+ //= require templates/myTpl
123
+
124
+ angular.module('myApp', ['MyTemplates']).directive('myDirective', function($injectable){
125
+ { restrict: 'A'
126
+ templateUrl: 'myTemplates-templates/myTpl'
127
+ // Etc...
128
+ }
129
+ });
130
+ ```
131
+
132
+ ## Contributing
133
+
134
+ 1. Fork it
135
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
136
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
137
+ 4. Push to the branch (`git push origin my-new-feature`)
138
+ 5. Create new Pull Request
data/Rakefile ADDED
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
@@ -0,0 +1,33 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'angular/html2js/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "angular-html2js"
8
+ spec.version = Angular::Html2js::VERSION
9
+ spec.authors = ["Nicholas Clark"]
10
+ spec.email = ["nick.clark@k3integrations.com"]
11
+ spec.description = %q{Angular HTML2JS allows you to use ng templates as first class citizens in the Rails/Sprockets world. Based on the karma-ng-html2js-preprocessor for Karma.}
12
+ spec.summary = %q{AngularJS HTML templates in Sprockets and Rails}
13
+ spec.homepage = "http://www.k3integrations.com"
14
+ spec.license = "MIT"
15
+
16
+ spec.files = `git ls-files`.split($/)
17
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
+ spec.require_paths = ["lib"]
20
+
21
+ spec.add_dependency "tilt", "~> 1.0"
22
+ spec.add_dependency "sprockets", "~> 2.0"
23
+
24
+ spec.add_development_dependency "bundler", "~> 1.3"
25
+ spec.add_development_dependency "rspec", "~> 2.12"
26
+ spec.add_development_dependency "rake", "~> 10.1.0"
27
+ spec.add_development_dependency "pry"
28
+ spec.add_development_dependency "therubyracer", "~> 0.11.4"
29
+ spec.add_development_dependency "coffee-script", "2.2.0"
30
+ spec.add_development_dependency "rails", "~> 4.0.0"
31
+ spec.add_development_dependency "capybara", "~> 2.1.0"
32
+ spec.add_development_dependency "sqlite3", "~> 1.3.7"
33
+ end
data/app/.gitignore ADDED
@@ -0,0 +1,16 @@
1
+ # See http://help.github.com/ignore-files/ for more about ignoring files.
2
+ #
3
+ # If you find yourself ignoring temporary files generated by your text editor
4
+ # or operating system, you probably want to add a global ignore instead:
5
+ # git config --global core.excludesfile '~/.gitignore_global'
6
+
7
+ # Ignore bundler config.
8
+ /.bundle
9
+
10
+ # Ignore the default SQLite database.
11
+ /db/*.sqlite3
12
+ /db/*.sqlite3-journal
13
+
14
+ # Ignore all logfiles and tempfiles.
15
+ /log/*.log
16
+ /tmp
data/app/Gemfile ADDED
@@ -0,0 +1,48 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
4
+ gem 'rails', '4.0.0'
5
+
6
+ # Use sqlite3 as the database for Active Record
7
+ #gem 'sqlite3'
8
+
9
+ # Use SCSS for stylesheets
10
+ #gem 'sass-rails', '~> 4.0.0'
11
+
12
+ # Use Uglifier as compressor for JavaScript assets
13
+ #gem 'uglifier', '>= 1.3.0'
14
+
15
+ # Use CoffeeScript for .js.coffee assets and views
16
+ #gem 'coffee-rails', '~> 4.0.0'
17
+
18
+ # See https://github.com/sstephenson/execjs#readme for more supported runtimes
19
+ # gem 'therubyracer', platforms: :ruby
20
+
21
+ # Use jquery as the JavaScript library
22
+ #gem 'jquery-rails'
23
+
24
+ # Turbolinks makes following links in your web application faster. Read more: https://github.com/rails/turbolinks
25
+ #gem 'turbolinks'
26
+
27
+ # Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder
28
+ #gem 'jbuilder', '~> 1.2'
29
+
30
+ #group :doc do
31
+ # bundle exec rake doc:rails generates the API under doc/api.
32
+ #gem 'sdoc', require: false
33
+ #end
34
+
35
+ # Use ActiveModel has_secure_password
36
+ # gem 'bcrypt-ruby', '~> 3.0.0'
37
+
38
+ # Use unicorn as the app server
39
+ # gem 'unicorn'
40
+
41
+ # Use Capistrano for deployment
42
+ # gem 'capistrano', group: :development
43
+
44
+ # Use debugger
45
+ # gem 'debugger', group: [:development, :test]
46
+
47
+ gem 'rspec'
48
+ gem 'angular-html2js', path: '../'
data/app/Rakefile ADDED
@@ -0,0 +1,6 @@
1
+ # Add your own tasks in files placed in lib/tasks ending in .rake,
2
+ # for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.
3
+
4
+ require File.expand_path('../config/application', __FILE__)
5
+
6
+ App::Application.load_tasks
@@ -0,0 +1 @@
1
+ <html>Hello World</html>
data/app/bin/bundle ADDED
@@ -0,0 +1,3 @@
1
+ #!/usr/bin/env ruby
2
+ ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', __FILE__)
3
+ load Gem.bin_path('bundler', 'bundle')
data/app/bin/rails ADDED
@@ -0,0 +1,4 @@
1
+ #!/usr/bin/env ruby
2
+ APP_PATH = File.expand_path('../../config/application', __FILE__)
3
+ require_relative '../config/boot'
4
+ require 'rails/commands'
data/app/bin/rake ADDED
@@ -0,0 +1,4 @@
1
+ #!/usr/bin/env ruby
2
+ require_relative '../config/boot'
3
+ require 'rake'
4
+ Rake.application.run
data/app/config.ru ADDED
@@ -0,0 +1,4 @@
1
+ # This file is used by Rack-based servers to start the application.
2
+
3
+ require ::File.expand_path('../config/environment', __FILE__)
4
+ run Rails.application
@@ -0,0 +1,23 @@
1
+ require File.expand_path('../boot', __FILE__)
2
+
3
+ require 'rails/all'
4
+
5
+ # Require the gems listed in Gemfile, including any gems
6
+ # you've limited to :test, :development, or :production.
7
+ Bundler.require(:default, Rails.env)
8
+
9
+ module App
10
+ class Application < Rails::Application
11
+ # Settings in config/environments/* take precedence over those specified here.
12
+ # Application configuration should go into files in config/initializers
13
+ # -- all .rb files in that directory are automatically loaded.
14
+
15
+ # Set Time.zone default to the specified zone and make Active Record auto-convert to this zone.
16
+ # Run "rake -D time" for a list of tasks for finding time zone names. Default is UTC.
17
+ # config.time_zone = 'Central Time (US & Canada)'
18
+
19
+ # The default locale is :en and all translations from config/locales/*.rb,yml are auto loaded.
20
+ # config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}').to_s]
21
+ # config.i18n.default_locale = :de
22
+ end
23
+ end
@@ -0,0 +1,4 @@
1
+ # Set up gems listed in the Gemfile.
2
+ ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', __FILE__)
3
+
4
+ require 'bundler/setup' if File.exists?(ENV['BUNDLE_GEMFILE'])
@@ -0,0 +1,25 @@
1
+ # SQLite version 3.x
2
+ # gem install sqlite3
3
+ #
4
+ # Ensure the SQLite 3 gem is defined in your Gemfile
5
+ # gem 'sqlite3'
6
+ development:
7
+ adapter: sqlite3
8
+ database: db/development.sqlite3
9
+ pool: 5
10
+ timeout: 5000
11
+
12
+ # Warning: The database defined as "test" will be erased and
13
+ # re-generated from your development database when you run "rake".
14
+ # Do not set this db to the same as development or production.
15
+ test:
16
+ adapter: sqlite3
17
+ database: db/test.sqlite3
18
+ pool: 5
19
+ timeout: 5000
20
+
21
+ production:
22
+ adapter: sqlite3
23
+ database: db/production.sqlite3
24
+ pool: 5
25
+ timeout: 5000
@@ -0,0 +1,5 @@
1
+ # Load the Rails application.
2
+ require File.expand_path('../application', __FILE__)
3
+
4
+ # Initialize the Rails application.
5
+ App::Application.initialize!
@@ -0,0 +1,29 @@
1
+ App::Application.configure do
2
+ # Settings specified here will take precedence over those in config/application.rb.
3
+
4
+ # In the development environment your application's code is reloaded on
5
+ # every request. This slows down response time but is perfect for development
6
+ # since you don't have to restart the web server when you make code changes.
7
+ config.cache_classes = false
8
+
9
+ # Do not eager load code on boot.
10
+ config.eager_load = false
11
+
12
+ # Show full error reports and disable caching.
13
+ config.consider_all_requests_local = true
14
+ config.action_controller.perform_caching = false
15
+
16
+ # Don't care if the mailer can't send.
17
+ config.action_mailer.raise_delivery_errors = false
18
+
19
+ # Print deprecation notices to the Rails logger.
20
+ config.active_support.deprecation = :log
21
+
22
+ # Raise an error on page load if there are pending migrations
23
+ config.active_record.migration_error = :page_load
24
+
25
+ # Debug mode disables concatenation and preprocessing of assets.
26
+ # This option may cause significant delays in view rendering with a large
27
+ # number of complex assets.
28
+ config.assets.debug = true
29
+ end
@@ -0,0 +1,80 @@
1
+ App::Application.configure do
2
+ # Settings specified here will take precedence over those in config/application.rb.
3
+
4
+ # Code is not reloaded between requests.
5
+ config.cache_classes = true
6
+
7
+ # Eager load code on boot. This eager loads most of Rails and
8
+ # your application in memory, allowing both thread web servers
9
+ # and those relying on copy on write to perform better.
10
+ # Rake tasks automatically ignore this option for performance.
11
+ config.eager_load = true
12
+
13
+ # Full error reports are disabled and caching is turned on.
14
+ config.consider_all_requests_local = false
15
+ config.action_controller.perform_caching = true
16
+
17
+ # Enable Rack::Cache to put a simple HTTP cache in front of your application
18
+ # Add `rack-cache` to your Gemfile before enabling this.
19
+ # For large-scale production use, consider using a caching reverse proxy like nginx, varnish or squid.
20
+ # config.action_dispatch.rack_cache = true
21
+
22
+ # Disable Rails's static asset server (Apache or nginx will already do this).
23
+ config.serve_static_assets = false
24
+
25
+ # Compress JavaScripts and CSS.
26
+ config.assets.js_compressor = :uglifier
27
+ # config.assets.css_compressor = :sass
28
+
29
+ # Do not fallback to assets pipeline if a precompiled asset is missed.
30
+ config.assets.compile = false
31
+
32
+ # Generate digests for assets URLs.
33
+ config.assets.digest = true
34
+
35
+ # Version of your assets, change this if you want to expire all your assets.
36
+ config.assets.version = '1.0'
37
+
38
+ # Specifies the header that your server uses for sending files.
39
+ # config.action_dispatch.x_sendfile_header = "X-Sendfile" # for apache
40
+ # config.action_dispatch.x_sendfile_header = 'X-Accel-Redirect' # for nginx
41
+
42
+ # Force all access to the app over SSL, use Strict-Transport-Security, and use secure cookies.
43
+ # config.force_ssl = true
44
+
45
+ # Set to :debug to see everything in the log.
46
+ config.log_level = :info
47
+
48
+ # Prepend all log lines with the following tags.
49
+ # config.log_tags = [ :subdomain, :uuid ]
50
+
51
+ # Use a different logger for distributed setups.
52
+ # config.logger = ActiveSupport::TaggedLogging.new(SyslogLogger.new)
53
+
54
+ # Use a different cache store in production.
55
+ # config.cache_store = :mem_cache_store
56
+
57
+ # Enable serving of images, stylesheets, and JavaScripts from an asset server.
58
+ # config.action_controller.asset_host = "http://assets.example.com"
59
+
60
+ # Precompile additional assets.
61
+ # application.js, application.css, and all non-JS/CSS in app/assets folder are already added.
62
+ # config.assets.precompile += %w( search.js )
63
+
64
+ # Ignore bad email addresses and do not raise email delivery errors.
65
+ # Set this to true and configure the email server for immediate delivery to raise delivery errors.
66
+ # config.action_mailer.raise_delivery_errors = false
67
+
68
+ # Enable locale fallbacks for I18n (makes lookups for any locale fall back to
69
+ # the I18n.default_locale when a translation can not be found).
70
+ config.i18n.fallbacks = true
71
+
72
+ # Send deprecation notices to registered listeners.
73
+ config.active_support.deprecation = :notify
74
+
75
+ # Disable automatic flushing of the log to improve performance.
76
+ # config.autoflush_log = false
77
+
78
+ # Use default logging formatter so that PID and timestamp are not suppressed.
79
+ config.log_formatter = ::Logger::Formatter.new
80
+ end