module Pugin
Constants
- ASSET_LOCATION_URL
- ASSET_VERSION
- STATIC_ASSET_LOCATION_URL
- STATIC_ASSET_PUBLIC_LOCATION_URL
- VERSION
Attributes
alternates[W]
Public Class Methods
alternates()
click to toggle source
# File lib/pugin.rb, line 11 def alternates @alternates || [] end
assets_path()
click to toggle source
# File lib/pugin.rb, line 54 def assets_path @assets_path ||= File.join gem_path, 'app', 'assets' end
gem_path()
click to toggle source
Paths
# File lib/pugin.rb, line 34 def gem_path @gem_path ||= File.expand_path '..', File.dirname(__FILE__) end
images_path()
click to toggle source
# File lib/pugin.rb, line 38 def images_path File.join assets_path, 'images' end
javascripts_path()
click to toggle source
# File lib/pugin.rb, line 42 def javascripts_path File.join assets_path, 'javascripts' end
load!()
click to toggle source
Inspired by bootsrap-sass
# File lib/pugin.rb, line 16 def load! if rails? register_rails_files elsif sinatra? register_sinatra_files elsif sprockets? register_sprockets end # Try and load HAML, raising an error if we are not able to begin require 'haml' rescue LoadError => e raise(LoadError, "pugin requires the 'haml' gem. Please check it is in your Gemfile - #{e.message}") end end
rails?()
click to toggle source
Environment detection helpers
# File lib/pugin.rb, line 59 def rails? defined?(::Rails) end
sinatra?()
click to toggle source
# File lib/pugin.rb, line 63 def sinatra? defined?(::Sinatra) end
sprockets?()
click to toggle source
# File lib/pugin.rb, line 67 def sprockets? defined?(::Sprockets) end
stylesheets_path()
click to toggle source
# File lib/pugin.rb, line 46 def stylesheets_path File.join assets_path, 'stylesheets' end
views_path()
click to toggle source
# File lib/pugin.rb, line 50 def views_path File.join gem_path, 'app', 'views' end
Private Class Methods
add_i18n_paths()
click to toggle source
# File lib/pugin.rb, line 85 def add_i18n_paths require 'i18n' I18n.load_path += Dir[File.join(gem_path, 'config', 'locales', '*.yml')] end
register_rails_files()
click to toggle source
# File lib/pugin.rb, line 73 def register_rails_files require 'pugin/engine' require 'pugin/railtie' setup_features end
register_sinatra_files()
click to toggle source
# File lib/pugin.rb, line 79 def register_sinatra_files add_i18n_paths setup_features require 'pugin/view_helpers' end
register_sprockets()
click to toggle source
# File lib/pugin.rb, line 103 def register_sprockets Sprockets.append_path(images_path) Sprockets.append_path(javascripts_path) Sprockets.append_path(stylesheets_path) Sprockets.append_path(views_path) end
setup_bandiera()
click to toggle source
# File lib/pugin.rb, line 90 def setup_bandiera raise(LoadError, 'pugin requires the host application to be using the bandiera-client gem. Please check your Gemfile and try again.') unless defined?(::Bandiera::Client) raise(LoadError, 'pugin requires the environment variable BANDIERA_URL to be set. Please set the environment variable and try again.') unless ENV['BANDIERA_URL'] require 'pugin/bandiera' include PuginBandieraClient end
setup_features()
click to toggle source
# File lib/pugin.rb, line 98 def setup_features setup_bandiera require 'pugin/feature' end