Skip to content

Commit

Permalink
Merge 7994700 into 403ba27
Browse files Browse the repository at this point in the history
  • Loading branch information
allomov committed Jul 30, 2014
2 parents 403ba27 + 7994700 commit 9e59724
Show file tree
Hide file tree
Showing 10 changed files with 50 additions and 17 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,4 @@ spec/dummy/tmp/
spec/dummy/.sass-cache
.coveralls.yml
coverage/
test_widget.*
1 change: 1 addition & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,5 @@ group :test do
gem 'simplecov', require: false
gem 'rspec-rails', '~> 2.14'
gem 'pry-rails', '~> 0.3'
gem 'generator_spec'
end
4 changes: 4 additions & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,9 @@ GEM
docile (1.1.3)
erubis (2.7.0)
execjs (2.2.1)
generator_spec (0.9.2)
activesupport (>= 3.0.0)
railties (>= 3.0.0)
hike (1.2.3)
i18n (0.6.9)
jquery-rails (3.1.1)
Expand Down Expand Up @@ -150,6 +153,7 @@ DEPENDENCIES
better_errors (~> 1.0)
coveralls
dashing-rails!
generator_spec
jquery-rails (~> 3.0)
pry-rails (~> 0.3)
rspec-rails (~> 2.14)
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/dashing/widgets_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ def prepend_view_paths
end

def main_app_view_path
Dashing.config.widgets_views_path.call
Dashing.config.widgets_views_path
end

def template_not_found
Expand Down
6 changes: 3 additions & 3 deletions lib/dashing/configuration.rb
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,9 @@ def initialize
@dashboard_layout_path = 'dashing/dashboard'

# Widgets
@widgets_views_path = -> { Rails.root.join('app', 'views', 'dashing', 'widgets') }
@widgets_js_path = 'app/assets/javascripts/dashing'
@widgets_css_path = 'app/assets/stylesheets/dashing'
@widgets_views_path = Rails.root.join('app', 'views', 'dashing', 'widgets')
@widgets_js_path = Rails.root.join('app', 'assets', 'javascripts', 'dashing')
@widgets_css_path = Rails.root.join('app', 'assets', 'stylesheets', 'dashing')
end

def redis
Expand Down
10 changes: 1 addition & 9 deletions lib/dashing/engine.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,6 @@ module Dashing
class Engine < ::Rails::Engine
isolate_namespace Dashing

config.assets.paths.unshift Dashing::Engine.root.join('vendor', 'assets', 'fonts', 'dashing')
config.assets.paths.unshift Dashing::Engine.root.join('vendor', 'assets', 'javascripts', 'dashing')
config.assets.paths.unshift Dashing::Engine.root.join('vendor', 'assets', 'stylesheets', 'dashing')
config.assets.paths.unshift Dashing.config.widgets_js_path
config.assets.paths.unshift Dashing.config.widgets_css_path

config.assets.precompile << /\.(?:svg|eot|woff|ttf)$/

config.paths['app/views'].unshift Dashing::Engine.root.join('app', 'views', 'dashing', 'widgets')
paths['app/views'].unshift Dashing::Engine.root.join('app', 'views', 'dashing', 'widgets')
end
end
13 changes: 13 additions & 0 deletions lib/dashing/railtie.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,18 @@
module Dashing
class Railtie < ::Rails::Railtie

initializer 'configure assets' do |app|
app.configure do
config.assets.paths.unshift Dashing::Engine.root.join('vendor', 'assets', 'fonts', 'dashing')
config.assets.paths.unshift Dashing::Engine.root.join('vendor', 'assets', 'javascripts', 'dashing')
config.assets.paths.unshift Dashing::Engine.root.join('vendor', 'assets', 'stylesheets', 'dashing')
config.assets.paths.unshift Dashing.config.widgets_js_path
config.assets.paths.unshift Dashing.config.widgets_css_path

config.assets.precompile << /\.(?:svg|eot|woff|ttf)$/
end
end

initializer 'require dashing jobs' do
Dir[Dashing.config.jobs_path.call.join('**', '*.rb')].each { |file| require file }
end
Expand Down
2 changes: 1 addition & 1 deletion lib/generators/dashing/widget_generator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ class WidgetGenerator < ::Rails::Generators::NamedBase
desc 'Creates a new Dashing widget.'

def widget
template 'widgets/new.html', Dashing.config.widgets_views_path.call.join("#{file_name}.html")
template 'widgets/new.html', Dashing.config.widgets_views_path.join("#{file_name}.html")
template 'widgets/new.scss', Dashing.config.widgets_css_path.join('widgets', "#{file_name}.scss")
template 'widgets/new.coffee', Dashing.config.widgets_js_path.join('widgets', "#{file_name}.coffee")
end
Expand Down
6 changes: 3 additions & 3 deletions spec/lib/dashing/configuration_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,9 @@
it { expect(instance.dashboard_layout_path).to eq('dashing/dashboard') }

# Widgets
it { expect(instance.widgets_views_path.call.to_s).to include('app/views/dashing/widgets') }
it { expect(instance.widgets_js_path).to eq('app/assets/javascripts/dashing') }
it { expect(instance.widgets_css_path).to eq('app/assets/stylesheets/dashing') }
it { expect(instance.widgets_views_path.to_s).to include('app/views/dashing/widgets') }
it { expect(instance.widgets_js_path.to_s).to include('app/assets/javascripts/dashing') }
it { expect(instance.widgets_css_path.to_s).to include('app/assets/stylesheets/dashing') }

describe '#request_thread_count' do

Expand Down
22 changes: 22 additions & 0 deletions spec/lib/generators/widget_generator_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
require 'spec_helper'
require 'generator_spec'
require 'generators/dashing/widget_generator'

describe Dashing::Generators::WidgetGenerator do

arguments %w(test_widget)

before do
run_generator
end

after do
`find #{Rails.root.join('app')} -name "test_widget.*" -delete`
end

it 'creates widget files' do
assert_file Rails.root.join 'app/views/dashing/widgets/test_widget.html'
assert_file Rails.root.join 'app/assets/javascripts/dashing/widgets/test_widget.coffee'
assert_file Rails.root.join 'app/assets/stylesheets/dashing/widgets/test_widget.scss'
end
end

0 comments on commit 9e59724

Please sign in to comment.