minifier 0.0.0

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.
checksums.yaml ADDED
@@ -0,0 +1,15 @@
1
+ ---
2
+ !binary "U0hBMQ==":
3
+ metadata.gz: !binary |-
4
+ MmQ3YTU4MTEzYjA3ZWY5NzgxODczYmVkZDY3MDJhNzQ2ZDI0ZGQzYg==
5
+ data.tar.gz: !binary |-
6
+ NGZlYWRiZDNlOGE4MTllMjU2Njk1MDNiYWIwNTFlNDRiOGVmMDY1Ng==
7
+ SHA512:
8
+ metadata.gz: !binary |-
9
+ NjE0ZDAxNzRiZmFjYzNiY2M2MGNkZGU2NDE2NzgzZDgyODA1MzFiZTgzNzgw
10
+ MDRjYTU0ZGI3YzdiNzE2MWM5YTA3ZTNhYzMzMjU0Mjc0NTdhODU3NzQyYzQ1
11
+ MzU1ZTI5ZjI4MTkwOGZiYjEyMjE0NWMxOTliMGM1ZjMxNTFlZjU=
12
+ data.tar.gz: !binary |-
13
+ NzBkMWM3ZTAzNWFlZWVhZTE1MjZmNzIyYzA1NjY2ZmVjMmRkNGRkMzUxYjU5
14
+ MGQ5ZGNjMmJmMTJkNDgwNGRhMGI5YTcwOWQyNWZjNmUyZTJkNzI3NjRiZjBh
15
+ ZTE3ZmYzMGJiYjg0ZTJhZjJiZmFjNWNhNDZmNWU4YjhlMTVjZTg=
data/lib/minifier.rb ADDED
@@ -0,0 +1,2 @@
1
+ #version 0.0.0
2
+ require_relative 'minifier/minifier.rb'
@@ -0,0 +1,45 @@
1
+ #minifies a CSS file
2
+ module Minifier
3
+
4
+ # Reads file from input and returns a string with stripped file
5
+ # potentially specify languages in later versions?
6
+ def self.minify(input)
7
+ #get file
8
+ file = (input.is_a?(IO)) ? input.read : input.dup.to_s
9
+ #comment removal
10
+ file = file.gsub(/\/*\*[\s\S]*?\*\/*/, '')
11
+
12
+ #whitespace removal
13
+ file = file.gsub(/\s+/, ' ')
14
+
15
+ #add semicolons (but prevent redundant)
16
+ file = file.gsub(/([^;\}])\}/, '\1;}')
17
+ file = file.gsub(/;+\}/, '}')
18
+
19
+ #RGB values to hex values (for css) - thanks to StackOverflow
20
+ file = file.gsub(/rgb\s*\(\s*([0-9,\s]+)\s*\)/) do |match|
21
+ '#' << $1.scan(/\d+/).map{|n| n.to_i.to_s(16).rjust(2, '0') }.join
22
+ end
23
+
24
+ # Replace 0(% ...) with just 0 (first two elements)
25
+ file = file.gsub(/([\s:])([+-]?0)(?:%|em|ex|px|in|cm|mm)/i, '\1\2') #take out the last part
26
+
27
+ file.strip
28
+ end
29
+
30
+ #returns a file containing the minified object
31
+ def self.make_file(minified)
32
+ file = StringIO.new(minified)
33
+ return file
34
+ end
35
+
36
+ #testing for other languages
37
+ def self.strip_comments(markers = ['#','//'] )
38
+ re = Regexp.union( markers ) # construct a regular expression which will match any of the markers
39
+ if index = (self =~ re)
40
+ self[0, index].rstrip # slice the string where the regular expression matches, and return it.
41
+ else
42
+ rstrip
43
+ end
44
+ end
45
+ end
metadata ADDED
@@ -0,0 +1,60 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: minifier
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.0
5
+ platform: ruby
6
+ authors:
7
+ - manan
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-06-24 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: rake
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ! '>='
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ! '>='
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ description: ! 'Minifier utility to compress large files. Currently works solely on
28
+ converting CSS to .min.css files. '
29
+ email: manan.shah.777@gmail.com
30
+ executables: []
31
+ extensions: []
32
+ extra_rdoc_files: []
33
+ files:
34
+ - lib/minifier.rb
35
+ - lib/minifier/minifier.rb
36
+ homepage: https://github.com/mananshah99/minifier
37
+ licenses:
38
+ - Apache
39
+ metadata: {}
40
+ post_install_message:
41
+ rdoc_options: []
42
+ require_paths:
43
+ - lib
44
+ required_ruby_version: !ruby/object:Gem::Requirement
45
+ requirements:
46
+ - - ! '>='
47
+ - !ruby/object:Gem::Version
48
+ version: 1.9.0
49
+ required_rubygems_version: !ruby/object:Gem::Requirement
50
+ requirements:
51
+ - - ! '>='
52
+ - !ruby/object:Gem::Version
53
+ version: '0'
54
+ requirements: []
55
+ rubyforge_project:
56
+ rubygems_version: 2.3.0
57
+ signing_key:
58
+ specification_version: 4
59
+ summary: Minifier utility for CSS files
60
+ test_files: []