evax 0.0.2 → 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -1 +1,54 @@
1
- # Evax
1
+ # Evax Compressor
2
+
3
+ Evax is a simple asset packaging library for Ruby, providing JavaScript/CSS concatenation and compression using UglifyJS and a really simple regex based CSS compressor. Just because enough is enough.
4
+
5
+ The idea behind it is to have a really simple library to compress your assets in the simplest way without any weird dependency. There are nice assets packaging systems out there but they have too many options for some cases. Sometimes, you just want to play with a pet project.
6
+
7
+ Create a YAML file describing assets, Evax will take it and compress the javascript and stylesheets files to the output directory of your choice. Done.
8
+
9
+ ## Instalation
10
+
11
+ gem install evax
12
+
13
+ ## Usage
14
+
15
+ ### assets.yml
16
+
17
+ output_path: tmp/
18
+
19
+ javascripts:
20
+ js_package_one:
21
+ - test/fixtures/javascripts/one.js
22
+ - test/fixtures/javascripts/two.js
23
+ - test/fixtures/javascripts/three.js
24
+ js_package_two:
25
+ - test/fixtures/javascripts/four.js
26
+
27
+ stylesheets:
28
+ css_package_one:
29
+ - test/fixtures/stylesheets/one.css
30
+ - test/fixtures/stylesheets/two.css
31
+ css_package_two:
32
+ - test/fixtures/stylesheets/three.css
33
+ - test/fixtures/stylesheets/four.css
34
+
35
+ ### Command Line
36
+
37
+ evax /path/to/assets.yml /relative/path
38
+
39
+ ### Rails
40
+
41
+ Add **evax** to your Gemfile:
42
+
43
+ gem 'evax'
44
+
45
+ Create a Rake task for running it, e.g.:
46
+
47
+ namespace :evax do
48
+ desc 'Build assets'
49
+ task :build do
50
+ ASSETS_PATH = /path/to/assets.yml
51
+ RELATVE_PATH = /relative/path
52
+ Evax.new(ASSETS_PATH, RELATVE_PATH).build
53
+ end
54
+ end
data/bin/evax CHANGED
@@ -10,8 +10,8 @@ rescue LoadError
10
10
  require 'evax'
11
11
  end
12
12
 
13
- if( ARGV.size < 2 )
14
- puts "use: $ evax <config_file_path> <relative_path>"
13
+ if ( ARGV.size < 2 )
14
+ Evax::Logger.log "use: $ evax <config_file_path> <relative_path>"
15
15
  exit 1
16
16
  end
17
17
 
@@ -9,18 +9,24 @@ Gem::Specification.new do |s|
9
9
  s.email = ["fguillen.mail@gmail.com", "juanjicho@gmail.com "]
10
10
  s.homepage = ""
11
11
  s.summary = "Very simple assets compressor"
12
- s.description = "Very simple assets compressor"
12
+ s.description = <<-EOS
13
+ Evax is a simple asset packaging library for Ruby,
14
+ providing JavaScript/CSS concatenation and compression
15
+ using UglifyJS and a really simple regex based CSS
16
+ compressor. Just because enough is enough.
17
+ EOS
13
18
 
14
19
  s.rubyforge_project = "evax"
15
20
 
16
- s.add_development_dependency "bundler", ">= 1.0.0.rc.6"
17
- s.add_development_dependency "rake"
18
- s.add_development_dependency "uglifier"
21
+ s.add_development_dependency "bundler", ">= 1.0.0.rc.6"
22
+ s.add_development_dependency "rake", "0.9.2.2"
23
+ s.add_development_dependency "mocha", "0.10.0"
24
+ s.add_development_dependency "delorean", "1.1.1"
19
25
 
20
- s.add_development_dependency "mocha"
26
+ s.add_dependency "uglifier", "1.1.0"
21
27
 
22
28
  s.files = `git ls-files`.split("\n")
23
29
  s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
24
30
  s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
25
31
  s.require_paths = ["lib"]
26
- end
32
+ end
@@ -3,16 +3,17 @@ require "uglifier"
3
3
 
4
4
  require_relative "evax/version"
5
5
  require_relative "evax/css_minifier"
6
+ require_relative "evax/logger"
6
7
 
7
8
  class Evax
8
9
  attr_reader :config_file, :relative_path
9
10
 
10
- def initialize( config_file, relative_path )
11
- @config_file = config_file
12
- @relative_path = relative_path
13
-
14
- puts "[Evax] Config File: #{config_file}"
15
- puts "[Evax] Relative Path: #{relative_path}"
11
+ def initialize( config_file = "config/assets.yml", relative_path = "public/assets" )
12
+ @config_file = File.expand_path( config_file )
13
+ @relative_path = File.expand_path( relative_path )
14
+
15
+ Evax::Logger.log "Config File: #{self.config_file}"
16
+ Evax::Logger.log "Relative Path: #{self.relative_path}"
16
17
  end
17
18
 
18
19
  def config
@@ -21,7 +22,7 @@ class Evax
21
22
 
22
23
  def join( type, group_name )
23
24
  config[type.to_s][group_name].map do |file_path|
24
- File.read file_path
25
+ File.read( File.join(relative_path, file_path) )
25
26
  end.join( "\n" )
26
27
  end
27
28
 
@@ -47,15 +48,15 @@ class Evax
47
48
  write_output( "#{group_name}.css", compress_string )
48
49
  end
49
50
  end
50
-
51
+
51
52
  def write_output( file_name, string )
52
- path = File.expand_path( File.join( relative_path, config['output_path'] ) )
53
+ path = File.expand_path( File.join( relative_path, config['output_path'] ) )
53
54
  file_path = File.join( path, file_name )
54
-
55
- puts "[Evax] Writting file: #{file_path}"
56
-
55
+
56
+ Evax::Logger.log "Writing file: #{file_path}"
57
+
57
58
  FileUtils.mkdir_p path
58
- File.open( file_path, 'w') { |f| f.write string }
59
+ File.open( file_path, 'w' ) { |f| f.write string }
59
60
  end
60
61
 
61
62
  def self.compress_js( js_string )
@@ -0,0 +1,5 @@
1
+ module Evax::Logger
2
+ def self.log( message )
3
+ puts "[Evax #{Time.now.strftime( "%F %T" )}] #{message}"
4
+ end
5
+ end
@@ -1,3 +1,3 @@
1
1
  class Evax
2
- VERSION = "0.0.2"
2
+ VERSION = "0.0.3"
3
3
  end
@@ -1,29 +1,43 @@
1
- require 'test/unit'
2
- require "mocha"
3
- require_relative "../lib/evax.rb"
4
-
5
- FIXTURES = "#{File.dirname(__FILE__)}/fixtures"
1
+ require_relative "test_helper"
6
2
 
7
3
  class EvaxTest < Test::Unit::TestCase
4
+ def setup
5
+ Evax::Logger.stubs( :log )
6
+ end
7
+
8
8
  def test_initialize
9
- evax = Evax.new( "wadus", "tradus" )
10
- assert_equal( "wadus", evax.config_file )
11
- assert_equal( "tradus", evax.relative_path )
9
+ evax = Evax.new( "/wadus", "/tradus" )
10
+ assert_match( "/wadus", evax.config_file )
11
+ assert_match( "/tradus", evax.relative_path )
12
12
  end
13
13
 
14
14
  def test_read_config_file
15
- evax = Evax.new( "#{FIXTURES}/assets.yml", nil )
15
+ evax = Evax.new( "#{FIXTURES}/assets.yml")
16
16
  assert_equal( "tmp/", evax.config["output_path"] )
17
17
  assert_equal( 2, evax.config["javascripts"].size )
18
18
  end
19
19
 
20
+ def test_join
21
+ evax = Evax.new( "#{FIXTURES}/assets.yml", "/wadus" )
22
+
23
+ [
24
+ "/wadus/test/fixtures/javascripts/one.js",
25
+ "/wadus/test/fixtures/javascripts/two.js",
26
+ "/wadus/test/fixtures/javascripts/three.js"
27
+ ].each do |path|
28
+ File.expects( :read ).with( path )
29
+ end
30
+
31
+ evax.join( :javascripts, "js_one" )
32
+ end
33
+
20
34
  def test_join_js_files
21
- evax = Evax.new( "#{FIXTURES}/assets.yml", nil )
35
+ evax = Evax.new( "#{FIXTURES}/assets.yml", "#{File.dirname(__FILE__)}/.." )
22
36
  assert_equal File.read("#{FIXTURES}/js_one.js"), evax.join( :javascripts, "js_one" )
23
37
  end
24
38
 
25
39
  def test_join_css_files
26
- evax = Evax.new( "#{FIXTURES}/assets.yml", nil )
40
+ evax = Evax.new( "#{FIXTURES}/assets.yml", "#{File.dirname(__FILE__)}/.." )
27
41
 
28
42
  assert_equal File.read("#{FIXTURES}/css_one.css"), evax.join( :stylesheets, "css_one" )
29
43
  end
@@ -66,7 +80,7 @@ class EvaxTest < Test::Unit::TestCase
66
80
  end
67
81
 
68
82
  def test_build
69
- evax = Evax.new( nil, nil )
83
+ evax = Evax.new
70
84
  evax.expects( :build_js )
71
85
  evax.expects( :build_css )
72
86
 
@@ -0,0 +1,11 @@
1
+ require_relative "test_helper"
2
+
3
+ class LoggerTest < Test::Unit::TestCase
4
+ def test_log
5
+ IO.any_instance.expects( :puts ).with( "[Evax 2001-02-01 04:05:06] hello!" )
6
+
7
+ Delorean.time_travel_to( "2001-02-01 04:05:06" ) do
8
+ Evax::Logger.log( "hello!" )
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,9 @@
1
+ require "test/unit"
2
+ require "mocha"
3
+ require "delorean"
4
+
5
+ require_relative "../lib/evax.rb"
6
+
7
+ class Test::Unit::TestCase
8
+ FIXTURES = "#{File.dirname(__FILE__)}/fixtures"
9
+ end
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 0
8
- - 2
9
- version: 0.0.2
8
+ - 3
9
+ version: 0.0.3
10
10
  platform: ruby
11
11
  authors:
12
12
  - Fernando Guillen
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2011-12-12 00:00:00 +01:00
18
+ date: 2011-12-13 00:00:00 +01:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency
@@ -41,40 +41,62 @@ dependencies:
41
41
  requirement: &id002 !ruby/object:Gem::Requirement
42
42
  none: false
43
43
  requirements:
44
- - - ">="
44
+ - - "="
45
45
  - !ruby/object:Gem::Version
46
46
  segments:
47
47
  - 0
48
- version: "0"
48
+ - 9
49
+ - 2
50
+ - 2
51
+ version: 0.9.2.2
49
52
  type: :development
50
53
  version_requirements: *id002
51
54
  - !ruby/object:Gem::Dependency
52
- name: uglifier
55
+ name: mocha
53
56
  prerelease: false
54
57
  requirement: &id003 !ruby/object:Gem::Requirement
55
58
  none: false
56
59
  requirements:
57
- - - ">="
60
+ - - "="
58
61
  - !ruby/object:Gem::Version
59
62
  segments:
60
63
  - 0
61
- version: "0"
64
+ - 10
65
+ - 0
66
+ version: 0.10.0
62
67
  type: :development
63
68
  version_requirements: *id003
64
69
  - !ruby/object:Gem::Dependency
65
- name: mocha
70
+ name: delorean
66
71
  prerelease: false
67
72
  requirement: &id004 !ruby/object:Gem::Requirement
68
73
  none: false
69
74
  requirements:
70
- - - ">="
75
+ - - "="
71
76
  - !ruby/object:Gem::Version
72
77
  segments:
73
- - 0
74
- version: "0"
78
+ - 1
79
+ - 1
80
+ - 1
81
+ version: 1.1.1
75
82
  type: :development
76
83
  version_requirements: *id004
77
- description: Very simple assets compressor
84
+ - !ruby/object:Gem::Dependency
85
+ name: uglifier
86
+ prerelease: false
87
+ requirement: &id005 !ruby/object:Gem::Requirement
88
+ none: false
89
+ requirements:
90
+ - - "="
91
+ - !ruby/object:Gem::Version
92
+ segments:
93
+ - 1
94
+ - 1
95
+ - 0
96
+ version: 1.1.0
97
+ type: :runtime
98
+ version_requirements: *id005
99
+ description: " Evax is a simple asset packaging library for Ruby,\n providing JavaScript/CSS concatenation and compression\n using UglifyJS and a really simple regex based CSS\n compressor. Just because enough is enough.\n"
78
100
  email:
79
101
  - fguillen.mail@gmail.com
80
102
  - "juanjicho@gmail.com "
@@ -94,6 +116,7 @@ files:
94
116
  - evax.gemspec
95
117
  - lib/evax.rb
96
118
  - lib/evax/css_minifier.rb
119
+ - lib/evax/logger.rb
97
120
  - lib/evax/version.rb
98
121
  - test/evax_test.rb
99
122
  - test/fixtures/assets.yml
@@ -111,6 +134,8 @@ files:
111
134
  - test/fixtures/stylesheets/one.css
112
135
  - test/fixtures/stylesheets/three.css
113
136
  - test/fixtures/stylesheets/two.css
137
+ - test/logger_test.rb
138
+ - test/test_helper.rb
114
139
  has_rdoc: true
115
140
  homepage: ""
116
141
  licenses: []
@@ -160,3 +185,5 @@ test_files:
160
185
  - test/fixtures/stylesheets/one.css
161
186
  - test/fixtures/stylesheets/three.css
162
187
  - test/fixtures/stylesheets/two.css
188
+ - test/logger_test.rb
189
+ - test/test_helper.rb