cjoiner 1.5.2 → 1.6.0
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +16 -0
- data/example/config.yaml +2 -0
- data/lib/cjoiner/engine.rb +1 -0
- data/lib/cjoiner/engines/jsjoiner.rb +23 -0
- data/lib/cjoiner/engines/undebugjs.rb +49 -0
- data/lib/cjoiner/version.rb +1 -1
- data/lib/cjoiner.rb +27 -11
- metadata +61 -79
data/README.md
CHANGED
@@ -63,11 +63,14 @@ This is the skeleton for the configuration file or the data object:
|
|
63
63
|
* `common_dependencies`: _{array}_ general dependencies array
|
64
64
|
* `common_path`: _{string}_ common path for all items
|
65
65
|
* `common_output`: _{string}_ common output path for all files
|
66
|
+
* undebugjs : _{boolean}_ remove _console_ statements
|
67
|
+
* undebugjs_prefix : _{string}_ set the _console_ prefix
|
66
68
|
* `files`: define files
|
67
69
|
* `file`: _{string}_ path and name for file (assuming `common_path` as root) to process, ex: `javascripts/all.js`
|
68
70
|
* `name`: _{string}_ output name
|
69
71
|
* `extension`: _{string}_ output extension
|
70
72
|
* `type`: _{string}_ file type, `sass`, `js` or `yaml`, this is optional as `cjoiner` can guess by the extension
|
73
|
+
* undebugjs : _{boolean}_ remove _console_ statements per file configuration
|
71
74
|
* `major`: _{int}_ major release
|
72
75
|
* `minor`: _{int}_ minor release
|
73
76
|
* `bugfix`: _{int}_ bugfix number
|
@@ -77,6 +80,18 @@ This is the skeleton for the configuration file or the data object:
|
|
77
80
|
* `dependencies`: _{array}_ custom dependencies array for this file
|
78
81
|
* `output`: _{string}_ file output assuming `common_output` as root
|
79
82
|
|
83
|
+
##### Remove _console_ statements
|
84
|
+
This option must be activated globally or per-file configuration and only works for uncompressed files.
|
85
|
+
This _engine_ is basically a simple _regex_ that remove all those lines matching [console statements](https://developers.google.com/chrome-developer-tools/docs/console-api).
|
86
|
+
|
87
|
+
Also, you can set your own _console_ prefix. for example:
|
88
|
+
|
89
|
+
```
|
90
|
+
undebugjs_prefix : APP
|
91
|
+
```
|
92
|
+
|
93
|
+
will remove `APP.log([...])`, `APP.warn([...])`...
|
94
|
+
|
80
95
|
##### Join text files
|
81
96
|
Set file type to `yaml` and define sources in another `yaml` file:
|
82
97
|
|
@@ -93,6 +108,7 @@ Set file type to `yaml` and define sources in another `yaml` file:
|
|
93
108
|
config :
|
94
109
|
common_path : /work/project/
|
95
110
|
common_output : /work/project/output/
|
111
|
+
undebugjs : true
|
96
112
|
debug : true
|
97
113
|
common_dependencies : [
|
98
114
|
javascripts/src/,
|
data/example/config.yaml
CHANGED
data/lib/cjoiner/engine.rb
CHANGED
@@ -1,5 +1,28 @@
|
|
1
1
|
require 'sprockets'
|
2
2
|
|
3
|
+
#NOTE: underscore.js interpolation hash(<%=(.*?)%>) conflicts with Sprockets
|
4
|
+
# and raises UndefinedConstantError.
|
5
|
+
#
|
6
|
+
# In order to avoid this behavior I just avoid the raise statement
|
7
|
+
# and always return the value
|
8
|
+
|
9
|
+
module Sprockets
|
10
|
+
class SourceLine
|
11
|
+
protected
|
12
|
+
def interpolate_constants!(result, constants)
|
13
|
+
result.gsub!(/<%=(.*?)%>/) do
|
14
|
+
constant = $1.strip
|
15
|
+
if value = constants[constant]
|
16
|
+
value
|
17
|
+
else
|
18
|
+
puts "WARNING: couldn't find constant `#{constant}' in #{inspect}"
|
19
|
+
"<%=#{constant}%>"
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
3
26
|
module Cjoiner
|
4
27
|
module Engines
|
5
28
|
# engine for js files
|
@@ -0,0 +1,49 @@
|
|
1
|
+
module Cjoiner
|
2
|
+
module Engines
|
3
|
+
# eliminates js debug statements
|
4
|
+
class UndebugJS < Cjoiner::Engines::Engine
|
5
|
+
def initialize(opts)
|
6
|
+
@keywords = []
|
7
|
+
set_keywords!
|
8
|
+
@engine = replace(opts[:content], opts[:prefix])
|
9
|
+
end
|
10
|
+
|
11
|
+
def add_keyword(keyword)
|
12
|
+
@keywords << keyword
|
13
|
+
end
|
14
|
+
|
15
|
+
def set_keywords!
|
16
|
+
add_keyword 'assert'
|
17
|
+
add_keyword 'clear'
|
18
|
+
add_keyword 'count'
|
19
|
+
add_keyword 'debug'
|
20
|
+
add_keyword 'dir'
|
21
|
+
add_keyword 'dirxml'
|
22
|
+
add_keyword 'error'
|
23
|
+
add_keyword 'group'
|
24
|
+
add_keyword 'groupCollapsed'
|
25
|
+
add_keyword 'groupEnd'
|
26
|
+
add_keyword 'info'
|
27
|
+
add_keyword 'log'
|
28
|
+
add_keyword 'profile'
|
29
|
+
add_keyword 'profileEnd'
|
30
|
+
add_keyword 'time'
|
31
|
+
add_keyword 'timeEnd'
|
32
|
+
add_keyword 'timeStamp'
|
33
|
+
add_keyword 'trace'
|
34
|
+
add_keyword 'warn'
|
35
|
+
add_keyword 'debugger'
|
36
|
+
add_keyword 'ungroup'
|
37
|
+
end
|
38
|
+
|
39
|
+
protected
|
40
|
+
def replace(str, prefix)
|
41
|
+
output = str
|
42
|
+
@keywords.each do|keyword|
|
43
|
+
output.gsub!(/^(\s*)?#{prefix}\.#{keyword}\(.*\);?\n?/, '')
|
44
|
+
end
|
45
|
+
output
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
data/lib/cjoiner/version.rb
CHANGED
data/lib/cjoiner.rb
CHANGED
@@ -68,6 +68,22 @@ module Cjoiner #:nodoc
|
|
68
68
|
:files => files
|
69
69
|
}).render
|
70
70
|
end
|
71
|
+
|
72
|
+
# save debug file
|
73
|
+
if debug
|
74
|
+
write_file debug_file, concatenation
|
75
|
+
end
|
76
|
+
|
77
|
+
#undebugjs
|
78
|
+
if file_opts["extension"].to_sym == :js
|
79
|
+
if @config["undebugjs"] and file_opts["undebugjs"].nil? or file_opts["undebugjs"]
|
80
|
+
concatenation = Cjoiner::Engines::UndebugJS.new(
|
81
|
+
:prefix => @config['undebugjs_prefix'],
|
82
|
+
:content => concatenation
|
83
|
+
).render
|
84
|
+
end
|
85
|
+
end
|
86
|
+
|
71
87
|
# compress
|
72
88
|
if @config["compress"] and file_opts["compress"].nil? or file_opts["compress"]
|
73
89
|
compressed = Cjoiner::Engines::Compressor.new(
|
@@ -78,12 +94,10 @@ module Cjoiner #:nodoc
|
|
78
94
|
:content => concatenation
|
79
95
|
}).render
|
80
96
|
end
|
81
|
-
|
82
|
-
if debug
|
83
|
-
write_file debug_file, concatenation
|
84
|
-
end
|
97
|
+
|
85
98
|
# save final file
|
86
99
|
write_file output_file, compressed != "" ? compressed : concatenation
|
100
|
+
|
87
101
|
# set custom output
|
88
102
|
if custom_output
|
89
103
|
output = @config["common_output"] ? @config["common_output"] : ""
|
@@ -100,13 +114,15 @@ module Cjoiner #:nodoc
|
|
100
114
|
def initialize(config = {})
|
101
115
|
@config =
|
102
116
|
{
|
103
|
-
"yui"
|
104
|
-
"munge"
|
105
|
-
"charset"
|
106
|
-
"debug"
|
107
|
-
"debug_suffix"
|
108
|
-
"compress"
|
109
|
-
"
|
117
|
+
"yui" => false,
|
118
|
+
"munge" => true,
|
119
|
+
"charset" => 'utf-8',
|
120
|
+
"debug" => false,
|
121
|
+
"debug_suffix" => 'debug',
|
122
|
+
"compress" => false,
|
123
|
+
"undebugjs" => false,
|
124
|
+
"undebugjs_prefix" => 'console',
|
125
|
+
"common_path" => ''
|
110
126
|
}.merge(config)
|
111
127
|
end
|
112
128
|
end
|
metadata
CHANGED
@@ -1,81 +1,72 @@
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
2
|
name: cjoiner
|
3
|
-
version: !ruby/object:Gem::Version
|
4
|
-
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.6.0
|
5
5
|
prerelease:
|
6
|
-
segments:
|
7
|
-
- 1
|
8
|
-
- 5
|
9
|
-
- 2
|
10
|
-
version: 1.5.2
|
11
6
|
platform: ruby
|
12
|
-
authors:
|
13
|
-
-
|
7
|
+
authors:
|
8
|
+
- Alejandro El Informático
|
14
9
|
autorequire:
|
15
10
|
bindir: bin
|
16
11
|
cert_chain: []
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
dependencies:
|
21
|
-
- !ruby/object:Gem::Dependency
|
12
|
+
date: 2013-07-30 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
22
15
|
name: sass
|
23
|
-
|
24
|
-
requirement: &id001 !ruby/object:Gem::Requirement
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
25
17
|
none: false
|
26
|
-
requirements:
|
27
|
-
- -
|
28
|
-
- !ruby/object:Gem::Version
|
29
|
-
hash: 5
|
30
|
-
segments:
|
31
|
-
- 3
|
32
|
-
- 2
|
33
|
-
- 5
|
18
|
+
requirements:
|
19
|
+
- - ! '>='
|
20
|
+
- !ruby/object:Gem::Version
|
34
21
|
version: 3.2.5
|
35
22
|
type: :runtime
|
36
|
-
version_requirements: *id001
|
37
|
-
- !ruby/object:Gem::Dependency
|
38
|
-
name: sprockets
|
39
23
|
prerelease: false
|
40
|
-
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ! '>='
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: 3.2.5
|
30
|
+
- !ruby/object:Gem::Dependency
|
31
|
+
name: sprockets
|
32
|
+
requirement: !ruby/object:Gem::Requirement
|
41
33
|
none: false
|
42
|
-
requirements:
|
43
|
-
- -
|
44
|
-
- !ruby/object:Gem::Version
|
45
|
-
hash: 19
|
46
|
-
segments:
|
47
|
-
- 1
|
48
|
-
- 0
|
49
|
-
- 2
|
34
|
+
requirements:
|
35
|
+
- - '='
|
36
|
+
- !ruby/object:Gem::Version
|
50
37
|
version: 1.0.2
|
51
38
|
type: :runtime
|
52
|
-
version_requirements: *id002
|
53
|
-
- !ruby/object:Gem::Dependency
|
54
|
-
name: yui-compressor
|
55
39
|
prerelease: false
|
56
|
-
|
40
|
+
version_requirements: !ruby/object:Gem::Requirement
|
57
41
|
none: false
|
58
|
-
requirements:
|
59
|
-
- -
|
60
|
-
- !ruby/object:Gem::Version
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
42
|
+
requirements:
|
43
|
+
- - '='
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
version: 1.0.2
|
46
|
+
- !ruby/object:Gem::Dependency
|
47
|
+
name: yui-compressor
|
48
|
+
requirement: !ruby/object:Gem::Requirement
|
49
|
+
none: false
|
50
|
+
requirements:
|
51
|
+
- - ! '>='
|
52
|
+
- !ruby/object:Gem::Version
|
66
53
|
version: 0.9.6
|
67
54
|
type: :runtime
|
68
|
-
|
55
|
+
prerelease: false
|
56
|
+
version_requirements: !ruby/object:Gem::Requirement
|
57
|
+
none: false
|
58
|
+
requirements:
|
59
|
+
- - ! '>='
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: 0.9.6
|
69
62
|
description: Join css and js assets and create a versioned file.
|
70
|
-
email:
|
63
|
+
email:
|
71
64
|
- aeinformatico@gmail.com
|
72
|
-
executables:
|
65
|
+
executables:
|
73
66
|
- cjoiner
|
74
67
|
extensions: []
|
75
|
-
|
76
68
|
extra_rdoc_files: []
|
77
|
-
|
78
|
-
files:
|
69
|
+
files:
|
79
70
|
- .gitignore
|
80
71
|
- Gemfile
|
81
72
|
- README.md
|
@@ -104,43 +95,34 @@ files:
|
|
104
95
|
- lib/cjoiner/engines/css.rb
|
105
96
|
- lib/cjoiner/engines/joiner.rb
|
106
97
|
- lib/cjoiner/engines/jsjoiner.rb
|
98
|
+
- lib/cjoiner/engines/undebugjs.rb
|
107
99
|
- lib/cjoiner/errors.rb
|
108
100
|
- lib/cjoiner/helpers.rb
|
109
101
|
- lib/cjoiner/version.rb
|
110
102
|
- license
|
111
|
-
has_rdoc: true
|
112
103
|
homepage: https://github.com/ainformatico/cjoiner
|
113
104
|
licenses: []
|
114
|
-
|
115
105
|
post_install_message:
|
116
106
|
rdoc_options: []
|
117
|
-
|
118
|
-
require_paths:
|
107
|
+
require_paths:
|
119
108
|
- lib
|
120
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
109
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
121
110
|
none: false
|
122
|
-
requirements:
|
123
|
-
- -
|
124
|
-
- !ruby/object:Gem::Version
|
125
|
-
|
126
|
-
|
127
|
-
- 0
|
128
|
-
version: "0"
|
129
|
-
required_rubygems_version: !ruby/object:Gem::Requirement
|
111
|
+
requirements:
|
112
|
+
- - ! '>='
|
113
|
+
- !ruby/object:Gem::Version
|
114
|
+
version: '0'
|
115
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
130
116
|
none: false
|
131
|
-
requirements:
|
132
|
-
- -
|
133
|
-
- !ruby/object:Gem::Version
|
134
|
-
|
135
|
-
segments:
|
136
|
-
- 0
|
137
|
-
version: "0"
|
117
|
+
requirements:
|
118
|
+
- - ! '>='
|
119
|
+
- !ruby/object:Gem::Version
|
120
|
+
version: '0'
|
138
121
|
requirements: []
|
139
|
-
|
140
122
|
rubyforge_project:
|
141
|
-
rubygems_version: 1.
|
123
|
+
rubygems_version: 1.8.23
|
142
124
|
signing_key:
|
143
125
|
specification_version: 3
|
144
|
-
summary: Simple tool for joining css and js assets and create a versioned file using
|
126
|
+
summary: Simple tool for joining css and js assets and create a versioned file using
|
127
|
+
a yaml file as configuration. Output format is 'filename.0.0.0.0.extension'
|
145
128
|
test_files: []
|
146
|
-
|