bunto-press 0.2.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 8c4d61a0d507ead8ce42f6d3d548ca8b3ab59020
4
+ data.tar.gz: 80bebe28f15e608c88f0e2a009ab6178a7805498
5
+ SHA512:
6
+ metadata.gz: 145425829e927bd9415306ececff72eab60a0a278ac6790203d574ae96608eb1d33ec93e626a93ca264da47aa2d8bc3a090e914c0a3183ac8a91d2d13df2d5c2
7
+ data.tar.gz: 9b7aebda9c428ec953ace1ace91a545ee54fefb78f7bf0497226ffb3bb8f6480b67a4a39758f21eab9ff80e876e777527bb61cdcf1d255732a828333035a2320
data/.gitignore ADDED
@@ -0,0 +1,17 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in bunto-press.gemspec
4
+ gemspec
data/LICENSE ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2012-present Stereobooster
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/Rakefile ADDED
@@ -0,0 +1,2 @@
1
+ #!/usr/bin/env rake
2
+ require "bundler/gem_tasks"
data/Readme.md ADDED
@@ -0,0 +1,71 @@
1
+ # bunto-press
2
+ Minifier plugin for bunto. Minifies all html, js, css files. Simple just drop it in solution. No Java required.
3
+
4
+ This plugin:
5
+ - compress html with the help of [html_press](https://github.com/stereobooster/html_press)
6
+ - compress JavaScript files with the help of [uglifier](https://github.com/lautis/uglifier)
7
+ - compress css files with the help of [css_press](https://github.com/stereobooster/css_press)
8
+
9
+ ## Installation
10
+
11
+ ### Bundler
12
+ Add this line to your application's `Gemfile`:
13
+ ```ruby
14
+ gem 'bunto-press'
15
+ ```
16
+
17
+ And then execute:
18
+ ```bash
19
+ $ bundle
20
+ ```
21
+
22
+ ### Standalone
23
+ Execute:
24
+ ```bash
25
+ $ gem install bunto-press
26
+ ```
27
+
28
+ ## Usage
29
+
30
+ ### With Bundler (recomended)
31
+ Create the following plugin in your projects _plugins directory.
32
+
33
+ ```ruby
34
+ # _plugins/bundler.rb
35
+ require "rubygems"
36
+ require "bundler/setup"
37
+ Bundler.require(:default)
38
+ ```
39
+
40
+ This will automatically require all of the gems specified in your Gemfile.
41
+
42
+ ### Standalone
43
+ Create the following plugin in your projects _plugins directory.
44
+
45
+ ```ruby
46
+ # _plugins/bunto-press-plugin.rb
47
+ require 'bunto-press'
48
+ ```
49
+
50
+ ### Settings
51
+
52
+ ```yaml
53
+ bunto-press:
54
+ exclude: 'atom.xml' # Exclude files from processing - file name, glob pattern or array of file names and glob patterns
55
+ js_options: {} # js minifier options
56
+ css_options: {} # css minifier options
57
+ html_options: {} # html minifier options
58
+ ```
59
+
60
+ ## TODO
61
+ - add test: run against simple bunto site and check if there is no errors
62
+ - Minify JPEGs with [`jpegtran`](/cmer/jpegtran) or `smush.it` ([smusher](/grosser/smusher))
63
+ - Minify PNGs with [`optipng`](/martinkozak/optipng) or `smush.it` ([smusher](/grosser/smusher))
64
+ - Auto CSS sprites (for example [sprite factory](/jakesgordon/sprite-factory/))
65
+
66
+ ## Contributing
67
+ 1. Fork it
68
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
69
+ 3. Commit your changes (`git commit -am 'Added some feature'`)
70
+ 4. Push to the branch (`git push origin my-new-feature`)
71
+ 5. Create new Pull Request
@@ -0,0 +1,25 @@
1
+ # -*- encoding: utf-8 -*-
2
+ require File.expand_path('../lib/bunto-press/version', __FILE__)
3
+
4
+ Gem::Specification.new do |gem|
5
+ gem.authors = ["sterebooster", "Suriyaa Kudo"]
6
+ gem.email = ["stereobooster@gmail.com", "github@suriyaa.tk"]
7
+ gem.description = %q{Minifier plugin for bunto. Minifies all html, js, css files. Simple just drop it in solution. No Java required}
8
+ gem.summary = %q{Minifier plugin for bunto. This plugin compress html with the help of html_press, compress JavaScript files with the help of uglifier, compress css files with the help of css_press}
9
+ gem.homepage = "http://github.com/bunto/bunto-press"
10
+ gem.license = "MIT"
11
+
12
+ gem.files = `git ls-files`.split($\)
13
+ gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
14
+ gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
15
+ gem.name = "bunto-press"
16
+ gem.require_paths = ["lib"]
17
+ gem.version = Bunto::Press::VERSION
18
+
19
+ gem.add_dependency "bunto"
20
+ gem.add_dependency "html_press", ">= 0.8.2"
21
+ gem.add_dependency "multi_css", ">= 0.1.0"
22
+ gem.add_dependency "multi_js", ">= 0.1.0"
23
+
24
+ gem.add_development_dependency "rake"
25
+ end
@@ -0,0 +1,111 @@
1
+ require "bunto-press/version"
2
+
3
+ require 'html_press'
4
+ require 'multi_css'
5
+ require 'multi_js'
6
+
7
+ module Bunto
8
+ module Compressor
9
+ def exclude?(dest, dest_path)
10
+ res = false
11
+ file_name = dest_path.slice(dest.length+1..dest_path.length)
12
+ exclude = @site.config['bunto-press'] && @site.config['bunto-press']['exclude']
13
+ if exclude
14
+ if exclude.is_a? String
15
+ exclude = [exclude]
16
+ end
17
+ exclude.each do |e|
18
+ if e == file_name || File.fnmatch(e, file_name)
19
+ res = true
20
+ break
21
+ end
22
+ end
23
+ end
24
+ res
25
+ end
26
+
27
+ def output_file(dest, content)
28
+ FileUtils.mkdir_p(File.dirname(dest))
29
+ File.open(dest, 'w') do |f|
30
+ f.write(content)
31
+ end
32
+ end
33
+
34
+ def output_html(path, content)
35
+ output_file(path, HtmlPress.press(content, @site.config['bunto-press'] && @site.config['bunto-press']['html_options'] || {}))
36
+ end
37
+
38
+ def output_js(path, content)
39
+ output_file(path, MultiJs.compile(content, @site.config['bunto-press'] && @site.config['bunto-press']['js_options'] || {}))
40
+ rescue MultiJs::ParseError => e
41
+ warn "Warning: parse error in #{path}. Don't panic - copying initial file"
42
+ warn "Details: #{e.message.strip}"
43
+ output_file(path, content)
44
+ end
45
+
46
+ def output_css(path, content)
47
+ output_file(path, MultiCss.min(content, @site.config['bunto-press'] && @site.config['bunto-press']['css_options'] || {}))
48
+ rescue MultiCss::ParseError => e
49
+ warn "Warning: parse error in #{path}. Don't panic - copying initial file"
50
+ warn "Details: #{e.message.strip}"
51
+ output_file(path, content)
52
+ end
53
+ end
54
+
55
+ class Post
56
+ include Compressor
57
+
58
+ def write(dest)
59
+ dest_path = destination(dest)
60
+ output_html(dest_path, output)
61
+ end
62
+ end
63
+
64
+ class Page
65
+ include Compressor
66
+
67
+ def write(dest)
68
+ dest_path = destination(dest)
69
+ if exclude?(dest, dest_path)
70
+ output_file(dest_path, output)
71
+ else
72
+ output_html(dest_path, output)
73
+ end
74
+ end
75
+ end
76
+
77
+ class StaticFile
78
+ include Compressor
79
+
80
+ def copy_file(path, dest_path)
81
+ FileUtils.mkdir_p(File.dirname(dest_path))
82
+ FileUtils.cp(path, dest_path)
83
+ end
84
+
85
+ def write(dest)
86
+ dest_path = destination(dest)
87
+
88
+ return false if File.exist?(dest_path) and !modified?
89
+ @@mtimes[path] = mtime
90
+
91
+ case File.extname(dest_path)
92
+ when '.js'
93
+ if dest_path =~ /.min.js$/
94
+ copy_file(path, dest_path)
95
+ else
96
+ output_js(dest_path, File.read(path))
97
+ end
98
+ when '.css'
99
+ if dest_path =~ /.min.css$/
100
+ copy_file(path, dest_path)
101
+ else
102
+ output_css(dest_path, File.read(path))
103
+ end
104
+ else
105
+ copy_file(path, dest_path)
106
+ end
107
+
108
+ true
109
+ end
110
+ end
111
+ end
@@ -0,0 +1,5 @@
1
+ module Bunto
2
+ module Press
3
+ VERSION = "0.2.1"
4
+ end
5
+ end
metadata ADDED
@@ -0,0 +1,127 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: bunto-press
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.2.1
5
+ platform: ruby
6
+ authors:
7
+ - sterebooster
8
+ - Suriyaa Kudo
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2017-08-07 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: bunto
16
+ requirement: !ruby/object:Gem::Requirement
17
+ requirements:
18
+ - - ">="
19
+ - !ruby/object:Gem::Version
20
+ version: '0'
21
+ type: :runtime
22
+ prerelease: false
23
+ version_requirements: !ruby/object:Gem::Requirement
24
+ requirements:
25
+ - - ">="
26
+ - !ruby/object:Gem::Version
27
+ version: '0'
28
+ - !ruby/object:Gem::Dependency
29
+ name: html_press
30
+ requirement: !ruby/object:Gem::Requirement
31
+ requirements:
32
+ - - ">="
33
+ - !ruby/object:Gem::Version
34
+ version: 0.8.2
35
+ type: :runtime
36
+ prerelease: false
37
+ version_requirements: !ruby/object:Gem::Requirement
38
+ requirements:
39
+ - - ">="
40
+ - !ruby/object:Gem::Version
41
+ version: 0.8.2
42
+ - !ruby/object:Gem::Dependency
43
+ name: multi_css
44
+ requirement: !ruby/object:Gem::Requirement
45
+ requirements:
46
+ - - ">="
47
+ - !ruby/object:Gem::Version
48
+ version: 0.1.0
49
+ type: :runtime
50
+ prerelease: false
51
+ version_requirements: !ruby/object:Gem::Requirement
52
+ requirements:
53
+ - - ">="
54
+ - !ruby/object:Gem::Version
55
+ version: 0.1.0
56
+ - !ruby/object:Gem::Dependency
57
+ name: multi_js
58
+ requirement: !ruby/object:Gem::Requirement
59
+ requirements:
60
+ - - ">="
61
+ - !ruby/object:Gem::Version
62
+ version: 0.1.0
63
+ type: :runtime
64
+ prerelease: false
65
+ version_requirements: !ruby/object:Gem::Requirement
66
+ requirements:
67
+ - - ">="
68
+ - !ruby/object:Gem::Version
69
+ version: 0.1.0
70
+ - !ruby/object:Gem::Dependency
71
+ name: rake
72
+ requirement: !ruby/object:Gem::Requirement
73
+ requirements:
74
+ - - ">="
75
+ - !ruby/object:Gem::Version
76
+ version: '0'
77
+ type: :development
78
+ prerelease: false
79
+ version_requirements: !ruby/object:Gem::Requirement
80
+ requirements:
81
+ - - ">="
82
+ - !ruby/object:Gem::Version
83
+ version: '0'
84
+ description: Minifier plugin for bunto. Minifies all html, js, css files. Simple just
85
+ drop it in solution. No Java required
86
+ email:
87
+ - stereobooster@gmail.com
88
+ - github@suriyaa.tk
89
+ executables: []
90
+ extensions: []
91
+ extra_rdoc_files: []
92
+ files:
93
+ - ".gitignore"
94
+ - Gemfile
95
+ - LICENSE
96
+ - Rakefile
97
+ - Readme.md
98
+ - bunto-press.gemspec
99
+ - lib/bunto-press.rb
100
+ - lib/bunto-press/version.rb
101
+ homepage: http://github.com/bunto/bunto-press
102
+ licenses:
103
+ - MIT
104
+ metadata: {}
105
+ post_install_message:
106
+ rdoc_options: []
107
+ require_paths:
108
+ - lib
109
+ required_ruby_version: !ruby/object:Gem::Requirement
110
+ requirements:
111
+ - - ">="
112
+ - !ruby/object:Gem::Version
113
+ version: '0'
114
+ required_rubygems_version: !ruby/object:Gem::Requirement
115
+ requirements:
116
+ - - ">="
117
+ - !ruby/object:Gem::Version
118
+ version: '0'
119
+ requirements: []
120
+ rubyforge_project:
121
+ rubygems_version: 2.6.12
122
+ signing_key:
123
+ specification_version: 4
124
+ summary: Minifier plugin for bunto. This plugin compress html with the help of html_press,
125
+ compress JavaScript files with the help of uglifier, compress css files with the
126
+ help of css_press
127
+ test_files: []