Plug Locomotive::Common Bring listen back to wagon
arnaud sellenet
committed Apr 14, 2014
commit 97cd02206b85335949a7aaf9c243cea1cc2b9efc
Showing 7
changed files with
38 additions
and 8 deletions
Gemfile
+4
-2
| @@ | @@ -7,11 +7,13 @@ gemspec |
| # gem 'locomotivecms-liquid', path: '../gems/liquid', require: false | |
| # gem 'locomotivecms-solid', path: '../gems/solid', require: false | |
| # gem 'locomotivecms_mounter', path: '../gems/mounter', require: false | |
| + | # gem 'locomotivecms_steam', path: '../gems/steam' |
| # gem 'locomotivecms_mounter', github: 'locomotivecms/mounter', ref: '34d24feeb8', require: false | |
| - | gem 'rb-fsevent', '~> 0.9.1' |
| + | gem 'locomotivecms_common', path: '../common/' |
| + | gem 'locomotivecms_steam', path: '../steam/' |
| + | gem 'pry' |
| group :test do | |
| - | gem 'pry' |
| gem 'coveralls', require: false | |
| end | |
| \ No newline at end of file | |
locomotive/wagon.rb b/lib/locomotive/wagon.rb
+3
-2
| @@ | @@ -1,3 +1,4 @@ |
| + | require 'common' |
| require 'locomotive/wagon/version' | |
| require 'locomotive/wagon/logger' | |
| require 'locomotive/wagon/listen' | |
| @@ | @@ -24,6 +25,7 @@ module Locomotive |
| # @param [ Hash ] options The options for the thin server (host, port) | |
| # | |
| def self.serve(path, options) | |
| + | |
| if reader = self.require_mounter(path, true) | |
| Bundler.require 'misc' | |
| @@ | @@ -55,7 +57,6 @@ module Locomotive |
| use_listen = Process.pid != parent_pid && !options[:disable_listen] | |
| end | |
| - | |
| Locomotive::Wagon::Listen.instance.start(reader) if use_listen | |
| server.start | |
| @@ | @@ -183,7 +184,7 @@ module Locomotive |
| # @param [ Object ] An instance of the reader is the get_reader parameter has been set. | |
| # | |
| def self.require_mounter(path, get_reader = false) | |
| - | Locomotive::Common::Logger.setup(path, false) |
| + | Locomotive::Common::Logger.setup(File.expand_path(File.join(path, 'log', 'wagon.log'))) |
| require 'locomotive/mounter' | |
locomotive/wagon/cli.rb b/lib/locomotive/wagon/cli.rb
+1
-1
| @@ | @@ -126,7 +126,7 @@ module Locomotive |
| if Locomotive::Wagon.init(name, path, options[:skip_bundle].to_s, generator, generator_options) | |
| self.print_next_instructions_when_site_created(name, path, options[:skip_bundle]) | |
| end | |
| - | rescue GeneratorException => e |
| + | rescue Locomotive::Common::GeneratorException => e |
| self.print_exception(e, options[:verbose]) | |
| exit(1) | |
| end | |
locomotive/wagon/generators/site/unzip.rb b/lib/locomotive/wagon/generators/site/unzip.rb
+2
-2
| @@ | @@ -19,7 +19,7 @@ module Locomotive |
| def ask_for_location | |
| @location = options[:location] || ask('What is the location (on the filesystem or url) of the zip file ?') | |
| - | raise GeneratorException.new('Please enter a location') if @location.blank? |
| + | raise Locomotive::Common::GeneratorException.new('Please enter a location') if @location.blank? |
| end | |
| def download_or_copy | |
| @@ | @@ -46,7 +46,7 @@ module Locomotive |
| @path = $1 if file.name =~ /(.*)\/config\/site.yml$/ | |
| end | |
| end | |
| - | rescue Exception => e |
| + | rescue Exception # TODO remove catch-all |
| raise GeneratorException.new("Unable to unzip the archive") | |
| end | |
locomotive/wagon/standalone_server.rb b/lib/locomotive/wagon/standalone_server.rb
+26
-0
| @@ | @@ -0,0 +1,26 @@ |
| + | $:.unshift(File.expand_path(File.dirname(__FILE__) + '/../..')) |
| + | |
| + | require 'locomotive/wagon/logger' |
| + | require 'locomotive/wagon/version' |
| + | require 'locomotive/steam/server' |
| + | require 'locomotive/mounter' |
| + | |
| + | module Locomotive |
| + | module Wagon |
| + | class StandaloneServer < Locomotive::Steam::Server |
| + | |
| + | def initialize(path) |
| + | Locomotive::Common::Logger.setup(path, false) |
| + | |
| + | # get the reader |
| + | reader = Locomotive::Mounter::Reader::FileSystem.instance |
| + | reader.run!(path: path) |
| + | |
| + | Bundler.require 'misc' |
| + | |
| + | # run the rack app |
| + | super(reader, disable_listen: true) |
| + | end |
| + | end |
| + | end |
| + | end |
| \ No newline at end of file | |
locomotivecms_wagon.gemspec
+1
-0
| @@ | @@ -28,6 +28,7 @@ Gem::Specification.new do |gem| |
| gem.add_dependency 'locomotivecms_steam', '~> 0.1.0' | |
| gem.add_dependency 'locomotivecms_common', '~> 0.0.1' | |
| gem.add_dependency 'better_errors', '~> 1.0' | |
| + | gem.add_dependency 'listen', '~> 2.4.0' |
| gem.add_dependency 'faker', '~> 0.9.5' | |
spec/support/helpers.rb
+1
-1
| @@ | @@ -17,7 +17,7 @@ module Spec |
| def run_server | |
| path = 'spec/fixtures/default' | |
| - | Locomotive::Steam::Logger.setup(path, false) |
| + | Locomotive::Common::Logger.setup(path, false) |
| reader = Locomotive::Mounter::Reader::FileSystem.instance | |
| reader.run!(path: path) | |
| Locomotive::Steam::Server.new(reader, disable_listen: true) | |