emblem 0.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,5 @@
1
+ lib/**/*.rb
2
+ bin/*
3
+ -
4
+ features/**/*.feature
5
+ LICENSE.txt
@@ -0,0 +1,52 @@
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
50
+ #
51
+ *.gem
52
+
@@ -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/machty/emblem.git#HEAD'
10
+ script: "bundle exec rspec"
data/Gemfile ADDED
@@ -0,0 +1,2 @@
1
+ source "http://rubygems.org"
2
+ gemspec
@@ -0,0 +1,26 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ emblem (0.0.1)
5
+ tilt
6
+
7
+ GEM
8
+ remote: http://rubygems.org/
9
+ specs:
10
+ diff-lcs (1.1.3)
11
+ rspec (2.12.0)
12
+ rspec-core (~> 2.12.0)
13
+ rspec-expectations (~> 2.12.0)
14
+ rspec-mocks (~> 2.12.0)
15
+ rspec-core (2.12.1)
16
+ rspec-expectations (2.12.0)
17
+ diff-lcs (~> 1.1.3)
18
+ rspec-mocks (2.12.0)
19
+ tilt (1.3.3)
20
+
21
+ PLATFORMS
22
+ ruby
23
+
24
+ DEPENDENCIES
25
+ emblem!
26
+ rspec
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2013 Alex Matchneer
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.
@@ -0,0 +1,28 @@
1
+ # Emblem.js Ruby Wrapper
2
+
3
+ Provides a lightweight ruby wrapper around [Emblem.js](https://github.com/machty/emblem.js)
4
+
5
+ `Emblem.compile('h1 Hello', templateName: 'welcome')`
6
+
7
+ ## Installation
8
+
9
+ This gem requires that an `emblem` command be available in the current path. Being as Emblem 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/machty/emblem.git#HEAD'
13
+ ```
14
+
15
+ ## Rails Integration
16
+
17
+ TODO
18
+
19
+ ## Plain Ruby
20
+
21
+ ```
22
+ gem 'emblem'
23
+ ```
24
+
25
+ ## Copyright
26
+
27
+ Copyright (c) 2013 Alex Matchneer. See LICENSE.txt for further details.
28
+
@@ -0,0 +1,12 @@
1
+ # encoding: utf-8
2
+
3
+ require 'rubygems'
4
+ require 'bundler'
5
+ begin
6
+ Bundler.setup(:default, :development)
7
+ rescue Bundler::BundlerError => e
8
+ $stderr.puts e.message
9
+ $stderr.puts "Run `bundle install` to install missing gems"
10
+ exit e.status_code
11
+ end
12
+ require 'rake'
data/VERSION ADDED
@@ -0,0 +1 @@
1
+ 0.0.1
@@ -0,0 +1,23 @@
1
+ # -*- encoding: utf-8 -*-
2
+ require File.expand_path("../lib/emblem/version", __FILE__)
3
+
4
+ Gem::Specification.new do |gem|
5
+ gem.name = "emblem"
6
+ gem.version = Emblem::VERSION
7
+ gem.authors = ["Alex Matchneer"]
8
+ gem.email = ["machty@gmail.com"]
9
+ gem.date = Date.today
10
+ gem.description = "Provides a ruby interface to Emblem.js"
11
+ gem.summary = "Emblem.js ruby wrapper"
12
+ gem.homepage = "https://github.com/machty/emblem-ruby"
13
+
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"]
18
+
19
+ gem.add_dependency "tilt"
20
+
21
+ gem.add_development_dependency "rspec"
22
+ end
23
+
@@ -0,0 +1,56 @@
1
+ # encoding: utf-8
2
+
3
+ require 'tilt'
4
+ require 'open3'
5
+
6
+ require File.expand_path('../emblem/version', __FILE__)
7
+
8
+ module Emblem
9
+
10
+ class << self
11
+ def engine
12
+ end
13
+
14
+ def engine=(engine)
15
+ end
16
+
17
+ def version
18
+ `emblem -v`
19
+ end
20
+
21
+ # Compile a Emblem file to JavaScript
22
+ # or generate the source maps.
23
+ #
24
+ # @param [String,#read] the source string or IO
25
+ # @param [Hash] options the compiler options
26
+ # @option options [String] format the output format, either `:map` or `:js`
27
+ #
28
+ def compile(script, options = {})
29
+ script = script.read if script.respond_to?(:read)
30
+ templateName = options[:templateName] || "template"
31
+ Open3.capture3("emblem -i #{templateName}", :stdin_data=>script)[0]
32
+ end
33
+ end
34
+
35
+ class EmblemTemplate < ::Tilt::Template
36
+ self.default_mime_type = 'application/javascript'
37
+
38
+ def self.engine_initialized?
39
+ true
40
+ end
41
+
42
+ def evaluate(scope, locals, &block)
43
+ @output ||= Emblem.compile(data, options)
44
+ end
45
+
46
+ def allows_script?
47
+ false
48
+ end
49
+
50
+ def prepare
51
+ end
52
+ end
53
+
54
+ ::Tilt.register EmblemTemplate, 'emblem'
55
+
56
+ end
@@ -0,0 +1,3 @@
1
+ module Emblem
2
+ VERSION = "0.0.2"
3
+ end
@@ -0,0 +1,57 @@
1
+ require 'spec_helper'
2
+
3
+ RSpec::Matchers.define :be_wrapped_in_closure do
4
+ match do |result|
5
+ result =~ /void function ()/
6
+ end
7
+ end
8
+
9
+ describe Emblem do
10
+
11
+ source = <<-eos
12
+ class App
13
+ +computed
14
+ myProp: -> 'hello world'
15
+ eos
16
+
17
+ it 'should compile' do
18
+ result = Emblem.compile(source)
19
+ result.should =~ /Ember\.Object\.extend/
20
+ result.should =~ /property/
21
+ end
22
+
23
+ describe Emblem::EmblemTemplate do
24
+
25
+ # Ensure default_bare has its default value.
26
+ default_bare = Emblem::EmblemTemplate.default_bare
27
+ before { Emblem::EmblemTemplate.default_bare = default_bare }
28
+
29
+ subject { Emblem::EmblemTemplate.new{ source } }
30
+
31
+ def render_and_check_output
32
+ result = subject.render
33
+ result.should =~ /Ember\.Object\.extend/
34
+ result.should =~ /property/
35
+ result
36
+ end
37
+
38
+ it 'should render' do
39
+ result = render_and_check_output
40
+ result.should be_wrapped_in_closure
41
+ end
42
+
43
+ context 'without closure wrapping' do
44
+ it 'should render without closure if default_bare is true' do
45
+ Emblem::EmblemTemplate.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 = Emblem::EmblemTemplate.new(bare: true) { source }
52
+ result = subject.render
53
+ result.should_not be_wrapped_in_closure
54
+ end
55
+ end
56
+ end
57
+ end
@@ -0,0 +1,7 @@
1
+ require 'bundler'
2
+ Bundler.require(:default, :test)
3
+
4
+ PROJECT_ROOT = File.expand_path(File.join(File.dirname(__FILE__), '..')).freeze
5
+ $LOAD_PATH << File.join(PROJECT_ROOT, 'lib')
6
+
7
+ require 'emblem'
metadata ADDED
@@ -0,0 +1,94 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: emblem
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.2
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Alex Matchneer
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2013-01-25 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: tilt
16
+ requirement: !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
21
+ version: '0'
22
+ type: :runtime
23
+ prerelease: false
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ! '>='
28
+ - !ruby/object:Gem::Version
29
+ version: '0'
30
+ - !ruby/object:Gem::Dependency
31
+ name: rspec
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
+ description: Provides a ruby interface to Emblem.js
47
+ email:
48
+ - machty@gmail.com
49
+ executables: []
50
+ extensions: []
51
+ extra_rdoc_files: []
52
+ files:
53
+ - .document
54
+ - .gitignore
55
+ - .travis.yml
56
+ - Gemfile
57
+ - Gemfile.lock
58
+ - LICENSE.txt
59
+ - README.md
60
+ - Rakefile
61
+ - VERSION
62
+ - emblem.gemspec
63
+ - lib/emblem.rb
64
+ - lib/emblem/version.rb
65
+ - spec/ember_script_spec.rb
66
+ - spec/spec_helper.rb
67
+ homepage: https://github.com/machty/emblem-ruby
68
+ licenses: []
69
+ post_install_message:
70
+ rdoc_options: []
71
+ require_paths:
72
+ - lib
73
+ required_ruby_version: !ruby/object:Gem::Requirement
74
+ none: false
75
+ requirements:
76
+ - - ! '>='
77
+ - !ruby/object:Gem::Version
78
+ version: '0'
79
+ required_rubygems_version: !ruby/object:Gem::Requirement
80
+ none: false
81
+ requirements:
82
+ - - ! '>='
83
+ - !ruby/object:Gem::Version
84
+ version: '0'
85
+ requirements: []
86
+ rubyforge_project:
87
+ rubygems_version: 1.8.24
88
+ signing_key:
89
+ specification_version: 3
90
+ summary: Emblem.js ruby wrapper
91
+ test_files:
92
+ - spec/ember_script_spec.rb
93
+ - spec/spec_helper.rb
94
+ has_rdoc: