bourbon_integrator 1.0.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.
data/README.md ADDED
@@ -0,0 +1,73 @@
1
+ # BourbonIntegrator
2
+
3
+ [![Gem Version](https://badge.fury.io/rb/bourbon_integrator.svg)](http://badge.fury.io/rb/bourbon_integrator)
4
+
5
+ ## Assumptions
6
+
7
+ * joins the [bourbon][bourbon] gem and its components into project dependencies
8
+ * provides tasks for assets management
9
+ * initialize the base structure
10
+
11
+ ## Installation
12
+
13
+ Add this line to your application's Gemfile:
14
+
15
+ gem 'bourbon_integrator'
16
+
17
+ And then execute:
18
+
19
+ $ bundle
20
+
21
+ Or install it yourself as:
22
+
23
+ $ gem install bourbon_integrator
24
+
25
+ ## Configuration
26
+
27
+ Through `BourbonIntegrator::Config` class:
28
+
29
+ ```ruby
30
+ config = BourbonIntegrator::Config.new(
31
+ "project_css_dir" => "css_dir" # default: "stylesheets"
32
+ "project_images_dir" => "img_dir" # default: "images"
33
+ "project_font_dir" => "font_dir" # default: "fonts"
34
+ "project_assets_verbose" => true # default: false
35
+ "project_cdn_url" => "http://cdn.net" # default: nil
36
+ "project_assets_http_path" => "assets" # default: "/"
37
+ "project_ui_dir" => "ui_dir" # default: "."
38
+ "project_public_dir" => "pub_dir" # default: "public"
39
+ "project_sass_dir" => "sass_dir" # default: "sass"
40
+ )
41
+ ```
42
+
43
+ ## Usage
44
+
45
+ Add to project's Rakefile:
46
+ ```ruby
47
+ require 'bourbon_integrator'
48
+ BourbonIntegrator::Tasks.load(BourbonIntegrator::Config.new)
49
+ ```
50
+
51
+ and list available tasks:
52
+ ```ruby
53
+ bundle exec rake -T
54
+ # rake bi:clean # Remove compiled css
55
+ # rake bi:compile # Compile css
56
+ # rake bi:init # Initialize base structure
57
+ # rake bi:watch # Run sass watch
58
+ ```
59
+
60
+ ## Versioning
61
+
62
+ See [semver.org][semver]
63
+
64
+ ## Contributing
65
+
66
+ 1. Fork it
67
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
68
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
69
+ 4. Push to the branch (`git push origin my-new-feature`)
70
+ 5. Create new Pull Request
71
+
72
+ [semver]: http://semver.org/
73
+ [bourbon]: http://bourbon.io/
@@ -0,0 +1,3 @@
1
+ $http_stylesheets_path = {{ http_stylesheets_path }}
2
+ $http_images_path = {{ http_images_path }}
3
+ $http_fonts_path = {{ http_fonts_path }}
@@ -0,0 +1,36 @@
1
+ # encoding: utf-8
2
+
3
+ # Copyright (C) 2016 Szymon Kopciewski
4
+ #
5
+ # This file is part of BourbonIntegrator.
6
+ #
7
+ # This program is free software: you can redistribute it and/or modify
8
+ # it under the terms of the GNU General Public License as published by
9
+ # the Free Software Foundation, either version 3 of the License, or
10
+ # (at your option) any later version.
11
+ #
12
+ # This program is distributed in the hope that it will be useful,
13
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
14
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
+ # GNU General Public License for more details.
16
+ #
17
+ # You should have received a copy of the GNU General Public License
18
+ # along with this program. If not, see <http://www.gnu.org/licenses/>.
19
+
20
+ require "bourbon_integrator/command_template"
21
+
22
+ module BourbonIntegrator
23
+ module Command
24
+ class Clean < CommandTemplate
25
+ def run
26
+ stylesheets_path = File.join(
27
+ @config.fetch("project_ui_dir"),
28
+ @config.fetch("project_public_dir"),
29
+ @config.fetch("project_css_dir")
30
+ )
31
+ @output.puts "*** Remove compiled CSS ***"
32
+ @executor.system "rm -rf #{stylesheets_path}/*"
33
+ end
34
+ end
35
+ end
36
+ end
@@ -0,0 +1,33 @@
1
+ # encoding: utf-8
2
+
3
+ # Copyright (C) 2016 Szymon Kopciewski
4
+ #
5
+ # This file is part of BourbonIntegrator.
6
+ #
7
+ # This program is free software: you can redistribute it and/or modify
8
+ # it under the terms of the GNU General Public License as published by
9
+ # the Free Software Foundation, either version 3 of the License, or
10
+ # (at your option) any later version.
11
+ #
12
+ # This program is distributed in the hope that it will be useful,
13
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
14
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
+ # GNU General Public License for more details.
16
+ #
17
+ # You should have received a copy of the GNU General Public License
18
+ # along with this program. If not, see <http://www.gnu.org/licenses/>.
19
+
20
+ require "bourbon_integrator/command_template"
21
+
22
+ module BourbonIntegrator
23
+ module Command
24
+ class Compile < CommandTemplate
25
+ def run
26
+ @output.puts "*** Compile CSS ***"
27
+ @executor.system(
28
+ "sass --scss --style #{sass_style} --update #{sass_path}:#{stylesheets_path}"
29
+ )
30
+ end
31
+ end
32
+ end
33
+ end
@@ -0,0 +1,98 @@
1
+ # encoding: utf-8
2
+
3
+ # Copyright (C) 2016 Szymon Kopciewski
4
+ #
5
+ # This file is part of BourbonIntegrator.
6
+ #
7
+ # This program is free software: you can redistribute it and/or modify
8
+ # it under the terms of the GNU General Public License as published by
9
+ # the Free Software Foundation, either version 3 of the License, or
10
+ # (at your option) any later version.
11
+ #
12
+ # This program is distributed in the hope that it will be useful,
13
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
14
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
+ # GNU General Public License for more details.
16
+ #
17
+ # You should have received a copy of the GNU General Public License
18
+ # along with this program. If not, see <http://www.gnu.org/licenses/>.
19
+
20
+ require "bourbon_integrator/command_template"
21
+ require "fileutils"
22
+ require "mustache"
23
+
24
+ module BourbonIntegrator
25
+ module Command
26
+ class Init < CommandTemplate
27
+ def run
28
+ generate_bourbon_dir
29
+ generate_neat_dir
30
+ generate_bitters_dir
31
+ generate_struct_vars
32
+ end
33
+
34
+ def generate_bourbon_dir
35
+ @output.puts "*** Initialize bourbon ***"
36
+ @executor.system "bourbon install --path #{sass_path}"
37
+ end
38
+
39
+ def generate_neat_dir
40
+ @output.puts "*** Initialize neat ***"
41
+ @executor.system "cd #{sass_path} && neat install"
42
+ end
43
+
44
+ def generate_bitters_dir
45
+ @output.puts "*** Initialize bitters ***"
46
+ @executor.system "bitters install --path #{sass_path}"
47
+ end
48
+
49
+ def generate_struct_vars
50
+ return if File.exist?(vars_file_path)
51
+ @output.puts "*** Creating _struct_vars file ***"
52
+ FileUtils.mkdir_p sass_path
53
+ File.open(vars_file_path, "w") do |f|
54
+ f.write render_vars_file
55
+ end
56
+ end
57
+
58
+ private
59
+
60
+ def render_vars_file
61
+ ::Mustache.render(
62
+ IO.read(default_vars_file_path),
63
+ http_stylesheets_path: http_stylesheets_path,
64
+ http_images_path: http_images_path,
65
+ http_fonts_path: http_fonts_path
66
+ )
67
+ end
68
+
69
+ def http_stylesheets_path
70
+ File.join(
71
+ http_base_path,
72
+ @config.fetch("project_css_dir")
73
+ )
74
+ end
75
+
76
+ def http_images_path
77
+ File.join(
78
+ http_base_path,
79
+ @config.fetch("project_images_dir")
80
+ )
81
+ end
82
+
83
+ def http_fonts_path
84
+ File.join(
85
+ http_base_path,
86
+ @config.fetch("project_font_dir")
87
+ )
88
+ end
89
+
90
+ def http_base_path
91
+ File.join(
92
+ @config.fetch("project_cdn_url").to_s,
93
+ @config.fetch("project_assets_http_path")
94
+ )
95
+ end
96
+ end
97
+ end
98
+ end
@@ -0,0 +1,31 @@
1
+ # encoding: utf-8
2
+
3
+ # Copyright (C) 2016 Szymon Kopciewski
4
+ #
5
+ # This file is part of BourbonIntegrator.
6
+ #
7
+ # This program is free software: you can redistribute it and/or modify
8
+ # it under the terms of the GNU General Public License as published by
9
+ # the Free Software Foundation, either version 3 of the License, or
10
+ # (at your option) any later version.
11
+ #
12
+ # This program is distributed in the hope that it will be useful,
13
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
14
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
+ # GNU General Public License for more details.
16
+ #
17
+ # You should have received a copy of the GNU General Public License
18
+ # along with this program. If not, see <http://www.gnu.org/licenses/>.
19
+
20
+ require "bourbon_integrator/command_template"
21
+
22
+ module BourbonIntegrator
23
+ module Command
24
+ class Watch < CommandTemplate
25
+ def run
26
+ @output.puts "*** Watching for changes ***"
27
+ @executor.exec "sass --scss --style #{sass_style} --watch #{sass_path}:#{stylesheets_path}"
28
+ end
29
+ end
30
+ end
31
+ end
@@ -0,0 +1,68 @@
1
+ # encoding: utf-8
2
+
3
+ # Copyright (C) 2016 Szymon Kopciewski
4
+ #
5
+ # This file is part of BourbonIntegrator.
6
+ #
7
+ # This program is free software: you can redistribute it and/or modify
8
+ # it under the terms of the GNU General Public License as published by
9
+ # the Free Software Foundation, either version 3 of the License, or
10
+ # (at your option) any later version.
11
+ #
12
+ # This program is distributed in the hope that it will be useful,
13
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
14
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
+ # GNU General Public License for more details.
16
+ #
17
+ # You should have received a copy of the GNU General Public License
18
+ # along with this program. If not, see <http://www.gnu.org/licenses/>.
19
+
20
+ module BourbonIntegrator
21
+ class CommandTemplate
22
+ def initialize(config:, output: $stdout, executor: ::Kernel)
23
+ @config = config
24
+ @output = output
25
+ @executor = executor
26
+ end
27
+
28
+ def run
29
+ raise NotImplementedError
30
+ end
31
+
32
+ private
33
+
34
+ def sass_path
35
+ File.join(
36
+ Rake.application.original_dir,
37
+ @config.fetch("project_ui_dir"),
38
+ @config.fetch("project_sass_dir")
39
+ )
40
+ end
41
+
42
+ def sass_style
43
+ @config.fetch("project_assets_verbose") ? "nested" : "compressed"
44
+ end
45
+
46
+ def stylesheets_path
47
+ File.join(
48
+ @config.fetch("project_ui_dir"),
49
+ @config.fetch("project_public_dir"),
50
+ @config.fetch("project_css_dir")
51
+ )
52
+ end
53
+
54
+ def vars_file_path
55
+ File.join(
56
+ sass_path,
57
+ "_struct_vars.scss"
58
+ )
59
+ end
60
+
61
+ def default_vars_file_path
62
+ File.join(
63
+ Gem.datadir("bourbon_integrator"),
64
+ "struct_vars.scss.mustache"
65
+ )
66
+ end
67
+ end
68
+ end
@@ -0,0 +1,34 @@
1
+ # encoding: utf-8
2
+
3
+ # Copyright (C) 2016 Szymon Kopciewski
4
+ #
5
+ # This file is part of BourbonIntegrator.
6
+ #
7
+ # This program is free software: you can redistribute it and/or modify
8
+ # it under the terms of the GNU General Public License as published by
9
+ # the Free Software Foundation, either version 3 of the License, or
10
+ # (at your option) any later version.
11
+ #
12
+ # This program is distributed in the hope that it will be useful,
13
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
14
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
+ # GNU General Public License for more details.
16
+ #
17
+ # You should have received a copy of the GNU General Public License
18
+ # along with this program. If not, see <http://www.gnu.org/licenses/>.
19
+
20
+ require "piko_model"
21
+
22
+ module BourbonIntegrator
23
+ class Config < PikoModel::Model
24
+ field "project_css_dir", default: "stylesheets"
25
+ field "project_images_dir", default: "images"
26
+ field "project_font_dir", default: "fonts"
27
+ field "project_assets_verbose", default: false
28
+ field "project_cdn_url", default: nil
29
+ field "project_assets_http_path", default: "/"
30
+ field "project_ui_dir", default: "."
31
+ field "project_public_dir", default: "public"
32
+ field "project_sass_dir", default: "sass"
33
+ end
34
+ end
@@ -0,0 +1,42 @@
1
+ # encoding: utf-8
2
+
3
+ # Copyright (C) 2016 Szymon Kopciewski
4
+ #
5
+ # This file is part of BourbonIntegrator.
6
+ #
7
+ # This program is free software: you can redistribute it and/or modify
8
+ # it under the terms of the GNU General Public License as published by
9
+ # the Free Software Foundation, either version 3 of the License, or
10
+ # (at your option) any later version.
11
+ #
12
+ # This program is distributed in the hope that it will be useful,
13
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
14
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
+ # GNU General Public License for more details.
16
+ #
17
+ # You should have received a copy of the GNU General Public License
18
+ # along with this program. If not, see <http://www.gnu.org/licenses/>.
19
+
20
+ require "bourbon_integrator/command/clean"
21
+ require "bourbon_integrator/command/compile"
22
+ require "bourbon_integrator/command/watch"
23
+
24
+ namespace :bi do
25
+ desc "Remove compiled css"
26
+ task :clean do
27
+ BourbonIntegrator::Command::Clean.new(config: BourbonIntegrator::Tasks.config).run
28
+ end
29
+
30
+ desc "Compile css"
31
+ task compile: %w(clean) do
32
+ BourbonIntegrator::Command::Compile.new(config: BourbonIntegrator::Tasks.config).run
33
+ end
34
+
35
+ desc "Run compass watch"
36
+ task :watch do
37
+ BourbonIntegrator::Command::Watch.new(config: BourbonIntegrator::Tasks.config).run
38
+ end
39
+
40
+ task c: %w(compile)
41
+ task w: %w(watch)
42
+ end
@@ -0,0 +1,27 @@
1
+ # encoding: utf-8
2
+
3
+ # Copyright (C) 2016 Szymon Kopciewski
4
+ #
5
+ # This file is part of BourbonIntegrator.
6
+ #
7
+ # This program is free software: you can redistribute it and/or modify
8
+ # it under the terms of the GNU General Public License as published by
9
+ # the Free Software Foundation, either version 3 of the License, or
10
+ # (at your option) any later version.
11
+ #
12
+ # This program is distributed in the hope that it will be useful,
13
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
14
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
+ # GNU General Public License for more details.
16
+ #
17
+ # You should have received a copy of the GNU General Public License
18
+ # along with this program. If not, see <http://www.gnu.org/licenses/>.
19
+
20
+ require "bourbon_integrator/command/init"
21
+
22
+ namespace :bi do
23
+ desc "Initialize base structure"
24
+ task :init do
25
+ BourbonIntegrator::Command::Init.new(config: BourbonIntegrator::Tasks.config).run
26
+ end
27
+ end
@@ -0,0 +1,32 @@
1
+ # encoding: utf-8
2
+
3
+ # Copyright (C) 2016 Szymon Kopciewski
4
+ #
5
+ # This file is part of BourbonIntegrator.
6
+ #
7
+ # This program is free software: you can redistribute it and/or modify
8
+ # it under the terms of the GNU General Public License as published by
9
+ # the Free Software Foundation, either version 3 of the License, or
10
+ # (at your option) any later version.
11
+ #
12
+ # This program is distributed in the hope that it will be useful,
13
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
14
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
+ # GNU General Public License for more details.
16
+ #
17
+ # You should have received a copy of the GNU General Public License
18
+ # along with this program. If not, see <http://www.gnu.org/licenses/>.
19
+
20
+ module BourbonIntegrator
21
+ module Tasks
22
+ class << self
23
+ attr_reader :config
24
+ end
25
+
26
+ def self.load(config)
27
+ @config = config
28
+ tasks_path = File.join(File.dirname(__FILE__), "tasks")
29
+ Dir["#{tasks_path}/*.rake"].each { |ext| ::Kernel.load(ext, true) } if defined?(::Rake)
30
+ end
31
+ end
32
+ end
@@ -0,0 +1,22 @@
1
+ # encoding: utf-8
2
+
3
+ # Copyright (C) 2016 Szymon Kopciewski
4
+ #
5
+ # This file is part of BourbonIntegrator.
6
+ #
7
+ # This program is free software: you can redistribute it and/or modify
8
+ # it under the terms of the GNU General Public License as published by
9
+ # the Free Software Foundation, either version 3 of the License, or
10
+ # (at your option) any later version.
11
+ #
12
+ # This program is distributed in the hope that it will be useful,
13
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
14
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
+ # GNU General Public License for more details.
16
+ #
17
+ # You should have received a copy of the GNU General Public License
18
+ # along with this program. If not, see <http://www.gnu.org/licenses/>.
19
+
20
+ module BourbonIntegrator
21
+ VERSION = "1.0.0".freeze
22
+ end
@@ -0,0 +1,22 @@
1
+ # encoding: utf-8
2
+
3
+ # Copyright (C) 2016 Szymon Kopciewski
4
+ #
5
+ # This file is part of BourbonIntegrator.
6
+ #
7
+ # This program is free software: you can redistribute it and/or modify
8
+ # it under the terms of the GNU General Public License as published by
9
+ # the Free Software Foundation, either version 3 of the License, or
10
+ # (at your option) any later version.
11
+ #
12
+ # This program is distributed in the hope that it will be useful,
13
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
14
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
+ # GNU General Public License for more details.
16
+ #
17
+ # You should have received a copy of the GNU General Public License
18
+ # along with this program. If not, see <http://www.gnu.org/licenses/>.
19
+
20
+ require "bourbon_integrator/version"
21
+ require "bourbon_integrator/config"
22
+ require "bourbon_integrator/tasks"