ember_script 0.0.2 → 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
data/.gitignore ADDED
@@ -0,0 +1,49 @@
1
+ # rcov generated
2
+ coverage
3
+ coverage.data
4
+
5
+ # rdoc generated
6
+ rdoc
7
+
8
+ # yard generated
9
+ doc
10
+ .yardoc
11
+
12
+ # bundler
13
+ .bundle
14
+
15
+ # jeweler generated
16
+ pkg
17
+
18
+ # Have editor/IDE/OS specific files you need to ignore? Consider using a global gitignore:
19
+ #
20
+ # * Create a file at ~/.gitignore
21
+ # * Include files you want ignored
22
+ # * Run: git config --global core.excludesfile ~/.gitignore
23
+ #
24
+ # After doing this, these files will be ignored in all your git projects,
25
+ # saving you from having to 'pollute' every project you touch with them
26
+ #
27
+ # 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)
28
+ #
29
+ # For MacOS:
30
+ #
31
+ #.DS_Store
32
+
33
+ # For TextMate
34
+ #*.tmproj
35
+ #tmtags
36
+
37
+ # For emacs:
38
+ #*~
39
+ #\#*
40
+ #.\#*
41
+
42
+ # For vim:
43
+ #*.swp
44
+
45
+ # For redcar:
46
+ #.redcar
47
+
48
+ # For rubinius:
49
+ #*.rbc
data/.travis.yml ADDED
@@ -0,0 +1,10 @@
1
+ language: ruby
2
+ rvm:
3
+ - 1.9.3
4
+ before_install:
5
+ - sudo apt-get -y install python-software-properties
6
+ - sudo add-apt-repository -y ppa:chris-lea/node.js
7
+ - sudo apt-get update
8
+ - sudo apt-get -y install nodejs npm
9
+ - sudo npm install -g 'git://github.com/ghempton/ember-script.git#HEAD'
10
+ script: "rspec"
data/Gemfile CHANGED
@@ -1,17 +1,2 @@
1
1
  source "http://rubygems.org"
2
-
3
- gem 'tilt'
4
-
5
- group :development do
6
- gem "bundler"
7
- gem "jeweler"
8
- end
9
-
10
- group :test do
11
- gem 'rspec'
12
- gem 'pry'
13
- gem 'pry-doc'
14
- gem 'pry-remote'
15
- gem 'pry-nav'
16
- gem 'pry-stack_explorer'
17
- end
2
+ gemspec
data/Gemfile.lock CHANGED
@@ -1,34 +1,13 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ ember_script (0.0.3)
5
+ tilt
6
+
1
7
  GEM
2
8
  remote: http://rubygems.org/
3
9
  specs:
4
- binding_of_caller (0.6.8)
5
- coderay (1.0.8)
6
10
  diff-lcs (1.1.3)
7
- git (1.2.5)
8
- jeweler (1.8.4)
9
- bundler (~> 1.0)
10
- git (>= 1.2.5)
11
- rake
12
- rdoc
13
- json (1.7.5)
14
- method_source (0.8.1)
15
- pry (0.9.10)
16
- coderay (~> 1.0.5)
17
- method_source (~> 0.8)
18
- slop (~> 3.3.1)
19
- pry-doc (0.4.4)
20
- pry (>= 0.9.9.6)
21
- yard (~> 0.8.1)
22
- pry-nav (0.2.2)
23
- pry (~> 0.9.10)
24
- pry-remote (0.1.6)
25
- pry (~> 0.9)
26
- slop (~> 3.0)
27
- pry-stack_explorer (0.4.7)
28
- binding_of_caller (~> 0.6.8)
29
- rake (10.0.2)
30
- rdoc (3.12)
31
- json (~> 1.4)
32
11
  rspec (2.12.0)
33
12
  rspec-core (~> 2.12.0)
34
13
  rspec-expectations (~> 2.12.0)
@@ -37,20 +16,11 @@ GEM
37
16
  rspec-expectations (2.12.0)
38
17
  diff-lcs (~> 1.1.3)
39
18
  rspec-mocks (2.12.0)
40
- slop (3.3.3)
41
19
  tilt (1.3.3)
42
- yard (0.8.3)
43
20
 
44
21
  PLATFORMS
45
22
  ruby
46
23
 
47
24
  DEPENDENCIES
48
- bundler
49
- jeweler
50
- pry
51
- pry-doc
52
- pry-nav
53
- pry-remote
54
- pry-stack_explorer
25
+ ember_script!
55
26
  rspec
56
- tilt
data/README.md CHANGED
@@ -1,24 +1,32 @@
1
- # ember-script-ruby
1
+ # EmberScript-Ruby
2
2
 
3
3
  Provides a lightweight ruby wrapper around [EmberScript](https://github.com/ghempton/ember-script).
4
4
 
5
5
  `EmberScript.compile(source)`
6
6
 
7
+ ## Installation
8
+
9
+ This gem requires that an `ember-script` command be available in the current path. Being as EmberScript is still in early development, it is best to install via npm from git. After installing [Node.js](http://nodejs.org/), run the following command:
10
+
11
+ ```
12
+ sudo npm install -g 'git://github.com/ghempton/ember-script.git#HEAD'
13
+ ```
14
+
7
15
  ## Rails Integration
8
16
 
9
- Should work out of the box with Sprockets or Tilt. EmberScript files should use the '.em' extension.
17
+ After following the installation instructions above, simply add the following to your gemfile:
10
18
 
11
- ## Installation
19
+ ```
20
+ gem 'ember_script-rails'
21
+ ```
12
22
 
13
- This gem requires that an `ember-script` command be available in the current path. Being as EmberScript is still in early development, it is best to install via npm from source. After installing [Node.js](http://nodejs.org/), run the following commands:
23
+ ## Plain Ruby
14
24
 
15
25
  ```
16
- git clone git@github.com:ghempton/ember-script.git
17
- cd ember-script
18
- sudo npm install -g
26
+ gem 'ember_script'
19
27
  ```
20
28
 
21
- ## Contributing to ember-script-ruby
29
+ ## Contributing to EmberScript-Ruby
22
30
 
23
31
  * Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet.
24
32
  * Check out the issue tracker to make sure someone already hasn't requested it and/or contributed it.
data/Rakefile CHANGED
@@ -9,18 +9,4 @@ rescue Bundler::BundlerError => e
9
9
  $stderr.puts "Run `bundle install` to install missing gems"
10
10
  exit e.status_code
11
11
  end
12
- require 'rake'
13
-
14
- require 'jeweler'
15
- Jeweler::Tasks.new do |gem|
16
- # gem is a Gem::Specification... see http://docs.rubygems.org/read/chapter/20 for more options
17
- gem.name = "ember_script"
18
- gem.homepage = "http://github.com/ghempton/ember-script-ruby"
19
- gem.license = "MIT"
20
- gem.summary = %Q{EmberScript ruby wrapper}
21
- gem.description = %Q{Provides a ruby interface to EmberScript}
22
- gem.email = "ghempton@gmail.com"
23
- gem.authors = ["Gordon L. Hempton"]
24
- # dependencies defined in Gemfile
25
- end
26
- Jeweler::RubygemsDotOrgTasks.new
12
+ require 'rake'
data/ember_script.gemspec CHANGED
@@ -1,56 +1,23 @@
1
- # Generated by jeweler
2
- # DO NOT EDIT THIS FILE DIRECTLY
3
- # Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
4
1
  # -*- encoding: utf-8 -*-
2
+ require File.expand_path("../lib/ember_script/version", __FILE__)
5
3
 
6
- Gem::Specification.new do |s|
7
- s.name = "ember_script"
8
- s.version = "0.0.2"
4
+ Gem::Specification.new do |gem|
5
+ gem.name = "ember_script"
6
+ gem.version = EmberScript::VERSION
7
+ gem.authors = ["Gordon L. Hempton"]
8
+ gem.email = ["ghempton@gmail.com"]
9
+ gem.date = Date.today
10
+ gem.description = "Provides a ruby interface to EmberScript"
11
+ gem.summary = "EmberScript ruby wrapper"
12
+ gem.homepage = "http://github.com/ghempton/ember-script-ruby"
9
13
 
10
- s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
- s.authors = ["Gordon L. Hempton"]
12
- s.date = "2012-12-08"
13
- s.description = "Provides a ruby interface to EmberScript"
14
- s.email = "ghempton@gmail.com"
15
- s.extra_rdoc_files = [
16
- "LICENSE.txt",
17
- "README.md"
18
- ]
19
- s.files = [
20
- ".document",
21
- "Gemfile",
22
- "Gemfile.lock",
23
- "LICENSE.txt",
24
- "README.md",
25
- "Rakefile",
26
- "VERSION",
27
- "ember_script.gemspec",
28
- "lib/ember_script.rb",
29
- "spec/ember_script_spec.rb",
30
- "spec/spec_helper.rb"
31
- ]
32
- s.homepage = "http://github.com/ghempton/ember-script-ruby"
33
- s.licenses = ["MIT"]
34
- s.require_paths = ["lib"]
35
- s.rubygems_version = "1.8.23"
36
- s.summary = "EmberScript ruby wrapper"
14
+ gem.files = `git ls-files`.split($/)
15
+ gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
16
+ gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
17
+ gem.require_paths = ["lib"]
37
18
 
38
- if s.respond_to? :specification_version then
39
- s.specification_version = 3
19
+ gem.add_dependency "tilt"
40
20
 
41
- if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
42
- s.add_runtime_dependency(%q<tilt>, [">= 0"])
43
- s.add_development_dependency(%q<bundler>, [">= 0"])
44
- s.add_development_dependency(%q<jeweler>, [">= 0"])
45
- else
46
- s.add_dependency(%q<tilt>, [">= 0"])
47
- s.add_dependency(%q<bundler>, [">= 0"])
48
- s.add_dependency(%q<jeweler>, [">= 0"])
49
- end
50
- else
51
- s.add_dependency(%q<tilt>, [">= 0"])
52
- s.add_dependency(%q<bundler>, [">= 0"])
53
- s.add_dependency(%q<jeweler>, [">= 0"])
54
- end
21
+ gem.add_development_dependency "rspec"
55
22
  end
56
23
 
@@ -0,0 +1,3 @@
1
+ module EmberScript
2
+ VERSION = "0.0.3"
3
+ end
data/lib/ember_script.rb CHANGED
@@ -1,6 +1,9 @@
1
1
  # encoding: utf-8
2
2
 
3
3
  require 'tilt'
4
+ require 'open3'
5
+
6
+ require 'ember_script/version'
4
7
 
5
8
  module EmberScript
6
9
 
@@ -26,13 +29,31 @@ module EmberScript
26
29
  def compile(script, options = {})
27
30
  script = script.read if script.respond_to?(:read)
28
31
 
29
- Open3.capture3("ember-script --js", :stdin_data=>script)[0]
32
+ if options.key?(:bare)
33
+ elsif options.key?(:no_wrap)
34
+ options[:bare] = options[:no_wrap]
35
+ else
36
+ options[:bare] = false
37
+ end
38
+ bare = options[:bare] ? "--bare" : ""
39
+
40
+ Open3.capture3("ember-script --js #{bare}", :stdin_data=>script)[0]
30
41
  end
31
42
  end
32
43
 
33
44
  class EmberScriptTemplate < ::Tilt::Template
34
45
  self.default_mime_type = 'application/javascript'
35
46
 
47
+ @@default_bare = false
48
+
49
+ def self.default_bare
50
+ @@default_bare
51
+ end
52
+
53
+ def self.default_bare=(value)
54
+ @@default_bare = value
55
+ end
56
+
36
57
  def self.engine_initialized?
37
58
  true
38
59
  end
@@ -46,9 +67,12 @@ module EmberScript
46
67
  end
47
68
 
48
69
  def prepare
70
+ if !options.key?(:bare) and !options.key?(:no_wrap)
71
+ options[:bare] = self.class.default_bare
72
+ end
49
73
  end
50
74
  end
51
75
 
52
76
  ::Tilt.register EmberScriptTemplate, 'em'
53
77
 
54
- end
78
+ end
@@ -1,5 +1,11 @@
1
1
  require 'spec_helper'
2
2
 
3
+ RSpec::Matchers.define :be_wrapped_in_closure do
4
+ match do |result|
5
+ result =~ /void function ()/
6
+ end
7
+ end
8
+
3
9
  describe EmberScript do
4
10
 
5
11
  source = <<-eos
@@ -16,14 +22,36 @@ eos
16
22
 
17
23
  describe EmberScript::EmberScriptTemplate do
18
24
 
25
+ # Ensure default_bare has its default value.
26
+ default_bare = EmberScript::EmberScriptTemplate.default_bare
27
+ before { EmberScript::EmberScriptTemplate.default_bare = default_bare }
28
+
19
29
  subject { EmberScript::EmberScriptTemplate.new{ source } }
20
30
 
21
- it 'should render' do
31
+ def render_and_check_output
22
32
  result = subject.render
23
33
  result.should =~ /Ember\.Object\.extend/
24
34
  result.should =~ /property/
35
+ result
25
36
  end
26
37
 
27
- end
38
+ it 'should render' do
39
+ result = render_and_check_output
40
+ result.should be_wrapped_in_closure
41
+ end
28
42
 
29
- end
43
+ context 'without closure wrapping' do
44
+ it 'should render without closure if default_bare is true' do
45
+ EmberScript::EmberScriptTemplate.default_bare = true
46
+ result = render_and_check_output
47
+ result.should_not be_wrapped_in_closure
48
+ end
49
+
50
+ it 'should render without closure if options[:bare] is true' do
51
+ subject = EmberScript::EmberScriptTemplate.new(bare: true) { source }
52
+ result = subject.render
53
+ result.should_not be_wrapped_in_closure
54
+ end
55
+ end
56
+ end
57
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ember_script
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-12-08 00:00:00.000000000 Z
12
+ date: 2012-12-26 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: tilt
@@ -28,23 +28,7 @@ dependencies:
28
28
  - !ruby/object:Gem::Version
29
29
  version: '0'
30
30
  - !ruby/object:Gem::Dependency
31
- name: bundler
32
- requirement: !ruby/object:Gem::Requirement
33
- none: false
34
- requirements:
35
- - - ! '>='
36
- - !ruby/object:Gem::Version
37
- version: '0'
38
- type: :development
39
- prerelease: false
40
- version_requirements: !ruby/object:Gem::Requirement
41
- none: false
42
- requirements:
43
- - - ! '>='
44
- - !ruby/object:Gem::Version
45
- version: '0'
46
- - !ruby/object:Gem::Dependency
47
- name: jeweler
31
+ name: rspec
48
32
  requirement: !ruby/object:Gem::Requirement
49
33
  none: false
50
34
  requirements:
@@ -60,14 +44,15 @@ dependencies:
60
44
  - !ruby/object:Gem::Version
61
45
  version: '0'
62
46
  description: Provides a ruby interface to EmberScript
63
- email: ghempton@gmail.com
47
+ email:
48
+ - ghempton@gmail.com
64
49
  executables: []
65
50
  extensions: []
66
- extra_rdoc_files:
67
- - LICENSE.txt
68
- - README.md
51
+ extra_rdoc_files: []
69
52
  files:
70
53
  - .document
54
+ - .gitignore
55
+ - .travis.yml
71
56
  - Gemfile
72
57
  - Gemfile.lock
73
58
  - LICENSE.txt
@@ -76,11 +61,11 @@ files:
76
61
  - VERSION
77
62
  - ember_script.gemspec
78
63
  - lib/ember_script.rb
64
+ - lib/ember_script/version.rb
79
65
  - spec/ember_script_spec.rb
80
66
  - spec/spec_helper.rb
81
67
  homepage: http://github.com/ghempton/ember-script-ruby
82
- licenses:
83
- - MIT
68
+ licenses: []
84
69
  post_install_message:
85
70
  rdoc_options: []
86
71
  require_paths:
@@ -91,9 +76,6 @@ required_ruby_version: !ruby/object:Gem::Requirement
91
76
  - - ! '>='
92
77
  - !ruby/object:Gem::Version
93
78
  version: '0'
94
- segments:
95
- - 0
96
- hash: 3780340409301024918
97
79
  required_rubygems_version: !ruby/object:Gem::Requirement
98
80
  none: false
99
81
  requirements:
@@ -106,4 +88,7 @@ rubygems_version: 1.8.23
106
88
  signing_key:
107
89
  specification_version: 3
108
90
  summary: EmberScript ruby wrapper
109
- test_files: []
91
+ test_files:
92
+ - spec/ember_script_spec.rb
93
+ - spec/spec_helper.rb
94
+ has_rdoc: