coyote 0.7.0 → 1.0.0.beta1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (53) hide show
  1. data/Manifest +13 -31
  2. data/README.md +1 -91
  3. data/Rakefile +8 -4
  4. data/bin/coyote +9 -32
  5. data/coyote.gemspec +4 -10
  6. data/lib/coyote.rb +28 -62
  7. data/lib/coyote/asset.rb +51 -0
  8. data/lib/coyote/assets/coffeescript.rb +29 -0
  9. data/lib/coyote/assets/javascript.rb +4 -0
  10. data/lib/coyote/bundle.rb +101 -0
  11. data/lib/coyote/closure_compiler.rb +9 -9
  12. data/lib/coyote/configuration.rb +23 -77
  13. data/lib/coyote/notifications.rb +22 -0
  14. data/test/scripts/input1.js +1 -0
  15. data/test/scripts/input2.js +1 -0
  16. data/test/scripts/input3.js +1 -0
  17. data/test/scripts/input4.js +1 -0
  18. data/test/scripts/lib/input5.coffee +3 -0
  19. data/test/scripts/lib/input6.js +1 -0
  20. data/test/scripts/lib/keystone/input7.js +2 -0
  21. data/test/scripts/vendor/input8.coffee +1 -0
  22. metadata +29 -70
  23. data/config/coyote-icon.png +0 -0
  24. data/config/coyote-usage.txt +0 -16
  25. data/config/coyote.yaml +0 -2
  26. data/lib/coyote/generator.rb +0 -49
  27. data/lib/coyote/notification.rb +0 -62
  28. data/lib/coyote/script.rb +0 -124
  29. data/lib/coyote/scripts/coffeescript.rb +0 -32
  30. data/lib/coyote/scripts/combine.rb +0 -54
  31. data/lib/coyote/scripts/javascript.rb +0 -4
  32. data/test/src/public/assets/javascripts/app/application/interface.coffee +0 -10
  33. data/test/src/public/assets/javascripts/app/application/main.coffee +0 -14
  34. data/test/src/public/assets/javascripts/app/application/pages/home.coffee +0 -9
  35. data/test/src/public/assets/javascripts/app/boot.coffee +0 -1
  36. data/test/src/public/assets/javascripts/lib/extensions.coffee +0 -8
  37. data/test/src/public/assets/javascripts/lib/imulus.coffee +0 -7
  38. data/test/src/public/assets/javascripts/lib/imulus/forms.coffee +0 -46
  39. data/test/src/public/assets/javascripts/lib/imulus/maps/infowindow.coffee +0 -37
  40. data/test/src/public/assets/javascripts/lib/imulus/maps/map.coffee +0 -51
  41. data/test/src/public/assets/javascripts/lib/imulus/maps/marker.coffee +0 -66
  42. data/test/src/public/assets/javascripts/lib/imulus/maps/point.coffee +0 -5
  43. data/test/src/public/assets/javascripts/lib/imulus/maps/results.coffee +0 -117
  44. data/test/src/public/assets/javascripts/lib/imulus/tables.coffee +0 -11
  45. data/test/src/public/assets/javascripts/lib/imulus/triggers.coffee +0 -26
  46. data/test/src/public/assets/javascripts/scripts.coffee +0 -14
  47. data/test/src/public/assets/javascripts/vendor/jquery.js +0 -18
  48. data/test/src/public/assets/javascripts/vendor/jquery/jquery.cookie.js +0 -89
  49. data/test/src/public/assets/javascripts/vendor/jquery/jquery.cycle.js +0 -21
  50. data/test/src/public/assets/javascripts/vendor/jquery/jquery.query.js +0 -224
  51. data/test/src/public/assets/javascripts/vendor/swfobject.js +0 -4
  52. data/test/src/public/scripts/scripts.combine +0 -18
  53. data/test/src/public/scripts/scripts.js +0 -944
Binary file
@@ -1,16 +0,0 @@
1
- ------------------------------------------
2
- Coyote - Command-line Concatenation
3
- http://github.com/imulus/coyote
4
- ------------------------------------------
5
-
6
- Usage : 'coyote Action [Environment] [Options]'
7
-
8
- == Actions
9
- build - Execute the compiler
10
- watch - Starts the Coyote observe mechanism.
11
- new - Create a Coyote configuration in this directory
12
-
13
- == Options
14
- -c | --compress - Use Google Closure Compiler
15
- -v | --verbose - Verbose CLI logging
16
-
data/config/coyote.yaml DELETED
@@ -1,2 +0,0 @@
1
- output: coyote.js
2
- input:
@@ -1,49 +0,0 @@
1
- module Coyote
2
- class Generator
3
- attr_accessor :files_found
4
-
5
- def initialize
6
- @files_found = []
7
- end
8
-
9
- def generate
10
- if config_exists?
11
- Coyote::Notification.new "This directory is already configured for Coyote.\n", "failure"
12
- else
13
- discover_files
14
- copy_config
15
- end
16
- end
17
-
18
- def discover_files
19
- js_files = File.join("**","*.js")
20
- cs_files = File.join("**","*.coffee")
21
- Dir.glob(js_files).each do |file|
22
- @files_found.push file
23
- end
24
- Dir.glob(cs_files).each do |file|
25
- @files_found.push file
26
- end
27
- end
28
-
29
- def config_exists?
30
- File.exists?(Coyote::CONFIG_FILENAME)
31
- end
32
-
33
- def copy_config
34
- Coyote::Notification.new "\nGenerating Coyote\n"
35
- Coyote::Notification.new "#{@files_found.length} files discovered\n"
36
-
37
- File.open("#{Coyote::CONFIG_PATH}/#{Coyote::CONFIG_FILENAME}") do |file|
38
- output_file = File.open(Coyote::CONFIG_FILENAME, 'w+')
39
- generated = file.read
40
- @files_found.each do |file|
41
- generated += " - #{file}\n"
42
- end
43
- output_file.write(generated)
44
- end
45
-
46
- Coyote::Notification.new "Coyote generated at #{Coyote::CONFIG_FILENAME}\n\n", "success"
47
- end
48
- end
49
- end
@@ -1,62 +0,0 @@
1
- module Coyote
2
- class Notification
3
-
4
- attr_accessor :growl, :application, :icon, :default_notifications, :notifications, :type, :message
5
-
6
- def initialize(message, type = "message")
7
- @message = message
8
- @type = type
9
-
10
- console_notify
11
-
12
- if Config::CONFIG['target_os'] =~ /darwin/i
13
- require 'appscript'
14
- @growl = Appscript.app("GrowlHelperApp");
15
-
16
- if @growl.is_running?
17
- growl_register
18
- growl_notify
19
- end
20
- end
21
- end
22
-
23
-
24
- def console_notify
25
- case @type
26
- when "success"
27
- print @message.green
28
- when "warning"
29
- print @message.yellow
30
- when "failure"
31
- print @message.red
32
- else
33
- print @message.white
34
- end
35
- end
36
-
37
-
38
- # trigger a growl notification
39
- def growl_notify
40
- options = { :title => @application,
41
- :description => @message.gsub(/[\n]+/, ""),
42
- :application_name => @application,
43
- :image_from_location => @icon,
44
- :sticky => false,
45
- :priority => 0,
46
- :with_name => notifications.first }
47
- @growl.notify options
48
- end
49
-
50
-
51
- # register Coyote as an application with Growl
52
- def growl_register
53
- @application = Coyote::APP_NAME
54
- @icon = "#{Coyote::CONFIG_PATH}/#{Coyote::CONFIG_ICON}"
55
- @default_notifications = ["Coyote Success"]
56
- @notifications = ["Coyote Success", "Coyote Failure"]
57
- @growl.register(:as_application => @application, :all_notifications => @notifications, :default_notifications => @default_notifications)
58
- end
59
-
60
-
61
- end
62
- end
data/lib/coyote/script.rb DELETED
@@ -1,124 +0,0 @@
1
- module Coyote
2
- autoload :JavaScript, 'coyote/scripts/javascript'
3
- autoload :CoffeeScript, 'coyote/scripts/coffeescript'
4
- autoload :Combine, 'coyote/scripts/combine'
5
-
6
- class Script
7
- attr_reader :filename, :relative_path
8
- attr_accessor :contents
9
-
10
- # Class method
11
- # Determine the type of file base on the file extension
12
- # and return an instance of the proper extended script class
13
- def self.select_and_init(filename)
14
- case File.extname(filename)
15
- when /\.js/i ; JavaScript.new(filename)
16
- when /\.coffee/i ; CoffeeScript.new(filename)
17
- when /\.combine/i ; Combine.new(filename)
18
- else ; self.new(filename)
19
- end
20
- end
21
-
22
-
23
- def initialize(filename, contents = "")
24
- @filename = filename
25
- @relative_path = @filename.gsub("#{Dir.pwd}/", '')
26
- @directory = File.dirname(@filename)
27
-
28
- if contents.empty? and File.exists? @filename
29
- @contents = File.open(@filename, 'r').read
30
- else
31
- @contents = contents
32
- end
33
- end
34
-
35
-
36
- # Append a string of additional content
37
- # to the end of the current script contents
38
- def append(string)
39
- @contents += "#{string}\n\n"
40
- end
41
-
42
-
43
- # Prepend a string of additional content
44
- # to the beginning of the current script contents
45
- def prepend(string)
46
- @contents = "#{string}\n\n" + @contents
47
- end
48
-
49
-
50
- # Defines the regex pattern for scanning the contents of the
51
- # file to look for require directives
52
- def require_pattern
53
- Regexp.new(/\/\/=\s*require\s*(.*)$/i) # '//= require a/b/c.js' => 'a/b/c.js'
54
- end
55
-
56
-
57
- # Scan the contents of the file for require directives
58
- # By default, it looks for a directive of '//= require a/b/c.js'
59
- # It determines the full filepath of the required file,
60
- # relative to the current file being read in
61
- def requires(pattern = require_pattern)
62
- matches = @contents.scan(pattern)
63
- matches.collect do |match|
64
- File.expand_path(match.last.strip, @directory)
65
- end
66
- end
67
-
68
-
69
- # Clear out the contents of the script, in-place
70
- def empty!
71
- @contents = ""
72
- end
73
-
74
-
75
- # Run the contents of the script through the Google Closure compile
76
- # It compresses the contents of the script in-place
77
- def compress!
78
- Coyote::Notification.new "Compiling #{@filename}...\n", "warning"
79
- compiler = ClosureCompiler.new.compile(@contents)
80
- if compiler.success?
81
- @contents = compiler.compiled_code
82
- elsif compiler.file_too_big?
83
- Coyote::Notification.new "Input code too big for API, creating uncompiled file\n", "failure"
84
- elsif compiler.errors
85
- Coyote::Notification.new "Google closure API failed to compile, creating uncompiled file\n", "failure"
86
- Coyote::Notification.new "Errors: \n", "failure"
87
- Coyote::Notification.new "#{compiler.errors.to_s}\n\n", "failure"
88
- end
89
- end
90
-
91
-
92
- # Save the contents of the script to disk
93
- def save
94
- output = File.open @filename, 'w+'
95
- output.write @contents
96
- output.close
97
- end
98
-
99
-
100
-
101
- protected
102
-
103
- # This method converts a JavaScript filepath to a CoffeeScript filepath in the same directory
104
- # Given the path /a/b/c.js it will return /a/b/c.coffee
105
- def convert_js_path_to_coffee(path)
106
- directory, basename = File.split(path)
107
- basename = File.basename(basename, '.js')
108
- "#{directory}/#{basename}.coffee"
109
- end
110
-
111
- # This method converts a CoffeeScript filepath to a JavaScript filepath in the same directory
112
- # Given the path /a/b/c.coffee it will return /a/b/c.js
113
- def convert_coffee_path_to_js(path)
114
- directory, basename = File.split(path)
115
- basename = File.basename(basename, '.coffee')
116
- "#{directory}/#{basename}.js"
117
- end
118
-
119
-
120
-
121
- end
122
- end
123
-
124
-
@@ -1,32 +0,0 @@
1
- module Coyote
2
- class CoffeeScript < Script
3
-
4
- # Defines the regex pattern for scanning the contents of the
5
- # file to look for require directives
6
- def require_pattern
7
- Regexp.new(/#=\s*require\s(.*)$/i) # '#= require a/b/c.coffee' => 'a/b/c.coffee'
8
- end
9
-
10
-
11
- # We're defining setters and getters here
12
- # for the contents of the script file
13
- # because we need to compile the CoffeeScript to JavaScript
14
- # on the way out
15
- def contents=(string)
16
- @contents = string
17
- end
18
-
19
- def contents
20
- compile!
21
- @contents
22
- end
23
-
24
-
25
- # Run the contents of the script through the CoffeeScript compile
26
- # Changes the content of the script in-place
27
- def compile!
28
- @contents = `cat #{@filename} | coffee -sc`
29
- end
30
-
31
- end
32
- end
@@ -1,54 +0,0 @@
1
- module Coyote
2
-
3
- # This class adds support for .combine files, following the style
4
- # of SassAndCoffee for .NET (https://github.com/xpaulbettsx/SassAndCoffee)
5
-
6
- class Combine < Script
7
-
8
- # .combine files serve primarily as a manifest listing files to pull in and combine
9
- # In turn, each line of a .combine file is a require directive, so what we do here
10
- # to detemine requires is read in each line of the file, do a bit of cleanup,
11
- # and return an array of full filepaths of the required files
12
- def requires
13
- requires = []
14
-
15
- File.open(@filename).readlines.each do |line|
16
- # Because the directives in the .combine file are not comments,
17
- # we have to strip out the directives from the file's contents
18
- @contents.gsub!(/#{line}/, '')
19
-
20
- # Clean up whitespace on the directive, and make sure it's not a blank line
21
- if line.strip! != ''
22
-
23
- # The .NET .combine engine automatically detects .js files as their .coffee counterparts
24
- # so we need to replicate that functionality and also look for .coffee files with the same filename
25
- file = check_for_alternate_filetype(File.expand_path(line, @directory))
26
- if file
27
- requires << file
28
- end
29
- end
30
- end
31
-
32
- return requires
33
- end
34
-
35
-
36
- # This method with look for an alternate filetype for a given filepath
37
- # If it is given a path of /a/b/c.js it will look for /a/b/c.coffee
38
- # and return whichever filetype it finds first
39
- # It looks for JavaScript first and then CoffeeScript, returning nil if it doesn't find anything
40
- def check_for_alternate_filetype(path)
41
- javascript = path
42
- coffeescript = convert_js_path_to_coffee(javascript)
43
-
44
- if File.file?(javascript)
45
- javascript
46
- elsif File.file?(coffeescript)
47
- coffeescript
48
- else
49
- nil
50
- end
51
- end
52
-
53
- end
54
- end
@@ -1,4 +0,0 @@
1
- module Coyote
2
- class JavaScript < Script
3
- end
4
- end
@@ -1,10 +0,0 @@
1
- @module "Application", ->
2
-
3
- class @Interface
4
- constructor: ->
5
- do @build
6
-
7
- build: ->
8
- new Imulus.Forms
9
- new Imulus.Tables
10
- new Imulus.Triggers
@@ -1,14 +0,0 @@
1
- @module "Application", ->
2
-
3
- @main = ->
4
- new Application.Interface
5
-
6
- initializers = $('body').attr('data-js-init')
7
-
8
- Application.initializers = if initializers? then initializers.replace(" ","").split(",") else []
9
-
10
- for initializer in Application.initializers
11
- segments = initializer.split(".")
12
- method = window
13
- method = method[segment] for segment in segments
14
- do method if method?
@@ -1,9 +0,0 @@
1
- @module "Application.Pages", ->
2
-
3
- @home = ->
4
- $('#slides').cycle({
5
- fx : 'fade',
6
- speed : 1000,
7
- timeout : 5000,
8
- pager : "#slides-nav"
9
- });
@@ -1 +0,0 @@
1
- $ -> Application.main()
@@ -1,8 +0,0 @@
1
- @module = (names, fn) ->
2
- names = names.split '.' if typeof names is 'string'
3
- space = @[names.shift()] ||= {}
4
- space.module ||= @module
5
- if names.length
6
- space.module names, fn
7
- else
8
- fn.call space
@@ -1,7 +0,0 @@
1
- @module "Imulus", ->
2
-
3
- @VERSION = '0.1.0'
4
-
5
- @elementSupportsAttribute = (element, attribute)->
6
- attribute of document.createElement element
7
-
@@ -1,46 +0,0 @@
1
- @module "Imulus", ->
2
- class @Forms
3
- constructor: ($form)->
4
- do @build
5
-
6
- build: ->
7
- if not Imulus.elementSupportsAttribute 'input', 'placeholder'
8
- $('input[placeholder]').each ->
9
- $input = $(this)
10
- placeholder = $input.attr 'placeholder'
11
- $input.val(placeholder).addClass 'inactive'
12
- $input.bind
13
- focus : ->
14
- if $input.val() is placeholder
15
- $input.val('').removeClass 'inactive'
16
- blur : ->
17
- if $input.val() is ''
18
- $input.val(placeholder).addClass 'inactive'
19
-
20
-
21
-
22
- $('fieldset.overlay .row').each ->
23
-
24
- $label = $(this).find 'label'
25
- $input = $(this).find 'input'
26
-
27
- if $input.val() isnt ""
28
- $label.hide()
29
-
30
- $label.click -> $input.focus()
31
-
32
- $input.bind
33
- focus: ->
34
- if $input.val() is ""
35
- $label.addClass 'faded'
36
-
37
- blur: ->
38
- if $input.val() is ""
39
- $label.fadeIn().removeClass 'faded'
40
-
41
- change: ->
42
- if $input.val() isnt ""
43
- $label.fadeOut().removeClass 'faded'
44
-
45
- keypress: ->
46
- $label.hide().removeClass 'faded'