coyote 0.4.2 → 0.5.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,38 +1,38 @@
1
1
  module Coyote
2
2
  class Generator
3
+ attr_accessor :files_found
3
4
 
4
- attr_accessor :options, :files_found
5
-
6
- def initialize(options)
7
- @options = options
5
+ def initialize
8
6
  @files_found = []
9
7
  end
10
8
 
11
9
  def generate
12
- discover_files
13
- if config_exists? && ! options[:force]
14
- Coyote::Notification.new "Coyote config already exists in this directory. Use --force to overwrite.\n", "failure"
15
- elsif (!config_exists?) || (config_exists? && options[:force])
10
+ if config_exists?
11
+ Coyote::Notification.new "This directory is already configured for Coyote.\n", "failure"
12
+ else
13
+ discover_files
16
14
  copy_config
17
15
  end
18
16
  end
19
17
 
20
18
  def discover_files
21
- js_files = File.join("**","*.js")
19
+ js_files = File.join("**","*#{Coyote::JavaScript::EXTENSION}")
20
+ cs_files = File.join("**","*#{Coyote::CoffeeScript::EXTENSION}")
22
21
  Dir.glob(js_files).each do |file|
23
22
  @files_found.push file
24
23
  end
24
+ Dir.glob(cs_files).each do |file|
25
+ @files_found.push file
26
+ end
25
27
  end
26
28
 
27
- # check to see if coyote.yaml already exists in directory
28
29
  def config_exists?
29
30
  File.exists?(Coyote::CONFIG_FILENAME)
30
31
  end
31
32
 
32
- # copy sample coyote.yaml to directory
33
33
  def copy_config
34
34
  Coyote::Notification.new "\nGenerating Coyote\n"
35
- Coyote::Notification.new "#{@files_found.length} JavaScript files discovered\n"
35
+ Coyote::Notification.new "#{@files_found.length} files discovered\n"
36
36
 
37
37
  File.open("#{Coyote::CONFIG_PATH}/#{Coyote::CONFIG_FILENAME}") do |file|
38
38
  output_file = File.open(Coyote::CONFIG_FILENAME, 'w+')
@@ -42,7 +42,7 @@ module Coyote
42
42
  end
43
43
  output_file.write(generated)
44
44
  end
45
-
45
+
46
46
  Coyote::Notification.new "Coyote generated at #{Coyote::CONFIG_FILENAME}\n\n", "success"
47
47
  end
48
48
  end
data/lib/coyote/output.rb CHANGED
@@ -3,15 +3,14 @@ require "rexml/document"
3
3
  module Coyote
4
4
  class Output
5
5
 
6
- attr_accessor :input, :input_files, :output_file, :output_filename, :compress, :hooks
6
+ attr_accessor :input, :input_files, :output_file, :output_filename, :compress
7
7
 
8
- def initialize(output_filename, compress = false, hooks)
8
+ def initialize(output_filename, compress = false)
9
9
  @output_filename = output_filename
10
10
  @output_file = File.open(@output_filename, 'w+')
11
11
  @input_files = []
12
12
  @input = ""
13
13
  @compress = compress
14
- @hooks = Coyote::Hooks.new(hooks)
15
14
  print "\n----- Creating #{@output_filename}\n".bold
16
15
  end
17
16
 
@@ -37,14 +36,10 @@ module Coyote
37
36
 
38
37
  # save output to file
39
38
  def save
40
- @hooks.invoke('before_compress')
41
39
  compress if @compress
42
- @hooks.invoke('after_compress')
43
- @hooks.invoke('before_save')
44
40
  @output_file.write(@input)
45
41
  @output_file.close
46
42
  Coyote::Notification.new "Successfully saved to #{@output_filename}\n", "success"
47
- @hooks.invoke('after_save')
48
43
  end
49
44
 
50
45
  def add_file_comments
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: coyote
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.2
4
+ version: 0.5.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2011-07-25 00:00:00.000000000Z
12
+ date: 2011-08-21 00:00:00.000000000Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: term-ansicolor
16
- requirement: &2169061080 !ruby/object:Gem::Requirement
16
+ requirement: &2168745980 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
@@ -21,10 +21,10 @@ dependencies:
21
21
  version: 1.0.5
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *2169061080
24
+ version_requirements: *2168745980
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: rb-fsevent
27
- requirement: &2169060520 !ruby/object:Gem::Requirement
27
+ requirement: &2168745300 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ! '>='
@@ -32,10 +32,10 @@ dependencies:
32
32
  version: 0.4.0
33
33
  type: :runtime
34
34
  prerelease: false
35
- version_requirements: *2169060520
35
+ version_requirements: *2168745300
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: rb-appscript
38
- requirement: &2169059860 !ruby/object:Gem::Requirement
38
+ requirement: &2168744720 !ruby/object:Gem::Requirement
39
39
  none: false
40
40
  requirements:
41
41
  - - ! '>='
@@ -43,10 +43,10 @@ dependencies:
43
43
  version: 0.6.1
44
44
  type: :runtime
45
45
  prerelease: false
46
- version_requirements: *2169059860
46
+ version_requirements: *2168744720
47
47
  - !ruby/object:Gem::Dependency
48
48
  name: term-ansicolor
49
- requirement: &2169059260 !ruby/object:Gem::Requirement
49
+ requirement: &2168744040 !ruby/object:Gem::Requirement
50
50
  none: false
51
51
  requirements:
52
52
  - - ! '>='
@@ -54,10 +54,10 @@ dependencies:
54
54
  version: 1.0.5
55
55
  type: :development
56
56
  prerelease: false
57
- version_requirements: *2169059260
57
+ version_requirements: *2168744040
58
58
  - !ruby/object:Gem::Dependency
59
59
  name: rb-fsevent
60
- requirement: &2169058660 !ruby/object:Gem::Requirement
60
+ requirement: &2168743420 !ruby/object:Gem::Requirement
61
61
  none: false
62
62
  requirements:
63
63
  - - ! '>='
@@ -65,10 +65,10 @@ dependencies:
65
65
  version: 0.4.0
66
66
  type: :development
67
67
  prerelease: false
68
- version_requirements: *2169058660
68
+ version_requirements: *2168743420
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: rb-appscript
71
- requirement: &2169058060 !ruby/object:Gem::Requirement
71
+ requirement: &2168742880 !ruby/object:Gem::Requirement
72
72
  none: false
73
73
  requirements:
74
74
  - - ! '>='
@@ -76,7 +76,7 @@ dependencies:
76
76
  version: 0.6.1
77
77
  type: :development
78
78
  prerelease: false
79
- version_requirements: *2169058060
79
+ version_requirements: *2168742880
80
80
  description: An intelligent command-line tool for combining and compressing JavaScript
81
81
  files.
82
82
  email: developer@imulus.com
@@ -88,52 +88,37 @@ extra_rdoc_files:
88
88
  - bin/coyote
89
89
  - lib/coyote.rb
90
90
  - lib/coyote/closure_compiler.rb
91
- - lib/coyote/config_reader.rb
91
+ - lib/coyote/configuration.rb
92
+ - lib/coyote/coy_file.rb
92
93
  - lib/coyote/fs_listener.rb
93
94
  - lib/coyote/fs_listeners/darwin.rb
94
95
  - lib/coyote/fs_listeners/linux.rb
95
96
  - lib/coyote/fs_listeners/polling.rb
96
97
  - lib/coyote/fs_listeners/windows.rb
97
98
  - lib/coyote/generator.rb
98
- - lib/coyote/hooks.rb
99
99
  - lib/coyote/notification.rb
100
100
  - lib/coyote/output.rb
101
101
  files:
102
- - Manifest
103
102
  - README.md
104
103
  - Rakefile
105
104
  - bin/coyote
106
105
  - config/coyote-icon.png
106
+ - config/coyote-usage.txt
107
107
  - config/coyote.yaml
108
+ - coyote.gemspec
108
109
  - lib/coyote.rb
109
110
  - lib/coyote/closure_compiler.rb
110
- - lib/coyote/config_reader.rb
111
+ - lib/coyote/configuration.rb
112
+ - lib/coyote/coy_file.rb
111
113
  - lib/coyote/fs_listener.rb
112
114
  - lib/coyote/fs_listeners/darwin.rb
113
115
  - lib/coyote/fs_listeners/linux.rb
114
116
  - lib/coyote/fs_listeners/polling.rb
115
117
  - lib/coyote/fs_listeners/windows.rb
116
118
  - lib/coyote/generator.rb
117
- - lib/coyote/hooks.rb
118
119
  - lib/coyote/notification.rb
119
120
  - lib/coyote/output.rb
120
- - test/coffeescript/coyote.yaml
121
- - test/coffeescript/lib/animals.js
122
- - test/coffeescript/src/animal.coffee
123
- - test/coffeescript/src/horse.coffee
124
- - test/coffeescript/src/init.coffee
125
- - test/coffeescript/src/snake.coffee
126
- - test/javascript/application.js
127
- - test/javascript/application/controller.js
128
- - test/javascript/application/interface.js
129
- - test/javascript/coyote.yaml
130
- - test/javascript/init.js
131
- - test/javascript/jquery/jquery.js
132
- - test/javascript/jquery/plugins/jquery.cookie.js
133
- - test/javascript/jquery/plugins/jquery.cycle.all.min.js
134
- - test/javascript/jquery/plugins/jquery.query.js
135
- - test/javascript/scripts.js
136
- - coyote.gemspec
121
+ - Manifest
137
122
  homepage: http://github.com/imulus/coyote
138
123
  licenses: []
139
124
  post_install_message:
@@ -1,92 +0,0 @@
1
- module Coyote
2
- class ConfigReader
3
-
4
- attr_accessor :config, :options, :input_files
5
-
6
- def initialize(options)
7
- @options = options
8
- @config = get_config_or_screw_off
9
- @input_files = []
10
- end
11
-
12
- def output_file
13
- @config['output']
14
- end
15
-
16
- def should_compress?
17
- @config['compress'] || options[:compress]
18
- end
19
-
20
- def hooks
21
- @config['hooks']
22
- end
23
-
24
- def find_input_files
25
- @input_files = []
26
- @config['input'].each { |input| add_input input }
27
- end
28
-
29
-
30
- def add_input(input)
31
- if input.class == Array
32
- input.each do |input|
33
- find_and_add_files input
34
- end
35
- elsif input.class == String and @config['output'] != input
36
- find_and_add_files input
37
- end
38
- end
39
-
40
-
41
- def find_and_add_files(input)
42
- Dir.glob(input).each do |file|
43
- required = find_requires file
44
- required.each do |requirement|
45
- find_and_add_files "**/#{requirement}.js"
46
- end
47
- if ! @input_files.include? file
48
- @input_files.push file
49
- end
50
- end
51
- end
52
-
53
-
54
- def find_requires(input_file)
55
- required = []
56
- File.open(input_file) do |file|
57
- file = file.read
58
- pattern = Regexp.new(/(\/\/.*)(require )(.*)$/x)
59
- matches = file.scan(pattern)
60
- matches.each do |match|
61
- required.push match.last.strip.to_s.gsub(/\.js/, '').gsub(/(\"|\')/, '')
62
- end
63
- end
64
- return required
65
- end
66
-
67
-
68
- def get_config_or_screw_off
69
- if File.exists?(Coyote::CONFIG_FILENAME)
70
- begin
71
- config = YAML.load(File.open(Coyote::CONFIG_FILENAME))
72
- if config.class == Hash && ! config.empty?
73
- return config
74
- else
75
-
76
- Coyote::Notification.new "Coyote configuration exists but has not been defined yet. Configure it in #{Coyote::CONFIG_FILENAME}\n", "failure"
77
- exit(0)
78
- end
79
- rescue ArgumentError => e
80
- Coyote::Notification.new "Could not parse YAML: #{e.message}\n", "failure"
81
- exit
82
- end
83
- else
84
- Coyote::Notification.new "Could not find a Coyote configuration file in this directory. Use 'coyote generate' to create one.\n", "failure"
85
- exit
86
- end
87
- end
88
-
89
-
90
-
91
- end
92
- end
data/lib/coyote/hooks.rb DELETED
@@ -1,18 +0,0 @@
1
- module Coyote
2
- class Hooks
3
-
4
- def initialize(hooks)
5
- @hooks = hooks || {}
6
- end
7
-
8
- def invoke(segment)
9
- if @hooks[segment] and ! @hooks[segment].strip.empty?
10
- command = @hooks[segment]
11
- Coyote::Notification.new "\nInvoking hook '#{segment}' - '#{command}' \n"
12
- output = `#{command}`
13
- Coyote::Notification.new "#{output}\n" if output != ""
14
- end
15
- end
16
-
17
- end
18
- end
@@ -1,9 +0,0 @@
1
- output: lib/animals.coffee
2
- input:
3
- - src/animal.coffee
4
- - src/horse.coffee
5
- - src/snake.coffee
6
- - src/init.coffee
7
- hooks:
8
- before_save: "echo great job"
9
- after_save: "coffee -c lib/animals.coffee && rm lib/animals.coffee"
@@ -1,46 +0,0 @@
1
- (function() {
2
- var Animal, Horse, Snake, sam, tom;
3
- var __hasProp = Object.prototype.hasOwnProperty, __extends = function(child, parent) {
4
- for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; }
5
- function ctor() { this.constructor = child; }
6
- ctor.prototype = parent.prototype;
7
- child.prototype = new ctor;
8
- child.__super__ = parent.prototype;
9
- return child;
10
- };
11
- Animal = (function() {
12
- function Animal(name) {
13
- this.name = name;
14
- }
15
- Animal.prototype.move = function(meters) {
16
- return console.log(this.name + " moved " + meters + "m.");
17
- };
18
- return Animal;
19
- })();
20
- Horse = (function() {
21
- __extends(Horse, Animal);
22
- function Horse() {
23
- Horse.__super__.constructor.apply(this, arguments);
24
- }
25
- Horse.prototype.move = function() {
26
- console.log("Galloping...");
27
- return Horse.__super__.move.call(this, 45);
28
- };
29
- return Horse;
30
- })();
31
- Snake = (function() {
32
- __extends(Snake, Animal);
33
- function Snake() {
34
- Snake.__super__.constructor.apply(this, arguments);
35
- }
36
- Snake.prototype.move = function() {
37
- console.log("Slithering...");
38
- return Snake.__super__.move.call(this, 5);
39
- };
40
- return Snake;
41
- })();
42
- sam = new Snake("Sammy the Python");
43
- tom = new Horse("Tommy the Palomino");
44
- sam.move();
45
- tom.move();
46
- }).call(this);
@@ -1,5 +0,0 @@
1
- class Animal
2
- constructor: (@name) ->
3
-
4
- move: (meters) ->
5
- console.log @name + " moved " + meters + "m."
@@ -1,5 +0,0 @@
1
- class Horse extends Animal
2
- move: ->
3
- console.log "Galloping..."
4
- super 45
5
-
@@ -1,5 +0,0 @@
1
- sam = new Snake "Sammy the Python"
2
- tom = new Horse "Tommy the Palomino"
3
-
4
- sam.move()
5
- tom.move()
@@ -1,4 +0,0 @@
1
- class Snake extends Animal
2
- move: ->
3
- console.log "Slithering..."
4
- super 5
@@ -1,3 +0,0 @@
1
- var Application = Application || {
2
-
3
- };