cjoiner is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
cjoiner is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with cjoiner. If not, see http://www.gnu.org/licenses/.
cjoiner
Join css, js or other text files and create a versioned file. It also supports compression.
For now cjoiner is designed to work with javascript using sprockets v.1.0.2 and css using sass, also you can join files using a yaml to define sources.
Author
Alejandro El Informático
Installation
$ [sudo] gem install cjoiner
Usage
As CLI tool
cjoiner will use pwd as a primary path and will look for config.yaml file if no config_file is passed as argument.
$ cjoiner [config_file]
As a library
require 'cjoiner'
Using an object:
cjoiner = Cjoiner::Joiner.new data
cjoiner.proccess!
Using the yaml file:
cjoiner = Cjoiner::Joiner.new
cjoiner.load_config! 'config.yaml'
cjoiner.proccess!
Configuration file
This is the skeleton for the configuration file or the data object:
config.yaml
-
config: configuration wrapper-
compress: {boolean} set compression for all files -
yui: {string} the yui-compressor java file to use if wanted -
munge: {boolean} short the variable names for js files -
charset: {string} set the charset -
debug: {boolean} save a file without compression, just all the concatenation -
debug_suffix: {string} suffix for thedebugfile, usuallyname.debug.extension -
common_dependencies: {array} general dependencies array -
common_path: {string} common path for all items -
common_output: {string} common output path for all files - undebugjs : {boolean} remove console statements
- undebugjs_prefix : {string} set the console prefix
-
files: define files-
file: {string} path and name for file (assumingcommon_pathas root) to process, ex:javascripts/all.js-
name: {string} output name -
extension: {string} output extension -
type: {string} file type,sass,jsoryaml, this is optional ascjoinercan guess by the extension - undebugjs : {boolean} remove console statements per file configuration
-
major: {int} major release -
minor: {int} minor release -
bugfix: {int} bugfix number -
compilation: {int} compilation number -
compress: {boolean} set compresion for this file, overrides general compression flag -
debug: {boolean} set debug for this file, overrides general debug flag -
dependencies: {array} custom dependencies array for this file -
output: {string} file output assumingcommon_outputas root
-
-
-
Remove console statements
This option must be activated globally or per-file configuration and only works for uncompressed files. This engine is basically a simple regex that remove all those lines matching console statements.
Also, you can set your own console prefix. for example:
undebugjs_prefix : APP
will remove APP.log([...]), APP.warn([...])...
Join text files
Set file type to yaml and define sources in another yaml file:
files:
- file-1.extension
- file-2.extension
- file-3.extension
Example
$ cjoiner project.yaml
### project.yaml
config :
common_path : /work/project/
common_output : /work/project/output/
undebugjs : true
debug : true
common_dependencies : [
javascripts/src/,
javascripts/src/core/,
javascripts/src/lib/,
sass/
]
files:
javascripts/all.js :
name : all
extension : js
major : 1
minor : 0
bugfix : 0
compilation : 0
output : /javascripts/
sass/css.sass :
type : sass
name : css
extension : css
major : 0
minor : 0
bugfix : 0
compilation : 1
output : /stylesheets/
other.yaml :
name : files
extension : output
major : 1
minor : 1
bugfix : 1
compilation : 1
### all.js (sprockets file)
//= require "lib.js"
//= require "debug.js"
//= require "vendor/plugin.js"
### css.sass (sass file)
@import defines
@import mixins
@import general
### other.yaml (other files)
files:
- file-1.extension
- file-2.extension
- file-3.extension
Will generate two compressed files and two debug files for javascript and sass files, and other file for the other files:
/work/project/output/javascripts/all.1.0.0.0.js/work/project/output/javascripts/all.debug.js/work/project/output/stylesheets/css.1.0.0.0.js/work/project/output/stylesheets/css.debug.js/work/project/output/files.1.1.1.1.output
Requirements
- ruby 1.8.7, 1.9.3
- rubygems > 1.3.7
- gems
- sprockets 1.0.2
- yui-compressor > 0.9.6
- sass > 3.1.4
TODO
- Create tests