dassets-lessv1 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
data/.gitignore ADDED
@@ -0,0 +1,19 @@
1
+ *.gem
2
+ *.log
3
+ *.rbc
4
+ .rbx/
5
+ .bundle
6
+ .config
7
+ .yardoc
8
+ Gemfile.lock
9
+ InstalledFiles
10
+ _yardoc
11
+ coverage
12
+ doc/
13
+ lib/bundler/man
14
+ pkg
15
+ rdoc
16
+ spec/reports
17
+ test/tmp
18
+ test/version_tmp
19
+ tmp
data/Gemfile ADDED
@@ -0,0 +1,6 @@
1
+ source "https://rubygems.org"
2
+
3
+ gemspec
4
+
5
+ gem 'rake'
6
+ gem 'pry'
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2013-Present Kelly Redding and Collin Redding
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,50 @@
1
+ # Dassets::Lessv1
2
+
3
+ Dassets [engine](https://github.com/redding/dassets#compiling) for compiling [LESS CSS](http://lesscss.org/) using the [1.x.x ruby compiler](https://github.com/cloudhead/less/tree/v1.2.21).
4
+
5
+ ## Usage
6
+
7
+ Register the engine:
8
+
9
+ ```ruby
10
+ # in config/assets.rb
11
+ require 'dassets'
12
+ require 'dassets-lessv1'
13
+
14
+ Dassets.configure do |c|
15
+ c.root_path '/some/root/path'
16
+
17
+ # register the Lessv1 engine to your source extension
18
+ c.engine 'less', Dassets::Lessv1::Engine
19
+ end
20
+ ```
21
+
22
+ Put your `.less` source files in your source path and digest them. Lessv1 will compile their content using the 1.x.x LESS ruby compiler, switch their extension to `.css`, and write the output to the output path.
23
+
24
+ ## Why LESS 1.x.x?
25
+
26
+ Less v1 worked great back in the day and still works great today. This is for those who need to use the older version or don't want the latest js-based implementation (and its dependencies) and don't mind running the older version.
27
+
28
+ Want to use LESS v2? Write an engine for it and it'll get mentioned it here.
29
+
30
+ ## Installation
31
+
32
+ Add this line to your application's Gemfile:
33
+
34
+ gem 'dassets-lessv1'
35
+
36
+ And then execute:
37
+
38
+ $ bundle
39
+
40
+ Or install it yourself as:
41
+
42
+ $ gem install dassets-lessv1
43
+
44
+ ## Contributing
45
+
46
+ 1. Fork it
47
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
48
+ 3. Commit your changes (`git commit -am 'Added some feature'`)
49
+ 4. Push to the branch (`git push origin my-new-feature`)
50
+ 5. Create new Pull Request
data/Rakefile ADDED
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
@@ -0,0 +1,27 @@
1
+ # -*- encoding: utf-8 -*-
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require "dassets-lessv1/version"
5
+
6
+ Gem::Specification.new do |gem|
7
+ gem.name = "dassets-lessv1"
8
+ gem.version = Dassets::Lessv1::VERSION
9
+ gem.authors = ["Kelly Redding", "Collin Redding"]
10
+ gem.email = ["kelly@kellyredding.com", "collin.redding@me.com"]
11
+ gem.description = %q{Dassets engine for compiling LESS CSS using the 1.x.x Ruby compiler}
12
+ gem.summary = %q{Dassets engine for compiling LESS CSS v1}
13
+ gem.homepage = "http://github.com/redding/dassets-lessv1"
14
+
15
+ gem.files = `git ls-files`.split($/)
16
+ gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
17
+ gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
18
+ gem.require_paths = ["lib"]
19
+
20
+ gem.add_development_dependency("assert")
21
+
22
+ # lock in to the 1.x.x LESS ruby compiler b/c this is Lessv1
23
+ # ie https://github.com/cloudhead/less/tree/v1.2.21
24
+ gem.add_dependency("less", ["~> 1.1"])
25
+ gem.add_dependency("dassets")
26
+
27
+ end
@@ -0,0 +1,31 @@
1
+ require 'less'
2
+ require 'dassets/engine'
3
+ require "dassets-lessv1/version"
4
+
5
+ module Dassets::Lessv1
6
+
7
+ class Engine < Dassets::Engine
8
+
9
+ def ext(input_ext)
10
+ 'css'
11
+ end
12
+
13
+ def compile(input_content)
14
+ Source.new(input_content).to_css
15
+ end
16
+
17
+ end
18
+
19
+ # This is a little wrapper class to the less engine. I use this to access
20
+ # and set the `@path` instance variable on the engine. This sets the root
21
+ # path all imports are done from. This just makes importing partials easier.
22
+
23
+ class Source < ::Less::Engine
24
+ attr_reader :path
25
+ def initialize(content, opts={})
26
+ @path = Dassets.config.source_path
27
+ super
28
+ end
29
+ end
30
+
31
+ end
@@ -0,0 +1,4 @@
1
+ module Dassets; end
2
+ module Dassets::Lessv1
3
+ VERSION = "0.1.0"
4
+ end
data/log/.gitkeep ADDED
File without changes
data/test/helper.rb ADDED
@@ -0,0 +1,18 @@
1
+ # this file is automatically required when you run `assert`
2
+ # put any test helpers here
3
+
4
+ # add the root dir to the load path
5
+ $LOAD_PATH.unshift(File.expand_path("../..", __FILE__))
6
+
7
+ # require pry for debugging (`binding.pry`)
8
+ require 'pry'
9
+
10
+ ENV['DASSETS_TEST_MODE'] = 'yes'
11
+ ENV['DASSETS_ASSETS_FILE'] = 'test/support/config/assets'
12
+ require 'dassets'
13
+ Dassets.init
14
+
15
+ require 'test/support/factory'
16
+ class Assert::Context
17
+ setup{ @factory = Dassets::Lessv1::Factory }
18
+ end
@@ -0,0 +1,8 @@
1
+ @nice_blue: #5B83AD;
2
+ @light_blue: @nice_blue + #111;
3
+ #header {
4
+ color: @light_blue;
5
+ }
6
+ div {
7
+ width: 1 + 1;
8
+ }
@@ -0,0 +1,9 @@
1
+ require 'dassets'
2
+ require 'dassets-lessv1'
3
+
4
+ Dassets.configure do |c|
5
+ c.root_path File.expand_path("../..", __FILE__)
6
+ c.engine 'less', Dassets::Lessv1::Engine
7
+ c.cache = nil
8
+ c.file_store 'public'
9
+ end
@@ -0,0 +1,38 @@
1
+ module Dassets::Lessv1
2
+
3
+ module Factory
4
+ module_function
5
+
6
+ def css
7
+ "SPAN {\n"\
8
+ " width: 20px;\n"\
9
+ " height: 30px;\n"\
10
+ "}\n"
11
+ end
12
+
13
+ def css_compiled
14
+ "SPAN {\n"\
15
+ " width: 20px;\n"\
16
+ " height: 30px;\n"\
17
+ "}\n"
18
+ end
19
+
20
+ def less
21
+ "@nice_blue: #5B83AD;\n"\
22
+ "@light_blue: @nice_blue + #111;\n"\
23
+ "#header {\n"\
24
+ " color: @light_blue;\n"\
25
+ "}\n"\
26
+ "div {\n"\
27
+ " width: 1 + 1;\n"\
28
+ "}\n"
29
+ end
30
+
31
+ def less_compiled
32
+ "#header { color: #6c94be; }\n"\
33
+ "div { width: 2; }\n"
34
+ end
35
+
36
+ end
37
+
38
+ end
@@ -0,0 +1,2 @@
1
+ #header { color: #6c94be; }
2
+ div { width: 2; }
@@ -0,0 +1,30 @@
1
+ require 'assert'
2
+ require 'fileutils'
3
+ require 'dassets'
4
+ require 'dassets-lessv1'
5
+
6
+ module Dassets::Lessv1
7
+
8
+ class DigestTests < Assert::Context
9
+ desc "digesting a less source file with the lessv1 engine registered"
10
+ setup do
11
+ @source_file = File.join(Dassets.config.source_path, "normal.less")
12
+ File.open(@source_file, 'w'){ |f| f.write(@factory.less) }
13
+ @compiled_file = File.join(Dassets.config.root_path, "public/normal-fe8a898deedf1cdbbbdd775ec0152c04.css")
14
+ @exp_compiled_content = @factory.less_compiled
15
+
16
+ FileUtils.rm_f @compiled_file
17
+ end
18
+
19
+ should "produce a css file with the source less compiled to css" do
20
+ assert_file_exists @source_file
21
+ assert_not_file_exists @compiled_file
22
+ Dassets.digest_source_files
23
+
24
+ assert_file_exists @compiled_file
25
+ assert_equal @exp_compiled_content, File.read(@compiled_file)
26
+ end
27
+
28
+ end
29
+
30
+ end
@@ -0,0 +1,34 @@
1
+ require 'assert'
2
+ require 'dassets/engine'
3
+ require 'dassets-lessv1'
4
+
5
+ class Dassets::Lessv1::Engine
6
+
7
+ class BaseTests < Assert::Context
8
+ desc "the Dassets::Lessv1 engine"
9
+ setup do
10
+ @engine = Dassets::Lessv1::Engine.new
11
+ end
12
+ subject{ @engine }
13
+
14
+ should "be a Dassets engine" do
15
+ assert_kind_of Dassets::Engine, subject
16
+ assert_respond_to 'ext', subject
17
+ assert_respond_to 'compile', subject
18
+ end
19
+
20
+ should "transform any input extension to `css`" do
21
+ assert_equal 'css', subject.ext('less')
22
+ assert_equal 'css', subject.ext('lss')
23
+ assert_equal 'css', subject.ext('lessv1')
24
+ assert_equal 'css', subject.ext('whatever')
25
+ end
26
+
27
+ should "compile any input content as LESS css" do
28
+ assert_equal @factory.css_compiled, subject.compile(@factory.css)
29
+ assert_equal @factory.less_compiled, subject.compile(@factory.less)
30
+ end
31
+
32
+ end
33
+
34
+ end
data/tmp/.gitkeep ADDED
File without changes
metadata ADDED
@@ -0,0 +1,132 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: dassets-lessv1
3
+ version: !ruby/object:Gem::Version
4
+ hash: 27
5
+ prerelease:
6
+ segments:
7
+ - 0
8
+ - 1
9
+ - 0
10
+ version: 0.1.0
11
+ platform: ruby
12
+ authors:
13
+ - Kelly Redding
14
+ - Collin Redding
15
+ autorequire:
16
+ bindir: bin
17
+ cert_chain: []
18
+
19
+ date: 2013-05-01 00:00:00 Z
20
+ dependencies:
21
+ - !ruby/object:Gem::Dependency
22
+ name: assert
23
+ prerelease: false
24
+ requirement: &id001 !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ">="
28
+ - !ruby/object:Gem::Version
29
+ hash: 3
30
+ segments:
31
+ - 0
32
+ version: "0"
33
+ type: :development
34
+ version_requirements: *id001
35
+ - !ruby/object:Gem::Dependency
36
+ name: less
37
+ prerelease: false
38
+ requirement: &id002 !ruby/object:Gem::Requirement
39
+ none: false
40
+ requirements:
41
+ - - ~>
42
+ - !ruby/object:Gem::Version
43
+ hash: 13
44
+ segments:
45
+ - 1
46
+ - 1
47
+ version: "1.1"
48
+ type: :runtime
49
+ version_requirements: *id002
50
+ - !ruby/object:Gem::Dependency
51
+ name: dassets
52
+ prerelease: false
53
+ requirement: &id003 !ruby/object:Gem::Requirement
54
+ none: false
55
+ requirements:
56
+ - - ">="
57
+ - !ruby/object:Gem::Version
58
+ hash: 3
59
+ segments:
60
+ - 0
61
+ version: "0"
62
+ type: :runtime
63
+ version_requirements: *id003
64
+ description: Dassets engine for compiling LESS CSS using the 1.x.x Ruby compiler
65
+ email:
66
+ - kelly@kellyredding.com
67
+ - collin.redding@me.com
68
+ executables: []
69
+
70
+ extensions: []
71
+
72
+ extra_rdoc_files: []
73
+
74
+ files:
75
+ - .gitignore
76
+ - Gemfile
77
+ - LICENSE.txt
78
+ - README.md
79
+ - Rakefile
80
+ - dassets-lessv1.gemspec
81
+ - lib/dassets-lessv1.rb
82
+ - lib/dassets-lessv1/version.rb
83
+ - log/.gitkeep
84
+ - test/helper.rb
85
+ - test/support/app/assets/normal.less
86
+ - test/support/config/assets.rb
87
+ - test/support/factory.rb
88
+ - test/support/public/normal-fe8a898deedf1cdbbbdd775ec0152c04.css
89
+ - test/system/digest_tests.rb
90
+ - test/unit/engine_tests.rb
91
+ - tmp/.gitkeep
92
+ homepage: http://github.com/redding/dassets-lessv1
93
+ licenses: []
94
+
95
+ post_install_message:
96
+ rdoc_options: []
97
+
98
+ require_paths:
99
+ - lib
100
+ required_ruby_version: !ruby/object:Gem::Requirement
101
+ none: false
102
+ requirements:
103
+ - - ">="
104
+ - !ruby/object:Gem::Version
105
+ hash: 3
106
+ segments:
107
+ - 0
108
+ version: "0"
109
+ required_rubygems_version: !ruby/object:Gem::Requirement
110
+ none: false
111
+ requirements:
112
+ - - ">="
113
+ - !ruby/object:Gem::Version
114
+ hash: 3
115
+ segments:
116
+ - 0
117
+ version: "0"
118
+ requirements: []
119
+
120
+ rubyforge_project:
121
+ rubygems_version: 1.8.24
122
+ signing_key:
123
+ specification_version: 3
124
+ summary: Dassets engine for compiling LESS CSS v1
125
+ test_files:
126
+ - test/helper.rb
127
+ - test/support/app/assets/normal.less
128
+ - test/support/config/assets.rb
129
+ - test/support/factory.rb
130
+ - test/support/public/normal-fe8a898deedf1cdbbbdd775ec0152c04.css
131
+ - test/system/digest_tests.rb
132
+ - test/unit/engine_tests.rb