dynsass 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +15 -0
- data/.gitignore +17 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +33 -0
- data/Rakefile +1 -0
- data/dynsass.gemspec +23 -0
- data/lib/dynsass/version.rb +3 -0
- data/lib/dynsass.rb +1 -0
- data/lib/generators/dynsass/create_stylesheet_generator.rb +13 -0
- data/lib/generators/templates/dyn_stylesheet.scss.erb +3 -0
- data/lib/generators/templates/dynamic_stylesheet.rb +58 -0
- metadata +84 -0
checksums.yaml
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
---
|
2
|
+
!binary "U0hBMQ==":
|
3
|
+
metadata.gz: !binary |-
|
4
|
+
ZTg1NGNhNGYwZmQ0NmM1MDM1OWYyYWM1ODVjYmJlZmUxMmIyYjAxMQ==
|
5
|
+
data.tar.gz: !binary |-
|
6
|
+
MGVlZWQyMmQyODc1YWY1NmUzNjgyZWM4YzdiNzE4NzllNmQyMTNmOQ==
|
7
|
+
!binary "U0hBNTEy":
|
8
|
+
metadata.gz: !binary |-
|
9
|
+
YTY3NTUxYjFiNmM3ODQ4MTkyZjY0MmQzYWNlMzNiMGZkNDE3MDYyZjJmMmM4
|
10
|
+
NTI1NjlhMzRmM2Q5Y2JjZjNiODU0NDgwMzhhZTA2OWZiMDQ0ODkyMmVjMjNl
|
11
|
+
ZjE4ZWViMTM3Y2QwYTQ1MjFmZmJlYzdjODk3MzkzMjA3ZDk1MTE=
|
12
|
+
data.tar.gz: !binary |-
|
13
|
+
Njk5OWFlOWMzOTI2NmQzZDRhODc4MGVhMWE4YmVlNTIxN2U4ODZiMmEwNTFm
|
14
|
+
ZGUxMGM5ZjhmMjZmMjRkMjljMGNkN2RhZDMyNjIwZTY2OGM2YzI4OGE5ZjUw
|
15
|
+
ZDE4ZTQ4NWE0ZGM0OTlhZDY2MmMzZjEwZWFjODk2ZDMzZGUzYWU=
|
data/.gitignore
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2013 Dmitry Trager
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,33 @@
|
|
1
|
+
# Dynsass
|
2
|
+
|
3
|
+
Generates custom Sass stylesheet that will be compiled dynamically during runtime.
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
gem 'dynsass'
|
10
|
+
|
11
|
+
And then execute:
|
12
|
+
|
13
|
+
$ bundle
|
14
|
+
|
15
|
+
Or install it yourself as:
|
16
|
+
|
17
|
+
$ gem install dynsass
|
18
|
+
|
19
|
+
## Usage
|
20
|
+
|
21
|
+
Just run generator with following command:
|
22
|
+
|
23
|
+
$ rails generate dynsass:create_stylesheet
|
24
|
+
|
25
|
+
This will copy scss.erb file into sass directory and main lib file into lib/classes.
|
26
|
+
|
27
|
+
## Contributing
|
28
|
+
|
29
|
+
1. Fork it
|
30
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
31
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
32
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
33
|
+
5. Create new Pull Request
|
data/Rakefile
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require "bundler/gem_tasks"
|
data/dynsass.gemspec
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'dynsass/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "dynsass"
|
8
|
+
spec.version = Dynsass::VERSION
|
9
|
+
spec.authors = ["Dmitry Trager"]
|
10
|
+
spec.email = ["dmitry.trager@flatstack.com"]
|
11
|
+
spec.description = %q{Generates custom Sass stylesheet that will be compiled dynamically during runtime}
|
12
|
+
spec.summary = %q{Custom Sass stylesheets generator}
|
13
|
+
spec.homepage = "https://github.com/dmitrytrager/dynsass"
|
14
|
+
spec.license = "MIT"
|
15
|
+
|
16
|
+
spec.files = `git ls-files`.split($/)
|
17
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
18
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
|
+
spec.require_paths = ["lib"]
|
20
|
+
|
21
|
+
spec.add_development_dependency "bundler", "~> 1.3"
|
22
|
+
spec.add_development_dependency "rake"
|
23
|
+
end
|
data/lib/dynsass.rb
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require "dynsass/version"
|
@@ -0,0 +1,13 @@
|
|
1
|
+
module Dynsass
|
2
|
+
module Generators
|
3
|
+
class CreateStylesheetGenerator < Rails::Generators::Base
|
4
|
+
source_root File.expand_path("../../templates", __FILE__)
|
5
|
+
|
6
|
+
def generate_dynsass
|
7
|
+
template "dyn_stylesheet.scss.erb", "app/assets/stylesheets/sass/"
|
8
|
+
template "dynamic_stylesheet.rb", "lib/classes/dynamic_stylesheet.rb"
|
9
|
+
end
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
@@ -0,0 +1,58 @@
|
|
1
|
+
class DynamicStylesheet
|
2
|
+
def initialize(options)
|
3
|
+
@options = options
|
4
|
+
end
|
5
|
+
|
6
|
+
def stylesheet_file
|
7
|
+
"#{Rails.env}_dyn_stylesheet.css"
|
8
|
+
end
|
9
|
+
|
10
|
+
def scss_file_path
|
11
|
+
Rails.root.join('app', 'assets', 'stylesheets', "#{self.stylesheet_file}.scss")
|
12
|
+
end
|
13
|
+
|
14
|
+
def erb_filename
|
15
|
+
'dyn_stylesheet.scss.erb'
|
16
|
+
end
|
17
|
+
|
18
|
+
def erb_file_path
|
19
|
+
Rails.root.join('app', 'assets', 'stylesheets', 'sass', erb_filename)
|
20
|
+
end
|
21
|
+
|
22
|
+
def render_scss
|
23
|
+
ERB.new(File.read(erb_file_path)).result(binding)
|
24
|
+
end
|
25
|
+
|
26
|
+
def compiled?
|
27
|
+
if Rails.application.config.assets.compile
|
28
|
+
File.exists?(self.scss_file_path) && !File.zero?(self.scss_file_path)
|
29
|
+
else
|
30
|
+
Rails.application.config.assets.digests[self.stylesheet_file].present?
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
def precompile
|
35
|
+
File.open(scss_file_path, 'w') { |f| f.write render_scss }
|
36
|
+
end
|
37
|
+
|
38
|
+
def compile
|
39
|
+
precompile
|
40
|
+
unless Rails.application.config.assets.compile
|
41
|
+
env = Rails.application.assets.is_a?(Sprockets::Index) ? Rails.application.assets.instance_variable_get('@environment') : Rails.application.assets
|
42
|
+
|
43
|
+
Sprockets::StaticCompiler.new(
|
44
|
+
env,
|
45
|
+
File.join(Rails.public_path, Rails.application.config.assets.prefix),
|
46
|
+
[self.stylesheet_file],
|
47
|
+
digest: true,
|
48
|
+
manifest: false
|
49
|
+
).compile
|
50
|
+
|
51
|
+
Rails.application.config.assets.digests[self.stylesheet_file] = env[self.stylesheet_file].digest_path
|
52
|
+
end
|
53
|
+
|
54
|
+
Dir[self.scss_file_path.sub(/\d+.css.scss$/, '*')].each do |file|
|
55
|
+
File.delete file unless file == self.scss_file_path.to_s
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
metadata
ADDED
@@ -0,0 +1,84 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: dynsass
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Dmitry Trager
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2013-12-29 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
requirement: !ruby/object:Gem::Requirement
|
15
|
+
requirements:
|
16
|
+
- - ~>
|
17
|
+
- !ruby/object:Gem::Version
|
18
|
+
version: '1.3'
|
19
|
+
version_requirements: !ruby/object:Gem::Requirement
|
20
|
+
requirements:
|
21
|
+
- - ~>
|
22
|
+
- !ruby/object:Gem::Version
|
23
|
+
version: '1.3'
|
24
|
+
type: :development
|
25
|
+
prerelease: false
|
26
|
+
name: bundler
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
requirement: !ruby/object:Gem::Requirement
|
29
|
+
requirements:
|
30
|
+
- - ! '>='
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: '0'
|
33
|
+
version_requirements: !ruby/object:Gem::Requirement
|
34
|
+
requirements:
|
35
|
+
- - ! '>='
|
36
|
+
- !ruby/object:Gem::Version
|
37
|
+
version: '0'
|
38
|
+
type: :development
|
39
|
+
prerelease: false
|
40
|
+
name: rake
|
41
|
+
description: Generates custom Sass stylesheet that will be compiled dynamically during
|
42
|
+
runtime
|
43
|
+
email:
|
44
|
+
- dmitry.trager@flatstack.com
|
45
|
+
executables: []
|
46
|
+
extensions: []
|
47
|
+
extra_rdoc_files: []
|
48
|
+
files:
|
49
|
+
- .gitignore
|
50
|
+
- Gemfile
|
51
|
+
- LICENSE.txt
|
52
|
+
- README.md
|
53
|
+
- Rakefile
|
54
|
+
- dynsass.gemspec
|
55
|
+
- lib/dynsass.rb
|
56
|
+
- lib/dynsass/version.rb
|
57
|
+
- lib/generators/dynsass/create_stylesheet_generator.rb
|
58
|
+
- lib/generators/templates/dyn_stylesheet.scss.erb
|
59
|
+
- lib/generators/templates/dynamic_stylesheet.rb
|
60
|
+
homepage: https://github.com/dmitrytrager/dynsass
|
61
|
+
licenses:
|
62
|
+
- MIT
|
63
|
+
metadata: {}
|
64
|
+
post_install_message:
|
65
|
+
rdoc_options: []
|
66
|
+
require_paths:
|
67
|
+
- lib
|
68
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
69
|
+
requirements:
|
70
|
+
- - ! '>='
|
71
|
+
- !ruby/object:Gem::Version
|
72
|
+
version: '0'
|
73
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
74
|
+
requirements:
|
75
|
+
- - ! '>='
|
76
|
+
- !ruby/object:Gem::Version
|
77
|
+
version: '0'
|
78
|
+
requirements: []
|
79
|
+
rubyforge_project:
|
80
|
+
rubygems_version: 2.0.5
|
81
|
+
signing_key:
|
82
|
+
specification_version: 4
|
83
|
+
summary: Custom Sass stylesheets generator
|
84
|
+
test_files: []
|