gridpaper 0.0.5 → 0.0.6

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 CHANGED
@@ -7,4 +7,4 @@ pkg/*
7
7
  *.scssc
8
8
  .sass-cache
9
9
  .scss-cache
10
- .css
10
+ **.css
data/Guardfile CHANGED
@@ -4,11 +4,11 @@ require 'colorize'
4
4
  module ::Guard
5
5
  class RakeInstall < Guard
6
6
  def start
7
-
7
+ ::Guard::Notifier::notify('ready', :title => 'Gridpaper')
8
8
  end
9
9
 
10
10
  def stop
11
-
11
+ ::Guard::Notifier::notify('stopped watching for changes', :title => 'Gridpaper')
12
12
  end
13
13
 
14
14
  def reload
@@ -21,7 +21,8 @@ module ::Guard
21
21
  end
22
22
 
23
23
  def run_on_change(paths)
24
- `rake install`
24
+ system('rake install')
25
+ ::Guard::Notifier::notify('built and installed', :title => 'Gridpaper')
25
26
  end
26
27
 
27
28
  end
@@ -29,5 +30,6 @@ end
29
30
 
30
31
  # Available options: :pidfile, :port, :executable
31
32
  guard 'rake-install' do
32
- watch %r{.+}
33
+ watch(%r{^.+\.gemspec})
34
+ watch(%r{^(lib\/.+)|(bin\/.+)|(templates\/.+)})
33
35
  end
@@ -19,7 +19,7 @@ The <tt>gridpaper generate</tt> command is also aliased to:
19
19
  gridpaper setup
20
20
  gridpaper add
21
21
 
22
- === Options
22
+ ==== Options
23
23
 
24
24
  The <tt>gridpaper</tt> command takes the following options
25
25
 
@@ -29,6 +29,21 @@ The <tt>gridpaper</tt> command takes the following options
29
29
  --stylesheets-dir STRING
30
30
  # the name of your stylesheets directory (default is "stylesheets")
31
31
 
32
+ === Watch
33
+
34
+ Watch your project folder for changes to the sass or scss files and convert them to css with
35
+ gridpaper watch
36
+
37
+ ==== Arguments
38
+
39
+ The <tt>gridpaper watch <input folder> <output folder></tt> command takes the following arguments
40
+
41
+ <input folder>
42
+ # A relative path to the folder containing your SASS files. Defaults to "stylesheets/sass"
43
+
44
+ <output folder>
45
+ # A relative path to the folder where your CSS files will be created. Defaults to "stylesheets"
46
+
32
47
  == Development
33
48
 
34
49
  === Changelog
@@ -30,32 +30,21 @@ command :generate do |c|
30
30
  end
31
31
 
32
32
  command :watch do |c|
33
- c.syntax = 'gridpaper watch'
33
+ c.syntax = 'gridpaper watch <input folder> <output folder>'
34
34
  c.description = 'Watches for changes in your input file and generates CSS to your output file.'
35
35
 
36
- # c.option '--stylesheets-dir STRING', String, 'Use a different directory to hold your stylesheets'
37
-
38
36
  c.action do |args, options|
39
- stylesheets_dir = options.stylesheets_dir || "stylesheets"
40
- # working_path = Dir.pwd
41
-
42
37
  input_path = args[0] || "stylesheets/sass"
43
- # input_path = File.expand_path File.join(working_path, input_path)
44
- output_path = args[1] || "../stylesheets"
45
- # output_path = File.expand_path File.join(working_path, output_path)
38
+ output_path = args[1] || "stylesheets"
46
39
 
47
- Gridpaper::Watch.new(input_path, output_path)
40
+ # Pass to sass --watch
41
+ # TODO:
42
+ # - Hook into this and load custom SASS functions
43
+ system("sass --watch #{ input_path }:#{ output_path }")
48
44
  end
49
45
 
50
46
  end
51
47
 
52
- def check_input_path(working_path)
53
- unless File.exists?(File.join(working_path, 'sass')) || File.exists?(File.join(working_path, 'scss'))
54
- puts "Could not find a directory named './#{ stylesheets_dir }/sass' or './#{ stylesheets_dir }/scss'. Aborting.".red
55
- return false
56
- end
57
- end
58
-
59
48
  alias_command :g, :generate
60
49
  alias_command :new, :generate
61
50
  alias_command :setup, :generate
@@ -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 }")
@@ -0,0 +1,27 @@
1
+ form
2
+
3
+ .field
4
+ margin-bottom: 1em
5
+
6
+ legend
7
+ display: block
8
+ margin-bottom: 1em
9
+
10
+ label
11
+ display: block
12
+
13
+ input[type="text"], input[type="email"], input[type="url"], input[type="search"], textarea
14
+ padding: 0.25em 0.5em
15
+ font:
16
+ size: 1em
17
+ family: sans-serif
18
+ border: 1px solid #7E7E7E
19
+
20
+ input[type="submit"]
21
+ padding: 0.5em 1em
22
+ border: 1px solid #7E7E7E
23
+ @include border-radius(5px)
24
+ cursor: pointer
25
+
26
+
27
+
@@ -0,0 +1,59 @@
1
+ /*
2
+ Default Gridpaper 24 Column Grid
3
+ Column Width: 24px
4
+ Gutter Width: 16px
5
+ Total Width: 976px
6
+
7
+ $grid-columns: 24 !default
8
+ $grid-column-width: 24px !default
9
+ $grid-gutter-width: 16px !default
10
+
11
+ @mixin container
12
+ width: ($grid-columns * $grid-column-width) + (($grid-columns - 1) * $grid-gutter-width)
13
+ padding:
14
+ left: $grid-gutter-width
15
+ right: $grid-gutter-width
16
+ margin:
17
+ left: auto
18
+ right: auto
19
+
20
+ @mixin column
21
+ display: block
22
+ float: left
23
+ &:last-child
24
+ margin-right: 0
25
+
26
+ @mixin span($n: $grid-columns, $adj: 0)
27
+ width: ($grid-column-width * $n) + ($grid-gutter-width * ($n - 1)) + $adj
28
+ margin-right: $grid-gutter-width
29
+
30
+ @mixin padding($left: inherit, $right: inherit)
31
+ @if $left != inherit
32
+ padding-left: ($grid-column-width * $left) + ($grid-gutter-width * $left)
33
+ @if $right != inherit
34
+ padding-right: ($grid-column-width * $right) + ($grid-gutter-width * $right)
35
+
36
+ @mixin margin($left: inherit, $right: inherit)
37
+ @if $left != inherit
38
+ margin-left: ($grid-column-width * $left) + ($grid-gutter-width * ($left - 1))
39
+ @if $right != inherit
40
+ margin-right: ($grid-column-width * $right) + ($grid-gutter-width * ($right - 1))
41
+
42
+ @mixin last
43
+ margin-right: 0
44
+ clear: right
45
+
46
+ @mixin text-columns($n, $gutter: $grid-gutter-width)
47
+ -webkit-column-count: $n
48
+ -moz-column-count: $n
49
+ column-count: $n
50
+ -webkit-column-gap: $gutter
51
+ -moz-column-gap: $gutter
52
+ column-gap: $gutter
53
+
54
+
55
+ @mixin showgrid
56
+ background: url(../images/grid.png)
57
+ border:
58
+ top: 1px solid fade-out(#dd7d96, 0.7)
59
+ right: 1px solid fade-out(#7dcadd, 0.3)
@@ -0,0 +1,102 @@
1
+ /*
2
+ html5doctor.com Reset Stylesheet
3
+ v1.6.1
4
+ Last Updated: 2010-09-17
5
+ Author: Richard Clark - http: //richclarkdesign.com
6
+ Twitter: @rich_clark
7
+
8
+ $base-font-size: 16px !default
9
+
10
+ html, body, div, span, object, iframe, h1, h2, h3, h4, h5, h6, p, a, blockquote, pre, abbr, address, cite, code, del, dfn, em, img, ins, kbd, q, samp, small, strong, sub, sup, var, b, i, dl, dt, dd, ol, ul, li, fieldset, form, label, legend, table, caption, tbody, tfoot, thead, tr, th, td, article, aside, canvas, details, figcaption, figure, footer, header, hgroup, menu, nav, section, summary, time, mark, audio, video
11
+ margin: 0
12
+ padding: 0
13
+ border: 0
14
+ outline: 0
15
+ font:
16
+ size: 100%
17
+ weight: normal
18
+ style: normal
19
+ family: sans-serif
20
+ vertical-align: baseline
21
+ background: transparent
22
+ line-height: 1
23
+
24
+ body
25
+ font-size: $base-font-size
26
+
27
+ article, aside, details, figcaption, figure, footer, header, hgroup, menu, nav, section
28
+ display: block
29
+
30
+ h1, h2, h3, h4, h5, h6, strong, b
31
+ font-weight: bold
32
+
33
+ em, i
34
+ font-style: italic
35
+
36
+ nav ul
37
+ list-style: none
38
+
39
+ blockquote, q
40
+ quotes: none
41
+
42
+ blockquote:before, blockquote:after, q:before, q:after
43
+ content: ''
44
+ content: none
45
+
46
+ ins
47
+ text-decoration: none
48
+
49
+ mark
50
+ font-style: italic
51
+ font-weight: bold
52
+
53
+ del
54
+ text-decoration: line-through
55
+
56
+ abbr[title], dfn[title]
57
+ border-bottom: 1px dotted
58
+ cursor: help
59
+
60
+ table
61
+ border-collapse: collapse
62
+ border-spacing: 0
63
+
64
+ hr
65
+ display: block
66
+ height: 0px
67
+ border: 0
68
+ border-top: 1px solid #cccccc
69
+ margin: 0
70
+ padding: 0
71
+
72
+ input, select
73
+ vertical-align: middle
74
+
75
+ textarea
76
+ margin: 0
77
+
78
+ h1
79
+ font-size: 5em
80
+ h2
81
+ font-size: 4em
82
+ h3
83
+ font-size: 3em
84
+ h4
85
+ font-size: 2em
86
+ h5
87
+ font-size: 1.5em
88
+ h6
89
+ font-size: 1em
90
+
91
+ @mixin clearfix
92
+ display: block
93
+ &:after
94
+ display: block
95
+ overflow: hidden
96
+ visibility: hidden
97
+ clear: both
98
+ height: 0
99
+ content: "\0020"
100
+
101
+ .clear
102
+ @include clearfix
@@ -0,0 +1,6 @@
1
+ @mixin sprite($url, $height: 100, $width: 100, $x: 0, $y: 0)
2
+ display: block
3
+ height: $height
4
+ width: $width
5
+ background: url($url)
6
+ background-position: ($x * $width) ($y * $height)
@@ -1,38 +1,2 @@
1
1
  @import settings
2
- @import ../../../templates/sass/gridpaper/all
3
-
4
- @import columns
5
-
6
- body
7
- @include container
8
- color: #333
9
-
10
- p
11
- line-height: 1.5em
12
- margin-bottom: 1.5em
13
- &:last-child
14
- margin-bottom: 0
15
-
16
- section, header, footer
17
- overflow: hidden
18
- margin-bottom: 1.5em
19
- padding-bottom: 1.5em
20
-
21
- .box
22
- @include column
23
- @include span(4)
24
-
25
- .fake-button
26
- @include border-radius(0px 30px, true)
27
- @include box-shadow(4px 4px 4px rgba(0,0,0,0.2))
28
- @include box-gradient(#eee, #aaa)
29
-
30
- section h4:first-child
31
- margin-bottom: 0.5em
32
- padding: 0.25em 0.5em
33
- color: #fff
34
- background: #333
35
-
36
- .something
37
- display: block
38
- position: relative
2
+ @import gridpaper/all
@@ -20,7 +20,7 @@ Gem::Specification.new do |s|
20
20
 
21
21
  s.add_dependency("commander", '>= 4.0.4')
22
22
  s.add_dependency("sass", '>=3.1.7')
23
- s.add_dependency("guard", '>=0.8.8')
24
- s.add_dependency("guard-sass", '>=0.5.4')
25
23
  s.add_dependency("colorize", '>= 0.5.8')
24
+
25
+ s.add_development_dependency("guard", '>=0.8.8')
26
26
  end
@@ -2,29 +2,24 @@ require 'rubygems'
2
2
  require 'gridpaper/version'
3
3
  require 'commander/import'
4
4
  require 'fileutils'
5
- require 'yaml'
6
5
  require 'colorize'
7
- require 'guard'
8
- # require 'guard-sass'
9
6
 
10
7
  module Gridpaper
11
8
  class Generate
12
9
 
13
10
  # Add Gridpaper to your project
14
11
  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
-
12
+ copy_files_to(
13
+ File.join(path, stylesheets_dir),
14
+ syntax.to_s
15
+ )
21
16
  end
22
17
 
23
18
  private
24
19
 
25
20
  def copy_files_to(destination, syntax)
26
21
  template_dir = File.expand_path(File.join(File.dirname(__FILE__), '../', 'templates', syntax.to_s))
27
- template_dir_dest = File.join(destination, syntax)
22
+ template_dir_dest = File.join(destination, 'sass')
28
23
  project_dir = Dir.pwd
29
24
 
30
25
  if File.exists?(template_dir_dest)
@@ -38,7 +33,7 @@ module Gridpaper
38
33
  # templates directory for the specified syntax
39
34
  Dir.chdir(File.expand_path(template_dir))
40
35
  files = Dir['**/*']
41
- puts files
36
+
42
37
  Dir.chdir(project_dir)
43
38
 
44
39
  files.each do |file|
@@ -63,33 +58,4 @@ module Gridpaper
63
58
  end
64
59
  end
65
60
 
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
61
  end
@@ -1,3 +1,3 @@
1
1
  module Gridpaper
2
- VERSION = "0.0.5"
2
+ VERSION = "0.0.6"
3
3
  end
@@ -0,0 +1,6 @@
1
+ @mixin sprite($url, $height: 100, $width: 100, $x: 0, $y: 0) {
2
+ display: block;
3
+ height: $height;
4
+ width: $width;
5
+ background: url($url);
6
+ background-position: $x * $width $y * $height; }
@@ -0,0 +1,45 @@
1
+ .column {
2
+ height: 100px;
3
+ margin-bottom: 16px;
4
+ background-color: $light-grey;
5
+ border: 1px solid $medium-grey; }
6
+
7
+ #columns-1 {
8
+ .column {
9
+ @include column;
10
+ @include span(24, -2px); } }
11
+
12
+ #columns-2 {
13
+ .column {
14
+ @include column;
15
+ @include span(12, -2px); } }
16
+
17
+ #columns-3 {
18
+ .column {
19
+ @include column;
20
+ @include span(8, -2px); } }
21
+
22
+ #columns-4 {
23
+ .column {
24
+ @include column;
25
+ @include span(6, -2px); } }
26
+
27
+ #columns-6 {
28
+ .column {
29
+ @include column;
30
+ @include span(4, -2px); } }
31
+
32
+ #columns-8 {
33
+ .column {
34
+ @include column;
35
+ @include span(3, -2px); } }
36
+
37
+ #columns-12 {
38
+ .column {
39
+ @include column;
40
+ @include span(2, -2px); } }
41
+
42
+ #columns-24 {
43
+ .column {
44
+ @include column;
45
+ @include span(1, -2px); } }
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gridpaper
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.5
4
+ version: 0.0.6
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -13,7 +13,7 @@ date: 2011-11-25 00:00:00.000000000Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: commander
16
- requirement: &70266714518720 !ruby/object:Gem::Requirement
16
+ requirement: &70163140373560 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
@@ -21,10 +21,10 @@ dependencies:
21
21
  version: 4.0.4
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *70266714518720
24
+ version_requirements: *70163140373560
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: sass
27
- requirement: &70266714518220 !ruby/object:Gem::Requirement
27
+ requirement: &70163140373060 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ! '>='
@@ -32,40 +32,29 @@ dependencies:
32
32
  version: 3.1.7
33
33
  type: :runtime
34
34
  prerelease: false
35
- version_requirements: *70266714518220
35
+ version_requirements: *70163140373060
36
36
  - !ruby/object:Gem::Dependency
37
- name: guard
38
- requirement: &70266714517760 !ruby/object:Gem::Requirement
39
- none: false
40
- requirements:
41
- - - ! '>='
42
- - !ruby/object:Gem::Version
43
- version: 0.8.8
44
- type: :runtime
45
- prerelease: false
46
- version_requirements: *70266714517760
47
- - !ruby/object:Gem::Dependency
48
- name: guard-sass
49
- requirement: &70266714517300 !ruby/object:Gem::Requirement
37
+ name: colorize
38
+ requirement: &70163140372540 !ruby/object:Gem::Requirement
50
39
  none: false
51
40
  requirements:
52
41
  - - ! '>='
53
42
  - !ruby/object:Gem::Version
54
- version: 0.5.4
43
+ version: 0.5.8
55
44
  type: :runtime
56
45
  prerelease: false
57
- version_requirements: *70266714517300
46
+ version_requirements: *70163140372540
58
47
  - !ruby/object:Gem::Dependency
59
- name: colorize
60
- requirement: &70266714516760 !ruby/object:Gem::Requirement
48
+ name: guard
49
+ requirement: &70163140372060 !ruby/object:Gem::Requirement
61
50
  none: false
62
51
  requirements:
63
52
  - - ! '>='
64
53
  - !ruby/object:Gem::Version
65
- version: 0.5.8
66
- type: :runtime
54
+ version: 0.8.8
55
+ type: :development
67
56
  prerelease: false
68
- version_requirements: *70266714516760
57
+ version_requirements: *70163140372060
69
58
  description: Gridpaper is a CSS framework built on top of SASS.
70
59
  email:
71
60
  - christiannaths@gmail.com
@@ -80,21 +69,19 @@ files:
80
69
  - README.rdoc
81
70
  - Rakefile
82
71
  - bin/gridpaper
83
- - examples/images/Untitled-1.png
84
72
  - examples/images/grid.png
85
73
  - examples/index.html
86
- - examples/stylesheets/sass/_columns.sass
87
74
  - examples/stylesheets/sass/_settings.sass
75
+ - examples/stylesheets/sass/gridpaper/_all.sass
76
+ - examples/stylesheets/sass/gridpaper/_effects.sass
77
+ - examples/stylesheets/sass/gridpaper/_forms.sass
78
+ - examples/stylesheets/sass/gridpaper/_grid.sass
79
+ - examples/stylesheets/sass/gridpaper/_reset.sass
80
+ - examples/stylesheets/sass/gridpaper/_utilities.sass
88
81
  - examples/stylesheets/sass/styles.sass
89
- - examples/stylesheets/scss/nested_folder/_imported_file.scss
90
- - examples/stylesheets/scss/nested_folder/generated.scss
91
- - examples/stylesheets/scss/something.scss
92
82
  - gridpaper.gemspec
93
- - lib/Guardfile
94
83
  - lib/gridpaper.rb
95
84
  - lib/gridpaper/version.rb
96
- - lib/guard/gridpaper-watch.rb
97
- - templates/examples/_columns.sass
98
85
  - templates/sass/_settings.sass
99
86
  - templates/sass/gridpaper/_all.sass
100
87
  - templates/sass/gridpaper/_effects.sass
@@ -102,6 +89,7 @@ files:
102
89
  - templates/sass/gridpaper/_grid.sass
103
90
  - templates/sass/gridpaper/_reset.sass
104
91
  - templates/sass/gridpaper/_utilities.sass
92
+ - templates/sass/gridpaper/examples/_columns.sass
105
93
  - templates/sass/styles.sass
106
94
  - templates/scss/_settings.scss
107
95
  - templates/scss/gridpaper/_all.scss
@@ -109,6 +97,8 @@ files:
109
97
  - templates/scss/gridpaper/_forms.scss
110
98
  - templates/scss/gridpaper/_grid.scss
111
99
  - templates/scss/gridpaper/_reset.scss
100
+ - templates/scss/gridpaper/_utilities.scss
101
+ - templates/scss/gridpaper/examples/_columns.scss
112
102
  - templates/scss/styles.scss
113
103
  homepage: http://christiannaths.com
114
104
  licenses: []
@@ -1,51 +0,0 @@
1
- #columns-example
2
- .row
3
- overflow: hidden
4
-
5
- .grid-column
6
- min-height: 15em
7
- margin: 0.5em 0
8
- @include showgrid
9
- background-color: #f1f1f1
10
-
11
-
12
- #two-columns
13
- div
14
- @include column
15
- @include span(12, -1px)
16
-
17
- #three-columns
18
- div
19
- @include column
20
- @include span(8, -1px)
21
-
22
- #four-columns
23
- div
24
- @include column
25
- @include span(6, -1px)
26
-
27
- #six-columns
28
- div
29
- @include column
30
- @include span(4, -1px)
31
-
32
- #eight-columns
33
- div
34
- @include column
35
- @include span(3, -1px)
36
-
37
-
38
- #text-columns-example
39
-
40
- .text-columns
41
- @include showgrid
42
- margin-bottom: 1.5em
43
-
44
- #two-text-columns
45
- @include text-columns(2)
46
-
47
- #three-text-columns
48
- @include text-columns(3)
49
-
50
- #four-text-columns
51
- @include text-columns(4)
@@ -1,3 +0,0 @@
1
- body {
2
- display: block;
3
- }
@@ -1 +0,0 @@
1
- @import "nested_folder/_imported_file";
@@ -1,147 +0,0 @@
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
@@ -1,129 +0,0 @@
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