ruby-station-runtime 0.0.4

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,27 @@
1
+ require 'rake/gempackagetask'
2
+
3
+ version = File.read('VERSION').chomp
4
+
5
+ spec = Gem::Specification.new do |s|
6
+ s.name = 'ruby-station-runtime'
7
+ s.version = version
8
+ s.has_rdoc = false
9
+ # s.extra_rdoc_files = %w(README.rdoc)
10
+ # s.rdoc_options = %w(--main README.rdoc)
11
+ s.summary = "Runtime library for RubyStation"
12
+ s.author = 'Yutaka HARA'
13
+ s.email = 'yutaka.hara/at/gmail.com'
14
+ # s.homepage = 'http://my-site.net'
15
+ s.files = %w(Rakefile) + Dir.glob("{lib}/**/*")
16
+ end
17
+
18
+ Rake::GemPackageTask.new(spec) do |pkg|
19
+ pkg.gem_spec = spec
20
+ end
21
+
22
+ desc 'Generate the gemspec'
23
+ task :gemspec do
24
+ file = File.dirname(__FILE__) + "/#{spec.name}.gemspec"
25
+ File.open(file, 'w') {|f| f << spec.to_ruby }
26
+ puts "Created gemspec: #{file}"
27
+ end
@@ -0,0 +1,30 @@
1
+ require 'optparse'
2
+
3
+ module RubyStation
4
+ @port = nil
5
+ @data_dir = nil
6
+
7
+ def self.parse_argv
8
+ OptionParser.new{|o|
9
+ o.on("--port N"){|n| @port = n}
10
+ o.on("--data-dir PATH"){|d| @data_dir = d}
11
+ }.parse!(ARGV)
12
+
13
+ unless @port
14
+ @port = 40000 + rand(10000)
15
+ warn "--port is not specified; assuming it is #{@port}"
16
+ end
17
+ unless @data_dir
18
+ @data_dir = File.expand_path("./")
19
+ warn "--data-dir is not specified; assuming it is #{@data_dir}"
20
+ end
21
+ end
22
+
23
+ def self.port; @port; end
24
+ def self.data_dir; @data_dir; end
25
+ def self.data_path(filename)
26
+ File.expand_path(filename, @data_dir)
27
+ end
28
+
29
+ autoload :Helper, "ruby-station/helper"
30
+ end
@@ -0,0 +1,5 @@
1
+ module RubyStation
2
+ module Helper
3
+ autoload :Rails, "ruby-station/helper/rails.rb"
4
+ end
5
+ end
@@ -0,0 +1,64 @@
1
+ require 'fileutils'
2
+ module RubyStation
3
+ module Helper
4
+
5
+ # This module helps invoking Rails apps.
6
+ # During execution of the application, Rails writes data to
7
+ # many directories (db/, log/, tmp/).
8
+ # So this helper copies all the files into data_dir and
9
+ # invoke the app within the directory.
10
+ #
11
+ # Be sure to run 'rake db:migrate RAILS_ENV=produciton'
12
+ # before you create the gem of your app.
13
+ #
14
+ # @example
15
+ # RubyStation::Helper::Rails.run
16
+ #
17
+ # @api external
18
+
19
+ module Rails
20
+
21
+ # Copy files (if needed) and start Rails server.
22
+ #
23
+ # @api external
24
+ def self.run
25
+ caller_path = caller[0][/^(.*):/, 1]
26
+ self.install(File.dirname(caller_path))
27
+
28
+ Dir.chdir(RubyStation.data_dir)
29
+ self.start_server
30
+ end
31
+
32
+ # Ensure your app is copied to data_dir.
33
+ # It does nothing if already copied.
34
+ #
35
+ # @api internal
36
+ def self.install(app_dir)
37
+ # Note: "." is needed, otherwise copied as data_dir/appname/*
38
+ from = File.join(app_dir, ".")
39
+ to = RubyStation.data_dir
40
+
41
+ unless installed?(from, to)
42
+ FileUtils.cp_r(from, to)
43
+ end
44
+ end
45
+
46
+ # Checks if the files are copied
47
+ #
48
+ # @api internal
49
+ def self.installed?(from, to)
50
+ # Note: Too simple?
51
+ File.exist?(File.join(to, "main.rb"))
52
+ end
53
+
54
+ # Start Rails with 'script/server'.
55
+ #
56
+ # @api internal
57
+ def self.start_server
58
+ Dir.chdir(RubyStation.data_dir)
59
+ # TODO: Support Windows
60
+ exec "./script/server -p #{RubyStation.port} -e production"
61
+ end
62
+ end
63
+ end
64
+ end
metadata ADDED
@@ -0,0 +1,58 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: ruby-station-runtime
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.4
5
+ platform: ruby
6
+ authors:
7
+ - Yutaka HARA
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+
12
+ date: 2009-08-15 00:00:00 +09:00
13
+ default_executable:
14
+ dependencies: []
15
+
16
+ description:
17
+ email: yutaka.hara/at/gmail.com
18
+ executables: []
19
+
20
+ extensions: []
21
+
22
+ extra_rdoc_files: []
23
+
24
+ files:
25
+ - Rakefile
26
+ - lib/ruby-station/helper/rails.rb
27
+ - lib/ruby-station/helper.rb
28
+ - lib/ruby-station.rb
29
+ has_rdoc: true
30
+ homepage:
31
+ licenses: []
32
+
33
+ post_install_message:
34
+ rdoc_options: []
35
+
36
+ require_paths:
37
+ - lib
38
+ required_ruby_version: !ruby/object:Gem::Requirement
39
+ requirements:
40
+ - - ">="
41
+ - !ruby/object:Gem::Version
42
+ version: "0"
43
+ version:
44
+ required_rubygems_version: !ruby/object:Gem::Requirement
45
+ requirements:
46
+ - - ">="
47
+ - !ruby/object:Gem::Version
48
+ version: "0"
49
+ version:
50
+ requirements: []
51
+
52
+ rubyforge_project:
53
+ rubygems_version: 1.3.5
54
+ signing_key:
55
+ specification_version: 3
56
+ summary: Runtime library for RubyStation
57
+ test_files: []
58
+