nodeify 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,5 @@
1
+ lib/**/*.rb
2
+ bin/*
3
+ -
4
+ features/**/*.feature
5
+ LICENSE.txt
@@ -0,0 +1,44 @@
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
+ node_modules
15
+
16
+ # jeweler generated
17
+ pkg
18
+
19
+ # Have editor/IDE/OS specific files you need to ignore? Consider using a global gitignore:
20
+ #
21
+ # * Create a file at ~/.gitignore
22
+ # * Include files you want ignored
23
+ # * Run: git config --global core.excludesfile ~/.gitignore
24
+ #
25
+ # After doing this, these files will be ignored in all your git projects,
26
+ # saving you from having to 'pollute' every project you touch with them
27
+ #
28
+ # 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)
29
+ #
30
+ # For MacOS:
31
+ #
32
+ #.DS_Store
33
+ #
34
+ # For TextMate
35
+ #*.tmproj
36
+ #tmtags
37
+ #
38
+ # For emacs:
39
+ #*~
40
+ #\#*
41
+ #.\#*
42
+ #
43
+ # For vim:
44
+ #*.swp
data/.rspec ADDED
@@ -0,0 +1 @@
1
+ --color
data/Gemfile ADDED
@@ -0,0 +1,3 @@
1
+ source :rubygems
2
+
3
+ gemspec :path => '.'
@@ -0,0 +1,115 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ nodeify (0.0.1)
5
+ execjs
6
+ rails (~> 3.1.0.rc8)
7
+ sandbox
8
+ sprockets
9
+
10
+ GEM
11
+ remote: http://rubygems.org/
12
+ specs:
13
+ actionmailer (3.1.0.rc8)
14
+ actionpack (= 3.1.0.rc8)
15
+ mail (~> 2.3.0)
16
+ actionpack (3.1.0.rc8)
17
+ activemodel (= 3.1.0.rc8)
18
+ activesupport (= 3.1.0.rc8)
19
+ builder (~> 3.0.0)
20
+ erubis (~> 2.7.0)
21
+ i18n (~> 0.6)
22
+ rack (~> 1.3.2)
23
+ rack-cache (~> 1.0.3)
24
+ rack-mount (~> 0.8.2)
25
+ rack-test (~> 0.6.1)
26
+ sprockets (~> 2.0.0.beta.15)
27
+ activemodel (3.1.0.rc8)
28
+ activesupport (= 3.1.0.rc8)
29
+ bcrypt-ruby (~> 3.0.0)
30
+ builder (~> 3.0.0)
31
+ i18n (~> 0.6)
32
+ activerecord (3.1.0.rc8)
33
+ activemodel (= 3.1.0.rc8)
34
+ activesupport (= 3.1.0.rc8)
35
+ arel (~> 2.2.1)
36
+ tzinfo (~> 0.3.29)
37
+ activeresource (3.1.0.rc8)
38
+ activemodel (= 3.1.0.rc8)
39
+ activesupport (= 3.1.0.rc8)
40
+ activesupport (3.1.0.rc8)
41
+ multi_json (~> 1.0)
42
+ arel (2.2.1)
43
+ bcrypt-ruby (3.0.0)
44
+ builder (3.0.0)
45
+ diff-lcs (1.1.3)
46
+ erubis (2.7.0)
47
+ execjs (1.2.4)
48
+ multi_json (~> 1.0)
49
+ git (1.2.5)
50
+ hike (1.2.1)
51
+ i18n (0.6.0)
52
+ jeweler (1.6.4)
53
+ bundler (~> 1.0)
54
+ git (>= 1.2.5)
55
+ rake
56
+ mail (2.3.0)
57
+ i18n (>= 0.4.0)
58
+ mime-types (~> 1.16)
59
+ treetop (~> 1.4.8)
60
+ mime-types (1.16)
61
+ multi_json (1.0.3)
62
+ polyglot (0.3.2)
63
+ rack (1.3.2)
64
+ rack-cache (1.0.3)
65
+ rack (>= 0.4)
66
+ rack-mount (0.8.2)
67
+ rack (>= 1.0.0)
68
+ rack-ssl (1.3.2)
69
+ rack
70
+ rack-test (0.6.1)
71
+ rack (>= 1.0)
72
+ rails (3.1.0.rc8)
73
+ actionmailer (= 3.1.0.rc8)
74
+ actionpack (= 3.1.0.rc8)
75
+ activerecord (= 3.1.0.rc8)
76
+ activeresource (= 3.1.0.rc8)
77
+ activesupport (= 3.1.0.rc8)
78
+ bundler (~> 1.0)
79
+ railties (= 3.1.0.rc8)
80
+ railties (3.1.0.rc8)
81
+ actionpack (= 3.1.0.rc8)
82
+ activesupport (= 3.1.0.rc8)
83
+ rack-ssl (~> 1.3.2)
84
+ rake (>= 0.8.7)
85
+ rdoc (~> 3.4)
86
+ thor (~> 0.14.6)
87
+ rake (0.9.2)
88
+ rdoc (3.9.4)
89
+ rspec (2.6.0)
90
+ rspec-core (~> 2.6.0)
91
+ rspec-expectations (~> 2.6.0)
92
+ rspec-mocks (~> 2.6.0)
93
+ rspec-core (2.6.4)
94
+ rspec-expectations (2.6.0)
95
+ diff-lcs (~> 1.1.2)
96
+ rspec-mocks (2.6.0)
97
+ sandbox (0.1.1)
98
+ sprockets (2.0.0)
99
+ hike (~> 1.2)
100
+ rack (~> 1.0)
101
+ tilt (!= 1.3.0, ~> 1.1)
102
+ thor (0.14.6)
103
+ tilt (1.3.3)
104
+ treetop (1.4.10)
105
+ polyglot
106
+ polyglot (>= 0.3.1)
107
+ tzinfo (0.3.29)
108
+
109
+ PLATFORMS
110
+ ruby
111
+
112
+ DEPENDENCIES
113
+ jeweler
114
+ nodeify!
115
+ rspec
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2011 Derek Kastner
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,81 @@
1
+ # nodeify
2
+
3
+ Bring CLI testing and npm modules to your JavaScript.
4
+
5
+ ## Requirements
6
+
7
+ Install Node.js and npm:
8
+
9
+ $ port install nodejs
10
+ $ curl http://npmjs.org/install.sh | sh
11
+
12
+ Nodeify is designed to work with Rails 3.1 and higher.
13
+
14
+ ## Installation
15
+
16
+ In your Gemfile:
17
+
18
+ gem 'nodeify'
19
+
20
+ Run:
21
+
22
+ $ bundle update
23
+ $ rails g nodeify:install
24
+
25
+ ## Usage
26
+
27
+ ### App-specific JavaScript
28
+
29
+ As with any Rails JS with the asset pipeline, put your app-specific JavaScripts in app/assets/javascripts directory.
30
+
31
+ ### require()
32
+
33
+ Under the standard Rails asset pipeline regime, the sprockets gem is used to manage JavaScript file loading/dependencies through the `//= require xxx` syntax. With Nodeify, your javascripts fit into the standard CommonJS modules framework. You can use `var MyLib = require('./xxx')` statements that are relative to your `app/assets/javascripts` directory and `lib/assets/javascripts` directory (both paths are added to NODE_PATHS). You can also use require() to load Node.js npm modules (see below).
34
+
35
+ #### Understanding require()
36
+
37
+ The CommonJS require() works a bit differently than Ruby's require or the sprockets //= require. CommonJS isolates modules (any code grouped into a file) into its own environment. Variables defined local to the module will only be available in that module. To expose certain objects...
38
+
39
+ TODO: Explanation
40
+
41
+ In the meantime, google CommonJS modules.
42
+
43
+ ### Node modules
44
+
45
+ In your app's root directory, add any npm module dependencies to package.json file, just like any Node.js server app or npm module. Nodeify will add a default package.json for you. Npm dependencies look like:
46
+
47
+ "dependencies": {
48
+ "jquery-browserify": ">= 1.3.x",
49
+ "jsonpath": "*"
50
+ },
51
+ "devDependencies": {
52
+ "browserify": "*"
53
+ }
54
+
55
+ Once you've updated dependencies, you can install the newest modules with
56
+
57
+ $ npm install
58
+
59
+ ## Asset Pipeline Misc.
60
+
61
+ Nodeify integrates seamlessly with the standard asset pipeline workflow. The only difference is the use of CommonJS require() instead of sprockets' require.
62
+
63
+ ## Testing
64
+
65
+ Testing tasks are defined in the Cakefile, according to whether jasmine (default) or vows is selected as the testing framework. Run your JavaScript tests with `cake test`. Individual files can be tested with `cake test -p spec/MyClassSpec.js` (jasmine) or `cake test -p test/my-class-test.js` (vows).
66
+
67
+ ## Contributing to nodeify
68
+
69
+ * Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet
70
+ * Check out the issue tracker to make sure someone already hasn't requested it and/or contributed it
71
+ * Fork the project
72
+ * Start a feature/bugfix branch
73
+ * Commit and push until you are happy with your contribution
74
+ * Make sure to add tests for it. This is important so I don't break it in a future version unintentionally.
75
+ * Please try not to mess with the Rakefile, version, or history. If you want to have your own version, or is otherwise necessary, that is fine, but please isolate to its own commit so I can cherry-pick around it.
76
+
77
+ ## Copyright
78
+
79
+ Copyright (c) 2011 Derek Kastner. See LICENSE.txt for
80
+ further details.
81
+
@@ -0,0 +1,50 @@
1
+ require 'rubygems'
2
+ require 'bundler'
3
+ begin
4
+ Bundler.setup(:default, :development)
5
+ rescue Bundler::BundlerError => e
6
+ $stderr.puts e.message
7
+ $stderr.puts "Run `bundle install` to install missing gems"
8
+ exit e.status_code
9
+ end
10
+ require 'rake'
11
+
12
+ require 'jeweler'
13
+ Jeweler::Tasks.new do |gem|
14
+ # gem is a Gem::Specification... see http://docs.rubygems.org/read/chapter/20 for more options
15
+ gem.name = "nodeify"
16
+ gem.homepage = "http://github.com/dkastner/nodeify"
17
+ gem.license = "MIT"
18
+ gem.summary = %Q{Bring the magic of node to your rails app}
19
+ gem.description = %Q{Adds CLI testing and node.js npm packages to your JavaScript}
20
+ gem.email = "dkastner@gmail.com"
21
+ gem.authors = ["Derek Kastner"]
22
+ # Include your dependencies below. Runtime dependencies are required when using your gem,
23
+ # and development dependencies are only needed for development (ie running rake tasks, tests, etc)
24
+ # gem.add_runtime_dependency 'jabber4r', '> 0.1'
25
+ # gem.add_development_dependency 'rspec', '> 1.2.3'
26
+ end
27
+ Jeweler::RubygemsDotOrgTasks.new
28
+
29
+ require 'rspec/core'
30
+ require 'rspec/core/rake_task'
31
+ RSpec::Core::RakeTask.new(:spec) do |spec|
32
+ spec.pattern = FileList['spec/**/*_spec.rb']
33
+ end
34
+
35
+ RSpec::Core::RakeTask.new(:rcov) do |spec|
36
+ spec.pattern = 'spec/**/*_spec.rb'
37
+ spec.rcov = true
38
+ end
39
+
40
+ task :default => :spec
41
+
42
+ require 'rake/rdoctask'
43
+ Rake::RDocTask.new do |rdoc|
44
+ version = File.exist?('VERSION') ? File.read('VERSION') : ""
45
+
46
+ rdoc.rdoc_dir = 'rdoc'
47
+ rdoc.title = "nodeify #{version}"
48
+ rdoc.rdoc_files.include('README*')
49
+ rdoc.rdoc_files.include('lib/**/*.rb')
50
+ end
@@ -0,0 +1,4 @@
1
+ require 'nodeify/rails'
2
+
3
+ module Nodeify
4
+ end
@@ -0,0 +1,24 @@
1
+ require 'execjs'
2
+ require 'sprockets'
3
+ require 'sandbox'
4
+
5
+ module Nodeify
6
+ class JavaScript < Sprockets::Processor
7
+ def render(context, options)
8
+ source = ''
9
+ Sandbox.play :path => 'tmp' do |path|
10
+ js_file = File.join(path, 'nodeify.js')
11
+ File.open(js_file, 'w') do |f|
12
+ f.puts <<-JAVASCRIPT
13
+ var browserify = require('browserify');
14
+ var b = browserify({ entry: '#{file}', require: { http: 'http-browserify' } });
15
+ process.stdout.write(b.bundle());
16
+ JAVASCRIPT
17
+ end
18
+ @source = `node #{js_file}` # TODO: ExecJS failed me here. Also, node can't seem to accept pipes
19
+ end
20
+
21
+ @source
22
+ end
23
+ end
24
+ end
@@ -0,0 +1,15 @@
1
+ require 'nodeify/java_script'
2
+
3
+ require 'sprockets'
4
+ require 'execjs'
5
+ require 'rails'
6
+
7
+ module Nodeify
8
+ class Rails < Rails::Railtie
9
+ initializer "nodeify.sprockets.environment" do |app|
10
+ ExecJS.runtime = ExecJS::Runtimes::Node
11
+ app.assets.unregister_preprocessor 'application/javascript', Sprockets::DirectiveProcessor
12
+ app.assets.register_bundle_processor 'application/javascript', Nodeify::JavaScript
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,3 @@
1
+ module Nodeify
2
+ VERSION = '0.0.1'
3
+ end
@@ -0,0 +1,26 @@
1
+ # -*- encoding: utf-8 -*-
2
+ $:.push File.expand_path("../lib", __FILE__)
3
+ require 'nodeify/version'
4
+
5
+ Gem::Specification.new do |s|
6
+ s.name = 'nodeify'
7
+ s.version = Nodeify::VERSION
8
+ s.platform = Gem::Platform::RUBY
9
+ s.authors = ['Derek Kastner']
10
+ s.email = ['dkastner+nodeify@gmail.com']
11
+ s.homepage = 'https://github.com/dkastner/nodeify'
12
+ s.summary = ''
13
+ s.description = ''
14
+
15
+ s.files = `git ls-files`.split("\n")
16
+ s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
17
+ s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
18
+ s.require_paths = ["lib"]
19
+
20
+ s.add_dependency 'execjs'
21
+ s.add_dependency 'rails', '~> 3.1.0.rc8'
22
+ s.add_dependency 'sandbox'
23
+ s.add_dependency 'sprockets'
24
+ s.add_development_dependency 'jeweler'
25
+ s.add_development_dependency 'rspec'
26
+ end
@@ -0,0 +1,8 @@
1
+ {
2
+ "name": "hootroot",
3
+ "version": "0.0.1",
4
+ "engine": "*",
5
+ "dependencies": {
6
+ "browserify": "*"
7
+ }
8
+ }
@@ -0,0 +1,3 @@
1
+ var foo = require('./bar');
2
+
3
+ foo.baz('hi');
@@ -0,0 +1,3 @@
1
+ module.exports.baz = function(str) {
2
+ console.log(str);
3
+ };
@@ -0,0 +1,15 @@
1
+ require 'spec_helper'
2
+ require 'sprockets'
3
+
4
+ describe Nodeify::JavaScript do
5
+ let(:env) { Sprockets::Environment.new }
6
+
7
+ describe '#build_source' do
8
+ it 'returns a hash with source, length, and digest' do
9
+ js = Nodeify::JavaScript.new 'spec/fixtures/application.js'
10
+ source = js.render(env, {})
11
+ source.should =~ /require/
12
+ end
13
+ end
14
+ end
15
+
@@ -0,0 +1,7 @@
1
+ require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
2
+
3
+ describe "Nodeify" do
4
+ it "fails" do
5
+ fail "hey buddy, you should probably rename this file and start specing for real"
6
+ end
7
+ end
@@ -0,0 +1,12 @@
1
+ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
2
+ $LOAD_PATH.unshift(File.dirname(__FILE__))
3
+ require 'rspec'
4
+ require 'nodeify'
5
+
6
+ # Requires supporting files with custom matchers and macros, etc,
7
+ # in ./support/ and its subdirectories.
8
+ Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each {|f| require f}
9
+
10
+ RSpec.configure do |config|
11
+
12
+ end
metadata ADDED
@@ -0,0 +1,135 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: nodeify
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Derek Kastner
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2011-09-08 00:00:00.000000000Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: execjs
16
+ requirement: &2157023940 !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: *2157023940
25
+ - !ruby/object:Gem::Dependency
26
+ name: rails
27
+ requirement: &2157023420 !ruby/object:Gem::Requirement
28
+ none: false
29
+ requirements:
30
+ - - ~>
31
+ - !ruby/object:Gem::Version
32
+ version: 3.1.0.rc8
33
+ type: :runtime
34
+ prerelease: false
35
+ version_requirements: *2157023420
36
+ - !ruby/object:Gem::Dependency
37
+ name: sandbox
38
+ requirement: &2157023000 !ruby/object:Gem::Requirement
39
+ none: false
40
+ requirements:
41
+ - - ! '>='
42
+ - !ruby/object:Gem::Version
43
+ version: '0'
44
+ type: :runtime
45
+ prerelease: false
46
+ version_requirements: *2157023000
47
+ - !ruby/object:Gem::Dependency
48
+ name: sprockets
49
+ requirement: &2157022540 !ruby/object:Gem::Requirement
50
+ none: false
51
+ requirements:
52
+ - - ! '>='
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ type: :runtime
56
+ prerelease: false
57
+ version_requirements: *2157022540
58
+ - !ruby/object:Gem::Dependency
59
+ name: jeweler
60
+ requirement: &2157022120 !ruby/object:Gem::Requirement
61
+ none: false
62
+ requirements:
63
+ - - ! '>='
64
+ - !ruby/object:Gem::Version
65
+ version: '0'
66
+ type: :development
67
+ prerelease: false
68
+ version_requirements: *2157022120
69
+ - !ruby/object:Gem::Dependency
70
+ name: rspec
71
+ requirement: &2157021700 !ruby/object:Gem::Requirement
72
+ none: false
73
+ requirements:
74
+ - - ! '>='
75
+ - !ruby/object:Gem::Version
76
+ version: '0'
77
+ type: :development
78
+ prerelease: false
79
+ version_requirements: *2157021700
80
+ description: ''
81
+ email:
82
+ - dkastner+nodeify@gmail.com
83
+ executables: []
84
+ extensions: []
85
+ extra_rdoc_files: []
86
+ files:
87
+ - .document
88
+ - .gitignore
89
+ - .rspec
90
+ - Gemfile
91
+ - Gemfile.lock
92
+ - LICENSE.txt
93
+ - README.markdown
94
+ - Rakefile
95
+ - lib/nodeify.rb
96
+ - lib/nodeify/java_script.rb
97
+ - lib/nodeify/rails.rb
98
+ - lib/nodeify/version.rb
99
+ - nodeify.gemspec
100
+ - package.json
101
+ - spec/fixtures/application.js
102
+ - spec/fixtures/bar.js
103
+ - spec/nodeify/java_script_spec.rb
104
+ - spec/nodeify_spec.rb
105
+ - spec/spec_helper.rb
106
+ homepage: https://github.com/dkastner/nodeify
107
+ licenses: []
108
+ post_install_message:
109
+ rdoc_options: []
110
+ require_paths:
111
+ - lib
112
+ required_ruby_version: !ruby/object:Gem::Requirement
113
+ none: false
114
+ requirements:
115
+ - - ! '>='
116
+ - !ruby/object:Gem::Version
117
+ version: '0'
118
+ required_rubygems_version: !ruby/object:Gem::Requirement
119
+ none: false
120
+ requirements:
121
+ - - ! '>='
122
+ - !ruby/object:Gem::Version
123
+ version: '0'
124
+ requirements: []
125
+ rubyforge_project:
126
+ rubygems_version: 1.8.5
127
+ signing_key:
128
+ specification_version: 3
129
+ summary: ''
130
+ test_files:
131
+ - spec/fixtures/application.js
132
+ - spec/fixtures/bar.js
133
+ - spec/nodeify/java_script_spec.rb
134
+ - spec/nodeify_spec.rb
135
+ - spec/spec_helper.rb