coyote 0.2.3 → 0.2.4

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/Rakefile CHANGED
@@ -2,8 +2,8 @@ require 'rubygems'
2
2
  require 'rake'
3
3
  require 'echoe'
4
4
 
5
- Echoe.new('coyote', '0.2.3') do |p|
6
- p.description = "A command-line tool for combining and compressing JS files"
5
+ Echoe.new('coyote', '0.2.4') do |p|
6
+ p.description = "A flexible command-line tool for combining and compressing JS files"
7
7
  p.summary = "Coyote is a command-line tool for combining and compressing JS files. It uses YAML for configuration and the Google Closure Compiler to compilation and compression."
8
8
  p.url = "http://github.com/caseyohara/coyote"
9
9
  p.author = "Casey O'Hara"
data/bin/coyote CHANGED
@@ -10,7 +10,6 @@ require "coyote/generator"
10
10
  require "coyote/output"
11
11
 
12
12
 
13
-
14
13
  options = {}
15
14
  OptionParser.new do |opts|
16
15
  opts.on("-f", "--force", "Force") do |f|
@@ -1,17 +1,22 @@
1
- # Example usage:
1
+ # Example usages:
2
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"
3
+ # Explicitly defining individual files to join
4
+ application:
5
+ compress: true
6
+ output: application.js
7
+ input:
8
+ - application/Application.Data.js
9
+ - application/Application.Controller.js
10
+ - application/Application.Interface.js
11
+
12
+ # Recursively searching and adding
13
+ application_classes:
14
+ compress: false
15
+ output: application.classes.js
16
+ input: application/**/*.class.js
17
+
18
+ # Adding by extension
19
+ jquery:
20
+ compress: true
21
+ output: jquery.plugins.js
22
+ input: jquery/plugins/*.js
@@ -2,13 +2,13 @@
2
2
 
3
3
  Gem::Specification.new do |s|
4
4
  s.name = %q{coyote}
5
- s.version = "0.2.3"
5
+ s.version = "0.2.4"
6
6
 
7
7
  s.required_rubygems_version = Gem::Requirement.new(">= 1.2") if s.respond_to? :required_rubygems_version=
8
8
  s.authors = ["Casey O'Hara"]
9
- s.date = %q{2011-04-30}
9
+ s.date = %q{2011-05-02}
10
10
  s.default_executable = %q{coyote}
11
- s.description = %q{A command-line tool for combining and compressing JS files}
11
+ s.description = %q{A flexible command-line tool for combining and compressing JS files}
12
12
  s.email = %q{casey.ohara@imulus.com}
13
13
  s.executables = ["coyote"]
14
14
  s.extra_rdoc_files = ["bin/coyote", "lib/coyote.rb", "lib/coyote/builder.rb", "lib/coyote/generator.rb", "lib/coyote/output.rb"]
@@ -3,7 +3,7 @@ require 'term/ansicolor'
3
3
  include Term::ANSIColor
4
4
 
5
5
  module Coyote
6
- VERSION = "0.1.0"
6
+ VERSION = "0.2.4"
7
7
  ROOT_PATH = Dir.pwd
8
8
  CONFIG_PATH = File.expand_path(File.dirname(__FILE__) + "/../config")
9
9
  CONFIG_FILENAME = "coyote.yaml"
@@ -5,21 +5,29 @@ module Coyote
5
5
 
6
6
  def initialize(options)
7
7
  @options = options
8
- @config = get_config_or_defaults
8
+ @config = get_config_or_screw_off
9
9
  end
10
10
 
11
11
  def build
12
- if @config && config_defined?
13
- @config.each do |k,v|
14
- input_files = @config[k]['files']
15
- output_filename = @config[k]['output']
12
+ if config_defined?
13
+ @config.each do |key,value|
14
+ input = value['input']
15
+ output_filename = value['output']
16
16
  output = Coyote::Output.new output_filename
17
17
 
18
- input_files.each do |filename|
19
- output.append(filename)
18
+ if input.class == Array
19
+ input.each do |input|
20
+ Dir.glob(input).each do |file|
21
+ output.append file
22
+ end
23
+ end
24
+ elsif input.class == String
25
+ Dir.glob(input).each do |file|
26
+ output.append file
27
+ end
20
28
  end
21
29
 
22
- if @config[k]['compress'] || @options[:compress]
30
+ if value['compress'] || @options[:compress]
23
31
  output.compress
24
32
  end
25
33
 
@@ -31,12 +39,13 @@ module Coyote
31
39
  end
32
40
 
33
41
 
34
- def get_config_or_defaults
42
+ def get_config_or_screw_off
35
43
  if File.exists?(Coyote::CONFIG_FILENAME)
36
- config = begin
37
- YAML.load(File.open(Coyote::CONFIG_FILENAME))
44
+ begin
45
+ return YAML.load(File.open(Coyote::CONFIG_FILENAME))
38
46
  rescue ArgumentError => e
39
47
  print "Could not parse YAML: #{e.message}\n".red
48
+ return false
40
49
  end
41
50
  else
42
51
  print "Could not find a Coyote configuration file in this directory. Use 'coyote generate' to create one.\n".red
@@ -45,7 +54,7 @@ module Coyote
45
54
  end
46
55
 
47
56
  def config_defined?
48
- @config.class == Hash && ! @config.empty?
57
+ @config && @config.class == Hash && ! @config.empty?
49
58
  end
50
59
  end
51
60
  end
@@ -13,13 +13,17 @@ module Coyote
13
13
 
14
14
  # open file, add contents to output
15
15
  def append(filename)
16
- @input_files.push(filename)
17
- File.open(filename, 'r') do |file|
18
- @input += "/***** #{filename} *****/\n"
19
- @input += file.read
20
- @input += "\n\n\n"
16
+ if File.exists?(filename)
17
+ @input_files.push(filename)
18
+ File.open(filename, 'r') do |file|
19
+ @input += "/***** #{filename} *****/\n"
20
+ @input += file.read
21
+ @input += "\n\n\n"
22
+ end
23
+ print "+ Added #{filename}\n"
24
+ else
25
+ print "! Error adding #{filename}\n"
21
26
  end
22
- print "+ Added #{filename}\n"
23
27
  end
24
28
 
25
29
  # save output to file
@@ -27,6 +31,7 @@ module Coyote
27
31
  add_file_comments
28
32
  @output_file.write(@input)
29
33
  print "Saved to #{@output_filename} \n\n".green
34
+ @output_file.close
30
35
  end
31
36
 
32
37
  def add_file_comments
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: coyote
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 0.2.3
5
+ version: 0.2.4
6
6
  platform: ruby
7
7
  authors:
8
8
  - Casey O'Hara
@@ -10,7 +10,7 @@ autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
12
 
13
- date: 2011-04-30 00:00:00 -06:00
13
+ date: 2011-05-02 00:00:00 -06:00
14
14
  default_executable:
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
@@ -57,7 +57,7 @@ dependencies:
57
57
  version: 1.0.5
58
58
  type: :development
59
59
  version_requirements: *id004
60
- description: A command-line tool for combining and compressing JS files
60
+ description: A flexible command-line tool for combining and compressing JS files
61
61
  email: casey.ohara@imulus.com
62
62
  executables:
63
63
  - coyote