gridpaper 0.0.5
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.
- data/.gitignore +10 -0
- data/Gemfile +4 -0
- data/Guardfile +33 -0
- data/README.rdoc +74 -0
- data/Rakefile +10 -0
- data/bin/gridpaper +62 -0
- data/examples/images/Untitled-1.png +0 -0
- data/examples/images/grid.png +0 -0
- data/examples/index.html +124 -0
- data/examples/stylesheets/sass/_columns.sass +51 -0
- data/examples/stylesheets/sass/_settings.sass +7 -0
- data/examples/stylesheets/sass/styles.sass +38 -0
- data/examples/stylesheets/scss/nested_folder/_imported_file.scss +3 -0
- data/examples/stylesheets/scss/nested_folder/generated.scss +0 -0
- data/examples/stylesheets/scss/something.scss +1 -0
- data/gridpaper.gemspec +26 -0
- data/lib/Guardfile +147 -0
- data/lib/gridpaper.rb +95 -0
- data/lib/gridpaper/version.rb +3 -0
- data/lib/guard/gridpaper-watch.rb +129 -0
- data/templates/examples/_columns.sass +46 -0
- data/templates/sass/_settings.sass +7 -0
- data/templates/sass/gridpaper/_all.sass +1 -0
- data/templates/sass/gridpaper/_effects.sass +31 -0
- data/templates/sass/gridpaper/_forms.sass +27 -0
- data/templates/sass/gridpaper/_grid.sass +59 -0
- data/templates/sass/gridpaper/_reset.sass +102 -0
- data/templates/sass/gridpaper/_utilities.sass +6 -0
- data/templates/sass/styles.sass +2 -0
- data/templates/scss/_settings.scss +7 -0
- data/templates/scss/gridpaper/_all.scss +7 -0
- data/templates/scss/gridpaper/_effects.scss +31 -0
- data/templates/scss/gridpaper/_forms.scss +19 -0
- data/templates/scss/gridpaper/_grid.scss +57 -0
- data/templates/scss/gridpaper/_reset.scss +106 -0
- data/templates/scss/styles.scss +2 -0
- metadata +137 -0
data/lib/Guardfile
ADDED
@@ -0,0 +1,147 @@
|
|
1
|
+
require 'gridpaper'
|
2
|
+
require 'colorize'
|
3
|
+
require 'guard/guard'
|
4
|
+
require 'sass'
|
5
|
+
|
6
|
+
module ::Guard
|
7
|
+
class GridpaperSass < ::Guard::Guard
|
8
|
+
|
9
|
+
DEFAULTS = {
|
10
|
+
:output => 'css', # Output directory
|
11
|
+
:notification => true, # Enable notifications?
|
12
|
+
:shallow => false, # Output nested directories?
|
13
|
+
:style => :nested, # Nested output
|
14
|
+
:debug_info => false, # File and line number info for FireSass
|
15
|
+
:noop => false, # Do no write output file
|
16
|
+
:hide_success => false, # Do not show success message
|
17
|
+
:load_paths => Dir.glob('**/**').find_all {|i| File.directory?(i) }
|
18
|
+
}
|
19
|
+
|
20
|
+
def initialize(watchers = [], options = {})
|
21
|
+
if options[:input]
|
22
|
+
options[:output] = options[:input] unless options.has_key?(:output)
|
23
|
+
watchers << ::Guard::Watcher.new(%r{^#{options.delete(:input)}/(.+\.s[ac]ss)$})
|
24
|
+
end
|
25
|
+
|
26
|
+
super(watchers, DEFAULTS.merge(options))
|
27
|
+
end
|
28
|
+
|
29
|
+
|
30
|
+
# Builds the sass or scss. Determines engine to use by extension
|
31
|
+
# of path given.
|
32
|
+
#
|
33
|
+
# @param file [String] path to file to build
|
34
|
+
# @return [String] the output css
|
35
|
+
#
|
36
|
+
def build_sass(file)
|
37
|
+
content = File.new(file).read
|
38
|
+
# sass or scss?
|
39
|
+
type = file[-4..-1].to_sym
|
40
|
+
sass_options = {
|
41
|
+
:syntax => type,
|
42
|
+
:load_paths => options[:load_paths],
|
43
|
+
:style => options[:style].to_sym,
|
44
|
+
:debug_info => options[:debug_info],
|
45
|
+
}
|
46
|
+
|
47
|
+
::Sass::Engine.new(content, sass_options).render
|
48
|
+
end
|
49
|
+
|
50
|
+
# Get the file path to output the css based on the file being
|
51
|
+
# built.
|
52
|
+
#
|
53
|
+
# @param file [String] path to file being built
|
54
|
+
# @return [String] path to file where output should be written
|
55
|
+
#
|
56
|
+
def get_output(file)
|
57
|
+
folder = File.join ::Guard.listener.directory, options[:output]
|
58
|
+
|
59
|
+
unless options[:shallow]
|
60
|
+
watchers.product([file]).each do |watcher, file|
|
61
|
+
if matches = file.match(watcher.pattern)
|
62
|
+
if matches[1]
|
63
|
+
folder = File.join(::Guard.listener.directory, options[:output], File.dirname(matches[1])).gsub(/\/\.$/, '')
|
64
|
+
break
|
65
|
+
end
|
66
|
+
end
|
67
|
+
end
|
68
|
+
end
|
69
|
+
|
70
|
+
FileUtils.mkdir_p folder
|
71
|
+
r = File.join folder, File.basename(file).split('.')[0]
|
72
|
+
r << '.css'
|
73
|
+
end
|
74
|
+
|
75
|
+
def ignored?(path)
|
76
|
+
File.basename(path)[0,1] == "_"
|
77
|
+
end
|
78
|
+
|
79
|
+
# ================
|
80
|
+
# = Guard method =
|
81
|
+
# ================
|
82
|
+
|
83
|
+
# Build all files being watched
|
84
|
+
def run_all
|
85
|
+
run_on_change(Watcher.match_files(self, Dir.glob(File.join('**', '[^_]*.*'))))
|
86
|
+
end
|
87
|
+
|
88
|
+
# Build the files given
|
89
|
+
def run_on_change(paths)
|
90
|
+
partials = paths.select { |f| ignored?(f) }
|
91
|
+
return run_all unless partials.empty?
|
92
|
+
|
93
|
+
changed_files = paths.reject{ |f| ignored?(f) }.map do |file|
|
94
|
+
css_file = get_output(file)
|
95
|
+
begin
|
96
|
+
contents = build_sass(file)
|
97
|
+
if contents
|
98
|
+
message = options[:noop] ? "verified #{file}" : "rebuilt #{file}"
|
99
|
+
|
100
|
+
File.open(css_file, 'w') {|f| f.write(contents) } unless options[:noop]
|
101
|
+
::Guard::UI.info "-> #{message}", :reset => true
|
102
|
+
if options[:notification] && !options[:hide_success]
|
103
|
+
::Guard::Notifier.notify(message, :title => "Guard::Sass", :image => :success)
|
104
|
+
end
|
105
|
+
end
|
106
|
+
css_file
|
107
|
+
rescue ::Sass::SyntaxError => e
|
108
|
+
::Guard::UI.error "Sass > #{e.sass_backtrace_str(file)}"
|
109
|
+
::Guard::Notifier.notify(
|
110
|
+
(options[:noop] ? 'validation' : 'rebuild') + " failed > #{e.sass_backtrace_str(file)}",
|
111
|
+
:title => "Guard::Sass",
|
112
|
+
:image => :error
|
113
|
+
) if options[:notification]
|
114
|
+
nil
|
115
|
+
end
|
116
|
+
end.compact
|
117
|
+
notify changed_files
|
118
|
+
end
|
119
|
+
|
120
|
+
def notify(changed_files)
|
121
|
+
::Guard.guards.reject{ |guard| guard == self }.each do |guard|
|
122
|
+
paths = Watcher.match_files(guard, changed_files)
|
123
|
+
guard.run_on_change paths unless paths.empty?
|
124
|
+
end
|
125
|
+
end
|
126
|
+
|
127
|
+
end
|
128
|
+
end
|
129
|
+
|
130
|
+
|
131
|
+
|
132
|
+
# input = File.join(Gridpaper::Watch::DIR, 'stylesheets')
|
133
|
+
# output = File.join(Gridpaper::Watch::DIR, 'stylesheets')
|
134
|
+
puts "#{ Gridpaper::Watch.input_path } => #{ Gridpaper::Watch.output_path }".light_red
|
135
|
+
|
136
|
+
guard 'gridpaper-sass', :input => Gridpaper::Watch.input_path, :output => Gridpaper::Watch.output_path do
|
137
|
+
# watch %r{^(s[ac]ss)/(.+\.s[ac]ss)$}
|
138
|
+
watch %r{^(.+\.s[ac]ss)$}
|
139
|
+
end
|
140
|
+
|
141
|
+
# guard 'sass',
|
142
|
+
# :input => Gridpaper::Watch.input_path,
|
143
|
+
# :output => Gridpaper::Watch.output_path,
|
144
|
+
# :style => :compact,
|
145
|
+
# :debug_info_ => true do
|
146
|
+
# watch %r{^(.+\.s[ac]ss)$}
|
147
|
+
# end
|
data/lib/gridpaper.rb
ADDED
@@ -0,0 +1,95 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'gridpaper/version'
|
3
|
+
require 'commander/import'
|
4
|
+
require 'fileutils'
|
5
|
+
require 'yaml'
|
6
|
+
require 'colorize'
|
7
|
+
require 'guard'
|
8
|
+
# require 'guard-sass'
|
9
|
+
|
10
|
+
module Gridpaper
|
11
|
+
class Generate
|
12
|
+
|
13
|
+
# Add Gridpaper to your project
|
14
|
+
def initialize(path, stylesheets_dir="stylesheets", syntax=:sass)
|
15
|
+
|
16
|
+
destination = File.join(path, stylesheets_dir)
|
17
|
+
puts stylesheets_dir.cyan
|
18
|
+
copy_files_to(destination, syntax.to_s)
|
19
|
+
|
20
|
+
|
21
|
+
end
|
22
|
+
|
23
|
+
private
|
24
|
+
|
25
|
+
def copy_files_to(destination, syntax)
|
26
|
+
template_dir = File.expand_path(File.join(File.dirname(__FILE__), '../', 'templates', syntax.to_s))
|
27
|
+
template_dir_dest = File.join(destination, syntax)
|
28
|
+
project_dir = Dir.pwd
|
29
|
+
|
30
|
+
if File.exists?(template_dir_dest)
|
31
|
+
output(template_dir_dest, :skipped)
|
32
|
+
else
|
33
|
+
FileUtils.mkdir_p(template_dir_dest)
|
34
|
+
output(template_dir_dest, :created)
|
35
|
+
end
|
36
|
+
|
37
|
+
# Get a listing of all files and folders in the
|
38
|
+
# templates directory for the specified syntax
|
39
|
+
Dir.chdir(File.expand_path(template_dir))
|
40
|
+
files = Dir['**/*']
|
41
|
+
puts files
|
42
|
+
Dir.chdir(project_dir)
|
43
|
+
|
44
|
+
files.each do |file|
|
45
|
+
src = File.join(template_dir, file)
|
46
|
+
dest = File.join(template_dir_dest, file)
|
47
|
+
|
48
|
+
if File.exists?(dest)
|
49
|
+
output(dest.to_s, :skipped)
|
50
|
+
else
|
51
|
+
FileUtils.mkdir_p(dest) if File.directory?(src)
|
52
|
+
FileUtils.cp(src, dest) unless File.directory?(src)
|
53
|
+
output(dest.to_s, :created)
|
54
|
+
end
|
55
|
+
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
59
|
+
def output(message, status)
|
60
|
+
puts "#{ status.to_s }: #{ message }".to_s.green if status == :created
|
61
|
+
puts "#{ status.to_s }: #{ message } (exists)".to_s.yellow if status == :skipped
|
62
|
+
puts "#{ status.to_s }: #{ message }".to_s.red if status == :failed
|
63
|
+
end
|
64
|
+
end
|
65
|
+
|
66
|
+
class Watch
|
67
|
+
|
68
|
+
|
69
|
+
def initialize(input, output)
|
70
|
+
# working_dir = Dir.pwd
|
71
|
+
@@output_path = output
|
72
|
+
@@input_path = input
|
73
|
+
|
74
|
+
guardfile = File.expand_path(File.join(File.dirname(__FILE__), 'Guardfile'))
|
75
|
+
# puts guardfile.cyan
|
76
|
+
|
77
|
+
# Guard.setup
|
78
|
+
# Guard::Dsl.evaluate_guardfile(:guardfile => guardfile)
|
79
|
+
# Guard::Dsl.local_guardfile_path(guardfile)
|
80
|
+
# puts Guard::Dsl.guardfile_path.cyan
|
81
|
+
|
82
|
+
Guard.start(:guardfile => guardfile, :watchdir => input)
|
83
|
+
end
|
84
|
+
|
85
|
+
def self.output_path
|
86
|
+
return @@output_path
|
87
|
+
end
|
88
|
+
|
89
|
+
def self.input_path
|
90
|
+
return @@input_path
|
91
|
+
end
|
92
|
+
|
93
|
+
end
|
94
|
+
|
95
|
+
end
|
@@ -0,0 +1,129 @@
|
|
1
|
+
require 'guard'
|
2
|
+
require 'guard/guard'
|
3
|
+
require 'guard/watcher'
|
4
|
+
|
5
|
+
require 'sass'
|
6
|
+
|
7
|
+
module Guard
|
8
|
+
class GridpaperWatch < Guard
|
9
|
+
|
10
|
+
DEFAULTS = {
|
11
|
+
:output => 'css', # Output directory
|
12
|
+
:notification => true, # Enable notifications?
|
13
|
+
:shallow => false, # Output nested directories?
|
14
|
+
:style => :nested, # Nested output
|
15
|
+
:debug_info => false, # File and line number info for FireSass
|
16
|
+
:noop => false, # Do no write output file
|
17
|
+
:hide_success => false, # Do not show success message
|
18
|
+
:load_paths => Dir.glob('**/**').find_all {|i| File.directory?(i) }
|
19
|
+
}
|
20
|
+
|
21
|
+
def initialize(watchers = [], options = {})
|
22
|
+
if options[:input]
|
23
|
+
options[:output] = options[:input] unless options.has_key?(:output)
|
24
|
+
watchers << ::Guard::Watcher.new(%r{^#{options.delete(:input)}/(.+\.s[ac]ss)$})
|
25
|
+
end
|
26
|
+
|
27
|
+
super(watchers, DEFAULTS.merge(options))
|
28
|
+
end
|
29
|
+
|
30
|
+
|
31
|
+
# Builds the sass or scss. Determines engine to use by extension
|
32
|
+
# of path given.
|
33
|
+
#
|
34
|
+
# @param file [String] path to file to build
|
35
|
+
# @return [String] the output css
|
36
|
+
#
|
37
|
+
def build_sass(file)
|
38
|
+
content = File.new(file).read
|
39
|
+
# sass or scss?
|
40
|
+
type = file[-4..-1].to_sym
|
41
|
+
sass_options = {
|
42
|
+
:syntax => type,
|
43
|
+
:load_paths => options[:load_paths],
|
44
|
+
:style => options[:style].to_sym,
|
45
|
+
:debug_info => options[:debug_info],
|
46
|
+
}
|
47
|
+
|
48
|
+
::Sass::Engine.new(content, sass_options).render
|
49
|
+
end
|
50
|
+
|
51
|
+
# Get the file path to output the css based on the file being
|
52
|
+
# built.
|
53
|
+
#
|
54
|
+
# @param file [String] path to file being built
|
55
|
+
# @return [String] path to file where output should be written
|
56
|
+
#
|
57
|
+
def get_output(file)
|
58
|
+
folder = File.join ::Guard.listener.directory, options[:output]
|
59
|
+
|
60
|
+
unless options[:shallow]
|
61
|
+
watchers.product([file]).each do |watcher, file|
|
62
|
+
if matches = file.match(watcher.pattern)
|
63
|
+
if matches[1]
|
64
|
+
folder = File.join(::Guard.listener.directory, options[:output], File.dirname(matches[1])).gsub(/\/\.$/, '')
|
65
|
+
break
|
66
|
+
end
|
67
|
+
end
|
68
|
+
end
|
69
|
+
end
|
70
|
+
|
71
|
+
FileUtils.mkdir_p folder
|
72
|
+
r = File.join folder, File.basename(file).split('.')[0]
|
73
|
+
r << '.css'
|
74
|
+
end
|
75
|
+
|
76
|
+
def ignored?(path)
|
77
|
+
File.basename(path)[0,1] == "_"
|
78
|
+
end
|
79
|
+
|
80
|
+
# ================
|
81
|
+
# = Guard method =
|
82
|
+
# ================
|
83
|
+
|
84
|
+
# Build all files being watched
|
85
|
+
def run_all
|
86
|
+
run_on_change(Watcher.match_files(self, Dir.glob(File.join('**', '[^_]*.*'))))
|
87
|
+
end
|
88
|
+
|
89
|
+
# Build the files given
|
90
|
+
def run_on_change(paths)
|
91
|
+
partials = paths.select { |f| ignored?(f) }
|
92
|
+
return run_all unless partials.empty?
|
93
|
+
|
94
|
+
changed_files = paths.reject{ |f| ignored?(f) }.map do |file|
|
95
|
+
css_file = get_output(file)
|
96
|
+
begin
|
97
|
+
contents = build_sass(file)
|
98
|
+
if contents
|
99
|
+
message = options[:noop] ? "verified #{file}" : "rebuilt #{file}"
|
100
|
+
|
101
|
+
File.open(css_file, 'w') {|f| f.write(contents) } unless options[:noop]
|
102
|
+
::Guard::UI.info "-> #{message}", :reset => true
|
103
|
+
if options[:notification] && !options[:hide_success]
|
104
|
+
::Guard::Notifier.notify(message, :title => "Guard::Sass", :image => :success)
|
105
|
+
end
|
106
|
+
end
|
107
|
+
css_file
|
108
|
+
rescue ::Sass::SyntaxError => e
|
109
|
+
::Guard::UI.error "Sass > #{e.sass_backtrace_str(file)}"
|
110
|
+
::Guard::Notifier.notify(
|
111
|
+
(options[:noop] ? 'validation' : 'rebuild') + " failed > #{e.sass_backtrace_str(file)}",
|
112
|
+
:title => "Guard::Sass",
|
113
|
+
:image => :error
|
114
|
+
) if options[:notification]
|
115
|
+
nil
|
116
|
+
end
|
117
|
+
end.compact
|
118
|
+
notify changed_files
|
119
|
+
end
|
120
|
+
|
121
|
+
def notify(changed_files)
|
122
|
+
::Guard.guards.reject{ |guard| guard == self }.each do |guard|
|
123
|
+
paths = Watcher.match_files(guard, changed_files)
|
124
|
+
guard.run_on_change paths unless paths.empty?
|
125
|
+
end
|
126
|
+
end
|
127
|
+
|
128
|
+
end
|
129
|
+
end
|
@@ -0,0 +1,46 @@
|
|
1
|
+
.column
|
2
|
+
height: 100px
|
3
|
+
margin-bottom: 16px
|
4
|
+
background-color: $light-grey
|
5
|
+
border: 1px solid $medium-grey
|
6
|
+
|
7
|
+
|
8
|
+
#columns-1
|
9
|
+
.column
|
10
|
+
@include column
|
11
|
+
@include span(24, -2px)
|
12
|
+
|
13
|
+
#columns-2
|
14
|
+
.column
|
15
|
+
@include column
|
16
|
+
@include span(12, -2px)
|
17
|
+
|
18
|
+
#columns-3
|
19
|
+
.column
|
20
|
+
@include column
|
21
|
+
@include span(8, -2px)
|
22
|
+
|
23
|
+
#columns-4
|
24
|
+
.column
|
25
|
+
@include column
|
26
|
+
@include span(6, -2px)
|
27
|
+
|
28
|
+
#columns-6
|
29
|
+
.column
|
30
|
+
@include column
|
31
|
+
@include span(4, -2px)
|
32
|
+
|
33
|
+
#columns-8
|
34
|
+
.column
|
35
|
+
@include column
|
36
|
+
@include span(3, -2px)
|
37
|
+
|
38
|
+
#columns-12
|
39
|
+
.column
|
40
|
+
@include column
|
41
|
+
@include span(2, -2px)
|
42
|
+
|
43
|
+
#columns-24
|
44
|
+
.column
|
45
|
+
@include column
|
46
|
+
@include span(1, -2px)
|
@@ -0,0 +1 @@
|
|
1
|
+
@import reset, grid, effects, forms
|
@@ -0,0 +1,31 @@
|
|
1
|
+
@mixin border-radius($radii, $ie: false)
|
2
|
+
-webkit-border-radius: $radii
|
3
|
+
-moz-border-radius: $radii
|
4
|
+
-ms-border-radius: $radii
|
5
|
+
-o-border-radius: $radii
|
6
|
+
border-radius: $radii
|
7
|
+
-moz-background-clip: padding
|
8
|
+
-webkit-background-clip: padding-box
|
9
|
+
background-clip: padding-box
|
10
|
+
@if $ie
|
11
|
+
position: relative
|
12
|
+
behavior: url(/javascripts/PIE.htc)
|
13
|
+
|
14
|
+
@mixin box-shadow($style, $ie: false)
|
15
|
+
-webkit-box-shadow: $style
|
16
|
+
-moz-box-shadow: $style
|
17
|
+
-ms-box-shadow: $style
|
18
|
+
-o-box-shadow: $style
|
19
|
+
box-shadow: $style
|
20
|
+
@if $ie
|
21
|
+
behavior: url(/javascripts/PIE.htc)
|
22
|
+
|
23
|
+
@mixin box-gradient($from, $to)
|
24
|
+
background-color: mix($from, $to)
|
25
|
+
background-image: -webkit-gradient(linear, left top, left bottom, from($from), to($to))
|
26
|
+
background-image: -webkit-linear-gradient(top, $from, $to)
|
27
|
+
background-image: -moz-linear-gradient(top, $from, $to)
|
28
|
+
background-image: -ms-linear-gradient(top, $from, $to)
|
29
|
+
background-image: -o-linear-gradient(top, $from, $to)
|
30
|
+
background-image: linear-gradient(top, $from, $to)
|
31
|
+
filter: progid:DXImageTransform.Microsoft.gradient(startColorStr="#{ $from }", EndColorStr="#{ $to }")
|