coyote 0.2.0
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.
- data/Manifest +8 -0
- data/Rakefile +13 -0
- data/bin/coyote +31 -0
- data/config/coyote.yaml +17 -0
- data/coyote.gemspec +37 -0
- data/lib/coyote.rb +10 -0
- data/lib/coyote/builder.rb +50 -0
- data/lib/coyote/generator.rb +34 -0
- data/lib/coyote/output.rb +37 -0
- metadata +90 -0
data/Manifest
ADDED
data/Rakefile
ADDED
@@ -0,0 +1,13 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'rake'
|
3
|
+
require 'echoe'
|
4
|
+
|
5
|
+
Echoe.new('coyote', '0.2.0') do |p|
|
6
|
+
p.description = "A command-line gem to combine multiple files"
|
7
|
+
p.url = "http://github.com/caseyohara/coyote"
|
8
|
+
p.author = "Casey O'Hara"
|
9
|
+
p.email = "casey.ohara@imulus.com"
|
10
|
+
p.ignore_pattern = ["tmp/*", "script/*"]
|
11
|
+
p.development_dependencies = ["closure-compiler >=1.1.1"]
|
12
|
+
p.runtime_dependencies = ["closure-compiler >=1.1.1"]
|
13
|
+
end
|
data/bin/coyote
ADDED
@@ -0,0 +1,31 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require 'fileutils'
|
4
|
+
require 'rubygems'
|
5
|
+
require 'closure-compiler'
|
6
|
+
require 'optparse'
|
7
|
+
require File.expand_path(File.dirname(__FILE__) + "/../lib/coyote")
|
8
|
+
require "coyote/builder"
|
9
|
+
require "coyote/generator"
|
10
|
+
require "coyote/output"
|
11
|
+
|
12
|
+
|
13
|
+
options = {}
|
14
|
+
OptionParser.new do |opts|
|
15
|
+
opts.on("-f", "--force", "Force") do |f|
|
16
|
+
options[:force] = f
|
17
|
+
end
|
18
|
+
opts.on("-c", "--compress", "Compress") do |c|
|
19
|
+
options[:compress] = c
|
20
|
+
end
|
21
|
+
end.parse!
|
22
|
+
|
23
|
+
|
24
|
+
case ARGV.first
|
25
|
+
when 'generate'
|
26
|
+
Coyote::Generator.new(options).generate
|
27
|
+
else
|
28
|
+
Coyote::Builder.new(options).build
|
29
|
+
end
|
30
|
+
|
31
|
+
|
data/config/coyote.yaml
ADDED
@@ -0,0 +1,17 @@
|
|
1
|
+
# Example usage:
|
2
|
+
|
3
|
+
# application:
|
4
|
+
# compress: false
|
5
|
+
# output: "application.js"
|
6
|
+
# files:
|
7
|
+
# - "application/Application.Data.js"
|
8
|
+
# - "application/Application.Controller.js"
|
9
|
+
# - "application/Application.Interface.js"
|
10
|
+
#
|
11
|
+
# jquery:
|
12
|
+
# compress: true
|
13
|
+
# output: "jquery.plugins.js"
|
14
|
+
# files:
|
15
|
+
# - "jquery/plugins/jquery.cookie.js"
|
16
|
+
# - "jquery/plugins/jquery.cycle.all.min.js"
|
17
|
+
# - "jquery/plugins/jquery.query.js"
|
data/coyote.gemspec
ADDED
@@ -0,0 +1,37 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
|
3
|
+
Gem::Specification.new do |s|
|
4
|
+
s.name = %q{coyote}
|
5
|
+
s.version = "0.2.0"
|
6
|
+
|
7
|
+
s.required_rubygems_version = Gem::Requirement.new(">= 1.2") if s.respond_to? :required_rubygems_version=
|
8
|
+
s.authors = ["Casey O'Hara"]
|
9
|
+
s.date = %q{2011-04-30}
|
10
|
+
s.default_executable = %q{coyote}
|
11
|
+
s.description = %q{A command-line tool for combining and compressing multiple JavaScript files}
|
12
|
+
s.email = %q{casey.ohara@imulus.com}
|
13
|
+
s.executables = ["coyote"]
|
14
|
+
s.extra_rdoc_files = ["bin/coyote", "lib/coyote.rb", "lib/coyote/builder.rb", "lib/coyote/generator.rb", "lib/coyote/output.rb"]
|
15
|
+
s.files = ["Manifest", "Rakefile", "bin/coyote", "config/coyote.yaml", "lib/coyote.rb", "lib/coyote/builder.rb", "lib/coyote/generator.rb", "lib/coyote/output.rb", "coyote.gemspec"]
|
16
|
+
s.homepage = %q{http://github.com/caseyohara/coyote}
|
17
|
+
s.rdoc_options = ["--line-numbers", "--inline-source", "--title", "Coyote"]
|
18
|
+
s.require_paths = ["lib"]
|
19
|
+
s.rubyforge_project = %q{coyote}
|
20
|
+
s.rubygems_version = %q{1.6.2}
|
21
|
+
s.summary = %q{A command-line tool for combining and compressing multiple JavaScript files. Uses YAML to define file paths and compression.}
|
22
|
+
|
23
|
+
if s.respond_to? :specification_version then
|
24
|
+
s.specification_version = 3
|
25
|
+
|
26
|
+
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
27
|
+
s.add_runtime_dependency(%q<closure-compiler>, [">= 1.1.1"])
|
28
|
+
s.add_development_dependency(%q<closure-compiler>, [">= 1.1.1"])
|
29
|
+
else
|
30
|
+
s.add_dependency(%q<closure-compiler>, [">= 1.1.1"])
|
31
|
+
s.add_dependency(%q<closure-compiler>, [">= 1.1.1"])
|
32
|
+
end
|
33
|
+
else
|
34
|
+
s.add_dependency(%q<closure-compiler>, [">= 1.1.1"])
|
35
|
+
s.add_dependency(%q<closure-compiler>, [">= 1.1.1"])
|
36
|
+
end
|
37
|
+
end
|
data/lib/coyote.rb
ADDED
@@ -0,0 +1,50 @@
|
|
1
|
+
module Coyote
|
2
|
+
class Builder
|
3
|
+
|
4
|
+
attr_accessor :config, :options
|
5
|
+
|
6
|
+
def initialize(options)
|
7
|
+
@options = options
|
8
|
+
@config = get_config_or_defaults
|
9
|
+
end
|
10
|
+
|
11
|
+
def build
|
12
|
+
if config_defined?
|
13
|
+
@config.each do |k,v|
|
14
|
+
input_files = @config[k]['files']
|
15
|
+
output_filename = @config[k]['output']
|
16
|
+
output = Coyote::Output.new output_filename
|
17
|
+
|
18
|
+
input_files.each do |filename|
|
19
|
+
output.append(filename)
|
20
|
+
end
|
21
|
+
|
22
|
+
if @config[k]['compress'] || @options[:compress]
|
23
|
+
output.compress
|
24
|
+
end
|
25
|
+
|
26
|
+
output.save
|
27
|
+
end
|
28
|
+
else
|
29
|
+
print "Coyote configuration exists but has not been defined yet. Configure it in #{Coyote::CONFIG_FILENAME}\n".red
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
|
34
|
+
def get_config_or_defaults
|
35
|
+
if File.exists?(Coyote::CONFIG_FILENAME)
|
36
|
+
parsed = begin
|
37
|
+
YAML.load(File.open(Coyote::CONFIG_FILENAME))
|
38
|
+
rescue ArgumentError => e
|
39
|
+
print "Could not parse YAML: #{e.message}\n".red
|
40
|
+
end
|
41
|
+
else
|
42
|
+
print "Could not find a Coyote configuration file in this directory.\n\n Use 'coyote generate' to create one.\n".red
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
def config_defined?
|
47
|
+
@config.class == Hash && ! @config.empty?
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
@@ -0,0 +1,34 @@
|
|
1
|
+
module Coyote
|
2
|
+
class Generator
|
3
|
+
|
4
|
+
attr_accessor :options
|
5
|
+
|
6
|
+
def initialize(options)
|
7
|
+
@options = options
|
8
|
+
end
|
9
|
+
|
10
|
+
def generate
|
11
|
+
if config_exists? && ! options[:force]
|
12
|
+
print "Coyote config already exists in this directory. Use --force to overwrite.\n".red
|
13
|
+
elsif (!config_exists?) || (config_exists? && options[:force])
|
14
|
+
copy_config
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
# check to see if coyote.yaml already exists in directory
|
19
|
+
def config_exists?
|
20
|
+
File.exists?(Coyote::CONFIG_FILENAME)
|
21
|
+
end
|
22
|
+
|
23
|
+
# copy sample coyote.yaml to directory
|
24
|
+
def copy_config
|
25
|
+
print "\n----- Generating Coyote\n".bold
|
26
|
+
File.open("#{Coyote::CONFIG_PATH}/#{Coyote::CONFIG_FILENAME}") do |file|
|
27
|
+
output_file = File.open(Coyote::CONFIG_FILENAME, 'w+')
|
28
|
+
output_file.write(file.read)
|
29
|
+
end
|
30
|
+
print "+ Coyote config generated at #{Coyote::CONFIG_FILENAME}\n"
|
31
|
+
print "Coyote generated \n\n".green
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
@@ -0,0 +1,37 @@
|
|
1
|
+
module Coyote
|
2
|
+
class Output
|
3
|
+
|
4
|
+
attr_accessor :input, :output_file, :output_filename
|
5
|
+
|
6
|
+
def initialize(output_filename)
|
7
|
+
@output_filename = output_filename
|
8
|
+
@output_file = File.open(@output_filename, 'w+')
|
9
|
+
@input = ""
|
10
|
+
print "\n----- Creating #{@output_filename}\n".bold
|
11
|
+
end
|
12
|
+
|
13
|
+
# open file, add contents to output
|
14
|
+
def append(filename)
|
15
|
+
File.open(filename, 'r') do |file|
|
16
|
+
@input += "/***** #{filename} *****/\n"
|
17
|
+
@input += file.read
|
18
|
+
@input += "\n\n\n"
|
19
|
+
end
|
20
|
+
print "+ Added #{filename}\n"
|
21
|
+
end
|
22
|
+
|
23
|
+
# save output to file
|
24
|
+
def save
|
25
|
+
@output_file.write(@input)
|
26
|
+
print "Saved to #{@output_filename} \n\n".green
|
27
|
+
end
|
28
|
+
|
29
|
+
# compress output
|
30
|
+
def compress
|
31
|
+
print "Compiling #{@output_filename}...\n"
|
32
|
+
@input = Closure::Compiler.new.compile(@input)
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
|
metadata
ADDED
@@ -0,0 +1,90 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: coyote
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
prerelease:
|
5
|
+
version: 0.2.0
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Casey O'Hara
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
|
13
|
+
date: 2011-04-30 00:00:00 Z
|
14
|
+
dependencies:
|
15
|
+
- !ruby/object:Gem::Dependency
|
16
|
+
name: closure-compiler
|
17
|
+
prerelease: false
|
18
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
19
|
+
none: false
|
20
|
+
requirements:
|
21
|
+
- - ">="
|
22
|
+
- !ruby/object:Gem::Version
|
23
|
+
version: 1.1.1
|
24
|
+
type: :runtime
|
25
|
+
version_requirements: *id001
|
26
|
+
- !ruby/object:Gem::Dependency
|
27
|
+
name: closure-compiler
|
28
|
+
prerelease: false
|
29
|
+
requirement: &id002 !ruby/object:Gem::Requirement
|
30
|
+
none: false
|
31
|
+
requirements:
|
32
|
+
- - ">="
|
33
|
+
- !ruby/object:Gem::Version
|
34
|
+
version: 1.1.1
|
35
|
+
type: :development
|
36
|
+
version_requirements: *id002
|
37
|
+
description: A command-line tool for combining and compressing multiple JavaScript files
|
38
|
+
email: casey.ohara@imulus.com
|
39
|
+
executables:
|
40
|
+
- coyote
|
41
|
+
extensions: []
|
42
|
+
|
43
|
+
extra_rdoc_files:
|
44
|
+
- bin/coyote
|
45
|
+
- lib/coyote.rb
|
46
|
+
- lib/coyote/builder.rb
|
47
|
+
- lib/coyote/generator.rb
|
48
|
+
- lib/coyote/output.rb
|
49
|
+
files:
|
50
|
+
- Manifest
|
51
|
+
- Rakefile
|
52
|
+
- bin/coyote
|
53
|
+
- config/coyote.yaml
|
54
|
+
- lib/coyote.rb
|
55
|
+
- lib/coyote/builder.rb
|
56
|
+
- lib/coyote/generator.rb
|
57
|
+
- lib/coyote/output.rb
|
58
|
+
- coyote.gemspec
|
59
|
+
homepage: http://github.com/caseyohara/coyote
|
60
|
+
licenses: []
|
61
|
+
|
62
|
+
post_install_message:
|
63
|
+
rdoc_options:
|
64
|
+
- --line-numbers
|
65
|
+
- --inline-source
|
66
|
+
- --title
|
67
|
+
- Coyote
|
68
|
+
require_paths:
|
69
|
+
- lib
|
70
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
71
|
+
none: false
|
72
|
+
requirements:
|
73
|
+
- - ">="
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: "0"
|
76
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
77
|
+
none: false
|
78
|
+
requirements:
|
79
|
+
- - ">="
|
80
|
+
- !ruby/object:Gem::Version
|
81
|
+
version: "1.2"
|
82
|
+
requirements: []
|
83
|
+
|
84
|
+
rubyforge_project: coyote
|
85
|
+
rubygems_version: 1.7.2
|
86
|
+
signing_key:
|
87
|
+
specification_version: 3
|
88
|
+
summary: A command-line tool for combining and compressing multiple JavaScript files. Uses YAML to define file paths and compression.
|
89
|
+
test_files: []
|
90
|
+
|