railsdotjs 0.0.1

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.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: ddb78401249143bac0088f26fb4021a27996637e
4
+ data.tar.gz: f8362c112a13e2892914745d3707a753287a578f
5
+ SHA512:
6
+ metadata.gz: f04202e00ec0f754c78f113d63038511254ff2e60862002324b819309ded2b9eb11e108a2e865f81dfc2700fa57c2b38cb3699b7c07fe3bf63b8321921cb5efd
7
+ data.tar.gz: a4494270e9f4fb046c3f7c0b4f587c6b77cf79518a50727a964f47aa98c5510010e9d5b21a7b21aa219f85ec89c80a52fb4552dc7015647e3056a4e1bbb8cb30
@@ -0,0 +1,28 @@
1
+ require 'rails/generators/active_record'
2
+
3
+ module RailsDotJs
4
+ module Generators
5
+ class DaemonGenerator < ActiveRecord::Generators::Base
6
+ desc 'create daemon_script template'
7
+ source_root File.expand_path('../templates', __FILE__)
8
+
9
+ def self.source_root
10
+ File.expand_path('../templates', __FILE__)
11
+ end
12
+
13
+ def setup_directory
14
+ empty_directory 'script'
15
+ end
16
+
17
+ def copy_templates
18
+ template "daemon_script.erb", "script/#{name.downcase}"
19
+ template "controll_script.erb", "script/#{name.downcase}_ctrl"
20
+ end
21
+
22
+ def chmod_scripts
23
+ chmod "script/#{name.downcase}", 0755
24
+ chmod "script/#{name.downcase}_ctrl", 0755
25
+ end
26
+ end
27
+ end
28
+ end
@@ -0,0 +1,18 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'rubygems'
4
+ require 'bundler/setup'
5
+ require 'daemons'
6
+
7
+ #damons gem options, please refer http://www.rubydoc.info/gems/daemons/Daemons#run-class_method
8
+ options = {
9
+ app_name: '<%= name.downcase %>',
10
+ dir_mode: :normal,
11
+ dir: 'tmp/pids',
12
+ multiple: false,
13
+ monitor: true,
14
+ log_dir: 'log',
15
+ log_output: true
16
+ }
17
+
18
+ Daemons.run 'script/<%= name.downcase %>', options
@@ -0,0 +1,17 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ <% class_name = name.downcase.classify %>
4
+ require 'rubygems'
5
+ require 'bundler/setup'
6
+ require 'railsdotjs'
7
+
8
+ class <%= class_name %>Runner
9
+ include RailsDotJs
10
+ def run
11
+ set_config(:node_path, "#{File.dirname __FILE__}/../app/nodejs")
12
+ ## it replace current process with the command executed so that it can be managed by daemons gem
13
+ # daemonize_node("someNodeScriptHere.js")
14
+ end
15
+ end
16
+
17
+ <%= class_name %>Runner.new.run
@@ -0,0 +1,27 @@
1
+ require 'rails/generators/active_record'
2
+
3
+ module RailsDotJs
4
+ module Generators
5
+ class InstallGenerator < ActiveRecord::Generators::Base
6
+ desc 'prepare node.js working environment'
7
+ argument :name, type: :string, default: ""
8
+ source_root File.expand_path('../templates', __FILE__)
9
+
10
+ def self.source_root
11
+ File.expand_path('../test', __FILE__)
12
+ end
13
+
14
+ def setup_directory
15
+ puts "test"
16
+ empty_directory 'app/nodejs'
17
+ template 'package.json', 'app/nodejs/package.json'
18
+ end
19
+
20
+ def add_node_modules_to_gitignore
21
+ append_to_file '.gitignore' do
22
+ "\n" + %w[#railsdotjs app/nodejs/node_modules app/nodejs/npm-debug.log].join("\n") + "\n"
23
+ end
24
+ end
25
+ end
26
+ end
27
+ end
@@ -0,0 +1,10 @@
1
+ {
2
+ "name": "",
3
+ "version": "0.0.1",
4
+ "description": "",
5
+ "scripts": {
6
+ "test": "echo \"Error: no test specified\" && exit 1"
7
+ },
8
+ "author": "",
9
+ "license": "ISC"
10
+ }
@@ -0,0 +1,22 @@
1
+ module RailsDotJs
2
+ module Execution
3
+
4
+ def execute_node(file)
5
+ Dir.chdir(fetch_config(:node_path)) do
6
+ system("#{node_cmd} #{file}")
7
+ end
8
+ end
9
+
10
+ def daemonize_node(file)
11
+ Dir.chdir(fetch_config(:node_path)) do
12
+ exec("#{node_cmd} #{file}")
13
+ end
14
+ end
15
+
16
+ private
17
+ def node_cmd
18
+ node_env = fetch_config(:node_env)
19
+ ENV['NVM_BIN'] ? "NODE_ENV=#{node_env} #{ENV['NVM_BIN']}/node" : "NODE_ENV=#{node_env} node"
20
+ end
21
+ end
22
+ end
@@ -0,0 +1,29 @@
1
+ require 'rails_dot_js/execution'
2
+
3
+ module RailsDotJs
4
+
5
+ def self.included(base)
6
+ base.send(:include, Execution)
7
+ end
8
+
9
+ #implement block later
10
+ def set_config(key, value)
11
+ _config[key] = value
12
+ end
13
+
14
+ def fetch_config(key)
15
+ _config[key]
16
+ end
17
+
18
+ private
19
+ def _config
20
+ @config ||= _default_config
21
+ end
22
+
23
+ def _default_config
24
+ {
25
+ node_path: File.expand_path('app/nodejs'),
26
+ node_env: ENV["RAILS_ENV"] || 'development'
27
+ }
28
+ end
29
+ end
data/lib/railsdotjs.rb ADDED
@@ -0,0 +1 @@
1
+ require 'rails_dot_js'
metadata ADDED
@@ -0,0 +1,107 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: railsdotjs
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Jonghun Yu
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2016-05-07 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: rails
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '3.2'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '3.2'
27
+ - !ruby/object:Gem::Dependency
28
+ name: daemons
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '1.2'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '1.2'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rspec
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '1.2'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '1.2'
55
+ - !ruby/object:Gem::Dependency
56
+ name: pry
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '0.10'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '0.10'
69
+ description: Node.js environment for Rails applications
70
+ email: jonghun.yu@nerdyfactory.com
71
+ executables: []
72
+ extensions: []
73
+ extra_rdoc_files: []
74
+ files:
75
+ - lib/generators/rails_dot_js/daemon/daemon_generator.rb
76
+ - lib/generators/rails_dot_js/daemon/templates/controll_script.erb
77
+ - lib/generators/rails_dot_js/daemon/templates/daemon_script.erb
78
+ - lib/generators/rails_dot_js/install/install_generator.rb
79
+ - lib/generators/rails_dot_js/install/templates/package.json
80
+ - lib/rails_dot_js.rb
81
+ - lib/rails_dot_js/execution.rb
82
+ - lib/railsdotjs.rb
83
+ homepage: https://github.com/nerdyfactory/railsdotjs
84
+ licenses:
85
+ - MIT
86
+ metadata: {}
87
+ post_install_message:
88
+ rdoc_options: []
89
+ require_paths:
90
+ - lib
91
+ required_ruby_version: !ruby/object:Gem::Requirement
92
+ requirements:
93
+ - - ">="
94
+ - !ruby/object:Gem::Version
95
+ version: '0'
96
+ required_rubygems_version: !ruby/object:Gem::Requirement
97
+ requirements:
98
+ - - ">="
99
+ - !ruby/object:Gem::Version
100
+ version: '0'
101
+ requirements: []
102
+ rubyforge_project:
103
+ rubygems_version: 2.5.1
104
+ signing_key:
105
+ specification_version: 4
106
+ summary: Node.js environment for Rails applications
107
+ test_files: []