style-guide 0.0.1 → 0.1.0

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.
Files changed (82) hide show
  1. data/.gitignore +1 -0
  2. data/.rspec +2 -0
  3. data/.travis.yml +16 -0
  4. data/Gemfile +0 -2
  5. data/Gemfile.lock +19 -7
  6. data/Guardfile +12 -0
  7. data/Procfile +1 -0
  8. data/README.md +26 -1
  9. data/app/controllers/style_guide/application_controller.rb +6 -0
  10. data/app/controllers/style_guide/style_controller.rb +3 -6
  11. data/app/views/layouts/style_guide/application.html.erb +4 -2
  12. data/app/views/style_guide/style/_sidebar.erb +5 -0
  13. data/app/views/style_guide/style/index.html.erb +5 -14
  14. data/config/routes.rb +1 -0
  15. data/lib/style_guide.rb +1 -3
  16. data/lib/style_guide/config.rb +9 -0
  17. data/lib/style_guide/engine.rb +5 -7
  18. data/lib/style_guide/partial.rb +21 -0
  19. data/lib/style_guide/section.rb +29 -0
  20. data/lib/style_guide/version.rb +1 -1
  21. data/script/ci.sh +3 -0
  22. data/spec/controllers/style_guide/style_controller_spec.rb +16 -0
  23. data/spec/dummy/app/assets/stylesheets/application.css +0 -1
  24. data/spec/dummy/config/boot.rb +4 -1
  25. data/spec/dummy/config/routes.rb +1 -1
  26. data/spec/lib/style_guide/config_spec.rb +17 -0
  27. data/spec/lib/style_guide/partial_spec.rb +54 -0
  28. data/spec/lib/style_guide/section_spec.rb +56 -0
  29. data/spec/spec_helper.rb +9 -0
  30. data/style-guide.gemspec +6 -3
  31. metadata +57 -108
  32. data/.gitmodules +0 -3
  33. data/spec/dummy/app/assets/stylesheets/bootstrap/accordion.less +0 -34
  34. data/spec/dummy/app/assets/stylesheets/bootstrap/alerts.less +0 -65
  35. data/spec/dummy/app/assets/stylesheets/bootstrap/bootstrap.less +0 -63
  36. data/spec/dummy/app/assets/stylesheets/bootstrap/breadcrumbs.less +0 -24
  37. data/spec/dummy/app/assets/stylesheets/bootstrap/button-groups.less +0 -242
  38. data/spec/dummy/app/assets/stylesheets/bootstrap/buttons.less +0 -232
  39. data/spec/dummy/app/assets/stylesheets/bootstrap/carousel.less +0 -131
  40. data/spec/dummy/app/assets/stylesheets/bootstrap/close.less +0 -31
  41. data/spec/dummy/app/assets/stylesheets/bootstrap/code.less +0 -58
  42. data/spec/dummy/app/assets/stylesheets/bootstrap/component-animations.less +0 -22
  43. data/spec/dummy/app/assets/stylesheets/bootstrap/dropdowns.less +0 -237
  44. data/spec/dummy/app/assets/stylesheets/bootstrap/forms.less +0 -683
  45. data/spec/dummy/app/assets/stylesheets/bootstrap/grid.less +0 -21
  46. data/spec/dummy/app/assets/stylesheets/bootstrap/hero-unit.less +0 -25
  47. data/spec/dummy/app/assets/stylesheets/bootstrap/labels-badges.less +0 -74
  48. data/spec/dummy/app/assets/stylesheets/bootstrap/layouts.less +0 -16
  49. data/spec/dummy/app/assets/stylesheets/bootstrap/media.less +0 -55
  50. data/spec/dummy/app/assets/stylesheets/bootstrap/mixins.less +0 -687
  51. data/spec/dummy/app/assets/stylesheets/bootstrap/modals.less +0 -94
  52. data/spec/dummy/app/assets/stylesheets/bootstrap/navbar.less +0 -475
  53. data/spec/dummy/app/assets/stylesheets/bootstrap/navs.less +0 -385
  54. data/spec/dummy/app/assets/stylesheets/bootstrap/pager.less +0 -41
  55. data/spec/dummy/app/assets/stylesheets/bootstrap/pagination.less +0 -121
  56. data/spec/dummy/app/assets/stylesheets/bootstrap/popovers.less +0 -117
  57. data/spec/dummy/app/assets/stylesheets/bootstrap/progress-bars.less +0 -122
  58. data/spec/dummy/app/assets/stylesheets/bootstrap/reset.less +0 -138
  59. data/spec/dummy/app/assets/stylesheets/bootstrap/responsive-1200px-min.less +0 -28
  60. data/spec/dummy/app/assets/stylesheets/bootstrap/responsive-767px-max.less +0 -193
  61. data/spec/dummy/app/assets/stylesheets/bootstrap/responsive-768px-979px.less +0 -19
  62. data/spec/dummy/app/assets/stylesheets/bootstrap/responsive-navbar.less +0 -185
  63. data/spec/dummy/app/assets/stylesheets/bootstrap/responsive-utilities.less +0 -43
  64. data/spec/dummy/app/assets/stylesheets/bootstrap/responsive.less +0 -48
  65. data/spec/dummy/app/assets/stylesheets/bootstrap/scaffolding.less +0 -52
  66. data/spec/dummy/app/assets/stylesheets/bootstrap/sprites.less +0 -193
  67. data/spec/dummy/app/assets/stylesheets/bootstrap/tables.less +0 -236
  68. data/spec/dummy/app/assets/stylesheets/bootstrap/thumbnails.less +0 -52
  69. data/spec/dummy/app/assets/stylesheets/bootstrap/tooltip.less +0 -70
  70. data/spec/dummy/app/assets/stylesheets/bootstrap/type.less +0 -227
  71. data/spec/dummy/app/assets/stylesheets/bootstrap/utilities.less +0 -30
  72. data/spec/dummy/app/assets/stylesheets/bootstrap/variables.less +0 -301
  73. data/spec/dummy/app/assets/stylesheets/bootstrap/wells.less +0 -29
  74. data/spec/dummy/app/assets/stylesheets/pivotal-bootstrap.css.less +0 -3
  75. data/spec/dummy/app/assets/stylesheets/pivotal-bootstrap/_colors.scss +0 -10
  76. data/spec/dummy/app/assets/stylesheets/pivotal-bootstrap/ars-maquette-web.css +0 -35
  77. data/spec/dummy/app/assets/stylesheets/pivotal-bootstrap/button.less +0 -5
  78. data/spec/dummy/app/assets/stylesheets/pivotal-bootstrap/layout.css.scss +0 -11
  79. data/spec/dummy/app/assets/stylesheets/pivotal-bootstrap/typography.css.scss +0 -20
  80. data/spec/dummy/app/assets/stylesheets/pivotal-bootstrap/variables.css.less +0 -10
  81. data/spec/dummy/app/controllers/home_controller.rb +0 -3
  82. data/spec/dummy/app/views/home/index.html.erb +0 -1
data/.gitignore CHANGED
@@ -9,3 +9,4 @@ spec/dummy/.sass-cache
9
9
  spec/dummy/app/assets/.DS_Store
10
10
 
11
11
  spec/dummy/app/assets/stylesheets/.DS_Store
12
+ /tmp
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --color
2
+ --format=nested
@@ -0,0 +1,16 @@
1
+ rvm:
2
+ - 1.9.3
3
+ script: script/ci.sh
4
+ env:
5
+ global:
6
+ secure: "Qwe5ArAGqbJeTk//8mwd5GSHazoJ+3L5B/MxhI7Ixx7Oe+Jmr54xU2T+q8c1\nQaxYKuACVjtUF/1Os8AiYeNL4OMVG4b+Zg285NkgHf7ouhg+y6PFTEUerSyi\nzJWK/h7Jqsj392BU6Anr5mf+SmySp3kphjGxe9TsR/2DPJC4OoQ="
7
+ after_script:
8
+ - gem install heroku
9
+ - git remote add heroku git@heroku.com:swivel.git
10
+ - echo "Host heroku.com" >> ~/.ssh/config
11
+ - echo " StrictHostKeyChecking no" >> ~/.ssh/config
12
+ - echo " CheckHostIP no" >> ~/.ssh/config
13
+ - echo " UserKnownHostsFile=/dev/null" >> ~/.ssh/config
14
+ - heroku keys:clear
15
+ - yes | heroku keys:add
16
+ - yes | git push heroku master
data/Gemfile CHANGED
@@ -1,5 +1,3 @@
1
1
  source "http://rubygems.org"
2
2
 
3
- gem "gem-release", :group => :development
4
-
5
3
  gemspec
@@ -2,6 +2,7 @@ PATH
2
2
  remote: .
3
3
  specs:
4
4
  style-guide (0.0.1)
5
+ jquery-rails
5
6
  rails
6
7
 
7
8
  GEM
@@ -44,7 +45,8 @@ GEM
44
45
  eventmachine (>= 0.12.9)
45
46
  erubis (2.7.0)
46
47
  eventmachine (1.0.0)
47
- gem-release (0.4.1)
48
+ foreman (0.60.2)
49
+ thor (>= 0.13.6)
48
50
  guard (1.5.4)
49
51
  listen (>= 0.4.2)
50
52
  lumberjack (>= 1.0.2)
@@ -57,6 +59,9 @@ GEM
57
59
  em-websocket (>= 0.2.0)
58
60
  guard (>= 1.5.0)
59
61
  multi_json (~> 1.0)
62
+ guard-rspec (2.3.0)
63
+ guard (>= 1.1)
64
+ rspec (~> 2.11)
60
65
  hike (1.2.1)
61
66
  i18n (0.6.1)
62
67
  journey (1.0.4)
@@ -73,7 +78,7 @@ GEM
73
78
  treetop (~> 1.4.8)
74
79
  method_source (0.8.1)
75
80
  mime-types (1.19)
76
- multi_json (1.3.7)
81
+ multi_json (1.4.0)
77
82
  polyglot (0.3.3)
78
83
  pry (0.9.10)
79
84
  coderay (~> 1.0.5)
@@ -109,12 +114,19 @@ GEM
109
114
  rspec-core (~> 2.12.0)
110
115
  rspec-expectations (~> 2.12.0)
111
116
  rspec-mocks (~> 2.12.0)
112
- rspec-core (2.12.0)
117
+ rspec-core (2.12.1)
113
118
  rspec-expectations (2.12.0)
114
119
  diff-lcs (~> 1.1.3)
115
120
  rspec-mocks (2.12.0)
121
+ rspec-rails (2.12.0)
122
+ actionpack (>= 3.0)
123
+ activesupport (>= 3.0)
124
+ railties (>= 3.0)
125
+ rspec-core (~> 2.12.0)
126
+ rspec-expectations (~> 2.12.0)
127
+ rspec-mocks (~> 2.12.0)
116
128
  slop (3.3.3)
117
- sprockets (2.2.1)
129
+ sprockets (2.2.2)
118
130
  hike (~> 1.2)
119
131
  multi_json (~> 1.0)
120
132
  rack (~> 1.0)
@@ -133,12 +145,12 @@ PLATFORMS
133
145
  ruby
134
146
 
135
147
  DEPENDENCIES
136
- gem-release
148
+ foreman
137
149
  guard-bundler
138
150
  guard-livereload
139
- jquery-rails
151
+ guard-rspec
140
152
  rb-fsevent
141
- rspec
153
+ rspec-rails
142
154
  style-guide!
143
155
  terminal-notifier-guard
144
156
  therubyracer
data/Guardfile CHANGED
@@ -12,3 +12,15 @@ guard 'livereload' do
12
12
  watch(%r{config/locales/.+\.yml})
13
13
  watch(%r{(app|vendor|spec/dummy/app)/assets/\w+/(.+\.(css|js|html)).*}) { |m| "/assets/#{m[2]}" }
14
14
  end
15
+
16
+ guard 'rspec', :cli => '--fail-fast --tag ~@slow:true' do
17
+ watch(%r{^spec/.+_spec\.rb$})
18
+ watch(%r{^lib/(.+)\.rb$}) { |m| "spec/lib/#{m[1]}_spec.rb" }
19
+ watch('spec/spec_helper.rb') { "spec" }
20
+
21
+ watch(%r{^app/(.+)\.rb$}) { |m| "spec/#{m[1]}_spec.rb" }
22
+ watch(%r{^app/(.*)(\.erb|\.haml)$}) { |m| "spec/#{m[1]}#{m[2]}_spec.rb" }
23
+ watch(%r{^app/controllers/(.+)_(controller)\.rb$}) { |m| ["spec/routing/#{m[1]}_routing_spec.rb", "spec/#{m[2]}s/#{m[1]}_#{m[2]}_spec.rb", "spec/acceptance/#{m[1]}_spec.rb"] }
24
+ watch(%r{^spec/support/(.+)\.rb$}) { "spec" }
25
+ watch('app/controllers/application_controller.rb') { "spec/controllers" }
26
+ end
@@ -0,0 +1 @@
1
+ web: bundle exec bash -lc "cd spec/dummy && rails server --port $PORT"
data/README.md CHANGED
@@ -1,6 +1,31 @@
1
1
  # StyleGuide
2
2
 
3
- Quickly see the bootstrap output of your application.
3
+ [![Build Status](https://secure.travis-ci.org/pivotalexperimental/style-guide.png?branch=master)](https://travis-ci.org/pivotalexperimental/style-guide)
4
+
5
+ Quickly see the styled output of your application.
6
+
7
+ ## Example
8
+
9
+ The canonical deployed instance is located at [http://swivel.herokuapp.com](http://swivel.herokuapp.com)
10
+
11
+ ## Usage
12
+
13
+ First, require the StyleGuide gem in your application.rb file:
14
+
15
+ Bundler.require
16
+ require "style_guide"
17
+
18
+ Next, mount the StyleGuide application in your `routes.rb` file:
19
+
20
+ mount StyleGuide::Engine => "/style-guide"
21
+
22
+ By default, StyleGuide will attempt to load directories full of partials and render them at its mounted path. Here's how to add your own directory full of partials:
23
+
24
+ config.style_guide.partial_paths << Rails.root.join("app/views/styles")
25
+
26
+ You could, however, just display only your partials (note the assignment):
27
+
28
+ config.style_guide.partial_paths = [Rails.root.join("app/views/styles")]
4
29
 
5
30
  ## License
6
31
 
@@ -1,4 +1,10 @@
1
1
  module StyleGuide
2
2
  class ApplicationController < ActionController::Base
3
+ def load_sections
4
+ @sections =
5
+ StyleGuide::Engine.config.style_guide.partial_paths.map do |path|
6
+ StyleGuide::Section.new(path)
7
+ end
8
+ end
3
9
  end
4
10
  end
@@ -1,12 +1,9 @@
1
1
  module StyleGuide
2
2
  class StyleController < StyleGuide::ApplicationController
3
+ before_filter :load_sections
4
+
3
5
  def index
4
- @partials = []
5
- StyleGuide::Engine.config.style_guide.partial_paths.each do |path|
6
- Dir.glob(File.expand_path("_*.erb", path)) do |partial|
7
- @partials << partial
8
- end
9
- end
6
+ @active = @sections.first
10
7
  end
11
8
  end
12
9
  end
@@ -27,9 +27,11 @@
27
27
  <a class="brand" href="/">Bootstrap</a>
28
28
  <div class="nav-collapse collapse">
29
29
  <ul class="nav">
30
- <li class="index active">
31
- <a href="/style-guide">Base CSS</a>
30
+ <% @sections.each_with_index do |section, index| %>
31
+ <li<%= (section == @active) ? ' class="active"'.html_safe : '' %>>
32
+ <a href="<%= root_path %>"><%= section.title %></a>
32
33
  </li>
34
+ <% end %>
33
35
  </ul>
34
36
  </div>
35
37
  </div>
@@ -0,0 +1,5 @@
1
+ <ul class="nav nav-list bs-docs-sidenav">
2
+ <% @active.partials.each do |partial| %>
3
+ <li><a href="#<%= partial.id %>"><i class="icon-chevron-right"></i> <%= partial.title %></a></li>
4
+ <% end %>
5
+ </ul>
@@ -2,30 +2,21 @@
2
2
  ================================================== -->
3
3
  <header class="jumbotron subhead" id="overview">
4
4
  <div class="container">
5
- <h1>Base CSS</h1>
6
- <p class="lead">Fundamental HTML elements styled and enhanced with extensible classes.</p>
5
+ <h1><%= @active.title %></h1>
7
6
  </div>
8
7
  </header>
9
8
 
10
-
11
9
  <div class="container">
12
10
  <!-- Docs nav
13
11
  ================================================== -->
14
12
  <div class="row">
15
13
  <div class="span3 bs-docs-sidebar">
16
- <ul class="nav nav-list bs-docs-sidenav">
17
- <li><a href="#typography"><i class="icon-chevron-right"></i> Typography</a></li>
18
- <li><a href="#code"><i class="icon-chevron-right"></i> Code</a></li>
19
- <li><a href="#tables"><i class="icon-chevron-right"></i> Tables</a></li>
20
- <li><a href="#forms"><i class="icon-chevron-right"></i> Forms</a></li>
21
- <li><a href="#buttons"><i class="icon-chevron-right"></i> Buttons</a></li>
22
- <li><a href="#images"><i class="icon-chevron-right"></i> Images</a></li>
23
- <li><a href="#icons"><i class="icon-chevron-right"></i> Icons by Glyphicons</a></li>
24
- </ul>
14
+ <%= render :partial => "sidebar" %>
25
15
  </div>
16
+
26
17
  <div class="span9">
27
- <% @partials.each do |partial| %>
28
- <%= render :file => partial %>
18
+ <% @active.partials.each do |partial| %>
19
+ <%= render :file => partial.path %>
29
20
  <% end %>
30
21
  </div>
31
22
  </div>
@@ -1,3 +1,4 @@
1
1
  StyleGuide::Engine.routes.draw do
2
2
  root :to => "style#index"
3
+ resource :style, :path => '', :only => [:index]
3
4
  end
@@ -1,4 +1,2 @@
1
+ require "style_guide/version"
1
2
  require "style_guide/engine"
2
-
3
- module StyleGuide
4
- end
@@ -0,0 +1,9 @@
1
+ module StyleGuide
2
+ class Config
3
+ attr_accessor :partial_paths
4
+
5
+ def initialize(options = {})
6
+ @partial_paths = options[:partial_paths] || [StyleGuide::Engine.root.join("app/views/style_guide/partials")]
7
+ end
8
+ end
9
+ end
@@ -1,12 +1,10 @@
1
+ require "rails/engine"
2
+ require "style_guide/config"
3
+ require "style_guide/section"
4
+
1
5
  module StyleGuide
2
6
  class Engine < ::Rails::Engine
3
7
  isolate_namespace StyleGuide
4
- class StyleGuideConfig < Struct.new(:partial_paths); end
5
-
6
- config.style_guide = StyleGuideConfig.new([])
7
-
8
- initializer "style_guide.set_up_variables", :before => :load_config_initializers do |app|
9
- app.config.style_guide.partial_paths << StyleGuide::Engine.root.join("app/views/style_guide/partials")
10
- end
8
+ config.style_guide = StyleGuide::Config.new
11
9
  end
12
10
  end
@@ -0,0 +1,21 @@
1
+ module StyleGuide
2
+ class Partial
3
+ attr_reader :path
4
+
5
+ def initialize(path)
6
+ @path = path
7
+ end
8
+
9
+ def id
10
+ @id ||= title.downcase.gsub(/[^a-zA-Z0-9]+/, "_")
11
+ end
12
+
13
+ def title
14
+ @title ||= File.basename(path, ".erb").titleize.strip
15
+ end
16
+
17
+ def content
18
+ @content || File.read(path)
19
+ end
20
+ end
21
+ end
@@ -0,0 +1,29 @@
1
+ require "style_guide/partial"
2
+
3
+ module StyleGuide
4
+ class Section
5
+ attr_reader :path
6
+
7
+ def initialize(path)
8
+ @path = path
9
+ end
10
+
11
+ def id
12
+ @id ||= path.gsub(/[^a-zA-Z0-9]/, " ").strip.gsub(/\s+/, "_")
13
+ end
14
+
15
+ def title
16
+ @title ||= File.basename(path).titleize
17
+ end
18
+
19
+ def partials
20
+ partial_paths.map { |path| StyleGuide::Partial.new(path) }
21
+ end
22
+
23
+ private
24
+
25
+ def partial_paths
26
+ @partial_paths ||= Dir.glob(File.expand_path("**/_*.erb", path))
27
+ end
28
+ end
29
+ end
@@ -1,3 +1,3 @@
1
1
  module StyleGuide
2
- VERSION = "0.0.1"
2
+ VERSION = "0.1.0"
3
3
  end
@@ -0,0 +1,3 @@
1
+ #!/bin/bash
2
+
3
+ bundle exec rspec
@@ -0,0 +1,16 @@
1
+ require "spec_helper"
2
+
3
+ describe StyleGuide::StyleController do
4
+ describe "#index" do
5
+ it "assigns sections" do
6
+ get :index, use_route: :styles
7
+ assigns(:sections).should be
8
+ assigns(:sections).first.should be_a StyleGuide::Section
9
+ end
10
+
11
+ it "sets the active section to the first one" do
12
+ get :index, use_route: :styles
13
+ assigns(:active).should == assigns(:sections).first
14
+ end
15
+ end
16
+ end
@@ -11,5 +11,4 @@
11
11
  *= require_self
12
12
  *= require bootstrap
13
13
  *= require bootstrap-responsive
14
- *= require pivotal-bootstrap
15
14
  */
@@ -1,3 +1,6 @@
1
+ $stdout.sync = true
2
+ $stderr.sync = true
3
+
1
4
  require 'rubygems'
2
5
  gemfile = File.expand_path('../../../../Gemfile', __FILE__)
3
6
 
@@ -7,4 +10,4 @@ if File.exist?(gemfile)
7
10
  Bundler.setup
8
11
  end
9
12
 
10
- $:.unshift File.expand_path('../../../../lib', __FILE__)
13
+ $:.unshift File.expand_path('../../../../lib', __FILE__)
@@ -1,4 +1,4 @@
1
1
  Rails.application.routes.draw do
2
- root :to => "home#index"
2
+ root :to => redirect("/style-guide")
3
3
  mount StyleGuide::Engine => "/style-guide"
4
4
  end
@@ -0,0 +1,17 @@
1
+ require "spec_helper"
2
+
3
+ describe StyleGuide::Config do
4
+ describe "#partial_paths" do
5
+ context "when no paths have been added" do
6
+ it { should have(1).partial_path }
7
+ its(:partial_paths) { should == [StyleGuide::Engine.root.join("app/views/style_guide/partials")] }
8
+ end
9
+
10
+ context "after a path has been added" do
11
+ before { subject.partial_paths << "partials-and-magic-beans" }
12
+
13
+ it { should have(2).partial_paths }
14
+ its(:partial_paths) { should include "partials-and-magic-beans" }
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,54 @@
1
+ require "spec_helper"
2
+
3
+ describe StyleGuide::Partial do
4
+ let(:path) { "/hygenic/_gargling.erb" }
5
+ let(:partial) { StyleGuide::Partial.new(path) }
6
+
7
+ describe "#title" do
8
+ subject { partial.title }
9
+
10
+ context "with a simple path" do
11
+ it { should == "Gargling" }
12
+ end
13
+
14
+ context "with a path activerecord would be good at" do
15
+ let(:path) { "/tasty/_tree-leather.erb" }
16
+
17
+ it { should == "Tree Leather" }
18
+ end
19
+
20
+ context "with a path containing extra stuff" do
21
+ let(:path) { "/help/_a!dog%has-m1y=keyb^oaard.erb" }
22
+
23
+ it { should == "A!Dog%Has M1y=Keyb^Oaard" }
24
+ end
25
+ end
26
+
27
+ describe "#id" do
28
+ subject { partial.id }
29
+
30
+ context "with a simple path" do
31
+ it { should == "gargling" }
32
+ end
33
+
34
+ context "with a good activerecord path" do
35
+ let(:path) { "/tasty/_thumb_tacks.erb" }
36
+
37
+ it { should == "thumb_tacks" }
38
+ end
39
+
40
+ context "with a path containing extra stuff" do
41
+ let(:path) { "/help/mugabe%has-m1y=keyb^oaard" }
42
+
43
+ it { should == "mugabe_has_m1y_keyb_oaard" }
44
+ end
45
+ end
46
+
47
+ describe "#content" do
48
+ before { File.stub(:read => "reading is for chumps") }
49
+
50
+ subject { partial.content }
51
+
52
+ it { should == "reading is for chumps" }
53
+ end
54
+ end