coffeefile 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/.document +5 -0
- data/.gitignore +49 -0
- data/LICENSE +20 -0
- data/README.md +9 -0
- data/Rakefile +7 -0
- data/bin/coffeefile +7 -0
- data/coffeefile.gemspec +24 -0
- data/lib/coffeefile.rb +36 -0
- data/test/test_coffeefile.rb +76 -0
- metadata +81 -0
data/.document
ADDED
data/.gitignore
ADDED
@@ -0,0 +1,49 @@
|
|
1
|
+
# rcov generated
|
2
|
+
coverage
|
3
|
+
|
4
|
+
# rdoc generated
|
5
|
+
rdoc
|
6
|
+
|
7
|
+
# yard generated
|
8
|
+
doc
|
9
|
+
.yardoc
|
10
|
+
|
11
|
+
# bundler
|
12
|
+
.bundle
|
13
|
+
|
14
|
+
# jeweler generated
|
15
|
+
pkg
|
16
|
+
|
17
|
+
# Have editor/IDE/OS specific files you need to ignore? Consider using a global gitignore:
|
18
|
+
#
|
19
|
+
# * Create a file at ~/.gitignore
|
20
|
+
# * Include files you want ignored
|
21
|
+
# * Run: git config --global core.excludesfile ~/.gitignore
|
22
|
+
#
|
23
|
+
# After doing this, these files will be ignored in all your git projects,
|
24
|
+
# saving you from having to 'pollute' every project you touch with them
|
25
|
+
#
|
26
|
+
# Not sure what to needs to be ignored for particular editors/OSes? Here's some ideas to get you started. (Remember, remove the leading # of the line)
|
27
|
+
#
|
28
|
+
# For MacOS:
|
29
|
+
#
|
30
|
+
#.DS_Store
|
31
|
+
|
32
|
+
# For TextMate
|
33
|
+
#*.tmproj
|
34
|
+
#tmtags
|
35
|
+
|
36
|
+
# For emacs:
|
37
|
+
#*~
|
38
|
+
#\#*
|
39
|
+
#.\#*
|
40
|
+
|
41
|
+
# For vim:
|
42
|
+
#*.swp
|
43
|
+
|
44
|
+
# For redcar:
|
45
|
+
#.redcar
|
46
|
+
|
47
|
+
# For rubinius:
|
48
|
+
#*.rbc
|
49
|
+
*.gem
|
data/LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) 2011 Robert R Evans
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
data/Rakefile
ADDED
data/bin/coffeefile
ADDED
data/coffeefile.gemspec
ADDED
@@ -0,0 +1,24 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
$:.push File.expand_path("../lib", __FILE__)
|
3
|
+
Gem::Specification.new do |s|
|
4
|
+
s.name = 'coffeefile'
|
5
|
+
s.version = '0.0.1'
|
6
|
+
s.platform = Gem::Platform::RUBY
|
7
|
+
s.authors = ["Robert R Evans"]
|
8
|
+
s.date = '2011-07-13'
|
9
|
+
s.email = 'robert@codewranglers.org'
|
10
|
+
s.homepage = 'http://github.com/codewranglers/coffeefile'
|
11
|
+
s.summary = "Multiple coffee-script file compiler"
|
12
|
+
s.description = <<-EOS
|
13
|
+
Use a Coffeefile to add all your coffee files that require compiling. Then use the coffefile command to compile.
|
14
|
+
EOS
|
15
|
+
s.license = "MIT"
|
16
|
+
s.files = `git ls-files`.split("\n")
|
17
|
+
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
18
|
+
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
19
|
+
s.require_paths = ["lib"]
|
20
|
+
|
21
|
+
|
22
|
+
s.add_runtime_dependency(%q<coffee-script>, ["~> 2.2.0"])
|
23
|
+
s.add_development_dependency(%q<rocco>, ["~> 0.6"])
|
24
|
+
end
|
data/lib/coffeefile.rb
ADDED
@@ -0,0 +1,36 @@
|
|
1
|
+
require 'coffee-script'
|
2
|
+
require 'pathname'
|
3
|
+
|
4
|
+
module Coffeefile
|
5
|
+
VERSION = '0.0.1'
|
6
|
+
|
7
|
+
module Source
|
8
|
+
def self.path
|
9
|
+
@path ||= Pathname.new(Dir.pwd).join('Coffeefile')
|
10
|
+
end
|
11
|
+
|
12
|
+
def self.contents
|
13
|
+
@contents ||= path.read.split("\n").compact.delete_if { |l| l.include?("#") }.collect do |f|
|
14
|
+
Dir.glob(f)
|
15
|
+
end.flatten!.uniq
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
class << self
|
20
|
+
def version
|
21
|
+
VERSION
|
22
|
+
end
|
23
|
+
|
24
|
+
def compile(output, options={})
|
25
|
+
contents = Source.contents.collect { |source| File.read(source) }.join("\n")
|
26
|
+
data = CoffeeScript.compile(contents, options)
|
27
|
+
fileout = output =~ /(\.js)$/ ? output : "#{output}.js"
|
28
|
+
File.open(File.join(Dir.pwd, fileout), 'w+') { |f| f.puts data }
|
29
|
+
end
|
30
|
+
|
31
|
+
def files_to_compile
|
32
|
+
Source.contents
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
end
|
@@ -0,0 +1,76 @@
|
|
1
|
+
require 'coffeefile'
|
2
|
+
require 'test/unit'
|
3
|
+
require 'fileutils'
|
4
|
+
|
5
|
+
class TestCoffeefile < Test::Unit::TestCase
|
6
|
+
COFFEEFILE = File.join(Dir.pwd, 'Coffeefile')
|
7
|
+
def setup
|
8
|
+
FileUtils.touch(COFFEEFILE)
|
9
|
+
File.open(COFFEEFILE, 'w+') do |file|
|
10
|
+
file.puts "# List of files in order of load"
|
11
|
+
file.puts "temp/app.coffee"
|
12
|
+
file.puts "temp/api.coffee"
|
13
|
+
file.puts "temp/views/**/*.coffee"
|
14
|
+
end
|
15
|
+
FileUtils.mkdir_p('temp/views/users')
|
16
|
+
FileUtils.mkdir_p('temp/views/bars')
|
17
|
+
FileUtils.touch('temp/app.coffee')
|
18
|
+
File.open('temp/app.coffee', 'w+') do |f|
|
19
|
+
f.puts "app: (options) ->"
|
20
|
+
f.puts " true"
|
21
|
+
end
|
22
|
+
FileUtils.touch('temp/api.coffee')
|
23
|
+
File.open('temp/api.coffee', 'w+') do |f|
|
24
|
+
f.puts "api: (options) ->"
|
25
|
+
f.puts " true"
|
26
|
+
end
|
27
|
+
FileUtils.touch('temp/views/main.coffee')
|
28
|
+
File.open('temp/views/main.coffee', 'w+') do |f|
|
29
|
+
f.puts "main: (options) ->"
|
30
|
+
f.puts " true"
|
31
|
+
end
|
32
|
+
FileUtils.touch('temp/views/detail.coffee')
|
33
|
+
FileUtils.touch('temp/views/users/main.coffee')
|
34
|
+
FileUtils.touch('temp/views/users/detail.coffee')
|
35
|
+
FileUtils.touch('temp/views/bars/main.coffee')
|
36
|
+
FileUtils.touch('temp/views/bars/detail.coffee')
|
37
|
+
end
|
38
|
+
|
39
|
+
def test_path
|
40
|
+
assert_equal File.join(Dir.pwd, 'Coffeefile'), Coffeefile::Source.path.to_s
|
41
|
+
end
|
42
|
+
|
43
|
+
def test_reading_coffeefile
|
44
|
+
assert_equal ["temp/app.coffee",
|
45
|
+
"temp/api.coffee",
|
46
|
+
"temp/views/bars/detail.coffee",
|
47
|
+
"temp/views/bars/main.coffee",
|
48
|
+
"temp/views/detail.coffee",
|
49
|
+
"temp/views/main.coffee",
|
50
|
+
"temp/views/users/detail.coffee",
|
51
|
+
"temp/views/users/main.coffee"], Coffeefile::Source.contents
|
52
|
+
end
|
53
|
+
|
54
|
+
|
55
|
+
def test_version_output
|
56
|
+
assert_equal '0.0.1', Coffeefile.version
|
57
|
+
end
|
58
|
+
|
59
|
+
def test_compiling_of_coffeescripts_with_no_extension
|
60
|
+
Coffeefile.compile('app')
|
61
|
+
assert_equal "(function() {\n ({\n app: function(options) {\n return true;\n },\n api: function(options) {\n return true;\n },\n main: function(options) {\n return true;\n }\n });\n}).call(this);\n", File.read(File.join(Dir.pwd, 'app.js'))
|
62
|
+
FileUtils.rm('app.js')
|
63
|
+
end
|
64
|
+
|
65
|
+
def test_compiling_of_coffeescripts_with_no_extension
|
66
|
+
Coffeefile.compile('program.js', :bare => true)
|
67
|
+
assert_equal "({\n app: function(options) {\n return true;\n },\n api: function(options) {\n return true;\n },\n main: function(options) {\n return true;\n }\n});\n", File.read(File.join(Dir.pwd, 'program.js'))
|
68
|
+
FileUtils.rm('program.js')
|
69
|
+
end
|
70
|
+
|
71
|
+
|
72
|
+
def teardown
|
73
|
+
FileUtils.rm(COFFEEFILE)
|
74
|
+
FileUtils.rm_rf('temp')
|
75
|
+
end
|
76
|
+
end
|
metadata
ADDED
@@ -0,0 +1,81 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: coffeefile
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Robert R Evans
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2011-07-13 00:00:00.000000000Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: coffee-script
|
16
|
+
requirement: &2158049660 !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ~>
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: 2.2.0
|
22
|
+
type: :runtime
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: *2158049660
|
25
|
+
- !ruby/object:Gem::Dependency
|
26
|
+
name: rocco
|
27
|
+
requirement: &2158049060 !ruby/object:Gem::Requirement
|
28
|
+
none: false
|
29
|
+
requirements:
|
30
|
+
- - ~>
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: '0.6'
|
33
|
+
type: :development
|
34
|
+
prerelease: false
|
35
|
+
version_requirements: *2158049060
|
36
|
+
description: ! ' Use a Coffeefile to add all your coffee files that require compiling.
|
37
|
+
Then use the coffefile command to compile.
|
38
|
+
|
39
|
+
'
|
40
|
+
email: robert@codewranglers.org
|
41
|
+
executables:
|
42
|
+
- coffeefile
|
43
|
+
extensions: []
|
44
|
+
extra_rdoc_files: []
|
45
|
+
files:
|
46
|
+
- .document
|
47
|
+
- .gitignore
|
48
|
+
- LICENSE
|
49
|
+
- README.md
|
50
|
+
- Rakefile
|
51
|
+
- bin/coffeefile
|
52
|
+
- coffeefile.gemspec
|
53
|
+
- lib/coffeefile.rb
|
54
|
+
- test/test_coffeefile.rb
|
55
|
+
homepage: http://github.com/codewranglers/coffeefile
|
56
|
+
licenses:
|
57
|
+
- MIT
|
58
|
+
post_install_message:
|
59
|
+
rdoc_options: []
|
60
|
+
require_paths:
|
61
|
+
- lib
|
62
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
63
|
+
none: false
|
64
|
+
requirements:
|
65
|
+
- - ! '>='
|
66
|
+
- !ruby/object:Gem::Version
|
67
|
+
version: '0'
|
68
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
69
|
+
none: false
|
70
|
+
requirements:
|
71
|
+
- - ! '>='
|
72
|
+
- !ruby/object:Gem::Version
|
73
|
+
version: '0'
|
74
|
+
requirements: []
|
75
|
+
rubyforge_project:
|
76
|
+
rubygems_version: 1.8.5
|
77
|
+
signing_key:
|
78
|
+
specification_version: 3
|
79
|
+
summary: Multiple coffee-script file compiler
|
80
|
+
test_files:
|
81
|
+
- test/test_coffeefile.rb
|