toppings 0.0.1 → 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (36) hide show
  1. checksums.yaml +4 -4
  2. data/LICENSE.txt +1 -1
  3. data/README.md +83 -17
  4. data/bin/topping +4 -0
  5. data/lib/toppings/cli.rb +43 -0
  6. data/lib/toppings/config.rb +67 -0
  7. data/lib/toppings/generators/components_generator.rb +44 -0
  8. data/lib/toppings/generators/install/base_generator.rb +23 -0
  9. data/lib/toppings/generators/install/compass_config_generator.rb +18 -0
  10. data/lib/toppings/generators/install/fonts_generator.rb +10 -0
  11. data/lib/toppings/generators/install/group_generator.rb +98 -0
  12. data/lib/toppings/generators/install/helper_generator.rb +10 -0
  13. data/lib/toppings/generators/install/layouts_generator.rb +10 -0
  14. data/lib/toppings/generators/install/modules_generator.rb +10 -0
  15. data/lib/toppings/generators/install/root_file_generator.rb +36 -0
  16. data/lib/toppings/generators/install/settings_generator.rb +10 -0
  17. data/lib/toppings/generators/install/setups_generator.rb +12 -0
  18. data/lib/toppings/generators/install_generator.rb +40 -0
  19. data/lib/toppings/generators/sass_file_generator.rb +43 -0
  20. data/lib/toppings/generators.rb +11 -0
  21. data/lib/toppings/helper/base_file_helper.rb +43 -0
  22. data/lib/toppings/helper/generator_registration_helper.rb +31 -0
  23. data/lib/toppings/helper/index_file_helper.rb +27 -0
  24. data/lib/toppings/helper/path_helper.rb +23 -0
  25. data/lib/toppings/helper/sass_content_helper.rb +38 -0
  26. data/lib/toppings/helper/sass_conversion_helper.rb +81 -0
  27. data/lib/toppings/helper/sass_file_helper.rb +14 -0
  28. data/lib/toppings/helper/sass_framework_helper.rb +30 -0
  29. data/lib/toppings/helper.rb +11 -0
  30. data/lib/toppings/version.rb +2 -1
  31. data/lib/toppings.rb +19 -2
  32. data/toppings.gemspec +28 -12
  33. metadata +189 -11
  34. data/.gitignore +0 -17
  35. data/Gemfile +0 -4
  36. data/Rakefile +0 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 60729af4b717dcfe8dd0dfbdd8ac686a66966bfc
4
- data.tar.gz: 543166f88253600ca25de2e746090416b307ec80
3
+ metadata.gz: ca79397d379601222b27f744571a2522643b4fee
4
+ data.tar.gz: eea12d3fb3a7cc1d803faf222e4d35489886d84a
5
5
  SHA512:
6
- metadata.gz: 8e54d83e0567ac3a4e633dded4b976fcc1466f091188a0a394cc207b3036c28e0b2b43ec8ac09875051161b9bd9d727f8a54b12f7cb52c15a6c4655aa866d898
7
- data.tar.gz: 2702e0a41eca7cbcb0d60d9eb641be38700817d062af8745ed0d83da84c24468607fd25b88dbac05436c262836bcf1154371ce343e5777b61ff80baa32a7e54f
6
+ metadata.gz: aa27f4e6fa1799c625c85bf75946e7d6a5d065f5957029ebfcc30754c2ff1102807635895d4cbb97452c2e43f75534e841d25c3c86dac10f5474317867706817
7
+ data.tar.gz: c3f70cb264d40f3962b1dd889c1bced05258570ff506bb37e2f0ef46538ca4b4b28a4e5d97e864123ad5f04c007b9be32ce35f4234bc7838e499c961659a2d87
data/LICENSE.txt CHANGED
@@ -1,4 +1,4 @@
1
- Copyright (c) 2013 TODO: Write your name
1
+ Copyright (c) 2013 Falk Hoppe
2
2
 
3
3
  MIT License
4
4
 
data/README.md CHANGED
@@ -1,29 +1,95 @@
1
- # Toppings
1
+ [![Build Status](https://travis-ci.org/toppings/toppings.png)](https://travis-ci.org/toppings/toppings)
2
+ [![Coverage Status](https://coveralls.io/repos/toppings/toppings/badge.png)](https://coveralls.io/r/toppings/toppings)
3
+ [![Code Climate](https://codeclimate.com/github/toppings/toppings.png)](https://codeclimate.com/github/mechanoid/toppings)
4
+ [![Dependency Status](https://gemnasium.com/toppings/toppings.png)](https://gemnasium.com/mechanoid/toppings)
5
+ [![Gem Version](https://badge.fury.io/rb/toppings.png)](http://badge.fury.io/rb/toppings)
6
+
7
+ ## Welcome to Toppings
8
+
9
+ The toppings project provides a basic generator set to create and maintain a generic structure for your css based application or framework frontend. Though the structure may be not final yet, it offers a great way of staying clean in your development base and lets you concentrate on the hard and heavy styling itself.
10
+
11
+ In the last few years a lot of work was done about frontend development via css which includes precompiling frameworks like sass and less and architectural patterns like [BEM](http://bem.info/method/definitions/), [OOCSS](http://oocss.org/) and [SMACCS](http://smacss.com/) which lead to combined framework definitions like [MVCSS](http://mvcss.github.io/) and [SMURF](http://railslove.com/blog/2012/11/09/taking-sass-to-the-next-level-with-smurf-and-extend).
12
+
13
+ Aside these ideas we have developed our frontend architecture on similar principles for years now, and did not want to bother anymore about how to name folders and structures in every project again and again. Out of this we tried to combine and compress the basic ideas around the aforementioned principles to some helpful generators, that provides a more or less complete filestructure for your css and some specific generators to add new css components for your modules, settings or even your font files. Unlike the core principles like BEM, OOCSS or SMACSS this framework is based on SASS/SCSS only, because (yeah, obvious i know :)) it is all about structuring/splitting your css code to encapsulated and reusable units.
14
+
15
+ While we try to make this gem highly configurable in later versions, we want to provide strong defaults, to get your application easily up and running, without fighting with five different grid frameworks, several naming strategies or something like that. But we will try to give you the possibility to easily interchange or disable most of the things, toppings provide.
16
+
17
+ ### Installation
18
+
19
+ Installing toppings should be easy with standard gem mananig, because it does not carry any native dependencies until now :). So just try to run `gem install toppings` (with sudo, when you are not running without ruby version management) or add the gem to your Gemfile with `gem 'toppings'`.
20
+
21
+
22
+ ### Usage
23
+
24
+ The toppings gem ships with a binary called `topping` which is basically a wrapper for some) [Thor LINK IS MISSING](…)-tasks and provides a similar syntax as the rails binary does for generation tasks.
25
+ (As a little side note, keep in mind to run `rbenv rehash` when using rbenv for managing your rubies, to create a binary shim, that links properly to the installed gem.)
26
+
27
+ But beforementioned there is a command for initializing your stylesheet environment called via `topping install`. Running this command will read the current configuration (give a look to the configuration section for more information) and then create a folder and file structure like you can see below.
28
+
29
+ ```
30
+ stylesheets
31
+ ├── fonts
32
+ │   └── _index.sass
33
+ ├── helper
34
+ │   ├── _index.sass
35
+ │   └── _debug.sass
36
+ ├── layouts
37
+ │   └── _index.sass
38
+ ├── modules
39
+ │   └── _index.sass
40
+ ├── settings
41
+ │   ├── _index.sass
42
+ │   ├── _borders.sass
43
+ │   ├── _colors.sass
44
+ │   ├── _dimensions.sass
45
+ │   ├── _shadows.sass
46
+ │   └── _typography.sass
47
+ ├── setups
48
+ │   ├── _index.sass
49
+ │   ├── _modular_scale.sass
50
+ │   ├── _responsive_grid.sass
51
+ │   └── _vertical_rhythm.sass
52
+ └── toppings.sass
53
+ ```
54
+
55
+ At first you may stumble upon the sass format of the generated files, and yes we decided for the sass style of the language as a default here. Let me start with, that this setting for sure is configurable [LINK TO SASS DIALECT CONFIG HERE](…), so it is really only a default. But lets discuss our decision over SASS vs. SCSS for short. I argued myself very often against the sass style over the newer SCSS (Sassy CSS) format, because it of course looks a lot more like CSS, as it is the case with HAML and HTML. But unlike HTML which is sometimes whitespace sensitive and where it may not make sense to keep a language layer between you and the markup output, arranging CSS rules is mainly about personal preferences, and not about language style. Many best practices about arranging your css rules, like one rule per line do perfectly match the sassy syntax. And in the end you were writing really good and readable stylesheets without the necessity of writing curly brackets over and over again. Enough commercials for now so we can get an eye on the structure itself.
56
+
57
+ When we start bottom to the top, we will mention a toppings.sass file in the root of our stylesheets folder (and yes the name of the file and the folder name and path is configurable [LINKS TO CONFIGURATIONS FOR ROOT FILE NAME AND PATH](…)). This file is responsible for the load order of our application framework and it should not ship any other content to keep our environment clean and simple.
58
+ That means you will find a bunch of imports including compass, your grid framework of choice (in the moment it is susy ;)) and a relative base file for each style group we listed above. These relative stylesheets encapsulate each concern by packing up the imports of the specific group, so that we just include or exclude an import of a base file to enable or disable a stylesheet group, like settings, modules and so on. More detailed information we will provide in the sass documentation of the generated files.
59
+
60
+
61
+ ### Configuration
62
+
63
+ t.b.d
64
+
65
+
66
+
67
+
68
+
69
+
70
+
71
+
72
+
73
+
74
+
75
+
76
+
77
+
78
+
79
+
80
+
81
+
82
+
83
+
2
84
 
3
- TODO: Write a gem description
4
85
 
5
- ## Installation
6
86
 
7
- Add this line to your application's Gemfile:
8
87
 
9
- gem 'toppings'
10
88
 
11
- And then execute:
12
89
 
13
- $ bundle
14
90
 
15
- Or install it yourself as:
16
91
 
17
- $ gem install toppings
18
92
 
19
- ## Usage
20
93
 
21
- TODO: Write usage instructions here
22
94
 
23
- ## Contributing
24
95
 
25
- 1. Fork it
26
- 2. Create your feature branch (`git checkout -b my-new-feature`)
27
- 3. Commit your changes (`git commit -am 'Add some feature'`)
28
- 4. Push to the branch (`git push origin my-new-feature`)
29
- 5. Create new Pull Request
data/bin/topping ADDED
@@ -0,0 +1,4 @@
1
+ #!/usr/bin/env ruby
2
+ # encoding: utf-8
3
+ require 'toppings/cli'
4
+ Toppings::CLI.start
@@ -0,0 +1,43 @@
1
+ # encoding: utf-8
2
+ require 'toppings'
3
+
4
+ module Toppings
5
+ class CLI < Thor
6
+ VALID_GENERATORS = %w{module setting font setup layout helper}.freeze
7
+
8
+
9
+ desc 'install', 'create a basic topping styles layout'
10
+
11
+ def install
12
+ Toppings::Generators::InstallGenerator.start
13
+ end
14
+
15
+ desc 'generate GENERATOR', 'generating a toppings component like modules, settings etc.'
16
+
17
+ def generate(generator = nil, *args)
18
+ if generator
19
+ if VALID_GENERATORS.include? generator
20
+ Toppings::Generators::ComponentsGenerator.start(args.unshift(generator))
21
+ else
22
+ args_error_message('invalid')
23
+ end
24
+ else
25
+ args_error_message('no')
26
+ end
27
+ end
28
+
29
+ desc 'g GENERATOR', 'shortcut for generate'
30
+
31
+ def g(generator = nil, *args)
32
+ generate(generator, *args)
33
+ end
34
+
35
+ private
36
+
37
+ def args_error_message(error_type)
38
+ say "ERROR: generate was called with #{error_type} generator argument"
39
+ say 'USAGE: valid generators are font | module | setting | setup'
40
+ end
41
+
42
+ end
43
+ end
@@ -0,0 +1,67 @@
1
+ # encoding: utf-8
2
+ require 'active_support/core_ext/hash/deep_merge'
3
+ require 'ostruct'
4
+
5
+ module Toppings
6
+ class Config < OpenStruct
7
+
8
+ def initialize(options = {})
9
+ super()
10
+
11
+ options.each do |option, value|
12
+ send "#{option}=", value.kind_of?(Hash) ? Toppings::Config.new(value) : value
13
+ end
14
+ end
15
+
16
+ class << self
17
+ def load
18
+ @config = new(joined_config)
19
+ end
20
+
21
+ def joined_config
22
+ default_config.deep_merge(custom_config)
23
+ end
24
+
25
+ def custom_config
26
+ @customs = parsed_config(custom_config_path)
27
+ end
28
+
29
+ def default_config
30
+ @defaults = parsed_config(default_config_path)
31
+ end
32
+
33
+ def parsed_config(path)
34
+ config_file = File.read(path) if File.exists?(path)
35
+ JSON.parse(config_file || '{}')
36
+ end
37
+
38
+ def default_config_path
39
+ gem_config_path.join default_config_name
40
+ end
41
+
42
+ def custom_config_path
43
+ app_config_path.join custom_config_name
44
+ end
45
+
46
+ def default_config_name
47
+ 'default.json'
48
+ end
49
+
50
+ def custom_config_name
51
+ 'toppings.json'
52
+ end
53
+
54
+ def gem_config_path
55
+ Pathname.new(Toppings.gem_root).join('config')
56
+ end
57
+
58
+ # The app config path is based on the current directory,
59
+ # from where the toppings command is called.
60
+ #
61
+ # TODO: app_config path should be configurable by a thor param
62
+ def app_config_path
63
+ Pathname.new('.').join('config')
64
+ end
65
+ end
66
+ end
67
+ end
@@ -0,0 +1,44 @@
1
+ # encoding: utf-8
2
+ require 'thor/group'
3
+
4
+ module Toppings
5
+ module Generators
6
+ class ComponentsGenerator < Thor::Group
7
+ include Thor::Actions
8
+ include Toppings::Helper::PathHelper
9
+ include Toppings::Helper::BaseFileHelper
10
+ include Toppings::Helper::IndexFileHelper
11
+
12
+ argument :type
13
+ argument :name
14
+
15
+ def create_component_file
16
+ self.class.base_name = type.pluralize
17
+ template rescued_sass_partial(type), base_path.join(sassy_file_name(name, partial: true))
18
+ create_file index_file_path, skip: true
19
+ append_import name, index_file_path
20
+ end
21
+
22
+ private
23
+
24
+ def rescued_sass_partial(type)
25
+ File.exists?(self.class.source_root.join(erb_template(type))) ? erb_template(type) : default_template
26
+ end
27
+
28
+ def erb_template(type)
29
+ sassy_file_name(type, type: :erb, partial: true)
30
+ end
31
+
32
+ def default_template
33
+ sassy_file_name('default', type: :erb, partial: true)
34
+ end
35
+
36
+ class << self
37
+ def source_root
38
+ template_path.join('components')
39
+ end
40
+ end
41
+
42
+ end
43
+ end
44
+ end
@@ -0,0 +1,23 @@
1
+ # encoding: utf-8
2
+ require 'thor/group'
3
+
4
+ module Toppings
5
+ module Generators
6
+ module Install
7
+ class BaseGenerator < Thor::Group
8
+ include Thor::Actions
9
+ include Toppings::Helper::PathHelper
10
+ include Toppings::Helper::BaseFileHelper
11
+ include Toppings::Helper::IndexFileHelper
12
+
13
+ def notify_invoke
14
+ say "invoke Install::#{self.class.stripped_class_name}"
15
+ end
16
+
17
+ def self.source_root
18
+ template_path
19
+ end
20
+ end
21
+ end
22
+ end
23
+ end
@@ -0,0 +1,18 @@
1
+ # encoding: utf-8
2
+ module Toppings
3
+ module Generators
4
+ module Install
5
+ class CompassConfigGenerator < BaseGenerator
6
+ class << self
7
+ def source_root
8
+ template_path
9
+ end
10
+ end
11
+
12
+ def compass_config
13
+ template 'compass.rb.tt', Pathname.new('.').join('config').join('compass.rb')
14
+ end
15
+ end
16
+ end
17
+ end
18
+ end
@@ -0,0 +1,10 @@
1
+ # encoding: utf-8
2
+ module Toppings
3
+ module Generators
4
+ module Install
5
+ class FontsGenerator < GroupGenerator
6
+
7
+ end
8
+ end
9
+ end
10
+ end
@@ -0,0 +1,98 @@
1
+ # encoding: utf-8
2
+ require_relative 'base_generator'
3
+ require_relative 'root_file_generator'
4
+
5
+ module Toppings
6
+ module Generators
7
+ module Install
8
+
9
+ # the GroupGenerator class provides some default behavior for a given
10
+ # generator, that extends the GroupGenerator.
11
+ #
12
+ # For each groupfile a new group folder is created and a relative base file
13
+ # is added to it, where included templates will be registered with appropriate
14
+ # import statements.
15
+ #
16
+ # Template pathes and target pathes become available by convention over the
17
+ # given specific classes base name, where the base name is build upon the classes name
18
+ # with stripped Generator suffix.
19
+ class GroupGenerator < BaseGenerator
20
+ include Toppings::Helper::BaseFileHelper
21
+
22
+ class_attribute :templates
23
+
24
+ class << self
25
+ # provides a path build upon the base name of a class as
26
+ # source root for the thor template engine.
27
+ #
28
+ # @return [String] path to the class namespaced template folder
29
+ def source_root
30
+ template_path.join(base_name)
31
+ end
32
+
33
+ # dsl method to register certain template files, that should be
34
+ # made available for the specific generator.
35
+ #
36
+ # @param files [*String] one or more template names
37
+ # @return [Array] returns the list of registered templates
38
+ def with_templates(*files)
39
+ files.each { |file| templates << file }
40
+ end
41
+
42
+ def with_template(file, options = {})
43
+ library = options[:vendor_library]
44
+ path = options[:template_folder]
45
+ Toppings::SASS_DEPENDENCIES.add(library) if library
46
+ file = library ? "#{library}.#{file}" : file.to_s
47
+ file = Pathname.new(path).join(file) if path
48
+ templates << file
49
+ end
50
+
51
+ # registered templates for a group, that will be made available in the setup
52
+ #
53
+ # @return [Set] of registered templates
54
+ def templates
55
+ @templates ||= Set.new
56
+ end
57
+ end
58
+
59
+ # creating the relative base file for a generator group and appending it
60
+ # to the root file located in the stylesheet root.
61
+ def create_base_import_file
62
+ create_file index_file_path, skip: true
63
+ append_import relative_index_name, root_file_path
64
+ end
65
+
66
+ # building templated files based on the beforehand registered template files
67
+ def create_template_files
68
+ templates.each { |file| group_template_file(file) } if self.templates?
69
+ end
70
+
71
+ private
72
+
73
+ # copies a template file for the given generator group to the relative base file base.
74
+ #
75
+ # @param file [String] template file name
76
+ def group_template_file(file)
77
+ file, path = parse_file_name(file)
78
+ create_sass_file(file, path: path)
79
+ append_import file, index_file_path
80
+ end
81
+
82
+ def create_sass_file(file, options = {})
83
+ Toppings::Generators::SassFileGenerator.new([file],
84
+ source_root: options[:path] || self.class.source_root,
85
+ target_path: base_path).invoke_all
86
+ end
87
+
88
+
89
+ def parse_file_name(file)
90
+ file = file.to_s
91
+ path_name = Pathname.new(file)
92
+ dir_name = path_name.dirname.to_s != '.' ? path_name.dirname : nil
93
+ [path_name.basename, dir_name]
94
+ end
95
+ end
96
+ end
97
+ end
98
+ end
@@ -0,0 +1,10 @@
1
+ # encoding: utf-8
2
+ module Toppings
3
+ module Generators
4
+ module Install
5
+ class HelperGenerator < GroupGenerator
6
+ with_templates :debug
7
+ end
8
+ end
9
+ end
10
+ end
@@ -0,0 +1,10 @@
1
+ # encoding: utf-8
2
+ module Toppings
3
+ module Generators
4
+ module Install
5
+ class LayoutsGenerator < GroupGenerator
6
+ # TODO: think about adding some examples here (https://github.com/toppings/toppings/issues/43)
7
+ end
8
+ end
9
+ end
10
+ end
@@ -0,0 +1,10 @@
1
+ # encoding: utf-8
2
+ module Toppings
3
+ module Generators
4
+ module Install
5
+ class ModulesGenerator < GroupGenerator
6
+
7
+ end
8
+ end
9
+ end
10
+ end
@@ -0,0 +1,36 @@
1
+ # encoding: utf-8
2
+ module Toppings
3
+ module Generators
4
+ module Install
5
+ class RootFileGenerator < BaseGenerator
6
+ include Toppings::Helper::SassFrameworkHelper
7
+
8
+ # the only ever fully compiled file at the moment
9
+ def create_root_file
10
+ create_file(root_file_path, skip: true) do
11
+ [vendor_framework_imports, blank_line, start_application_framework].flatten.join
12
+ end
13
+ end
14
+
15
+ private
16
+
17
+ def vendor_framework_imports
18
+ imports = sass_framework_imports.map { |import| import_format(import) }
19
+ imports.unshift root_file_headline('Vendor Frameworks')
20
+ end
21
+
22
+ def start_application_framework
23
+ root_file_headline 'Application Framework'
24
+ end
25
+
26
+ def root_file_comment(message)
27
+ add_line_comment message, root_file_path
28
+ end
29
+
30
+ def root_file_headline(message)
31
+ headline_comment message, root_file_path
32
+ end
33
+ end
34
+ end
35
+ end
36
+ end
@@ -0,0 +1,10 @@
1
+ # encoding: utf-8
2
+ module Toppings
3
+ module Generators
4
+ module Install
5
+ class SettingsGenerator < GroupGenerator
6
+ with_templates :colors, :shadows, :borders, :typography, :dimensions
7
+ end
8
+ end
9
+ end
10
+ end
@@ -0,0 +1,12 @@
1
+ # encoding: utf-8
2
+ require_relative 'group_generator'
3
+
4
+ module Toppings
5
+ module Generators
6
+ module Install
7
+ class SetupsGenerator < GroupGenerator
8
+ with_templates :vertical_rhythm
9
+ end
10
+ end
11
+ end
12
+ end
@@ -0,0 +1,40 @@
1
+ # encoding: utf-8
2
+ require 'thor/group'
3
+
4
+ # require related install generator files
5
+ Dir.glob(File.join(Toppings.gem_root, '**', 'install', '*_generator.rb')).each do |generator|
6
+ require generator
7
+ end
8
+
9
+ Toppings.conf.required_vendors.each do |vendor|
10
+ require vendor
11
+ end
12
+
13
+ module Toppings
14
+ module Generators
15
+ class InstallGenerator < Thor::Group
16
+ include Thor::Actions
17
+ include Toppings::Helper::GeneratorRegistrationHelper
18
+
19
+ register Toppings::Generators::Install::FontsGenerator,
20
+ Toppings::Generators::Install::SettingsGenerator,
21
+ Toppings::Generators::Install::HelperGenerator,
22
+ Toppings::Generators::Install::SetupsGenerator,
23
+ Toppings::Generators::Install::ModulesGenerator,
24
+ Toppings::Generators::Install::LayoutsGenerator,
25
+ Toppings::Generators::Install::CompassConfigGenerator
26
+
27
+ def notify_invoke
28
+ say 'invoke InstallGenerator'
29
+ end
30
+
31
+ def create_root_file
32
+ Toppings::Generators::Install::RootFileGenerator.start
33
+ end
34
+
35
+ def run_registered_generators
36
+ registered_generators.each { |generator| generator.start }
37
+ end
38
+ end
39
+ end
40
+ end
@@ -0,0 +1,43 @@
1
+ # encoding: utf-8
2
+ require 'thor/group'
3
+ require 'toppings/helper'
4
+
5
+ module Toppings
6
+ module Generators
7
+ class SassFileGenerator < Thor::Group
8
+ include Thor::Actions
9
+ include Toppings::Helper::SassConversionHelper
10
+ include Toppings::Helper::SassFileHelper
11
+
12
+ argument :file_name
13
+ class_option :target_path
14
+ class_option :source_root
15
+ class_option :standalone
16
+
17
+ class << self
18
+ attr_accessor :source_root
19
+ end
20
+
21
+ def set_current_source_root
22
+ self.class.source_root = options[:source_root]
23
+ end
24
+
25
+ def create_file_from_template
26
+ template sassy_file_name(file_name, dialect: Toppings.conf.sass.template_dialect), file_path(file_name) do |content|
27
+ content if valid_sass?(content)
28
+ Toppings.conf.sass.dialect == 'scss' ? convert_to_scss(content) : content
29
+ end
30
+ end
31
+
32
+ private
33
+
34
+ def file_path(file_name)
35
+ base_path.join(sassy_file_name(file_name))
36
+ end
37
+
38
+ def base_path
39
+ options[:target_path]
40
+ end
41
+ end
42
+ end
43
+ end
@@ -0,0 +1,11 @@
1
+ # encoding: utf-8
2
+ module Toppings::Generators
3
+
4
+ end
5
+
6
+ # manual require statements upfront to keep them in ordered before all others
7
+ require 'toppings/generators/sass_file_generator'
8
+ require 'toppings/generators/install/base_generator'
9
+ require 'toppings/generators/install/group_generator'
10
+ require 'toppings/generators/install_generator'
11
+ require 'toppings/generators/components_generator'
@@ -0,0 +1,43 @@
1
+ # encoding: utf-8
2
+ module Toppings
3
+ module Helper
4
+ module BaseFileHelper
5
+ extend ActiveSupport::Concern
6
+
7
+ included do
8
+ include Toppings::Helper::SassContentHelper
9
+ include Toppings::Helper::SassFileHelper
10
+
11
+ self.class.send :attr_writer, :base_name
12
+ end
13
+
14
+ private
15
+
16
+
17
+ def base_path
18
+ @base_path ||= stylesheets_path.join(relative_base_path)
19
+ end
20
+
21
+ def relative_base_path
22
+ @relative_base_path ||= Pathname.new(base_name)
23
+ end
24
+
25
+ def base_name
26
+ self.class.base_name
27
+ end
28
+
29
+ module ClassMethods
30
+
31
+ def base_name
32
+ @base_name ||= stripped_class_name.gsub(/Generator$/, '').underscore
33
+ end
34
+
35
+ # As base for our naming conventions we want the class name only,
36
+ # without any module space
37
+ def stripped_class_name
38
+ name.demodulize
39
+ end
40
+ end
41
+ end
42
+ end
43
+ end
@@ -0,0 +1,31 @@
1
+ # encoding: utf-8
2
+ module Toppings
3
+ module Helper
4
+ module GeneratorRegistrationHelper
5
+ extend ActiveSupport::Concern
6
+
7
+ included do
8
+ class_attribute :_generators
9
+ end
10
+
11
+ def registered_generators
12
+ self.class.generators
13
+ end
14
+
15
+ private :registered_generators
16
+
17
+ module ClassMethods
18
+
19
+ def generators
20
+ self._generators ||= []
21
+ end
22
+
23
+ def register(*new_generators)
24
+ generators.concat new_generators
25
+ end
26
+
27
+ end
28
+
29
+ end
30
+ end
31
+ end
@@ -0,0 +1,27 @@
1
+ # encoding: utf-8
2
+ module Toppings
3
+ module Helper
4
+ module IndexFileHelper
5
+ extend ActiveSupport::Concern
6
+
7
+ included do
8
+ include Toppings::Helper::BaseFileHelper
9
+ end
10
+
11
+ private
12
+
13
+ def index_file_path
14
+ base_path.join(index_file_name)
15
+ end
16
+
17
+ def relative_index_name
18
+ relative_base_path.join(Toppings.conf.stylesheets.relative_index_file)
19
+ end
20
+
21
+ def index_file_name
22
+ sassy_file_name Toppings.conf.stylesheets.relative_index_file
23
+ end
24
+
25
+ end
26
+ end
27
+ end
@@ -0,0 +1,23 @@
1
+ # encoding: utf-8
2
+ module Toppings
3
+ module Helper
4
+ module PathHelper
5
+ extend ActiveSupport::Concern
6
+
7
+ def stylesheets_path
8
+ @stylesheets_path ||= Pathname('.').join(Toppings.conf.stylesheets.root_folder)
9
+ end
10
+
11
+ def root_file_path
12
+ stylesheets_path.join(sassy_file_name(Toppings.conf.stylesheets.root_file, standalone: true))
13
+ end
14
+
15
+ module ClassMethods
16
+ def template_path
17
+ @template_path ||= Pathname(Toppings.gem_root).join('lib', 'toppings', 'templates')
18
+ end
19
+ end
20
+
21
+ end
22
+ end
23
+ end
@@ -0,0 +1,38 @@
1
+ # encoding: utf-8
2
+ module Toppings
3
+ module Helper
4
+ module SassContentHelper
5
+ extend ActiveSupport::Concern
6
+
7
+ private
8
+
9
+ def add_line_comment(message, file)
10
+ append_to_file file, "// #{message}"
11
+ end
12
+
13
+ def headline_comment(message, file)
14
+ <<-EOM
15
+ #{devider(file)}
16
+ // #{message}
17
+ #{devider(file)}
18
+ EOM
19
+ end
20
+
21
+ def devider(file)
22
+ '// ---------------------------------------------------------------------------'
23
+ end
24
+
25
+ def blank_line
26
+ "\n"
27
+ end
28
+
29
+ def append_import(import_file, target_file, options = {})
30
+ append_to_file target_file, import_format(import_file)
31
+ end
32
+
33
+ def import_format(import_file)
34
+ "@import \"#{import_file}\"\n"
35
+ end
36
+ end
37
+ end
38
+ end
@@ -0,0 +1,81 @@
1
+ # encoding: utf-8
2
+ require 'tempfile'
3
+ require 'sass'
4
+ require 'sass/exec'
5
+ require 'sass/util'
6
+ require 'compass'
7
+ require 'digest'
8
+
9
+ module Toppings::Helper::SassConversionHelper
10
+ extend ActiveSupport::Concern
11
+
12
+ included do
13
+ attr_accessor :source_file, :target_file
14
+ end
15
+
16
+ def convert_to_scss(content)
17
+ init_tempfiles_for_conversion(content)
18
+
19
+ # convert source content to the target format, placed in the target file
20
+ # TODO: make conversion more dynamic, by allowing conversion from scss to sass too.
21
+ ::Sass::Util.silence_sass_warnings do
22
+ Sass::Exec::SassConvert.new(['-F', 'sass', '-T', 'scss', source_file, target_file]).parse
23
+ end
24
+
25
+ converted_content
26
+ ensure
27
+ [source_file, target_file].each(&:close)
28
+ [source_file, target_file].each(&:unlink)
29
+ end
30
+
31
+ def valid_sass?(content, file_path = nil)
32
+ load_dependencies(file_path)
33
+
34
+ ::Sass::Util.silence_sass_warnings do
35
+ begin
36
+ Sass::Engine.new(content, sass_engine_options.merge(check_syntax: true)).render
37
+ rescue ::Sass::SyntaxError => e
38
+ say e.message
39
+ false
40
+ end
41
+ end
42
+ end
43
+
44
+ def load_dependencies(file_path = nil)
45
+ Toppings::SASS_DEPENDENCIES.each { |dep| require dep.to_s }
46
+ load_compass_paths
47
+ load_paths << file_path if file_path
48
+ end
49
+
50
+ def load_compass_paths
51
+ load_paths.merge Compass.configuration.sass_load_paths
52
+ end
53
+
54
+ def load_paths
55
+ sass_engine_options[:load_paths] ||= Set.new
56
+ end
57
+
58
+ def sass_engine_options
59
+ @sass_engine_options ||= {}
60
+ end
61
+
62
+ private
63
+
64
+ def init_tempfiles_for_conversion(content)
65
+ file_name = Digest::MD5.new.update(content)
66
+ @source_file = Tempfile.new("#{file_name}_source")
67
+ @target_file = Tempfile.new("#{file_name}_target")
68
+
69
+ write_source(content)
70
+ end
71
+
72
+ def write_source(content)
73
+ source_file.write(content)
74
+ source_file.rewind
75
+ end
76
+
77
+ def converted_content
78
+ target_file.rewind
79
+ target_file.read
80
+ end
81
+ end
@@ -0,0 +1,14 @@
1
+ # encoding: utf-8
2
+ module Toppings::Helper::SassFileHelper
3
+ def sassy_file_name(file, options = {})
4
+ sass_file = []
5
+
6
+ sass_file.tap do |f|
7
+ f << (options[:standalone] ? file : "_#{file}")
8
+ f << (options[:dialect] || Toppings.conf.sass.dialect)
9
+ f << 'erb' if options[:type] == :erb
10
+ end
11
+
12
+ sass_file.join('.')
13
+ end
14
+ end
@@ -0,0 +1,30 @@
1
+ # encoding: utf-8
2
+ module Toppings
3
+ module Helper
4
+ module SassFrameworkHelper
5
+ extend ActiveSupport::Concern
6
+
7
+ included do
8
+ include Toppings::Helper::SassContentHelper
9
+ end
10
+
11
+ private
12
+
13
+ def sass_framework_imports
14
+ [core_framework, css3_framework, reset_framework]
15
+ end
16
+
17
+ def core_framework
18
+ Toppings.conf.sass.framework.core
19
+ end
20
+
21
+ def css3_framework
22
+ Toppings.conf.sass.framework.css3
23
+ end
24
+
25
+ def reset_framework
26
+ Toppings.conf.sass.framework.reset
27
+ end
28
+ end
29
+ end
30
+ end
@@ -0,0 +1,11 @@
1
+ # encoding: utf-8
2
+ module Toppings::Helper
3
+
4
+ end
5
+
6
+ # require other setup generator files
7
+ Dir.glob(File.join(Toppings.gem_root, '**', 'helper', '*_helper.rb')).each do |helper|
8
+ require helper
9
+ end
10
+
11
+
@@ -1,3 +1,4 @@
1
+ # encoding: utf-8
1
2
  module Toppings
2
- VERSION = "0.0.1"
3
+ VERSION = '0.0.3'
3
4
  end
data/lib/toppings.rb CHANGED
@@ -1,5 +1,22 @@
1
- require "toppings/version"
1
+ # encoding: utf-8
2
+ require 'set'
3
+ require 'active_support/all'
4
+ require 'compass'
5
+ require 'thor'
2
6
 
3
7
  module Toppings
4
- # Your code goes here...
8
+ SASS_DEPENDENCIES ||= Set.new
9
+
10
+ def self.gem_root
11
+ @gem_root ||= File.expand_path('../..', __FILE__)
12
+ end
13
+
14
+ def self.conf
15
+ @conf ||= Toppings::Config.load
16
+ end
5
17
  end
18
+
19
+ require 'toppings/version'
20
+ require 'toppings/config'
21
+ require 'toppings/helper'
22
+ require 'toppings/generators'
data/toppings.gemspec CHANGED
@@ -4,20 +4,36 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
4
  require 'toppings/version'
5
5
 
6
6
  Gem::Specification.new do |spec|
7
- spec.name = "toppings"
8
- spec.version = Toppings::VERSION
9
- spec.authors = ["Falk Hoppe, Roman Stranghöner"]
10
- spec.email = ["falkhoppe81@gmail.com"]
11
- spec.description = %q{css frontend framework based on sass/scss}
12
- spec.summary = %q{css frontend framework based on sass/scss}
13
- # spec.homepage = ""
14
- spec.license = "MIT"
7
+ spec.name = "toppings"
8
+ spec.version = Toppings::VERSION
9
+ spec.authors = ["Falk Hoppe, Roman Stranghöner"]
10
+ spec.email = ["falkhoppe81@gmail.com"]
11
+ spec.description = %q{css frontend framework based on sass/scss}
12
+ spec.summary = %q{css frontend framework based on sass/scss}
13
+ spec.homepage = "http://toppings.github.io/toppings/"
14
+ spec.license = "MIT"
15
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"]
16
+ spec.files = %w(LICENSE.txt README.md toppings.gemspec)
17
+ spec.files += Dir.glob("bin/**/*")
18
+ spec.files += Dir.glob("lib/**/*.rb")
19
+
20
+ spec.executables = %w{topping}
21
+ spec.test_files = spec.files.grep(%r{^(spec|features)/})
22
+ spec.require_paths = ["lib"]
23
+ spec.required_rubygems_version = '>= 1.3.6'
20
24
 
21
25
  spec.add_development_dependency "bundler", "~> 1.3"
22
26
  spec.add_development_dependency "rake"
27
+ spec.add_development_dependency "rake-notes"
28
+ spec.add_development_dependency "autotest"
29
+ spec.add_development_dependency "rubocop"
30
+ spec.add_development_dependency "code_statistics"
31
+
32
+ spec.add_dependency "thor", ">= 0.18.1"
33
+ spec.add_dependency "activesupport", ">= 3.2"
34
+ spec.add_dependency "compass", ">= 0.12.2"
35
+ spec.add_dependency "modular-scale"
36
+ spec.add_dependency "toppings-normalize", "~> 0.0.3"
37
+ spec.add_dependency "toppings-singularity"
38
+ spec.add_dependency "toppings-modular_scale"
23
39
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: toppings
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Falk Hoppe, Roman Stranghöner
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-05-08 00:00:00.000000000 Z
11
+ date: 2013-08-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -38,22 +38,200 @@ dependencies:
38
38
  - - '>='
39
39
  - !ruby/object:Gem::Version
40
40
  version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rake-notes
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - '>='
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - '>='
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: autotest
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - '>='
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - '>='
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: rubocop
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
+ - !ruby/object:Gem::Dependency
84
+ name: code_statistics
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - '>='
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - '>='
95
+ - !ruby/object:Gem::Version
96
+ version: '0'
97
+ - !ruby/object:Gem::Dependency
98
+ name: thor
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - '>='
102
+ - !ruby/object:Gem::Version
103
+ version: 0.18.1
104
+ type: :runtime
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - '>='
109
+ - !ruby/object:Gem::Version
110
+ version: 0.18.1
111
+ - !ruby/object:Gem::Dependency
112
+ name: activesupport
113
+ requirement: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - '>='
116
+ - !ruby/object:Gem::Version
117
+ version: '3.2'
118
+ type: :runtime
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - '>='
123
+ - !ruby/object:Gem::Version
124
+ version: '3.2'
125
+ - !ruby/object:Gem::Dependency
126
+ name: compass
127
+ requirement: !ruby/object:Gem::Requirement
128
+ requirements:
129
+ - - '>='
130
+ - !ruby/object:Gem::Version
131
+ version: 0.12.2
132
+ type: :runtime
133
+ prerelease: false
134
+ version_requirements: !ruby/object:Gem::Requirement
135
+ requirements:
136
+ - - '>='
137
+ - !ruby/object:Gem::Version
138
+ version: 0.12.2
139
+ - !ruby/object:Gem::Dependency
140
+ name: modular-scale
141
+ requirement: !ruby/object:Gem::Requirement
142
+ requirements:
143
+ - - '>='
144
+ - !ruby/object:Gem::Version
145
+ version: '0'
146
+ type: :runtime
147
+ prerelease: false
148
+ version_requirements: !ruby/object:Gem::Requirement
149
+ requirements:
150
+ - - '>='
151
+ - !ruby/object:Gem::Version
152
+ version: '0'
153
+ - !ruby/object:Gem::Dependency
154
+ name: toppings-normalize
155
+ requirement: !ruby/object:Gem::Requirement
156
+ requirements:
157
+ - - ~>
158
+ - !ruby/object:Gem::Version
159
+ version: 0.0.3
160
+ type: :runtime
161
+ prerelease: false
162
+ version_requirements: !ruby/object:Gem::Requirement
163
+ requirements:
164
+ - - ~>
165
+ - !ruby/object:Gem::Version
166
+ version: 0.0.3
167
+ - !ruby/object:Gem::Dependency
168
+ name: toppings-singularity
169
+ requirement: !ruby/object:Gem::Requirement
170
+ requirements:
171
+ - - '>='
172
+ - !ruby/object:Gem::Version
173
+ version: '0'
174
+ type: :runtime
175
+ prerelease: false
176
+ version_requirements: !ruby/object:Gem::Requirement
177
+ requirements:
178
+ - - '>='
179
+ - !ruby/object:Gem::Version
180
+ version: '0'
181
+ - !ruby/object:Gem::Dependency
182
+ name: toppings-modular_scale
183
+ requirement: !ruby/object:Gem::Requirement
184
+ requirements:
185
+ - - '>='
186
+ - !ruby/object:Gem::Version
187
+ version: '0'
188
+ type: :runtime
189
+ prerelease: false
190
+ version_requirements: !ruby/object:Gem::Requirement
191
+ requirements:
192
+ - - '>='
193
+ - !ruby/object:Gem::Version
194
+ version: '0'
41
195
  description: css frontend framework based on sass/scss
42
196
  email:
43
197
  - falkhoppe81@gmail.com
44
- executables: []
198
+ executables:
199
+ - topping
45
200
  extensions: []
46
201
  extra_rdoc_files: []
47
202
  files:
48
- - .gitignore
49
- - Gemfile
50
203
  - LICENSE.txt
51
204
  - README.md
52
- - Rakefile
53
- - lib/toppings.rb
54
- - lib/toppings/version.rb
55
205
  - toppings.gemspec
56
- homepage:
206
+ - bin/topping
207
+ - lib/toppings/cli.rb
208
+ - lib/toppings/config.rb
209
+ - lib/toppings/generators/components_generator.rb
210
+ - lib/toppings/generators/install/base_generator.rb
211
+ - lib/toppings/generators/install/compass_config_generator.rb
212
+ - lib/toppings/generators/install/fonts_generator.rb
213
+ - lib/toppings/generators/install/group_generator.rb
214
+ - lib/toppings/generators/install/helper_generator.rb
215
+ - lib/toppings/generators/install/layouts_generator.rb
216
+ - lib/toppings/generators/install/modules_generator.rb
217
+ - lib/toppings/generators/install/root_file_generator.rb
218
+ - lib/toppings/generators/install/settings_generator.rb
219
+ - lib/toppings/generators/install/setups_generator.rb
220
+ - lib/toppings/generators/install_generator.rb
221
+ - lib/toppings/generators/sass_file_generator.rb
222
+ - lib/toppings/generators.rb
223
+ - lib/toppings/helper/base_file_helper.rb
224
+ - lib/toppings/helper/generator_registration_helper.rb
225
+ - lib/toppings/helper/index_file_helper.rb
226
+ - lib/toppings/helper/path_helper.rb
227
+ - lib/toppings/helper/sass_content_helper.rb
228
+ - lib/toppings/helper/sass_conversion_helper.rb
229
+ - lib/toppings/helper/sass_file_helper.rb
230
+ - lib/toppings/helper/sass_framework_helper.rb
231
+ - lib/toppings/helper.rb
232
+ - lib/toppings/version.rb
233
+ - lib/toppings.rb
234
+ homepage: http://toppings.github.io/toppings/
57
235
  licenses:
58
236
  - MIT
59
237
  metadata: {}
@@ -70,10 +248,10 @@ required_rubygems_version: !ruby/object:Gem::Requirement
70
248
  requirements:
71
249
  - - '>='
72
250
  - !ruby/object:Gem::Version
73
- version: '0'
251
+ version: 1.3.6
74
252
  requirements: []
75
253
  rubyforge_project:
76
- rubygems_version: 2.0.0
254
+ rubygems_version: 2.0.6
77
255
  signing_key:
78
256
  specification_version: 4
79
257
  summary: css frontend framework based on sass/scss
data/.gitignore DELETED
@@ -1,17 +0,0 @@
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 DELETED
@@ -1,4 +0,0 @@
1
- source 'https://rubygems.org'
2
-
3
- # Specify your gem's dependencies in toppings.gemspec
4
- gemspec
data/Rakefile DELETED
@@ -1 +0,0 @@
1
- require "bundler/gem_tasks"