yui-compressor-ext 0.0.2 → 0.0.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/Manifest.txt CHANGED
@@ -20,11 +20,13 @@ script/generate.cmd
20
20
  test/cli/commands/test_all.rb
21
21
  test/cli/commands/test_css.rb
22
22
  test/cli/commands/test_js.rb
23
+ test/sample/assets/css-1.css
24
+ test/sample/assets/css-2.css
25
+ test/sample/assets/js-1.js
26
+ test/sample/assets/js-2.js
27
+ test/sample/compressed/compiled.css
28
+ test/sample/compressed/compiled.js
23
29
  test/sample/config.yml
24
- test/sample/css-1.css
25
- test/sample/css-2.css
26
- test/sample/js-1.js
27
- test/sample/js-2.js
30
+ test/test_config.rb
28
31
  test/test_helper.rb
29
- test/text_config.rb
30
32
  yui-compressor-ext.gemspec
data/README.rdoc CHANGED
@@ -1,104 +1,31 @@
1
1
  = YUI Compressor Extension
2
2
 
3
- * http://osc.matsukei.net/projects/ruby-yui-compressor-ext/wiki
3
+ * {http://osc.matsukei.net/projects/ruby-yui-compressor-ext/wiki}
4
4
 
5
- == DESCRIPTION:
5
+ == DESCRIPTION
6
6
 
7
- YUI Compressor Extension is an enhancing library of {YUI Compressor}[http://github.com/sstephenson/ruby-yui-compressor/] .
7
+ YUI Compressor Extension is an enhancing library of {http://github.com/sstephenson/ruby-yui-compressor/ YUI Compressor}.
8
8
  The following functions can be used by this extension.
9
9
  * CLI interface
10
10
  * Compression and uniting of multiple assets
11
11
 
12
- == REQUIREMENTS:
12
+ == REQUIREMENTS
13
13
 
14
14
  * yui-compressor
15
15
  * cri
16
16
  * win32-open3 (Only win32-Platform)
17
17
 
18
- == INSTALL:
18
+ == INSTALL
19
19
 
20
20
  $ gem install yui-compressor-ext
21
21
 
22
- == Usage
22
+ == DOCUMENTATION
23
23
 
24
- === First Step
24
+ * {http://osc.matsukei.net/projects/ruby-yui-compressor-ext/wiki/Overview Overview}
25
+ * {http://osc.matsukei.net/projects/ruby-yui-compressor-ext/wiki/Users_Guide Users Guide}
26
+ * {http://osc.matsukei.net/projects/ruby-yui-compressor-ext/wiki/Changelog Changelog}
25
27
 
26
- Please see {here}[http://github.com/sstephenson/ruby-yui-compressor/] about Ruby-YUI Compressor.
27
-
28
- === Basic Concepts
29
-
30
- For example, it is assumed that the following files exist.
31
-
32
- /path/to/assets/javascripts/hoge.js
33
- /path/to/assets/javascripts/foo.js
34
- /path/to/assets/css/base.css
35
- /path/to/assets/css/custom.css
36
-
37
- Create configuration file to <code>/path/to/assets/config.yml</code> (YAML Format).
38
-
39
- output_dir: /path/to/assets
40
- js:
41
- base_dir: /path/to/assets/javascripts
42
- files:
43
- - hoge.js #=> js:base_dir + hoge.js
44
- - foo.js #=> js:base_dir + foo.js
45
- output: min.js #=> output_dir + min.js
46
- css:
47
- # When do not use "base_dir"
48
- files:
49
- - /path/to/assets/css/base.css
50
- - /path/to/assets/css/custom.css
51
- output: min.css #=> output_dir + min.css
52
-
53
- Compress and uniting CSS and JavaScripts (All).
54
-
55
- $ cd /path/to/assets
56
- $ yuicompress all
57
-
58
- Then, JavaScript and the CSS file that the compression uniting is done based on the configuration file as follows are made.
59
-
60
- /path/to/assets/javascripts/hoge.js
61
- /path/to/assets/javascripts/foo.js
62
- /path/to/assets/min.js <== created
63
- /path/to/assets/css/base.css
64
- /path/to/assets/css/custom.css
65
- /path/to/assets/min.css <== created
66
-
67
- To process only CSS or JavaScript, as follows is done.
68
-
69
- $ yuicompress css (or js)
70
-
71
- In addition, it is also possible to execute the place of the configuration file specifying it.
72
-
73
- $ yuicompress css /path/to/assets/config.yml
74
-
75
- === Setting to options for YUI Compressor
76
-
77
- Optional execution of YUI-Compressor can be described by the configuration file.
78
- Please see {here}[http://yui.rubyforge.org/classes/YUI/CssCompressor.html] and {here}[http://yui.rubyforge.org/classes/YUI/JavaScriptCompressor.html] about the option that can be set.
79
-
80
- # Global options. It is applied to both of these.
81
- options:
82
- :charset: utf-8
83
- :line_break: 100
84
- output_dir: /path/to/assets
85
- js:
86
- # Options for JavaScript. It is merge to Global options.
87
- options:
88
- :charset: sjis
89
- base_dir: /path/to/assets/javascripts
90
- files:
91
- - hoge.js
92
- - foo.js
93
- output: min.js
94
- css:
95
- # When do not use "base_dir"
96
- files:
97
- - /path/to/assets/css/base.css
98
- - /path/to/assets/css/custom.css
99
- output: min.css
100
-
101
- == LICENSE:
28
+ == LICENSE
102
29
 
103
30
  (The MIT License)
104
31
 
data/Rakefile CHANGED
@@ -12,15 +12,13 @@ Hoe.plugin :yard
12
12
  # Run 'rake -T' to see list of generated tasks (from gem root directory)
13
13
  $hoe = Hoe.spec 'yui-compressor-ext' do
14
14
  self.developer 'Matsukei Co.,Ltd', 'osc@matsukei.co.jp'
15
- self.description = %q{YUI Compressor Extensions is an enhancing library of YUI Compressor.
16
- The following functions can be used by this extension.
17
- * CLI interface
18
- * Compression and uniting of multiple assets}
19
- self.summary = %q{YUI Compressor Extensions is an enhancing library of YUI Compressor}
20
- self.version = '0.0.2'
15
+ self.description = %q{YUI Compressor Extension is an enhancing library of YUI Compressor. The functions that CLI interface, Compression and uniting of multiple assets can be used by this extension.}
16
+ self.summary = %q{YUI Compressor Extension is an enhancing library of YUI Compressor}
17
+ self.version = '0.0.3'
21
18
  self.extra_rdoc_files = ['README.rdoc']
22
19
  self.extra_deps = [['yui-compressor','>= 0.9.1'], ['cri','>= 1.0.0'], ['win32-open3', '>= 0.3.2']]
23
- self.yard_title = "YUI-Compressor Extensions (#{self.version})"
20
+ self.yard_title = "YUI-Compressor Extension (#{self.version})"
21
+ self.yard_opts = ['--main', 'README.rdoc']
24
22
  end
25
23
 
26
24
  require 'newgem/tasks'
@@ -19,7 +19,7 @@ end
19
19
  end
20
20
 
21
21
  module YUI::Compressor::Ext
22
- VERSION = '0.0.2'
22
+ VERSION = '0.0.3'
23
23
  end
24
24
 
25
25
  # Load Ext modules.
@@ -1,11 +1,13 @@
1
1
  # coding: utf-8
2
2
  require 'yaml'
3
+ require 'pathname'
3
4
 
4
5
  class YUI::Compressor
5
6
  class Ext::Config
6
7
  DEFAULT = 'config.yml'
7
8
 
8
9
  class << self
10
+
9
11
  # @param [String] path
10
12
  # @return [Ext::Config]
11
13
  def load_file(path)
@@ -21,7 +23,7 @@ class YUI::Compressor
21
23
  raise 'Invalid configuration file.'
22
24
  end
23
25
 
24
- new(config)
26
+ new(config, File.expand_path(path))
25
27
  end
26
28
 
27
29
  private
@@ -32,53 +34,72 @@ class YUI::Compressor
32
34
  end
33
35
  end
34
36
 
37
+ # @return [Array, Hash]
38
+ attr_reader :config
39
+
40
+ # @return [Pathname]
41
+ attr_reader :path
42
+
35
43
  # @param [Array, Hash] config
36
- def initialize(config)
44
+ # @param [String] path
45
+ def initialize(config, path)
37
46
  @config = config
47
+ @path = Pathname.new(path)
38
48
  end
39
49
 
40
50
  # @param [String] type
41
51
  # @return [String]
42
52
  def output(type)
43
- File.join(*[clean_path(@config['output_dir']),
44
- clean_path(config_for(type, 'output'))].compact)
53
+ build_path(@config['output_dir'], config_for(type, 'output'))
45
54
  end
46
55
 
47
56
  # @param [String] type
48
57
  # @return [Array<String>]
49
58
  def files(type)
50
- base = clean_path(config_for(type, 'base_dir'))
51
- files = config_for(type, 'files')
52
- files.map do |file|
53
- File.join(*[base, clean_path(file)].compact)
59
+ dir = config_for(type, 'files_dir') || config_for(type, 'base_dir')
60
+ config_for(type, 'files').map do |file|
61
+ build_path(dir, file)
54
62
  end
55
63
  end
56
64
 
57
65
  # @param [String] type
58
66
  # @return [Hash]
59
67
  def options(type)
60
- base = @config['options'] || {}
61
- base.merge(config_for(type, 'options') || {})
68
+ opts = @config['options'] || {}
69
+ opts.merge(config_for(type, 'options') || {})
62
70
  end
63
71
 
64
72
  private
65
73
 
66
- # @param [String] type
67
- # @param [String] config
68
- # @return [Object]
69
- def config_for(type, config)
70
- @config[type] && @config[type][config]
71
- end
72
-
74
+ # @param [String] base
73
75
  # @param [String] path
74
76
  # @return [String]
75
- def clean_path(path)
76
- if path
77
- path = path.strip
78
- path.empty? ? nil : path.tr("\\", '/')
77
+ def build_path(base, path)
78
+ unless Pathname(path).absolute?
79
+ path = File.join(*[base, path].compact)
80
+ Pathname(path).absolute? ? path : File.join(*[base_path, path].compact)
81
+ else
82
+ path
83
+ end
84
+ end
85
+
86
+ # @return [String?]
87
+ def base_path
88
+ case path = (@config['base_path'] || :self)
89
+ when Symbol
90
+ path == :exec ? nil : @path.realpath.dirname.to_s
91
+ when String
92
+ path
79
93
  else
80
94
  nil
81
95
  end
82
96
  end
97
+
98
+ # @param [String] type
99
+ # @param [String] config
100
+ # @return [Object]
101
+ def config_for(type, config)
102
+ @config[type] && @config[type][config]
103
+ end
83
104
  end
84
105
  end
File without changes
File without changes
File without changes
File without changes
@@ -0,0 +1 @@
1
+ body{font-family:Meiryo,Arial;margin:0;padding:0;}ul,li,dl,dt,dd{margin:0;}.c1{color:#f00;}.c2{border:1px solid #00f;}
@@ -0,0 +1 @@
1
+ var j1=function(a,b){return a+b};var j2=function(a,b){return a+b};
@@ -1,13 +1,13 @@
1
- output_dir: .
1
+ base_path: :self
2
+ output_dir: ./compressed
2
3
  js:
3
- base_dir: .
4
+ files_dir: ./assets
4
5
  files:
5
6
  - js-1.js
6
7
  - js-2.js
7
8
  output: compiled.js
8
9
  css:
9
- base_dir: .
10
10
  files:
11
- - css-1.css
12
- - css-2.css
11
+ - ./assets/css-1.css
12
+ - ./assets/css-2.css
13
13
  output: compiled.css
@@ -1,7 +1,7 @@
1
1
  require File.dirname(__FILE__) + '/test_helper.rb'
2
2
 
3
3
  class YUI::Compressor::Ext::ConfigTest < Test::Unit::TestCase
4
-
4
+ # TODO
5
5
  def test_truth
6
6
  assert true
7
7
  end
@@ -2,28 +2,25 @@
2
2
 
3
3
  Gem::Specification.new do |s|
4
4
  s.name = %q{yui-compressor-ext}
5
- s.version = "0.0.2"
5
+ s.version = "0.0.3"
6
6
 
7
7
  s.required_rubygems_version = Gem::Requirement.new("> 1.3.1") if s.respond_to? :required_rubygems_version=
8
8
  s.authors = ["Matsukei Co.,Ltd"]
9
- s.date = %q{2010-12-31}
9
+ s.date = %q{2011-1-1}
10
10
  s.default_executable = %q{yuicompress}
11
- s.description = %q{YUI Compressor Extension is an enhancing library of YUI Compressor.
12
- The following functions can be used by this extension.
13
- * CLI interface
14
- * Compression and uniting of multiple assets}
11
+ s.description = %q{YUI Compressor Extension is an enhancing library of YUI Compressor. The functions that CLI interface, Compression and uniting of multiple assets can be used by this extension.}
15
12
  s.email = ["osc@matsukei.co.jp"]
16
13
  s.executables = ["yuicompress"]
17
14
  s.extra_rdoc_files = ["README.rdoc", "Manifest.txt"]
18
- s.files = ["README.rdoc", "Manifest.txt", "Rakefile", "bin/yuicompress", "lib/yui/compressor/ext.rb", "lib/yui/compressor/ext/cli.rb", "lib/yui/compressor/ext/cli/base.rb", "lib/yui/compressor/ext/cli/commands.rb", "lib/yui/compressor/ext/cli/commands/abstract.rb", "lib/yui/compressor/ext/cli/commands/all.rb", "lib/yui/compressor/ext/cli/commands/css.rb", "lib/yui/compressor/ext/cli/commands/js.rb", "lib/yui/compressor/ext/config.rb", "script/console", "script/console.cmd", "script/destroy", "script/destroy.cmd", "script/generate", "script/generate.cmd", "test/cli/commands/test_all.rb", "test/cli/commands/test_css.rb", "test/cli/commands/test_js.rb", "test/sample/config.yml", "test/sample/css-1.css", "test/sample/css-2.css", "test/sample/js-1.js", "test/sample/js-2.js", "test/test_helper.rb", "test/text_config.rb", "yui-compressor-ext.gemspec"]
15
+ s.files = ["Manifest.txt", "README.rdoc", "Rakefile", "bin/yuicompress", "lib/yui/compressor/ext.rb", "lib/yui/compressor/ext/cli.rb", "lib/yui/compressor/ext/cli/base.rb", "lib/yui/compressor/ext/cli/commands.rb", "lib/yui/compressor/ext/cli/commands/abstract.rb", "lib/yui/compressor/ext/cli/commands/all.rb", "lib/yui/compressor/ext/cli/commands/css.rb", "lib/yui/compressor/ext/cli/commands/js.rb", "lib/yui/compressor/ext/config.rb", "script/console", "script/console.cmd", "script/destroy", "script/destroy.cmd", "script/generate", "script/generate.cmd", "test/cli/commands/test_all.rb", "test/cli/commands/test_css.rb", "test/cli/commands/test_js.rb", "test/sample/assets/css-1.css", "test/sample/assets/css-2.css", "test/sample/assets/js-1.js", "test/sample/assets/js-2.js", "test/sample/compressed/compiled.css", "test/sample/compressed/compiled.js", "test/sample/config.yml", "test/test_config.rb", "test/test_helper.rb", "yui-compressor-ext.gemspec"]
19
16
  s.has_rdoc = %q{yard}
20
17
  s.homepage = %q{http://osc.matsukei.net/projects/ruby-yui-compressor-ext/wiki}
21
- s.rdoc_options = ["--title", "YUI-Compressor Extension (#{s.version})", "--quiet"]
18
+ s.rdoc_options = ["--main", "README.rdoc", "--title", "YUI-Compressor Extension (0.0.3)", "--quiet"]
22
19
  s.require_paths = ["lib"]
23
20
  s.rubyforge_project = %q{yui-compressor-ext}
24
21
  s.rubygems_version = %q{1.3.7}
25
- s.summary = %q{YUI Compressor Extensions is an enhancing library of YUI Compressor}
26
- s.test_files = ["test/cli/commands/test_all.rb", "test/cli/commands/test_css.rb", "test/cli/commands/test_js.rb", "test/test_helper.rb"]
22
+ s.summary = %q{YUI Compressor Extension is an enhancing library of YUI Compressor}
23
+ s.test_files = ["test/cli/commands/test_all.rb", "test/cli/commands/test_css.rb", "test/cli/commands/test_js.rb", "test/test_config.rb", "test/test_helper.rb"]
27
24
 
28
25
  if s.respond_to? :specification_version then
29
26
  current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: yui-compressor-ext
3
3
  version: !ruby/object:Gem::Version
4
- hash: 27
4
+ hash: 25
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 0
9
- - 2
10
- version: 0.0.2
9
+ - 3
10
+ version: 0.0.3
11
11
  platform: ruby
12
12
  authors:
13
13
  - Matsukei Co.,Ltd
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2010-12-31 00:00:00 +09:00
18
+ date: 2011-01-01 00:00:00 +09:00
19
19
  default_executable: yuicompress
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency
@@ -114,11 +114,7 @@ dependencies:
114
114
  version: 2.6.0
115
115
  type: :development
116
116
  version_requirements: *id006
117
- description: |-
118
- YUI Compressor Extension is an enhancing library of YUI Compressor.
119
- The following functions can be used by this extension.
120
- * CLI interface
121
- * Compression and uniting of multiple assets
117
+ description: YUI Compressor Extension is an enhancing library of YUI Compressor. The functions that CLI interface, Compression and uniting of multiple assets can be used by this extension.
122
118
  email:
123
119
  - osc@matsukei.co.jp
124
120
  executables:
@@ -129,8 +125,8 @@ extra_rdoc_files:
129
125
  - README.rdoc
130
126
  - Manifest.txt
131
127
  files:
132
- - README.rdoc
133
128
  - Manifest.txt
129
+ - README.rdoc
134
130
  - Rakefile
135
131
  - bin/yuicompress
136
132
  - lib/yui/compressor/ext.rb
@@ -151,13 +147,15 @@ files:
151
147
  - test/cli/commands/test_all.rb
152
148
  - test/cli/commands/test_css.rb
153
149
  - test/cli/commands/test_js.rb
150
+ - test/sample/assets/css-1.css
151
+ - test/sample/assets/css-2.css
152
+ - test/sample/assets/js-1.js
153
+ - test/sample/assets/js-2.js
154
+ - test/sample/compressed/compiled.css
155
+ - test/sample/compressed/compiled.js
154
156
  - test/sample/config.yml
155
- - test/sample/css-1.css
156
- - test/sample/css-2.css
157
- - test/sample/js-1.js
158
- - test/sample/js-2.js
157
+ - test/test_config.rb
159
158
  - test/test_helper.rb
160
- - test/text_config.rb
161
159
  - yui-compressor-ext.gemspec
162
160
  has_rdoc: yard
163
161
  homepage: http://osc.matsukei.net/projects/ruby-yui-compressor-ext/wiki
@@ -165,8 +163,10 @@ licenses: []
165
163
 
166
164
  post_install_message:
167
165
  rdoc_options:
166
+ - --main
167
+ - README.rdoc
168
168
  - --title
169
- - YUI-Compressor Extension (0.0.2)
169
+ - YUI-Compressor Extension (0.0.3)
170
170
  - --quiet
171
171
  require_paths:
172
172
  - lib
@@ -196,9 +196,10 @@ rubyforge_project: yui-compressor-ext
196
196
  rubygems_version: 1.3.7
197
197
  signing_key:
198
198
  specification_version: 3
199
- summary: YUI Compressor Extensions is an enhancing library of YUI Compressor
199
+ summary: YUI Compressor Extension is an enhancing library of YUI Compressor
200
200
  test_files:
201
201
  - test/cli/commands/test_all.rb
202
202
  - test/cli/commands/test_css.rb
203
203
  - test/cli/commands/test_js.rb
204
+ - test/test_config.rb
204
205
  - test/test_helper.rb