t3-rails 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/MIT-LICENSE +20 -0
- data/README.md +74 -0
- data/Rakefile +41 -0
- data/lib/generators/t3/behavior_generator.rb +17 -0
- data/lib/generators/t3/bootstrap_generator.rb +42 -0
- data/lib/generators/t3/generator_helper.rb +19 -0
- data/lib/generators/t3/module_generator.rb +17 -0
- data/lib/generators/t3/service_generator.rb +17 -0
- data/lib/generators/templates/behavior.js +45 -0
- data/lib/generators/templates/module.js +45 -0
- data/lib/generators/templates/service.js +45 -0
- data/lib/t3/rails.rb +8 -0
- data/lib/t3/rails/version.rb +6 -0
- data/test/dummy/README.rdoc +28 -0
- data/test/dummy/Rakefile +6 -0
- data/test/dummy/app/assets/javascripts/application.js +13 -0
- data/test/dummy/app/assets/stylesheets/application.css +15 -0
- data/test/dummy/app/controllers/application_controller.rb +5 -0
- data/test/dummy/app/helpers/application_helper.rb +2 -0
- data/test/dummy/app/views/layouts/application.html.erb +14 -0
- data/test/dummy/bin/bundle +3 -0
- data/test/dummy/bin/rails +4 -0
- data/test/dummy/bin/rake +4 -0
- data/test/dummy/bin/setup +29 -0
- data/test/dummy/config.ru +4 -0
- data/test/dummy/config/application.rb +27 -0
- data/test/dummy/config/boot.rb +5 -0
- data/test/dummy/config/environment.rb +5 -0
- data/test/dummy/config/environments/development.rb +41 -0
- data/test/dummy/config/environments/production.rb +79 -0
- data/test/dummy/config/environments/test.rb +42 -0
- data/test/dummy/config/initializers/assets.rb +11 -0
- data/test/dummy/config/initializers/backtrace_silencers.rb +7 -0
- data/test/dummy/config/initializers/cookies_serializer.rb +3 -0
- data/test/dummy/config/initializers/filter_parameter_logging.rb +4 -0
- data/test/dummy/config/initializers/inflections.rb +16 -0
- data/test/dummy/config/initializers/mime_types.rb +4 -0
- data/test/dummy/config/initializers/session_store.rb +3 -0
- data/test/dummy/config/initializers/wrap_parameters.rb +14 -0
- data/test/dummy/config/locales/en.yml +23 -0
- data/test/dummy/config/routes.rb +56 -0
- data/test/dummy/config/secrets.yml +22 -0
- data/test/dummy/log/development.log +4 -0
- data/test/dummy/log/test.log +3962 -0
- data/test/dummy/public/404.html +67 -0
- data/test/dummy/public/422.html +67 -0
- data/test/dummy/public/500.html +66 -0
- data/test/dummy/public/favicon.ico +0 -0
- data/test/dummy/tmp/app/assets/javascripts/behaviors/validate.js +45 -0
- data/test/generators/behavior_generator_test.rb +21 -0
- data/test/generators/bootstrap_generator_test.rb +75 -0
- data/test/generators/module_generator_test.rb +21 -0
- data/test/generators/service_generator_test.rb +21 -0
- data/test/t3_rails_test.rb +13 -0
- data/test/test_helper.rb +18 -0
- data/vendor/assets/javascripts/t3-testing.js +459 -0
- data/vendor/assets/javascripts/t3.js +1233 -0
- data/vendor/assets/javascripts/t3.min.js +18 -0
- metadata +172 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: cbfb2287b40b6b9a0382065e4dfd22ca90c0f8a5
|
4
|
+
data.tar.gz: 841a9684161684840b841df46a4e574c802cd7b7
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 579a88e36b6d8a2a30de4ee303e42213d34a34909f250e6f0cf419b62b092ebb551fdc2f892824b1e63639392f437a9de4c6b5439ed1efe2e9927b94ed33a98a
|
7
|
+
data.tar.gz: b493e2ce472bcc51d6028073f1db9222984df6d9e8024bc22a63fdf696f79afe5e5d7e8c52e39c86af9cf831a09a0f2a62c199f65ec8aaede37d8983414ebe47
|
data/MIT-LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright 2015 Dom Christie
|
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,74 @@
|
|
1
|
+
# t3-rails
|
2
|
+
|
3
|
+
Easily set up the [T3 JavaScript framework](http://t3js.org/) within your Rails 4+ application.
|
4
|
+
|
5
|
+
This gem includes the T3 assets (including the T3 testing bundle), along with generators for setting up application structure and for creating modules, services, and behaviors.
|
6
|
+
|
7
|
+
**Note**: this gem is currently in development and as such has not been thoroughly tested in the wild. Testing and improvements (particularly regarding older versions of Ruby/Rails) are welcome!
|
8
|
+
|
9
|
+
## Getting Started
|
10
|
+
|
11
|
+
Add the gem to your application Gemfile:
|
12
|
+
|
13
|
+
```ruby
|
14
|
+
gem 't3-rails'
|
15
|
+
```
|
16
|
+
|
17
|
+
Run `bundle install`, then generate the application structure:
|
18
|
+
|
19
|
+
```
|
20
|
+
rails g t3:bootstrap
|
21
|
+
```
|
22
|
+
|
23
|
+
Initialize your T3 app by calling `Box.Application.init()`. As the [T3 docs](http://t3js.org/docs/getting-started/application) suggest, you may want to call `init()`:
|
24
|
+
|
25
|
+
> - Inline at the bottom of the page
|
26
|
+
> - In a window.onload event handler
|
27
|
+
> - In a DOMContentLoaded event handler
|
28
|
+
|
29
|
+
For example to initialize on DOM ready and on page load (a Turbolinks event), you may want to include the following:
|
30
|
+
|
31
|
+
```javascript
|
32
|
+
(function() {
|
33
|
+
var init = function() { Box.Application.init(); };
|
34
|
+
$(document).ready(init).on('page:load', init);
|
35
|
+
})();
|
36
|
+
```
|
37
|
+
|
38
|
+
## Generators
|
39
|
+
|
40
|
+
### `bootstrap`
|
41
|
+
|
42
|
+
```
|
43
|
+
rails g t3:bootstrap
|
44
|
+
```
|
45
|
+
|
46
|
+
Sets up `modules`, `services`, and `behaviors` directories in `app/assets/javascripts`. Injects `require` statements in `application.js` for including the `t3.js` and the component directories.
|
47
|
+
|
48
|
+
### `module`
|
49
|
+
|
50
|
+
```
|
51
|
+
rails g t3:module name
|
52
|
+
```
|
53
|
+
|
54
|
+
Creates a new module in the `modules` directory.
|
55
|
+
|
56
|
+
### `service`
|
57
|
+
|
58
|
+
```
|
59
|
+
rails g t3:service name
|
60
|
+
```
|
61
|
+
|
62
|
+
Creates a new service in the `services` directory.
|
63
|
+
|
64
|
+
### `behavior`
|
65
|
+
|
66
|
+
```
|
67
|
+
rails g t3:behavior name
|
68
|
+
```
|
69
|
+
|
70
|
+
Creates a new behavior in the `behaviors` directory.
|
71
|
+
|
72
|
+
## Copyright and Licenses
|
73
|
+
|
74
|
+
t3-rails is copyright © 2015 Dom Christie and released under the MIT license. T3 is licensed under the Apache License, Version 2.0.
|
data/Rakefile
ADDED
@@ -0,0 +1,41 @@
|
|
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 = 'T3Rails'
|
12
|
+
rdoc.options << '--line-numbers'
|
13
|
+
rdoc.rdoc_files.include('README.rdoc')
|
14
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
15
|
+
end
|
16
|
+
|
17
|
+
Bundler::GemHelper.install_tasks
|
18
|
+
|
19
|
+
require 'rake/testtask'
|
20
|
+
|
21
|
+
Rake::TestTask.new(:test) do |t|
|
22
|
+
t.libs << 'lib'
|
23
|
+
t.libs << 'test'
|
24
|
+
t.pattern = 'test/**/*_test.rb'
|
25
|
+
t.verbose = false
|
26
|
+
end
|
27
|
+
|
28
|
+
desc "Update T3 versions"
|
29
|
+
task :update_t3 do
|
30
|
+
def download_t3(version)
|
31
|
+
%w(t3 t3.min t3-testing).each do |file_name|
|
32
|
+
puts "Downloading #{file_name}.js"
|
33
|
+
puts `curl -o vendor/assets/javascripts/#{file_name}.js http://cdn.rawgit.com/box/t3js/v#{version}/dist/#{file_name}.js`
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
download_t3(T3::Rails::T3_VERSION)
|
38
|
+
puts "\e[32mDone!\e[0m"
|
39
|
+
end
|
40
|
+
|
41
|
+
task default: :test
|
@@ -0,0 +1,17 @@
|
|
1
|
+
require 'generators/t3/generator_helper'
|
2
|
+
|
3
|
+
module T3
|
4
|
+
module Generators
|
5
|
+
class BehaviorGenerator < ::Rails::Generators::NamedBase
|
6
|
+
include T3::Generators::GeneratorHelper
|
7
|
+
|
8
|
+
source_root File.expand_path("../../templates", __FILE__)
|
9
|
+
|
10
|
+
desc 'Creates a new T3 behavior'
|
11
|
+
|
12
|
+
def create_behavior_files
|
13
|
+
create_component_files
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,42 @@
|
|
1
|
+
require 'generators/t3/generator_helper'
|
2
|
+
|
3
|
+
module T3
|
4
|
+
module Generators
|
5
|
+
class BootstrapGenerator < ::Rails::Generators::Base
|
6
|
+
include T3::Generators::GeneratorHelper
|
7
|
+
|
8
|
+
desc 'Sets up T3 and default asset directories'
|
9
|
+
class_option :skip_git, type: :boolean, aliases: '-g', default: false, desc: 'Do not create .gitkeep files'
|
10
|
+
|
11
|
+
def create_directories
|
12
|
+
components.each do |c|
|
13
|
+
empty_directory "#{install_path}/#{c}"
|
14
|
+
create_file "#{install_path}/#{c}/.gitkeep" unless options[:skip_git]
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
def inject_t3
|
19
|
+
requires = "//= require t3\n"
|
20
|
+
|
21
|
+
requires += components.map { |dir|
|
22
|
+
"//= require_tree ./#{dir}"
|
23
|
+
}.join("\n") + "\n"
|
24
|
+
|
25
|
+
inject_into_file "#{install_path}/application.js", requires,
|
26
|
+
before: '//= require_tree .'
|
27
|
+
|
28
|
+
# If //= require_tree . does not exist, inject at the bottom
|
29
|
+
# (Thor ensures that the content is not injected more than once)
|
30
|
+
inject_into_file "#{install_path}/application.js", requires,
|
31
|
+
before: %r{\z}
|
32
|
+
end
|
33
|
+
|
34
|
+
private
|
35
|
+
|
36
|
+
def components
|
37
|
+
%W{behaviors modules services}
|
38
|
+
end
|
39
|
+
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
module T3
|
2
|
+
module Generators
|
3
|
+
module GeneratorHelper
|
4
|
+
private
|
5
|
+
|
6
|
+
def install_path
|
7
|
+
'app/assets/javascripts'
|
8
|
+
end
|
9
|
+
|
10
|
+
def create_component_files
|
11
|
+
generator_name = self.class.generator_name
|
12
|
+
|
13
|
+
template "#{generator_name}.js",
|
14
|
+
File.join(install_path, generator_name.pluralize, "#{file_path}.js")
|
15
|
+
end
|
16
|
+
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
require 'generators/t3/generator_helper'
|
2
|
+
|
3
|
+
module T3
|
4
|
+
module Generators
|
5
|
+
class ModuleGenerator < ::Rails::Generators::NamedBase
|
6
|
+
include T3::Generators::GeneratorHelper
|
7
|
+
|
8
|
+
source_root File.expand_path("../../templates", __FILE__)
|
9
|
+
|
10
|
+
desc 'Creates a new T3 module'
|
11
|
+
|
12
|
+
def create_module_files
|
13
|
+
create_component_files
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
require 'generators/t3/generator_helper'
|
2
|
+
|
3
|
+
module T3
|
4
|
+
module Generators
|
5
|
+
class ServiceGenerator < ::Rails::Generators::NamedBase
|
6
|
+
include T3::Generators::GeneratorHelper
|
7
|
+
|
8
|
+
source_root File.expand_path("../../templates", __FILE__)
|
9
|
+
|
10
|
+
desc 'Creates a new T3 service'
|
11
|
+
|
12
|
+
def create_service_files
|
13
|
+
create_component_files
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,45 @@
|
|
1
|
+
/**
|
2
|
+
* @fileoverview Description of file
|
3
|
+
* @author your name
|
4
|
+
*/
|
5
|
+
|
6
|
+
/*global Box*/
|
7
|
+
|
8
|
+
/**
|
9
|
+
* Description of behavior.
|
10
|
+
*/
|
11
|
+
Box.Application.addBehavior('<%= class_name.underscore %>', function(context) {
|
12
|
+
|
13
|
+
'use strict';
|
14
|
+
|
15
|
+
//-----------------------------------------------------------
|
16
|
+
// Private
|
17
|
+
//-----------------------------------------------------------
|
18
|
+
|
19
|
+
/**
|
20
|
+
* Description of function.
|
21
|
+
* @param {type} name Description
|
22
|
+
* @returns {type} Description
|
23
|
+
* @private
|
24
|
+
*/
|
25
|
+
function privateFunction(name) {
|
26
|
+
|
27
|
+
}
|
28
|
+
|
29
|
+
//-----------------------------------------------------------
|
30
|
+
// Public
|
31
|
+
//-----------------------------------------------------------
|
32
|
+
|
33
|
+
return {
|
34
|
+
|
35
|
+
/**
|
36
|
+
* Description of method.
|
37
|
+
* @param {type} name Description
|
38
|
+
* @returns {type} Description
|
39
|
+
*/
|
40
|
+
method: function(name) {
|
41
|
+
|
42
|
+
}
|
43
|
+
};
|
44
|
+
|
45
|
+
});
|
@@ -0,0 +1,45 @@
|
|
1
|
+
/**
|
2
|
+
* @fileoverview Description of file
|
3
|
+
* @author your name
|
4
|
+
*/
|
5
|
+
|
6
|
+
/*global Box*/
|
7
|
+
|
8
|
+
/**
|
9
|
+
* Description of module.
|
10
|
+
*/
|
11
|
+
Box.Application.addModule('<%= class_name.underscore %>', function(context) {
|
12
|
+
|
13
|
+
'use strict';
|
14
|
+
|
15
|
+
//-----------------------------------------------------------
|
16
|
+
// Private
|
17
|
+
//-----------------------------------------------------------
|
18
|
+
|
19
|
+
/**
|
20
|
+
* Description of function.
|
21
|
+
* @param {type} name Description
|
22
|
+
* @returns {type} Description
|
23
|
+
* @private
|
24
|
+
*/
|
25
|
+
function privateFunction(name) {
|
26
|
+
|
27
|
+
}
|
28
|
+
|
29
|
+
//-----------------------------------------------------------
|
30
|
+
// Public
|
31
|
+
//-----------------------------------------------------------
|
32
|
+
|
33
|
+
return {
|
34
|
+
|
35
|
+
/**
|
36
|
+
* Description of method.
|
37
|
+
* @param {type} name Description
|
38
|
+
* @returns {type} Description
|
39
|
+
*/
|
40
|
+
method: function(name) {
|
41
|
+
|
42
|
+
}
|
43
|
+
};
|
44
|
+
|
45
|
+
});
|
@@ -0,0 +1,45 @@
|
|
1
|
+
/**
|
2
|
+
* @fileoverview Description of file
|
3
|
+
* @author your name
|
4
|
+
*/
|
5
|
+
|
6
|
+
/*global Box*/
|
7
|
+
|
8
|
+
/**
|
9
|
+
* Description of service.
|
10
|
+
*/
|
11
|
+
Box.Application.addService('<%= class_name.underscore %>', function(application) {
|
12
|
+
|
13
|
+
'use strict';
|
14
|
+
|
15
|
+
//-----------------------------------------------------------
|
16
|
+
// Private
|
17
|
+
//-----------------------------------------------------------
|
18
|
+
|
19
|
+
/**
|
20
|
+
* Description of function.
|
21
|
+
* @param {type} name Description
|
22
|
+
* @returns {type} Description
|
23
|
+
* @private
|
24
|
+
*/
|
25
|
+
function privateFunction(name) {
|
26
|
+
|
27
|
+
}
|
28
|
+
|
29
|
+
//-----------------------------------------------------------
|
30
|
+
// Public
|
31
|
+
//-----------------------------------------------------------
|
32
|
+
|
33
|
+
return {
|
34
|
+
|
35
|
+
/**
|
36
|
+
* Description of method.
|
37
|
+
* @param {type} name Description
|
38
|
+
* @returns {type} Description
|
39
|
+
*/
|
40
|
+
method: function(name) {
|
41
|
+
|
42
|
+
}
|
43
|
+
};
|
44
|
+
|
45
|
+
});
|
data/lib/t3/rails.rb
ADDED
@@ -0,0 +1,28 @@
|
|
1
|
+
== README
|
2
|
+
|
3
|
+
This README would normally document whatever steps are necessary to get the
|
4
|
+
application up and running.
|
5
|
+
|
6
|
+
Things you may want to cover:
|
7
|
+
|
8
|
+
* Ruby version
|
9
|
+
|
10
|
+
* System dependencies
|
11
|
+
|
12
|
+
* Configuration
|
13
|
+
|
14
|
+
* Database creation
|
15
|
+
|
16
|
+
* Database initialization
|
17
|
+
|
18
|
+
* How to run the test suite
|
19
|
+
|
20
|
+
* Services (job queues, cache servers, search engines, etc.)
|
21
|
+
|
22
|
+
* Deployment instructions
|
23
|
+
|
24
|
+
* ...
|
25
|
+
|
26
|
+
|
27
|
+
Please feel free to use a different markup language if you do not plan to run
|
28
|
+
<tt>rake doc:app</tt>.
|