barista 0.2.1 → 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -70,3 +70,14 @@ Currently available options are:
70
70
  * no\_wrap - stop coffee from automatically wrapping JS in a closure.
71
71
  * change\_output\_prefix! - method to change the output prefix for a framework.
72
72
 
73
+ ## Note on Patches/Pull Requests ##
74
+
75
+ 1. Fork the project.
76
+ 2. Make your feature addition or bug fix.
77
+ 3. Add tests for it. This is important so I don't break it in a future version unintentionally.
78
+ 4. Commit, do not mess with rakefile, version, or history. (if you want to have your own version, that is fine but bump version in a commit by itself I can ignore when I pull)
79
+ 5. Send me a pull request. Bonus points for topic branches.
80
+
81
+ ## Copyright ##
82
+
83
+ Copyright (c) 2010 Darcy Laycock. See LICENSE for details.
@@ -8,7 +8,7 @@ class BaristaController < ActionController::Base
8
8
  path = normalize_path(params[:js_path])
9
9
  p path
10
10
  return head(:forbidden) unless can_render_path?(path)
11
- compiled = Barista.render_path(path)
11
+ compiled = Barista.compile_file!(path)
12
12
  compiled.nil? ? head(:not_found) : render(:text => compiled.to_s)
13
13
  end
14
14
 
@@ -22,4 +22,4 @@ class BaristaController < ActionController::Base
22
22
  !path.include?("..")
23
23
  end
24
24
 
25
- end
25
+ end
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{barista}
8
- s.version = "0.2.1"
8
+ s.version = "0.3.0"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Darcy Laycock"]
12
- s.date = %q{2010-05-03}
12
+ s.date = %q{2010-06-11}
13
13
  s.description = %q{Automatically compiles app/scripts/*.coffee to javascript for rails awesomesauce.}
14
14
  s.email = %q{sutto@sutto.net}
15
15
  s.extra_rdoc_files = [
@@ -38,14 +38,14 @@ Gem::Specification.new do |s|
38
38
  s.homepage = %q{http://github.com/Sutto/barista}
39
39
  s.rdoc_options = ["--charset=UTF-8"]
40
40
  s.require_paths = ["lib"]
41
- s.rubygems_version = %q{1.3.6}
41
+ s.rubygems_version = %q{1.3.7}
42
42
  s.summary = %q{Transparent coffeescript support for rails 3}
43
43
 
44
44
  if s.respond_to? :specification_version then
45
45
  current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
46
46
  s.specification_version = 3
47
47
 
48
- if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
48
+ if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
49
49
  else
50
50
  end
51
51
  else
@@ -2,34 +2,34 @@ require 'active_support'
2
2
  require 'pathname'
3
3
 
4
4
  module Barista
5
-
5
+
6
6
  autoload :Compiler, 'barista/compiler'
7
7
  autoload :Filter, 'barista/filter'
8
8
  autoload :Framework, 'barista/framework'
9
-
9
+
10
10
  class << self
11
-
11
+
12
12
  def configure
13
13
  yield self if block_given?
14
14
  end
15
-
15
+
16
16
  def root
17
17
  @root ||= Rails.root.join("app", "coffeescripts")
18
18
  end
19
-
19
+
20
20
  def root=(value)
21
21
  @root = Pathname(value.to_s)
22
22
  Framework.default_framework = nil
23
23
  end
24
-
24
+
25
25
  def output_root
26
26
  @output_root ||= Rails.root.join("public", "javascripts")
27
27
  end
28
-
28
+
29
29
  def output_root=(value)
30
30
  @output_root = Pathname(value.to_s)
31
31
  end
32
-
32
+
33
33
  def compile_file!(file, force = false)
34
34
  origin_path, framework = Framework.full_path_for(file)
35
35
  return if origin_path.blank?
@@ -37,12 +37,12 @@ module Barista
37
37
  return unless force || Compiler.dirty?(origin_path, destination_path)
38
38
  debug "Compiling #{file} from framework '#{framework.name}'"
39
39
  FileUtils.mkdir_p File.dirname(destination_path)
40
- File.open(destination_path, "w+") do |f|
41
- f.write Compiler.compile(File.read(origin_path))
42
- end
43
- true
40
+ content = Compiler.compile(origin_path)
41
+ # Write the rendered content to file.
42
+ File.open(destination_path, "w+") { |f| f.write content }
43
+ content
44
44
  rescue SystemCallError
45
- false
45
+ ""
46
46
  end
47
47
 
48
48
  def compile_all!(force = false)
@@ -104,4 +104,4 @@ module Barista
104
104
  end
105
105
  end
106
106
 
107
- end
107
+ end
@@ -6,22 +6,19 @@ module Barista
6
6
  class << self; attr_accessor :bin_path; end
7
7
  self.bin_path ||= "coffee"
8
8
 
9
- def self.compile(content)
10
- new(content).to_js
9
+ def self.compile(path)
10
+ new(path).to_js
11
11
  end
12
12
 
13
- def initialize(content)
13
+ def initialize(path)
14
14
  @compiled = false
15
- @content = content
15
+ @path = path
16
16
  end
17
17
 
18
18
  def compile!
19
19
  # Compiler code thanks to bistro_car.
20
- tf = temp_file_for_content
21
- @compiled_content = invoke_coffee(temp_file_for_content.path)
20
+ @compiled_content = invoke_coffee(@path)
22
21
  @compiled = true
23
- ensure
24
- tf.unlink rescue nil
25
22
  end
26
23
 
27
24
  def to_js
@@ -41,13 +38,6 @@ module Barista
41
38
  end.join(" ")
42
39
  end
43
40
 
44
- def temp_file_for_content(content = @content)
45
- tf = Tempfile.new("barista-#{content_hash}.coffee")
46
- tf.write content
47
- tf.close
48
- tf
49
- end
50
-
51
41
  def invoke_coffee(path)
52
42
  command = "#{self.class.bin_path} #{coffee_options} '#{path}'".squeeze(' ')
53
43
  %x(#{command})
@@ -58,4 +48,4 @@ module Barista
58
48
  end
59
49
 
60
50
  end
61
- end
51
+ end
@@ -1,8 +1,8 @@
1
1
  module Barista
2
2
  module Version
3
3
  MAJOR = 0
4
- MINOR = 2
5
- PATCH = 1
4
+ MINOR = 3
5
+ PATCH = 0
6
6
  STRING = [MAJOR, MINOR, PATCH].join(".")
7
7
  end
8
- end
8
+ end
metadata CHANGED
@@ -1,12 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: barista
3
3
  version: !ruby/object:Gem::Version
4
+ hash: 19
4
5
  prerelease: false
5
6
  segments:
6
7
  - 0
7
- - 2
8
- - 1
9
- version: 0.2.1
8
+ - 3
9
+ - 0
10
+ version: 0.3.0
10
11
  platform: ruby
11
12
  authors:
12
13
  - Darcy Laycock
@@ -14,7 +15,7 @@ autorequire:
14
15
  bindir: bin
15
16
  cert_chain: []
16
17
 
17
- date: 2010-05-03 00:00:00 +08:00
18
+ date: 2010-06-11 00:00:00 +08:00
18
19
  default_executable:
19
20
  dependencies: []
20
21
 
@@ -55,23 +56,27 @@ rdoc_options:
55
56
  require_paths:
56
57
  - lib
57
58
  required_ruby_version: !ruby/object:Gem::Requirement
59
+ none: false
58
60
  requirements:
59
61
  - - ">="
60
62
  - !ruby/object:Gem::Version
63
+ hash: 3
61
64
  segments:
62
65
  - 0
63
66
  version: "0"
64
67
  required_rubygems_version: !ruby/object:Gem::Requirement
68
+ none: false
65
69
  requirements:
66
70
  - - ">="
67
71
  - !ruby/object:Gem::Version
72
+ hash: 3
68
73
  segments:
69
74
  - 0
70
75
  version: "0"
71
76
  requirements: []
72
77
 
73
78
  rubyforge_project:
74
- rubygems_version: 1.3.6
79
+ rubygems_version: 1.3.7
75
80
  signing_key:
76
81
  specification_version: 3
77
82
  summary: Transparent coffeescript support for rails 3