atomic_sass 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.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 15d11fa9c28df308ffe4ea33f3cb579063b2e7f1
4
+ data.tar.gz: 9fa8136b2f4a7a5226583ce078a5ccb544156ef8
5
+ SHA512:
6
+ metadata.gz: f73fb7df6fe5ec8a12bb66beacb911b52cfcd9a3a80b4efc94edf256580bcc26ba470d520f521ebeeb3c5b00a202e8adc7b58e4e46024f63a45be3a334b639b5
7
+ data.tar.gz: 3647c5f14d63ecae2a2d384282563ec159cfccee63c7c545a27b6d4e8708cd53b8ca99c635de2b06e6e4c936484c9fdfc0e05fb960ac9a629488d1455e7c88b9
data/.gitignore ADDED
@@ -0,0 +1,17 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
data/Gemfile ADDED
@@ -0,0 +1,3 @@
1
+ source 'https://rubygems.org'
2
+
3
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2013 Travis Staton
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,48 @@
1
+ # Atomic Sass
2
+
3
+ Generators that make [atomic design](http://coding.smashingmagazine.com/2013/08/02/other-interface-atomic-design-sass/) with SASS easy.
4
+
5
+
6
+ ## Installation
7
+
8
+ ```bash
9
+ gem install atomic_sass
10
+ ```
11
+
12
+ ## Usage
13
+
14
+ Initialize your project
15
+
16
+ ```bash
17
+ atom init
18
+ ```
19
+
20
+ ##### Generate your documents by passing the appropriate flag then an array of new document names
21
+
22
+ - quark `atom g -q header nav footer aside`
23
+ - utility `atom g -u clearfix`
24
+ - atom `atom g -a input button`
25
+ - molecules `atom g -m seachbar top_nav`
26
+
27
+ or a few at once
28
+ ```bash
29
+ atom g -a input button -q header nav footer -m seachbar top_nav
30
+ ```
31
+
32
+ ##### specify which molecules will use your atom at generation
33
+ ( -i is short for --include )
34
+ ```bash
35
+ atom g -a input button -i seachbar
36
+ ```
37
+
38
+ ##### or include some atoms in a quark (or quarks)
39
+ ```bash
40
+ atom g -q header
41
+ atom g -a text_shadow --include-quark header
42
+ ```
43
+
44
+ ##### nested routes are automatically resolved too, so nest all you like
45
+ ```bash
46
+ atom g -m header/searchbar
47
+ atom g -a typography/textfields/input -i header/searchbar
48
+ ```
data/Rakefile ADDED
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
@@ -0,0 +1,27 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'atomic_sass/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "atomic_sass"
8
+ spec.version = AtomicSass::VERSION
9
+ spec.authors = ["Travis Staton"]
10
+ spec.email = ["hello@travisstaton.com"]
11
+ spec.description = %q{Generators for making atomic sass easy}
12
+ spec.summary = %q{Generators for making atomic sass easy}
13
+ spec.homepage = ""
14
+ spec.license = "MIT"
15
+
16
+ spec.files = `git ls-files`.split($/)
17
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
+ spec.require_paths = ["lib"]
20
+
21
+ spec.add_dependency "sass", [">= 3.2.0"]
22
+ spec.add_dependency "thor", [">= 0.18"]
23
+ spec.add_dependency "activesupport", [">= 3.0.0"]
24
+
25
+ spec.add_development_dependency "bundler", "~> 1.3"
26
+ spec.add_development_dependency "rake"
27
+ end
data/bin/atom ADDED
@@ -0,0 +1,5 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'atomic_sass'
4
+
5
+ ::AtomicSass::SassGenerator.start
@@ -0,0 +1,7 @@
1
+ // Molecules are where atomic styles/mixins coalesce into practical styles that
2
+ // describe real elements on the page. If you find yourself defining many
3
+ // styles here you should step back and ask yourself what can be extracted
4
+ // into a quark or an atom.
5
+
6
+ //--- BEGIN IMPORTS
7
+ //--- END IMPORTS
@@ -0,0 +1,6 @@
1
+ // Quarks are basic building blocks of your site, these are global styles
2
+ // on html tags, for instance a global style for the paragraph tag would go
3
+ // in this directory
4
+
5
+ //--- BEGIN IMPORTS
6
+ //--- END IMPORTS
@@ -0,0 +1,5 @@
1
+ // This directory is is for partials that are global to the application.
2
+ // for example this would be a great place for a css reset
3
+
4
+ //--- BEGIN IMPORTS
5
+ //--- END IMPORTS
@@ -0,0 +1,3 @@
1
+ module AtomicSass
2
+ VERSION = "0.1.0"
3
+ end
@@ -0,0 +1,165 @@
1
+ require "atomic_sass/version"
2
+ require 'active_support/core_ext/string/inflections'
3
+ require 'sass'
4
+ require 'sass/exec'
5
+ require 'thor'
6
+
7
+ module AtomicSass
8
+ class SassGenerator < Thor
9
+ map 'g' => :generate
10
+ include Thor::Actions
11
+
12
+ desc 'init', 'Create base structure for atomic sass'
13
+ def init
14
+ build_base_structure
15
+ end
16
+
17
+ desc 'generate', 'Generate individual document'
18
+ %w[ molecule atom utility quark include ].each do |type|
19
+ method_option type.to_sym, type: :array, aliases: %W[ -#{type[0,1]} ]
20
+ end
21
+ method_option 'include-quark', type: :array
22
+ def generate
23
+ _only_file_options.each do |key, values|
24
+ values.each do |value|
25
+ file_path, enclosing_dirs = _extract_and_create_dirs(value, "sass/#{key.pluralize}")
26
+ create_sass_doc("sass/#{key.pluralize}/#{enclosing_dirs}_#{file_path}.sass", key)
27
+ end
28
+ append_to_manifest(key, values)
29
+ end
30
+ _include_atoms(_only_include_options, options[:atom]) if _only_include_options && options[:atom]
31
+ end
32
+
33
+ desc 'build', 'Compile the sass to css'
34
+ method_option :watch, type: :boolean, aliases: %W[ -w ]
35
+ def build
36
+ if options[:watch]
37
+ _compile_and_watch_sass
38
+ else
39
+ _compile_sass
40
+ end
41
+ end
42
+
43
+ no_commands do
44
+
45
+ def create_sass_doc(path, key)
46
+ if not key.match /molecule|quark/
47
+ create_file(path)
48
+ else
49
+ create_file(path) do
50
+ ["//--- BEGIN IMPORTS", "//--- END IMPORTS", "\n"].join("\n")
51
+ end
52
+ end
53
+ end
54
+
55
+ def append_to_manifest(manifest_type, generated_filenames)
56
+ unless manifest_type == 'atom'
57
+ inject_into_file("sass/#{manifest_type.pluralize}/#{manifest_type}_manifest.sass", before: "\n//--- END IMPORTS") do
58
+ generated_filenames.map do |filename|
59
+ "@import #{filename}"
60
+ end.join("\n").prepend("\n")
61
+ end
62
+ end
63
+ end
64
+
65
+ def build_base_structure
66
+ entries = %w[ utility quark molecule atom ]
67
+ manifest_entries = entries.reject { |e| e == 'atom' }
68
+ empty_directory('sass')
69
+ empty_directory('css')
70
+ _build_application_sass(manifest_entries)
71
+ _build_empty_dirs(entries)
72
+ _build_manifest_entries(manifest_entries)
73
+ end
74
+
75
+ def _compile_sass
76
+ if ::Sass::Exec::Sass.new(%w[ sass/application.sass:css/application.css ]).parse
77
+ puts "Successfully built application.css"
78
+ else
79
+ puts "Failed to build sass"
80
+ end
81
+ end
82
+
83
+
84
+ def _compile_and_watch_sass
85
+ _compile_sass
86
+ puts "Watching for changes to application.sass"
87
+ unless ::Sass::Exec::Sass.new(%w[ --watch sass/application.sass:css/application.css ]).parse
88
+ puts "Failed to watch sass"
89
+ end
90
+ end
91
+
92
+ def _build_application_sass(entries)
93
+ create_file("sass/application.sass") do
94
+ entries.map do |entry|
95
+ "@import #{entry.pluralize}/#{entry}_manifest"
96
+ end.join("\n")
97
+ end
98
+ end
99
+
100
+ def _build_empty_dirs(entries)
101
+ entries.each do |entry|
102
+ empty_directory("sass/#{entry.pluralize}")
103
+ end
104
+ end
105
+
106
+ def _extract_and_create_dirs(path, prefix)
107
+ enclosing_dirs = File.dirname(path) if File.dirname(path) != '.'
108
+ empty_directory("#{prefix}/#{enclosing_dirs}") if enclosing_dirs
109
+ return [File.basename(path), enclosing_dirs ? "#{enclosing_dirs}/" : '']
110
+ end
111
+
112
+ def _build_manifest_entries(entries)
113
+ entries.each do |entry|
114
+ template("#{entry}_manifest.tt", "sass/#{entry.pluralize}/#{entry}_manifest.sass")
115
+ end
116
+ end
117
+
118
+ def _escape_file_path(path)
119
+ nesting_count = path.split('/').length
120
+ if nesting_count == 0
121
+ return ''
122
+ else
123
+ return '../' * nesting_count
124
+ end
125
+ end
126
+
127
+ def _include_atoms(include_types, atoms)
128
+ include_types.each do |type, filenames|
129
+ filenames.each do |filename|
130
+ file_path, enclosing_dirs = _extract_and_create_dirs(filename, "sass/#{type.pluralize}")
131
+ inject_into_file("sass/#{type.pluralize}/#{enclosing_dirs}_#{file_path}.sass", before: "\n//--- END IMPORTS") do
132
+ atoms.map do |atom|
133
+ "@import ../#{_escape_file_path(enclosing_dirs)}atoms/#{atom}"
134
+ end.join("\n").prepend("\n")
135
+ end
136
+ end
137
+ end
138
+ end
139
+
140
+ def _only_file_options
141
+ options.reject { |key, value| key.match /include/ }
142
+ end
143
+
144
+ def _only_include_options
145
+ filtered_options = options.select { |key, value| key.match /include/ }
146
+ if filtered_options.length > 0
147
+ normalized_hash = {}
148
+ normalized_hash['molecule'] = filtered_options['include'] if filtered_options['include']
149
+ normalized_hash['quark'] = filtered_options['include-quark'] if filtered_options['include-quark']
150
+ return normalized_hash
151
+ else
152
+ return nil
153
+ end
154
+ end
155
+ end
156
+
157
+ def self.source_root
158
+ File.dirname(__FILE__)
159
+ end
160
+
161
+ def self.source_paths
162
+ [File.join(File.expand_path(File.dirname(__FILE__)), 'atomic_sass', 'templates')]
163
+ end
164
+ end
165
+ end
metadata ADDED
@@ -0,0 +1,128 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: atomic_sass
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Travis Staton
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2013-10-01 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: sass
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - '>='
18
+ - !ruby/object:Gem::Version
19
+ version: 3.2.0
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - '>='
25
+ - !ruby/object:Gem::Version
26
+ version: 3.2.0
27
+ - !ruby/object:Gem::Dependency
28
+ name: thor
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - '>='
32
+ - !ruby/object:Gem::Version
33
+ version: '0.18'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - '>='
39
+ - !ruby/object:Gem::Version
40
+ version: '0.18'
41
+ - !ruby/object:Gem::Dependency
42
+ name: activesupport
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - '>='
46
+ - !ruby/object:Gem::Version
47
+ version: 3.0.0
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - '>='
53
+ - !ruby/object:Gem::Version
54
+ version: 3.0.0
55
+ - !ruby/object:Gem::Dependency
56
+ name: bundler
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ~>
60
+ - !ruby/object:Gem::Version
61
+ version: '1.3'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ~>
67
+ - !ruby/object:Gem::Version
68
+ version: '1.3'
69
+ - !ruby/object:Gem::Dependency
70
+ name: rake
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - '>='
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - '>='
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ description: Generators for making atomic sass easy
84
+ email:
85
+ - hello@travisstaton.com
86
+ executables:
87
+ - atom
88
+ extensions: []
89
+ extra_rdoc_files: []
90
+ files:
91
+ - .gitignore
92
+ - Gemfile
93
+ - LICENSE.txt
94
+ - README.md
95
+ - Rakefile
96
+ - atomic_sass.gemspec
97
+ - bin/atom
98
+ - lib/atomic_sass.rb
99
+ - lib/atomic_sass/templates/molecule_manifest.tt
100
+ - lib/atomic_sass/templates/quark_manifest.tt
101
+ - lib/atomic_sass/templates/utility_manifest.tt
102
+ - lib/atomic_sass/version.rb
103
+ homepage: ''
104
+ licenses:
105
+ - MIT
106
+ metadata: {}
107
+ post_install_message:
108
+ rdoc_options: []
109
+ require_paths:
110
+ - lib
111
+ required_ruby_version: !ruby/object:Gem::Requirement
112
+ requirements:
113
+ - - '>='
114
+ - !ruby/object:Gem::Version
115
+ version: '0'
116
+ required_rubygems_version: !ruby/object:Gem::Requirement
117
+ requirements:
118
+ - - '>='
119
+ - !ruby/object:Gem::Version
120
+ version: '0'
121
+ requirements: []
122
+ rubyforge_project:
123
+ rubygems_version: 2.0.3
124
+ signing_key:
125
+ specification_version: 4
126
+ summary: Generators for making atomic sass easy
127
+ test_files: []
128
+ has_rdoc: