Skip to content
Browse files

Added Grunt

  • Loading branch information...
1 parent 6db61f1 commit 4c96708757cb182300c31ec4a0b9357434ef2e58 @Wildhoney committed Nov 5, 2013
Showing with 60 additions and 5 deletions.
  1. +26 −0 .jshintrc
  2. +31 −0 Gruntfile.js
  3. +2 −0 dist/cloud-convert.min.js
  4. +1 −1 package.json
  5. +0 −1 packages/CloudConvert.js
  6. +0 −3 test.php
View
26 .jshintrc
@@ -0,0 +1,26 @@
+{
+ "camelcase" : true,
+ "curly" : true,
+ "eqeqeq" : true,
+ "forin" : true,
+ "immed" : true,
+ "latedef" : true,
+ "newcap" : true,
+ "noarg" : true,
+ "strict" : true,
+ "trailing" : true,
+ "undef" : false,
+ "unused" : true,
+ "maxparams" : 10,
+ "maxdepth" : 5,
+ "maxstatements" : 25,
+ "maxcomplexity" : 10,
+
+ "asi" : true,
+ "eqnull" : true,
+ "funcscope" : true,
+ "sub" : true,
+
+ "browser" : true,
+ "jquery" : true
+}
View
31 Gruntfile.js
@@ -0,0 +1,31 @@
+module.exports = function(grunt) {
+
+ // Project configuration.
+ grunt.initConfig({
+
+ pkg: grunt.file.readJSON('package.json'),
+ jshint: {
+ all: ['packages/CloudConvert.js'],
+ options: {
+ jshintrc: '.jshintrc'
+ }
+ },
+ uglify: {
+ options: {
+ banner: '/*! <%= pkg.name %> by <%= pkg.author %> created on <%= grunt.template.today("yyyy-mm-dd") %> */\n'
+ },
+ build: {
+ src: ['packages/CloudConvert.js'],
+ dest: 'dist/<%= pkg.name %>.min.js'
+ }
+ }
+ });
+
+ grunt.loadNpmTasks('grunt-contrib-uglify');
+ grunt.loadNpmTasks('grunt-contrib-jshint');
+
+ grunt.registerTask('test', ['jshint']);
+ grunt.registerTask('build', ['uglify']);
+ grunt.registerTask('default', ['uglify', 'jshint']);
+
+};
View
2 dist/cloud-convert.min.js
@@ -0,0 +1,2 @@
+/*! cloud-convert by Adam Timberlake <adam.timberlake@gmail.com> created on 2013-11-05 */
+!function(a){"use strict";var b=require("fs"),c=require("js-yaml"),d=require("util"),e=require("request"),f=require("q"),g=require("mime"),h=require("restler"),i=function(){};i.prototype={urlProcess:"https://api.cloudconvert.org/process?inputformat=%s&outputformat=%s&apikey=%s",urlActions:{"delete":"delete",cancel:"cancel"},details:{file:null,from:null,into:null},task:{id:null,url:null},apiKey:"",defaultInterval:2500,callbacks:{uploading:null,uploaded:null,converting:null,finished:null},when:function(a,b,c){this.callbacks[a]={method:b,interval:c||this.defaultInterval}},convert:function(a){return this.details.file=a,this},from:function(a){return this.details.from=a,this},into:function(a){return this.details.into=a,this},process:function(){var a=this;b.readFile(__dirname+"/config.yaml","utf-8",function(b,d){a.apiKey=c.load(d).apiKey,a._convert.apply(a)})},_convert:function(){var a=d.format(this.urlProcess,this.details.from,this.details.into,this.apiKey),c=this;this._getContent(a).then(function(a){var b=f.defer();return"id"in a&&(c.task.id=a.id,c.task.url=d.format("https:%s",a.url),b.resolve()),b.reject(),b.promise}).then(function(){b.stat(c.details.file,function(a,b){var d=g.lookup(c.details.file),e=b.size;c.callbacks.uploading.method();var f={rejectUnauthorized:!1,multipart:!0,data:{input:"upload",file:h.file(c.details.file,null,e,null,d),outputformat:c.details.into}};h.post(c.task.url,f).on("complete",function(a){c.callbacks.uploaded.method(a);var b=setInterval(function(){c._getContent(c.task.url).then(function(a){return"finished"===a.step?(c.callbacks.finished.method(a),clearInterval(b),void 0):(c.callbacks.converting.method(a),void 0)})},c.callbacks.converting.interval)})})})},_getContent:function(a){var b=f.defer(),c={url:a,strictSSL:!1};return e(c,function(a,c,d){return a&&200!==c.statusCode?b.reject(a):b.resolve(JSON.parse(d))}),b.promise}},a.exports=i}(module);
View
2 package.json
@@ -1,5 +1,5 @@
{
- "name": "CloudConvert",
+ "name": "cloud-convert",
"version": "0.0.1",
"description": "Easy-to-use Node.js implementation of the CloudConvert API.",
"main": "index.js",
View
1 packages/CloudConvert.js
@@ -7,7 +7,6 @@
yaml = require('js-yaml'),
util = require('util'),
request = require('request'),
- https = require('https'),
q = require('q'),
mime = require('mime'),
restler = require('restler');
View
3 test.php
@@ -1,3 +0,0 @@
-<?php
-
-print_r($_FILES);

0 comments on commit 4c96708

Please sign in to comment.
Something went wrong with that request. Please try again.