├── .gitignore ├── lib ├── helix-rails.rb ├── helix │ └── rails.rb ├── helix_runtime │ ├── rails │ │ ├── version.rb │ │ ├── check_outdated.rb │ │ └── railtie.rb │ └── rails.rb ├── tasks │ └── helix.rake └── generators │ └── helix │ ├── install_generator.rb │ └── crate_generator.rb ├── Gemfile └── helix-rails.gemspec /.gitignore: -------------------------------------------------------------------------------- 1 | Gemfile.lock 2 | -------------------------------------------------------------------------------- /lib/helix-rails.rb: -------------------------------------------------------------------------------- 1 | require 'helix_runtime/rails' 2 | -------------------------------------------------------------------------------- /lib/helix/rails.rb: -------------------------------------------------------------------------------- 1 | require 'helix_runtime/rails' 2 | -------------------------------------------------------------------------------- /Gemfile: -------------------------------------------------------------------------------- 1 | source 'https://rubygems.org' 2 | 3 | gemspec 4 | -------------------------------------------------------------------------------- /lib/helix_runtime/rails/version.rb: -------------------------------------------------------------------------------- 1 | module HelixRuntime 2 | module Rails 3 | VERSION = '0.5.0' 4 | end 5 | end 6 | -------------------------------------------------------------------------------- /lib/tasks/helix.rake: -------------------------------------------------------------------------------- 1 | require 'helix_runtime/parent_build_task' 2 | 3 | HelixRuntime::ParentBuildTask.new 4 | 5 | task "assets:precompile" => :build 6 | -------------------------------------------------------------------------------- /lib/helix_runtime/rails.rb: -------------------------------------------------------------------------------- 1 | require 'helix_runtime' 2 | require 'helix_runtime/rails/version' 3 | require 'helix_runtime/rails/railtie' 4 | 5 | module HelixRuntime 6 | module Rails 7 | end 8 | end 9 | -------------------------------------------------------------------------------- /lib/generators/helix/install_generator.rb: -------------------------------------------------------------------------------- 1 | # This should really be HelixRuntime, but we want nicer naming 2 | module Helix 3 | class InstallGenerator < Rails::Generators::Base 4 | desc "install Helix" 5 | def configure_application 6 | application("config.helix.outdated_error = :page_load", env: :development) 7 | end 8 | end 9 | end 10 | -------------------------------------------------------------------------------- /lib/helix_runtime/rails/check_outdated.rb: -------------------------------------------------------------------------------- 1 | module HelixRuntime 2 | module Rails 3 | class CheckOutdated 4 | def initialize(app, project) 5 | @app = app 6 | @project = project 7 | @last_check = 0 8 | end 9 | 10 | def call(env) 11 | @project.ensure_built! 12 | @app.call(env) 13 | end 14 | end 15 | end 16 | end 17 | -------------------------------------------------------------------------------- /lib/generators/helix/crate_generator.rb: -------------------------------------------------------------------------------- 1 | require 'helix_runtime/cli' 2 | 3 | # This should really be HelixRuntime, but we want nicer naming 4 | module Helix 5 | class CrateGenerator < Rails::Generators::Base 6 | desc "add Helix crate" 7 | argument :name, :type => :string 8 | 9 | def add_crate 10 | cli = HelixRuntime::CLI::Base.new 11 | cli.invoke(:crate, [name]) 12 | end 13 | end 14 | end 15 | -------------------------------------------------------------------------------- /helix-rails.gemspec: -------------------------------------------------------------------------------- 1 | # coding: utf-8 2 | lib = File.expand_path('../lib', __FILE__) 3 | $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib) 4 | require 'helix_runtime/rails/version' 5 | 6 | Gem::Specification.new do |spec| 7 | spec.name = "helix-rails" 8 | spec.version = HelixRuntime::Rails::VERSION 9 | spec.authors = ["Peter Wagenet"] 10 | spec.email = ["peter.wagenet@gmail.com"] 11 | 12 | spec.summary = %q{Helix for Rails} 13 | spec.homepage = "https://usehelix.com" 14 | 15 | spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) } 16 | spec.require_paths = ["lib"] 17 | 18 | spec.add_dependency "helix_runtime", ">= 0.5.0" 19 | spec.add_dependency "rails", ">= 4.0" 20 | 21 | spec.add_development_dependency "bundler", "~> 1.10" 22 | end 23 | -------------------------------------------------------------------------------- /lib/helix_runtime/rails/railtie.rb: -------------------------------------------------------------------------------- 1 | require 'helix_runtime/rails/check_outdated' 2 | 3 | module HelixRuntime 4 | module Rails 5 | class Railtie < ::Rails::Railtie 6 | config.helix = ActiveSupport::OrderedOptions.new 7 | 8 | rake_tasks do 9 | load File.expand_path("../../../tasks/helix.rake", __FILE__) 10 | end 11 | 12 | initializer "helix.build_check" do |app| 13 | project = HelixRuntime::ParentProject.new(app.root) 14 | 15 | # This will be added by the install generator, but people may forget to run it 16 | if ::Rails.env.development? && !config.helix.key?(:outdated_error) 17 | config.helix.outdated_error = :page_load 18 | end 19 | 20 | if config.helix.delete(:outdated_error) == :page_load 21 | config.app_middleware.insert_after ::ActionDispatch::Callbacks, 22 | HelixRuntime::Rails::CheckOutdated, project 23 | end 24 | end 25 | end 26 | end 27 | end 28 | --------------------------------------------------------------------------------