densify 0.0.1

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,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: c86ab702fde5c5b4b6e1cb5f78ccc731b6934d9b
4
+ data.tar.gz: 5d6160fb789cfc4430100dd7d4e83d521213ea59
5
+ SHA512:
6
+ metadata.gz: 72792ee7c0b60449c08550eac6031ce92a3ff8db45b1ba1149369c4519176769f7ccfc8daf8029e8599248c653a0ef1e418884121a985f09f81f862e55e7c316
7
+ data.tar.gz: f7e5666e486ce8be743ccff3f5bf8b3f3714ec180eeab823f4a2f44e18ffce1c4a88ab24da54f3bb4db30447e8cc568acbc23961dabe79890881567b8095479f
data/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) <year> <copyright holders>
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
@@ -0,0 +1,65 @@
1
+ #include "densify.h"
2
+ #include <stdio.h>
3
+ #include "ruby.h"
4
+
5
+ static VALUE densify(VALUE mod);
6
+
7
+ void Init_densify() {
8
+ rb_define_method(rb_cString, "densify", RUBY_METHOD_FUNC(densify), 0);
9
+ }
10
+
11
+ static VALUE densify(VALUE self) {
12
+ // Convert ruby string into c string and length
13
+ int length = RSTRING_LEN(self);
14
+ char *string = RSTRING_PTR(self);
15
+
16
+ // set up string to accept characters from ruby string
17
+ char minified[length+1];
18
+ int minified_index = 0; // since the overall length of the original string > length of the minified string
19
+
20
+ int is_in_quotes = 0;
21
+ int is_in_spaces = 0;
22
+
23
+ for (int i = 0; i < length; i++) {
24
+ char curr_char = string[i];
25
+
26
+ // current char is a quote
27
+ if (curr_char == '"' || curr_char == '\'') {
28
+ is_in_quotes = (is_in_quotes == 0)?1:0;
29
+ }
30
+
31
+ // if in quotes, add the character automatically
32
+ if (is_in_quotes == 1) {
33
+ minified[minified_index] = curr_char;
34
+ minified_index++;
35
+ continue;
36
+ }
37
+
38
+ switch (curr_char) {
39
+ case '\n':
40
+ // skip
41
+ // just ignore this character
42
+ break;
43
+ case '\t':
44
+ curr_char = ' ';
45
+ break;
46
+ case ' ':
47
+ // If this is the first space, add the space
48
+ if (is_in_spaces == 0) {
49
+ minified[minified_index] = curr_char;
50
+ minified_index++;
51
+ }
52
+
53
+ // indicate that we are in a series of spaces
54
+ is_in_spaces = 1;
55
+ break;
56
+ default: // this is every other character
57
+ is_in_spaces = 0;
58
+ minified[minified_index] = curr_char;
59
+ minified_index++;
60
+ break;
61
+ }
62
+ }
63
+ minified[minified_index] = '\0'; // don't add anything to the index because it will have been incremented after the last character is appended in the for loop
64
+ return rb_str_new2(minified);
65
+ }
File without changes
@@ -0,0 +1,2 @@
1
+ require "mkmf"
2
+ create_makefile "densify"
metadata ADDED
@@ -0,0 +1,50 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: densify
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Nathaniel Symer
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-04-30 00:00:00.000000000 Z
12
+ dependencies: []
13
+ description: Densify is a general-purpose string minification gem written purely in
14
+ C. It takes mere microseconds (literally) to minify thousands of lines of CSS to
15
+ almost the size other minfiers acheive.
16
+ email: nate@ivytap.com
17
+ executables: []
18
+ extensions:
19
+ - ext/densify/extconf.rb
20
+ extra_rdoc_files: []
21
+ files:
22
+ - LICENSE
23
+ - ext/densify/densify.c
24
+ - ext/densify/densify.h
25
+ - ext/densify/extconf.rb
26
+ homepage: https://github.com/ivytap/densify
27
+ licenses:
28
+ - MIT
29
+ metadata: {}
30
+ post_install_message:
31
+ rdoc_options: []
32
+ require_paths:
33
+ - ext
34
+ required_ruby_version: !ruby/object:Gem::Requirement
35
+ requirements:
36
+ - - ">="
37
+ - !ruby/object:Gem::Version
38
+ version: '0'
39
+ required_rubygems_version: !ruby/object:Gem::Requirement
40
+ requirements:
41
+ - - ">="
42
+ - !ruby/object:Gem::Version
43
+ version: '0'
44
+ requirements: []
45
+ rubyforge_project:
46
+ rubygems_version: 2.2.1
47
+ signing_key:
48
+ specification_version: 4
49
+ summary: Minify strings, lightning fast.
50
+ test_files: []