half-pipe 0.0.1 → 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (69) hide show
  1. checksums.yaml +7 -0
  2. data/README.md +17 -2
  3. data/app/helpers/half_pipe_helper.rb +1 -1
  4. data/examples/rails/.bowerrc +3 -0
  5. data/examples/rails/.gitignore +21 -0
  6. data/examples/rails/.jshintrc +34 -0
  7. data/examples/rails/Gemfile +38 -0
  8. data/examples/rails/Gruntfile.js +67 -0
  9. data/examples/rails/README.rdoc +28 -0
  10. data/examples/rails/Rakefile +6 -0
  11. data/examples/rails/app/controllers/application_controller.rb +5 -0
  12. data/examples/rails/app/controllers/concerns/.keep +0 -0
  13. data/examples/rails/app/controllers/posts_controller.rb +9 -0
  14. data/examples/rails/app/helpers/application_helper.rb +2 -0
  15. data/examples/rails/app/mailers/.keep +0 -0
  16. data/examples/rails/app/models/.keep +0 -0
  17. data/examples/rails/app/models/concerns/.keep +0 -0
  18. data/examples/rails/app/models/post.rb +27 -0
  19. data/examples/rails/app/scripts/application.js +27 -0
  20. data/examples/rails/app/scripts/features/posts.js +28 -0
  21. data/examples/rails/app/scripts/main.js +17 -0
  22. data/examples/rails/app/styles/main.scss +1 -0
  23. data/examples/rails/app/views/layouts/application.html.erb +14 -0
  24. data/examples/rails/app/views/posts/index.html.erb +7 -0
  25. data/examples/rails/app/views/posts/show.html.erb +2 -0
  26. data/examples/rails/bin/bundle +3 -0
  27. data/examples/rails/bin/rails +4 -0
  28. data/examples/rails/bin/rake +4 -0
  29. data/examples/rails/bower.json +9 -0
  30. data/examples/rails/config.ru +4 -0
  31. data/examples/rails/config/application.rb +39 -0
  32. data/examples/rails/config/boot.rb +4 -0
  33. data/examples/rails/config/environment.rb +5 -0
  34. data/examples/rails/config/environments/development.rb +23 -0
  35. data/examples/rails/config/environments/production.rb +65 -0
  36. data/examples/rails/config/environments/test.rb +36 -0
  37. data/examples/rails/config/initializers/backtrace_silencers.rb +7 -0
  38. data/examples/rails/config/initializers/filter_parameter_logging.rb +4 -0
  39. data/examples/rails/config/initializers/inflections.rb +16 -0
  40. data/examples/rails/config/initializers/mime_types.rb +5 -0
  41. data/examples/rails/config/initializers/sass.rb +2 -0
  42. data/examples/rails/config/initializers/secret_token.rb +12 -0
  43. data/examples/rails/config/initializers/session_store.rb +3 -0
  44. data/examples/rails/config/initializers/wrap_parameters.rb +10 -0
  45. data/examples/rails/config/locales/en.yml +23 -0
  46. data/examples/rails/config/routes.rb +53 -0
  47. data/examples/rails/db/seeds.rb +7 -0
  48. data/examples/rails/lib/assets/.keep +0 -0
  49. data/examples/rails/lib/tasks/.keep +0 -0
  50. data/examples/rails/log/.keep +0 -0
  51. data/examples/rails/package.json +15 -0
  52. data/examples/rails/public/404.html +58 -0
  53. data/examples/rails/public/422.html +58 -0
  54. data/examples/rails/public/500.html +57 -0
  55. data/examples/rails/public/favicon.ico +0 -0
  56. data/examples/rails/public/robots.txt +5 -0
  57. data/examples/rails/vendor/assets/javascripts/.keep +0 -0
  58. data/examples/rails/vendor/assets/stylesheets/.keep +0 -0
  59. data/half-pipe.gemspec +1 -0
  60. data/lib/generators/half_pipe/install_generator.rb +6 -1
  61. data/lib/generators/half_pipe/templates/Gruntfile.js +10 -12
  62. data/lib/generators/half_pipe/templates/app/scripts/application.js +3 -2
  63. data/lib/generators/half_pipe/templates/package.json +2 -2
  64. data/lib/half-pipe/rails.rb +10 -0
  65. data/lib/half-pipe/version.rb +1 -1
  66. data/lib/rack/half-pipe.rb +26 -30
  67. data/lib/sass/half_pipe_functions.rb +7 -0
  68. data/lib/tasks/assets.rake +50 -0
  69. metadata +80 -13
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 6b1ff38df667bbc3470faa09055259c084d30f6d
4
+ data.tar.gz: 8e8e5c065f2ba50d58a0a9e1679ef73d4f77f456
5
+ SHA512:
6
+ metadata.gz: 3fc3909bb624f799182679940bed0d2af151b0ad3dfeb9ee09d9964543096f660128bd8171a3da37a63df5d9df01b7d5a052060fc854c46dad02793065f24db7
7
+ data.tar.gz: fa22616f76f43f524104c69f9753b5aa31818f60615b66d4bee5a25cfcf8881e2ecf958ee07e8dac9e815186d0f56e070db36f7054dda729805513558ab224a8
data/README.md CHANGED
@@ -89,15 +89,30 @@ Build assets by running `grunt build`. This will compile Javascripts to `public/
89
89
 
90
90
  In this early release if you want to configure anything, you'll have to manually change `Gruntfile.js`. We'd like to make this more invisible in the future; please post any use cases for configuration as Github issues.
91
91
 
92
+ ## History
93
+
94
+ ### 07/19/2013 v0.1.0
95
+
96
+ - Override Rails' `rake assets:precompile` to run `grunt build` for easier deployments
97
+ - Allow for configuring asset server with `config.half_pipe.serve_assets = true|false`
98
+ - Use Almond for requirejs optimization so as not to need requirejs in production
99
+
100
+
92
101
  ## Roadmap
93
102
 
94
- - Asset fingerprinting
103
+ - v0.2 - Asset fingerprinting
104
+
105
+ ## Future Features
106
+
95
107
  - Precompilation of client-side templates
96
108
  - Javascript module generator
97
109
  - Configurable asset directories
98
110
  - Configurable build directories
99
111
  - Better support for images
100
- - Better support for non-Rails Ruby frameworks
112
+ - Support for additional module loaders (including ES6 modules)
113
+ - Padrino support
114
+ - Middleman support
101
115
  - Support for most popular [AltJS](http://www.altjs.com) languages
102
116
  - BYO support for less common languages
103
117
  - Automatic symlinking of CSS files within bower to SCSS partials within `app/styles`
118
+ - Read .bowerrc for Bower directory
@@ -1,7 +1,7 @@
1
1
  module HalfPipeHelper
2
2
 
3
3
  def requirejs_include_tag(script, options={})
4
- root = if Rails.env.production? then "scripts" else "components/requirejs" end
4
+ root = if Rails.application.config.half_pipe.serve_assets then "components/requirejs" else "scripts" end
5
5
  javascript_include_tag "/#{root}/require.js", { data: { main: script } }
6
6
  end
7
7
 
@@ -0,0 +1,3 @@
1
+ {
2
+ "json": "bower.json"
3
+ }
@@ -0,0 +1,21 @@
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
17
+
18
+ node_modules
19
+ components
20
+
21
+ .sass-cache
@@ -0,0 +1,34 @@
1
+ {
2
+ "camelcase": true,
3
+ "indent": 2,
4
+ "white": false,
5
+ "curly": true,
6
+ "eqeqeq": true,
7
+ "immed": true,
8
+ "latedef": true,
9
+ "newcap": false,
10
+ "noarg": true,
11
+ "sub": true,
12
+ "undef": true,
13
+ "boss": true,
14
+ "eqnull": true,
15
+ "browser": true,
16
+ "globals": {
17
+ "test": true,
18
+ "asyncTest": true,
19
+ "start": true,
20
+ "expect": true,
21
+ "module": true,
22
+ "define": true,
23
+ "sinon": true,
24
+ "require": true,
25
+ "console": true,
26
+ "Class": true,
27
+ "Events": true,
28
+ "Options": true,
29
+ "Element": true,
30
+ "$": true,
31
+ "$$": true
32
+ }
33
+ }
34
+
@@ -0,0 +1,38 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
4
+ gem 'rails', '4.0.0.rc1'
5
+
6
+ # Use CoffeeScript for .js.coffee assets and views
7
+ gem 'coffee-rails', '~> 4.0.0'
8
+
9
+ # See https://github.com/sstephenson/execjs#readme for more supported runtimes
10
+ # gem 'therubyracer', platforms: :ruby
11
+
12
+ # Use jquery as the JavaScript library
13
+ gem 'jquery-rails'
14
+
15
+ # Turbolinks makes following links in your web application faster. Read more: https://github.com/rails/turbolinks
16
+ gem 'turbolinks'
17
+
18
+ # Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder
19
+ gem 'jbuilder', '~> 1.0.1'
20
+
21
+ gem 'half-pipe', path: '../../'
22
+
23
+ group :doc do
24
+ # bundle exec rake doc:rails generates the API under doc/api.
25
+ gem 'sdoc', require: false
26
+ end
27
+
28
+ # Use ActiveModel has_secure_password
29
+ # gem 'bcrypt-ruby', '~> 3.0.0'
30
+
31
+ # Use unicorn as the app server
32
+ # gem 'unicorn'
33
+
34
+ # Use Capistrano for deployment
35
+ # gem 'capistrano', group: :development
36
+
37
+ # Use debugger
38
+ # gem 'debugger', group: [:development, :test]
@@ -0,0 +1,67 @@
1
+ /*global module:false*/
2
+ module.exports = function(grunt) {
3
+
4
+
5
+ // Project configuration.
6
+ grunt.initConfig({
7
+ // Metadata.
8
+ pkg: grunt.file.readJSON('package.json'),
9
+
10
+ jshint: {
11
+ options: {
12
+ jshintrc: '.jshintrc'
13
+ },
14
+ gruntfile: {
15
+ src: 'Gruntfile.js'
16
+ }
17
+ },
18
+
19
+ sass: {
20
+ options: {
21
+ style: 'expanded',
22
+ require: ['./config/initializers/sass']
23
+ },
24
+ 'tmp/styles/main.css': [
25
+ 'app/styles/main.scss'
26
+ ]
27
+ },
28
+
29
+ cssmin: {
30
+ 'public/styles/main.css': 'tmp/styles/main.css'
31
+ },
32
+
33
+ requirejs: {
34
+ options: {
35
+ baseUrl: "app/scripts",
36
+ mainConfigFile: "app/scripts/application.js",
37
+ name: "main",
38
+ out: "public/scripts/application.js"
39
+ },
40
+ scripts: {
41
+ }
42
+ },
43
+
44
+ copy: {
45
+ 'public/scripts/require.js': 'components/requirejs/require.js'
46
+ },
47
+
48
+ clean: ['public/assets/', 'tmp/']
49
+
50
+ });
51
+
52
+ // These plugins provide necessary tasks.
53
+ grunt.loadNpmTasks('grunt-contrib-jshint');
54
+ grunt.loadNpmTasks('grunt-contrib-sass');
55
+ grunt.loadNpmTasks('grunt-contrib-cssmin');
56
+ grunt.loadNpmTasks('grunt-contrib-copy');
57
+ grunt.loadNpmTasks('grunt-contrib-clean');
58
+ grunt.loadNpmTasks('grunt-contrib-requirejs');
59
+
60
+ // Default task.
61
+ grunt.registerTask('default', 'build');
62
+
63
+ // Build task.
64
+ grunt.registerTask('build', ['jshint', 'sass', 'cssmin', 'copy', 'requirejs']);
65
+
66
+ };
67
+
@@ -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>.
@@ -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
+ Blog::Application.load_tasks
@@ -0,0 +1,5 @@
1
+ class ApplicationController < ActionController::Base
2
+ # Prevent CSRF attacks by raising an exception.
3
+ # For APIs, you may want to use :null_session instead.
4
+ protect_from_forgery with: :exception
5
+ end
File without changes
@@ -0,0 +1,9 @@
1
+ class PostsController < ApplicationController
2
+ def index
3
+ @posts = Post.all
4
+ end
5
+
6
+ def show
7
+ @post = Post.find(params[:id])
8
+ end
9
+ end
@@ -0,0 +1,2 @@
1
+ module ApplicationHelper
2
+ end
File without changes
File without changes
File without changes
@@ -0,0 +1,27 @@
1
+ require 'ostruct'
2
+
3
+ class Post
4
+
5
+ FIXTURES = [{
6
+ id: 1,
7
+ title: "Lorem ipsum whatever",
8
+ content: "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Maecenas tempus gravida imperdiet. Pellentesque imperdiet justo quis erat feugiat porttitor. Nulla aliquet neque vitae elit tincidunt in venenatis risus faucibus. Etiam faucibus pretium enim, et rutrum libero feugiat vitae. Donec a lectus vitae est lobortis vulputate. Nulla facilisi. Donec pellentesque pretium lectus, eu volutpat nibh molestie nec."
9
+ }, {
10
+ id: 2,
11
+ title: "Foo bar baz",
12
+ content: "Foo bar baz qux quux"
13
+ }]
14
+
15
+ def self.all
16
+ FIXTURES.map do |f|
17
+ OpenStruct.new(f)
18
+ end
19
+ end
20
+
21
+ def self.find(id)
22
+ all.find do |f|
23
+ f.id == id.to_i
24
+ end
25
+ end
26
+
27
+ end
@@ -0,0 +1,27 @@
1
+ require.config({
2
+ baseUrl: '/scripts',
3
+ paths: {
4
+ 'blog': 'main',
5
+ 'flight': '/components/flight',
6
+ 'jquery': '/components/jquery/jquery'
7
+ }
8
+ });
9
+
10
+ require(
11
+ [
12
+ 'flight/lib/compose',
13
+ 'flight/lib/registry',
14
+ 'flight/lib/advice',
15
+ 'flight/lib/logger',
16
+ 'flight/tools/debug/debug',
17
+ 'jquery'
18
+ ],
19
+
20
+ function(compose, registry, advice, withLogging, debug){
21
+ debug.enable(true);
22
+ compose.mixin(registry, [advice.withAdvice, withLogging]);
23
+ require(['blog'], function(initialize){
24
+ initialize();
25
+ });
26
+ }
27
+ );
@@ -0,0 +1,28 @@
1
+ "use strict";
2
+
3
+ define(['flight/lib/component'], function(defineComponent){
4
+
5
+ return defineComponent(posts);
6
+
7
+ function posts(){
8
+
9
+ this.defaultAttrs({
10
+ postSelector: ".post"
11
+ });
12
+
13
+ this.visitPost = function(e){
14
+ e.preventDefault();
15
+ var url = $(e.target).attr("href");
16
+ history.pushState(null, "Post", url);
17
+ $(document).trigger("postChosen");
18
+ };
19
+
20
+ this.after("initialize", function(){
21
+ this.on("click", {
22
+ postSelector: this.visitPost
23
+ });
24
+ });
25
+
26
+ }
27
+
28
+ });
@@ -0,0 +1,17 @@
1
+ 'use strict';
2
+
3
+ define('blog',
4
+ [
5
+ 'features/posts'
6
+ ],
7
+
8
+ function(Posts){
9
+
10
+ function initialize(){
11
+ Posts.attachTo("#posts");
12
+ }
13
+
14
+ return initialize;
15
+
16
+ }
17
+ );
@@ -0,0 +1 @@
1
+ @import "bower!normalize-css/normalize";
@@ -0,0 +1,14 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <title>Blog</title>
5
+ <%= csrf_meta_tags %>
6
+ <%= stylesheet_link_tag "/styles/main" %>
7
+ </head>
8
+ <body>
9
+
10
+ <%= yield %>
11
+
12
+ <%= requirejs_include_tag "/scripts/application.js" %>
13
+ </body>
14
+ </html>
@@ -0,0 +1,7 @@
1
+ <ul id="posts">
2
+ <% @posts.each do |post| %>
3
+ <li class="post">
4
+ <%= link_to post.title, post_path(post.id) %>
5
+ </li>
6
+ <% end %>
7
+ </ul>
@@ -0,0 +1,2 @@
1
+ <h1><%= @post.title %></h1>
2
+ <%= simple_format @post.content %>
@@ -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')
@@ -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'