+ build scripts for crypto.hex

+ reusing ant.project.name as the title for API docs
This commit is contained in:
cbonar 2012-01-26 22:57:59 +01:00
parent ddc0c4464a
commit 30bbf0e743
5 changed files with 221 additions and 0 deletions

View file

@ -5,3 +5,5 @@ codecs/rsa/target
codecs/rsa/.project
tools/yuicompressor-*.jar
tools/ivy-*.jar
codecs/hex/local.properties
codecs/hex/target

View file

@ -0,0 +1,69 @@
########################################
#
# This file is a convenient way to define some parameters,
# rather than from inside the build script.
#
# Depending on the ant targets that will be invoked,
# some properties will be required, some others won't.
#
# Some important properties are marked "required" so you can spot
# the ones to define locally if you want to build this project.
#
# You should not need to override those properties.
# If you really need to, you can create a new file called "local.properties"
# in the same directory and put inside any property you want to fit your local configuration.
#
# Do NOT commit the "local.properties" file to the version control system
# (CVS, SVN, ...) : it should stay as a local configuration only.
# Do not commit or remove this file from the v.c.s. either ;-o
#
# If you don't wish to create such a file, you can pass the required properties
# to ant as command line arguments using the -D option.
#
########################################
basedir=.
# Where the source files are : here Maven-style
src.dir=${basedir}/src/main/javascript
# Where the generated files are going
target.dir=${basedir}/target
# Where the generated libraries are going
lib.dir=${target.dir}/lib
# Where to copy the documentation
doc.dir=${target.dir}/doc
########################################
#
# External programs : you should copy this section to "local.properties"
# and change it for your configuration.
#
########################################
# (convenience) -> set to common 'tools' directory
#tools.dir=../../tools
# JsUnit files
#jsunit.dir=/opt/jsunit
jsunit.coreJs=${jsunit.dir}/app/jsUnitCore.js
#jsunit.build=${jsunit.dir}/build.xml
jsunit.testRunner=${jsunit.dir}/testRunner.html
#jsunit.browsers=/usr/bin/firefox,/usr/bin/konqueror
# Ivy settings
# (required) -> set to Ivy libraries directory (contains all required *.jar)
#ivy.lib.dir=/opt/ivy
#ivy.file = ${basedir}/ivy.xml
#repository.dir=${target}/ivy
# (required) -> define this property in your "local.properties" file
# Full path to the jar of the YUI compressor (http://developer.yahoo.com/yui/compressor)
#yuicompressor.jar=${tools.dir}/yuicompressor-2.4.7.jar
# (required) -> define this property in your "local.properties" file
# Command line to execute JSDoc (http://jsdoc.sourceforge.net)
#jsdoc=${tools.dir}/JSDoc/jsdoc.pl

107
codecs/hex/build.xml Normal file
View file

@ -0,0 +1,107 @@
<!--
Build script for the project "Crypto.Hex".
This script is an Ant script using Ivy extension to resolve dependencies.
You will need both Ant (http://ant.apache.org/) and Ivy (http://ant.apache.org/ivy) to use it.
-->
<project name="Crypto.Hex" default="package" xmlns:ivy="antlib:org.apache.ivy.ant">
<!-- ==================== -->
<!-- Settings -->
<!-- ==================== -->
<!-- default properties, specific to this project -->
<property file="local.properties"/>
<property file="build.properties"/>
<!-- ==================== -->
<!-- Third party tasks -->
<!-- ==================== -->
<path id="ivy.lib.path">
<fileset file="${ant.ivytask.path}" />
</path>
<taskdef resource="org/apache/ivy/ant/antlib.xml" uri="antlib:org.apache.ivy.ant" classpathref="ivy.lib.path"/>
<!-- ==================== -->
<!-- Main targets : they are greatly inspired from the Maven build lifecycle -->
<!-- ==================== -->
<target name="validate" description="Validates the project is correct and all necessary information is available.">
<!-- Retrieves dependencies with ivy : required to initialize the cache and to get informations about the module being built -->
<ivy:retrieve />
<!-- Creates required directories -->
<mkdir dir="${target.dir}" />
</target>
<target name="compile" depends="validate" description="Compiles the source code of the project.">
<!-- nothing more to do -->
</target>
<target name="test" depends="compile" description="Tests the compiled source code using a suitable unit testing framework. These tests should not require the code be packaged or deployed.">
<!-- nothing more to do -->
</target>
<target name="package" depends="build-src, build-min, test, doc" description="Takes the compiled code and package it in its distributable format, such as a JAR.">
<!-- nothing more to do -->
</target>
<target name="integration-test" depends="package" description="Processes and deploys the package if necessary into an environment where integration tests can be run.">
<!-- nothing more to do -->
</target>
<target name="verify" depends="integration-test" description="Runs any checks to verify the package is valid and meets quality criteria.">
<!-- nothing more to do -->
</target>
<target name="install" depends="verify" description="Installs the package into the local repository, for use as a dependency in other projects locally.">
<!-- 'local' resolver is a default one bundled with Ivy -->
<!-- 'artifactspattern' must match the name of the files this script builds -->
<ivy:publish resolver="local" srcivypattern="ivy.xml" artifactspattern="${lib.dir}/[artifact]-[revision].[ext]" overwrite="true" forcedeliver="true" />
<!--<echo message="Published to default local Ivy repository." />-->
</target>
<target name="deploy" depends="verify" description="Done in an integration or release environment, copies the final package to the remote repository for sharing with other developers and projects.">
<!-- nothing more to do -->
</target>
<target name="clean" description="Cleans this project.">
<delete includeemptydirs="true" dir="${target.dir}"/>
</target>
<!-- ==================== -->
<!-- Some more specific targets -->
<!-- ==================== -->
<target name="doc" depends="validate" description="Generates developer documentation.">
<!-- Generates a report of dependencies -->
<ivy:report todir="${doc.dir}/ivy"/>
<!-- Generates the API doc -->
<exec command="${jsdoc}" failonerror="true">
<arg value="-d"/> <arg value="${doc.dir}/api"/>
<arg value="--no-lexical-privates"/>
<arg value="--package-naming"/>
<arg value="--nested-file-naming"/>
<arg line="--project-name ${ant.project.name}"/>
<arg value="${src.dir}"/>
</exec>
<echo message="Done generating doc." />
</target>
<target name="build-src" depends="validate" description="Builds the default .js.">
<copy file="${src.dir}/hex.js" tofile="${lib.dir}/hex-${ivy.revision}.js" />
<echo message="Copied : ${lib.dir}/hex-${ivy.revision}.js" />
</target>
<target name="build-min" depends="validate" description="Builds a minified version of the .js.">
<java jar="${yuicompressor.jar}" fork="true" output="${lib.dir}/hex-min-${ivy.revision}.js" failonerror="true">
<arg line="--type js" />
<arg file="${src.dir}/hex.js"/>
</java>
<echo message="Minified : ${lib.dir}/hex-min-${ivy.revision}.js" />
</target>
</project>

21
codecs/hex/ivy.xml Normal file
View file

@ -0,0 +1,21 @@
<ivy-module version="2.0">
<info organisation="crypto" module="hex" revision="1.0.0" status="integration">
<ivyauthor name="Nicolas BONARDELLE" url="http://nicobo.net/contact?subject=crypto+hex+ivy"/>
<description homepage="http://code.google.com/p/ciform">
This library provides conversion functions from/to hexadecimal format.
</description>
</info>
<configurations>
<!-- The source script as plain text, including all inner informations and comments. -->
<conf name="source"/>
<!-- An obfuscated, size-reduced version of the script. Use to speed up loading time in final environment. -->
<conf name="minified"/>
</configurations>
<publications>
<artifact name="hex" type="js" conf="source"/>
<artifact name="hex-min" type="js" conf="minified"/>
</publications>
<dependencies>
<!-- no dependency required -->
</dependencies>
</ivy-module>

View file

@ -1,3 +1,13 @@
//
// NOTE : The original code is wrapped so that the defined functions don't collide with existing ones.
// See http://michaux.ca/articles/javascript-namespacing.
//
Crypto_Hex = (function() {
//
// START OF ORIGINAL CODE
//
/*
* conversion functions:
@ -74,3 +84,15 @@ function hex2s(hex)
return r;
}
//
// END OF ORIGINAL CODE
//
return {
s2b: s2b,
b2s: b2s,
s2hex: s2hex,
hex2s: hex2s
};
})();