css_canon 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +17 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +64 -0
- data/Rakefile +1 -0
- data/css_canon.gemspec +22 -0
- data/lib/css_canon/generators/install_generator.rb +46 -0
- data/lib/css_canon/generators/templates/app/assets/stylesheets/application.css.scss +23 -0
- data/lib/css_canon/generators/templates/app/assets/stylesheets/base.css.scss +6 -0
- data/lib/css_canon/generators/templates/app/assets/stylesheets/layout/grid_additions.css.scss +0 -0
- data/lib/css_canon/generators/templates/app/assets/stylesheets/module/README +3 -0
- data/lib/css_canon/generators/templates/app/assets/stylesheets/vendor_overrides/README +2 -0
- data/lib/css_canon/generators/templates/vendor/assets/stylesheets/vendor.css.scss +3 -0
- data/lib/css_canon/version.rb +3 -0
- data/lib/css_canon.rb +6 -0
- metadata +82 -0
data/.gitignore
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2012 Michael Johnston
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,64 @@
|
|
1
|
+
# css_canon
|
2
|
+
|
3
|
+
Imposes a "canonical" css/sass/[SMACSS][2] structure on a Rails 3.x project.
|
4
|
+
|
5
|
+
* Assumes using [Zurb Foundation][1]. Pull requests for Bootstrap or other frameworks welcome.
|
6
|
+
* imposes the following directory structures
|
7
|
+
|
8
|
+
```
|
9
|
+
|
10
|
+
├── app
|
11
|
+
│ ├── assets
|
12
|
+
│ │ └── stylesheets
|
13
|
+
│ │ ├── application.css.scss
|
14
|
+
│ │ ├── base.css.scss
|
15
|
+
│ │ ├── foundation_and_overrides.scss
|
16
|
+
│ │ ├── home.css.scss
|
17
|
+
│ │ ├── layout
|
18
|
+
│ │ │ └── grid_additions.css.scss
|
19
|
+
│ │ ├── module
|
20
|
+
│ │ │ └──
|
21
|
+
│ │ └── vendor_overrides
|
22
|
+
│ │ └──
|
23
|
+
└── vendor
|
24
|
+
├── assets
|
25
|
+
│ └── stylesheets
|
26
|
+
│ ├── non_sass
|
27
|
+
│ │ └──
|
28
|
+
│ ├── sass
|
29
|
+
│ │ └──
|
30
|
+
│ └── vendor.css
|
31
|
+
|
32
|
+
```
|
33
|
+
|
34
|
+
## Example
|
35
|
+
For an example rails app using this structure, see [this repo][3]
|
36
|
+
## Installation
|
37
|
+
|
38
|
+
Add this line to your application's Gemfile:
|
39
|
+
|
40
|
+
gem 'css_canon'
|
41
|
+
|
42
|
+
And then execute:
|
43
|
+
|
44
|
+
$ bundle
|
45
|
+
|
46
|
+
Or install it yourself as:
|
47
|
+
|
48
|
+
$ gem install css_canon
|
49
|
+
|
50
|
+
## Usage
|
51
|
+
|
52
|
+
rails g css_canon
|
53
|
+
|
54
|
+
## Contributing
|
55
|
+
|
56
|
+
1. Fork it
|
57
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
58
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
59
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
60
|
+
5. Create new Pull Request
|
61
|
+
|
62
|
+
[1]: https://github.com/zurb/foundation "Zurb Foundation"
|
63
|
+
[2]: http://smacss.com "Scalable and Modular Architecture for CSS"
|
64
|
+
[3]: https://github.com/lastobelus/assets_css_structure "Example Rails app using the css_canon setup"
|
data/Rakefile
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require "bundler/gem_tasks"
|
data/css_canon.gemspec
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'css_canon/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |gem|
|
7
|
+
gem.name = "css_canon"
|
8
|
+
gem.version = CssCanon::VERSION
|
9
|
+
gem.authors = ["Michael Johnston"]
|
10
|
+
gem.email = ["lastobelus@mac.com"]
|
11
|
+
gem.description = %q{Imposes a "canonical" css/sass/SMACSS structure on a Rails 3.x project.}
|
12
|
+
gem.summary = %q{Imposes a "canonical" css/sass/SMACSS structure on a Rails 3.x project.}
|
13
|
+
gem.homepage = "https://github.com/lastobelus/css_canon"
|
14
|
+
|
15
|
+
gem.files = `git ls-files`.split($/)
|
16
|
+
gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
|
17
|
+
gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
|
18
|
+
gem.require_paths = ["lib"]
|
19
|
+
|
20
|
+
gem.add_dependency "zurb-foundation", "~> 3.2.0"
|
21
|
+
|
22
|
+
end
|
@@ -0,0 +1,46 @@
|
|
1
|
+
module CssCanon
|
2
|
+
module Generators
|
3
|
+
class InstallGenerator < Rails::Generators::Base
|
4
|
+
source_root File.join(File.dirname(__FILE__), 'templates')
|
5
|
+
desc 'imposes a canonical css structure'
|
6
|
+
|
7
|
+
def install_foundation_if_not_installed
|
8
|
+
unless File.exists?("app/assets/stylesheets/foundation_and_overrides.scss")
|
9
|
+
generate "foundation:install"
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
def copy_app_asset_templates
|
14
|
+
say "setting up app/assets/stylesheets..."
|
15
|
+
if File.exists? "app/assets/stylesheets/application.css"
|
16
|
+
File.rename "app/assets/stylesheets/application.css", "app/assets/stylesheets/TO_MIGRATE.css"
|
17
|
+
end
|
18
|
+
copy_file "app/assets/stylesheets/application.css.scss"
|
19
|
+
copy_file "app/assets/stylesheets/base.css.scss"
|
20
|
+
directory "app/assets/stylesheets/layout"
|
21
|
+
directory "app/assets/stylesheets/module"
|
22
|
+
end
|
23
|
+
|
24
|
+
def copy_vendor_asset_templates
|
25
|
+
say "setting up vendor/assets/stylesheets..."
|
26
|
+
copy_file "vendor/assets/stylesheets/vendor.css.scss"
|
27
|
+
end
|
28
|
+
|
29
|
+
def modify_zurb_overrides_file
|
30
|
+
say "adding example use of brand variables to foundation_and_overrides..."
|
31
|
+
foundation_file = "app/assets/stylesheets/foundation_and_overrides.scss"
|
32
|
+
color_example_regex = %r{^ *// *\$mainColor:.*}
|
33
|
+
our_color_example = <<-EOCSS
|
34
|
+
\n// override foundation variables with variables defined in base.css.scss,
|
35
|
+
// so that branding can easily be changed in a single place
|
36
|
+
// $mainColor: $brandOne;"
|
37
|
+
EOCSS
|
38
|
+
if File.readlines(foundation_file).grep(color_example_regex).size > 0
|
39
|
+
gsub_file foundation_file, color_example_regex, our_color_example
|
40
|
+
else
|
41
|
+
inject_into_file foundation_file, our_color_example, after: %r{// Colors Settings}
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
// non-sass files go in vendor/assetts/stylesheets/application
|
2
|
+
// and vendor/assetts/stylesheets/vendor.css does a require_tree .
|
3
|
+
//= require vendor
|
4
|
+
//= require_self
|
5
|
+
|
6
|
+
// site/brand specific sass variables go here
|
7
|
+
@import "base";
|
8
|
+
// here foundation variables are set to values defined in base
|
9
|
+
@import "foundation_and_overrides";
|
10
|
+
|
11
|
+
// overrides/customizations of vendor libs go here.
|
12
|
+
// If possible they should be independent, so this can be left as a blob
|
13
|
+
@import "vendor_overrides/**/*";
|
14
|
+
|
15
|
+
// styles which build on basic foundation layouts.
|
16
|
+
// Should use SMACSS -- if the glob stops working
|
17
|
+
// consider that a css code smell
|
18
|
+
@import "layout/**/*";
|
19
|
+
|
20
|
+
// styles which build modules.
|
21
|
+
// Should use SMACSS -- if the glob stops working
|
22
|
+
// consider that a css code smell
|
23
|
+
@import "module/**/*";
|
File without changes
|
@@ -0,0 +1,2 @@
|
|
1
|
+
Include files here that override styles in vendored css, with a file or directory with a name matching the name of the directory in vendor/assets/stylesheets that contains the 3rd-party css
|
2
|
+
These files are imported after base.css.scss and foundation_overrides.css.scss, so they can use sass variables/mixins defined there
|
data/lib/css_canon.rb
ADDED
metadata
ADDED
@@ -0,0 +1,82 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: css_canon
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Michael Johnston
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2012-12-17 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: zurb-foundation
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ~>
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: 3.2.0
|
22
|
+
type: :runtime
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ~>
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: 3.2.0
|
30
|
+
description: Imposes a "canonical" css/sass/SMACSS structure on a Rails 3.x project.
|
31
|
+
email:
|
32
|
+
- lastobelus@mac.com
|
33
|
+
executables: []
|
34
|
+
extensions: []
|
35
|
+
extra_rdoc_files: []
|
36
|
+
files:
|
37
|
+
- .gitignore
|
38
|
+
- Gemfile
|
39
|
+
- LICENSE.txt
|
40
|
+
- README.md
|
41
|
+
- Rakefile
|
42
|
+
- css_canon.gemspec
|
43
|
+
- lib/css_canon.rb
|
44
|
+
- lib/css_canon/generators/install_generator.rb
|
45
|
+
- lib/css_canon/generators/templates/app/assets/stylesheets/application.css.scss
|
46
|
+
- lib/css_canon/generators/templates/app/assets/stylesheets/base.css.scss
|
47
|
+
- lib/css_canon/generators/templates/app/assets/stylesheets/layout/grid_additions.css.scss
|
48
|
+
- lib/css_canon/generators/templates/app/assets/stylesheets/module/README
|
49
|
+
- lib/css_canon/generators/templates/app/assets/stylesheets/vendor_overrides/README
|
50
|
+
- lib/css_canon/generators/templates/vendor/assets/stylesheets/vendor.css.scss
|
51
|
+
- lib/css_canon/version.rb
|
52
|
+
homepage: https://github.com/lastobelus/css_canon
|
53
|
+
licenses: []
|
54
|
+
post_install_message:
|
55
|
+
rdoc_options: []
|
56
|
+
require_paths:
|
57
|
+
- lib
|
58
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
59
|
+
none: false
|
60
|
+
requirements:
|
61
|
+
- - ! '>='
|
62
|
+
- !ruby/object:Gem::Version
|
63
|
+
version: '0'
|
64
|
+
segments:
|
65
|
+
- 0
|
66
|
+
hash: -2663183119578062736
|
67
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
68
|
+
none: false
|
69
|
+
requirements:
|
70
|
+
- - ! '>='
|
71
|
+
- !ruby/object:Gem::Version
|
72
|
+
version: '0'
|
73
|
+
segments:
|
74
|
+
- 0
|
75
|
+
hash: -2663183119578062736
|
76
|
+
requirements: []
|
77
|
+
rubyforge_project:
|
78
|
+
rubygems_version: 1.8.24
|
79
|
+
signing_key:
|
80
|
+
specification_version: 3
|
81
|
+
summary: Imposes a "canonical" css/sass/SMACSS structure on a Rails 3.x project.
|
82
|
+
test_files: []
|