fewer 0.0.0 → 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.0.0
1
+ 0.0.1
data/fewer.gemspec ADDED
@@ -0,0 +1,65 @@
1
+ # Generated by jeweler
2
+ # DO NOT EDIT THIS FILE DIRECTLY
3
+ # Instead, edit Jeweler::Tasks in Rakefile, and run the gemspec command
4
+ # -*- encoding: utf-8 -*-
5
+
6
+ Gem::Specification.new do |s|
7
+ s.name = %q{fewer}
8
+ s.version = "0.0.1"
9
+
10
+ s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
+ s.authors = ["Ben Pickles"]
12
+ s.date = %q{2010-08-10}
13
+ s.description = %q{Rack middleware to bundle assets and help you make fewer HTTP requests.}
14
+ s.email = %q{spideryoung@gmail.com}
15
+ s.extra_rdoc_files = [
16
+ "LICENSE",
17
+ "README.md"
18
+ ]
19
+ s.files = [
20
+ ".gitignore",
21
+ "LICENSE",
22
+ "README.md",
23
+ "Rakefile",
24
+ "VERSION",
25
+ "fewer.gemspec",
26
+ "lib/fewer.rb",
27
+ "lib/fewer/app.rb",
28
+ "lib/fewer/engines.rb",
29
+ "lib/fewer/engines/abstract.rb",
30
+ "lib/fewer/engines/css.rb",
31
+ "lib/fewer/engines/js.rb",
32
+ "lib/fewer/engines/js_min.rb",
33
+ "lib/fewer/engines/less.rb",
34
+ "lib/fewer/errors.rb",
35
+ "lib/fewer/serializer.rb",
36
+ "test/app_test.rb",
37
+ "test/engine_test.rb",
38
+ "test/test_helper.rb"
39
+ ]
40
+ s.homepage = %q{http://github.com/benpickles/fewer}
41
+ s.rdoc_options = ["--charset=UTF-8"]
42
+ s.require_paths = ["lib"]
43
+ s.rubygems_version = %q{1.3.7}
44
+ s.summary = %q{Rack middleware to bundle assets and help you make fewer HTTP requests.}
45
+ s.test_files = [
46
+ "test/app_test.rb",
47
+ "test/engine_test.rb",
48
+ "test/sass_engine_test.rb",
49
+ "test/test_helper.rb"
50
+ ]
51
+
52
+ if s.respond_to? :specification_version then
53
+ current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
54
+ s.specification_version = 3
55
+
56
+ if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
57
+ s.add_runtime_dependency(%q<rack>, [">= 0"])
58
+ else
59
+ s.add_dependency(%q<rack>, [">= 0"])
60
+ end
61
+ else
62
+ s.add_dependency(%q<rack>, [">= 0"])
63
+ end
64
+ end
65
+
data/lib/fewer/engines.rb CHANGED
@@ -2,6 +2,8 @@ module Fewer
2
2
  module Engines
3
3
  autoload :Abstract, 'fewer/engines/abstract'
4
4
  autoload :Css, 'fewer/engines/css'
5
+ autoload :Js, 'fewer/engines/js'
6
+ autoload :JsMin, 'fewer/engines/js_min'
5
7
  autoload :Less, 'fewer/engines/less'
6
8
  end
7
9
  end
@@ -9,13 +9,6 @@ module Fewer
9
9
  check_paths!
10
10
  end
11
11
 
12
- def check_paths!
13
- if (missing = paths.reject { |path| File.exist?(path) }).any?
14
- files = missing.map { |path| path.to_s }.join("\n")
15
- raise Fewer::MissingSourceFileError.new("Missing source file#{'s' if missing.size > 1}:\n#{files}")
16
- end
17
- end
18
-
19
12
  def content_type
20
13
  'text/plain'
21
14
  end
@@ -31,8 +24,7 @@ module Fewer
31
24
 
32
25
  def paths
33
26
  names.map { |name|
34
- # TODO: Fix rather large security hole...
35
- File.join(root, "#{name}#{extension}")
27
+ File.join(root, "#{File.basename(name.to_s)}#{extension}")
36
28
  }
37
29
  end
38
30
 
@@ -41,6 +33,14 @@ module Fewer
41
33
  File.read(path)
42
34
  }.join("\n")
43
35
  end
36
+
37
+ private
38
+ def check_paths!
39
+ if (missing = paths.reject { |path| File.exist?(path) }).any?
40
+ files = missing.map { |path| path.to_s }.join("\n")
41
+ raise Fewer::MissingSourceFileError.new("Missing source file#{'s' if missing.size > 1}:\n#{files}")
42
+ end
43
+ end
44
44
  end
45
45
  end
46
46
  end
@@ -0,0 +1,13 @@
1
+ module Fewer
2
+ module Engines
3
+ class Js < Abstract
4
+ def content_type
5
+ 'application/x-javascript'
6
+ end
7
+
8
+ def extension
9
+ '.js'
10
+ end
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,19 @@
1
+ autoload :Closure, 'closure-compiler'
2
+
3
+ module Fewer
4
+ module Engines
5
+ class JsMin < Abstract
6
+ def content_type
7
+ 'application/x-javascript'
8
+ end
9
+
10
+ def extension
11
+ '.js'
12
+ end
13
+
14
+ def read
15
+ ::Closure::Compiler.new.compress(super)
16
+ end
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,26 @@
1
+ require 'test_helper'
2
+
3
+ class EngineTest < Test::Unit::TestCase
4
+ def test_sanitise_paths
5
+ bad_files = ['./../private.txt', '/etc/passwd']
6
+ engine = engine_klass_no_checking.new('./happy-place', bad_files)
7
+ assert_equal ['./happy-place/private.txt', './happy-place/passwd'], engine.paths
8
+ end
9
+
10
+ def test_stringify_paths
11
+ engine = engine_klass_no_checking.new('.', [:symbol, { :a => :b }])
12
+ assert_equal ['./symbol', './ab'], engine.paths
13
+ end
14
+
15
+ private
16
+ def engine_klass(&block)
17
+ Class.new(Fewer::Engines::Abstract, &block)
18
+ end
19
+
20
+ def engine_klass_no_checking
21
+ engine_klass do
22
+ private
23
+ def check_paths!; end
24
+ end
25
+ end
26
+ end
@@ -0,0 +1,22 @@
1
+ require 'test_helper'
2
+
3
+ class EnginesTest < Test::Unit::TestCase
4
+ def test_sass_engine
5
+ engine = Fewer::Engines::Sass.new(template_root, 'sass')
6
+ assert_equal sass, engine.read
7
+ end
8
+
9
+ private
10
+ def sass
11
+ '#navbar li {
12
+ border-top-radius: 10px;
13
+ -moz-border-radius-top: 10px;
14
+ -webkit-border-top-radius: 10px; }
15
+
16
+ #footer {
17
+ border-top-radius: 10px;
18
+ -moz-border-radius-top: 10px;
19
+ -webkit-border-top-radius: 10px; }
20
+ '
21
+ end
22
+ end
data/test/test_helper.rb CHANGED
@@ -5,8 +5,9 @@ require 'mocha'
5
5
  require 'rack/test'
6
6
 
7
7
  begin
8
- require 'redgreen'
8
+ require 'leftright'
9
9
  rescue LoadError
10
+ puts "You're missing out on pretty colours! `gem install leftright`"
10
11
  end
11
12
 
12
13
  require 'fewer'
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fewer
3
3
  version: !ruby/object:Gem::Version
4
- hash: 31
4
+ hash: 29
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 0
9
- - 0
10
- version: 0.0.0
9
+ - 1
10
+ version: 0.0.1
11
11
  platform: ruby
12
12
  authors:
13
13
  - Ben Pickles
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2010-07-23 00:00:00 +01:00
18
+ date: 2010-08-10 00:00:00 +01:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency
@@ -47,18 +47,21 @@ files:
47
47
  - README.md
48
48
  - Rakefile
49
49
  - VERSION
50
+ - fewer.gemspec
50
51
  - lib/fewer.rb
51
52
  - lib/fewer/app.rb
52
53
  - lib/fewer/engines.rb
53
54
  - lib/fewer/engines/abstract.rb
54
55
  - lib/fewer/engines/css.rb
56
+ - lib/fewer/engines/js.rb
57
+ - lib/fewer/engines/js_min.rb
55
58
  - lib/fewer/engines/less.rb
56
59
  - lib/fewer/errors.rb
57
60
  - lib/fewer/serializer.rb
58
61
  - test/app_test.rb
62
+ - test/engine_test.rb
59
63
  - test/test_helper.rb
60
- - test/abstract_bundler_test.rb
61
- - test/less_bundler_test.rb
64
+ - test/sass_engine_test.rb
62
65
  has_rdoc: true
63
66
  homepage: http://github.com/benpickles/fewer
64
67
  licenses: []
@@ -94,7 +97,7 @@ signing_key:
94
97
  specification_version: 3
95
98
  summary: Rack middleware to bundle assets and help you make fewer HTTP requests.
96
99
  test_files:
97
- - test/abstract_bundler_test.rb
98
100
  - test/app_test.rb
99
- - test/less_bundler_test.rb
101
+ - test/engine_test.rb
102
+ - test/sass_engine_test.rb
100
103
  - test/test_helper.rb
@@ -1,11 +0,0 @@
1
- # require 'test_helper'
2
- #
3
- # class AbstractBundlerTest < Test::Unit::TestCase
4
- # def setup
5
- # @bundler = Fewer::Engines::Abstract.new('.', ['a.txt', 'b.txt'])
6
- # end
7
- #
8
- # def test_root_to_a_pathname
9
- # assert_kind_of Pathname, @bundler.root
10
- # end
11
- # end
@@ -1,7 +0,0 @@
1
- # require 'test_helper'
2
- #
3
- # class LessBundlerTest < Test::Unit::TestCase
4
- # def test_a
5
- #
6
- # end
7
- # end