mountain_view 0.7.0 → 0.7.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 0305d3c9a0ff118d9cc7aa66edb9d465a0fddb40
4
- data.tar.gz: 9b8f941a917df4013f6587808ebf3f4c0f79a699
3
+ metadata.gz: 25ec841a341408131f8ccd8733828fe272c650ff
4
+ data.tar.gz: 542bd1791a9512035b28beaf141c500a78b702cd
5
5
  SHA512:
6
- metadata.gz: 37ba111912d81f7d2ee90e005c38c58bd020e7d5ce45499e61483cfd59f3476e212dfff7ceb1826fcf0405f58a198279579a5eb9b892022e55595f0d1e34051f
7
- data.tar.gz: 9f2527cdfb3dffe88b25374e6577b4518b2f48c9d8f9157e992be2aac660cbebe08211d3a998fd2b6f9d9f6c669c24764159de81be3c05306a5c6635baa7057a
6
+ metadata.gz: f1141f20cc830bf54197f9e72f9fc0d3479314b2b12247e888dc7a30cfcff4e0924a53e76a412119169acd5b0b7935cd2f096e05d5fb68d738dcebfde3acf958
7
+ data.tar.gz: 3399e1b98ae937d0b49d8a5f350fcbaefcc5cf1931b80b4aa836bda6e4407d8bba5b0875cfd956966f1e28f07cf440dfa4e97bfb621f4cbd1cae12259e95d963
data/README.md CHANGED
@@ -71,13 +71,6 @@ helper:
71
71
  <%= render_component "header", title: "This is a title", subtitle: "And this is a subtitle" %>
72
72
  ```
73
73
 
74
- #### Note about URL helpers
75
-
76
- If you want to use URL helpers in your components (eg: `<%= link_to "Users", users_path %>`) you should prefix the helper with `main_app`, so the component knows the proper route when displayed on the stylesheet.
77
- With that, the example above would look like `<%= link_to "Users", main_app.users_path %>`.
78
-
79
- **Important**: This is a temporary work-around, and will be fixed in future versions of Mountain View.
80
-
81
74
  ### Assets
82
75
  You can require all the components CSS and JS automatically by requiring `mountain_view` in your main JS and CSS files.
83
76
 
@@ -1,9 +1,9 @@
1
- <% if Dir.exists?(Rails.root.join("app", "components") ) %>
2
- <% depend_on Rails.root.join('app', 'components').to_s %>
3
- <% Dir.glob(Rails.root.join('app', 'components', '*')).each do |component_dir|
1
+ <% if Dir.exists?(MountainView.configuration.components_path) %>
2
+ <% depend_on MountainView.configuration.components_path.to_s %>
3
+ <% Dir.glob(MountainView.configuration.components_path.join('*')).each do |component_dir|
4
4
  component = File.basename component_dir
5
5
  begin
6
- require_asset "#{component}/#{component}"
6
+ require_asset "#{component}/#{component}.js"
7
7
  rescue Sprockets::FileNotFound
8
8
  Rails.logger.debug("MountainView: javascript not found for component '#{component}'")
9
9
  %>
@@ -1,4 +1,5 @@
1
1
  /*
2
+ *= require_self
2
3
  *= require mountain_view
3
4
  *= require mountain_view/prism
4
5
  */
@@ -168,4 +169,4 @@ body{
168
169
 
169
170
  .mv-hint strong{
170
171
  font-weight: bold;
171
- }
172
+ }
@@ -1,12 +1,12 @@
1
1
  <% MountainView.configuration.included_stylesheets.each do |included_stylesheet| %>
2
2
  <%= require_asset included_stylesheet %>
3
3
  <% end %>
4
- <% if Dir.exists?(Rails.root.join("app", "components") ) %>
5
- <% depend_on Rails.root.join('app', 'components').to_s %>
6
- <% Dir.glob(Rails.root.join('app', 'components', '*')).each do |component_dir|
4
+ <% if Dir.exists?(MountainView.configuration.components_path) %>
5
+ <% depend_on MountainView.configuration.components_path.to_s %>
6
+ <% Dir.glob(MountainView.configuration.components_path.join('*')).each do |component_dir|
7
7
  component = File.basename component_dir
8
8
  begin
9
- require_asset "#{component}/#{component}"
9
+ require_asset "#{component}/#{component}.css"
10
10
  rescue Sprockets::FileNotFound
11
11
  Rails.logger.debug("MountainView: stylesheet not found for component '#{component}'")
12
12
  %>
@@ -1,7 +1,8 @@
1
1
  module MountainView
2
2
  module StyleguideHelper
3
3
  def mv_components
4
- Dir.glob(Rails.root.join("app", "components", "*")).map do |component_dir|
4
+ component_dirs = MountainView.configuration.components_path.join("*")
5
+ Dir.glob(component_dirs).map do |component_dir|
5
6
  MountainView::Component.new File.basename(component_dir)
6
7
  end
7
8
  end
@@ -15,7 +15,7 @@ module MountainView
15
15
  end
16
16
 
17
17
  def stubs_file
18
- Rails.root.join("app/components/#{name}/#{name}.yml")
18
+ MountainView.configuration.components_path.join(name, "#{name}.yml")
19
19
  end
20
20
 
21
21
  def stubs?
@@ -1,9 +1,14 @@
1
1
  module MountainView
2
2
  class Configuration
3
3
  attr_accessor :included_stylesheets
4
+ attr_reader :components_path
4
5
 
5
6
  def initialize
6
7
  @included_stylesheets = []
7
8
  end
9
+
10
+ def components_path=(path)
11
+ @components_path = Pathname.new(path)
12
+ end
8
13
  end
9
14
  end
@@ -6,15 +6,22 @@ module MountainView
6
6
  class Engine < ::Rails::Engine
7
7
  isolate_namespace MountainView
8
8
 
9
+ initializer "mountain_view.components_path" do |app|
10
+ MountainView.configure do |c|
11
+ c.components_path ||= app.root.join("app", "components")
12
+ end
13
+ end
14
+
9
15
  initializer "mountain_view.assets" do |app|
10
- Rails.application.config.assets.paths << app.root.join("app", "components")
16
+ Rails.application.config.assets.paths <<
17
+ MountainView.configuration.components_path
11
18
  Rails.application.config.assets.precompile += %w( mountain_view/styleguide.css
12
19
  mountain_view/styleguide.js )
13
20
  end
14
21
 
15
22
  initializer "mountain_view.append_view_paths" do |app|
16
23
  ActiveSupport.on_load :action_controller do
17
- append_view_path app.root.join("app", "components")
24
+ append_view_path MountainView.configuration.components_path
18
25
  end
19
26
  end
20
27
 
@@ -1,3 +1,3 @@
1
1
  module MountainView
2
- VERSION = "0.7.0".freeze
2
+ VERSION = "0.7.1".freeze
3
3
  end
data/lib/mountain_view.rb CHANGED
@@ -1,6 +1,5 @@
1
1
  require "mountain_view/version"
2
2
  require "mountain_view/configuration"
3
- require 'mountain_view/engine' if defined?(Rails)
4
3
 
5
4
  module MountainView
6
5
  def self.configuration
@@ -11,3 +10,5 @@ module MountainView
11
10
  yield(configuration)
12
11
  end
13
12
  end
13
+
14
+ require "mountain_view/engine" if defined?(Rails)