scms 3.0.1 → 3.0.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- MzkwY2RiZDFhZmJiNzA3NjFmYzI0MWFhMTFlMGVkMDk2NDMwNGU5ZA==
4
+ YmEyNWY2NzYyNjE4NzNiODllNDFlMjFhZTIyMTRhM2YwNWUzNWQ2MQ==
5
5
  data.tar.gz: !binary |-
6
- NDk2YjU2ZDRhYTA5NTdkMTYzYjY3NTBmMzRiOGEyODI3N2E1N2EzZA==
6
+ NjYyNDhmNTEwOTQyZThmNWY1NDRjYTI3YjE4NDM1MjgyODRlY2M4Mg==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- NjRhYTU4MmEzZjFkN2ZmZGIzNTdmMDhiOTFlMDI3NTEwMjNiYTMzZjRkOWQ0
10
- YjA0Y2UwZTIwYWQ1NTk2ZjNjN2JhOTViYTJhNjZlZjBkMjViOWVkNmRhMjM0
11
- YzJiZDFhMTY2MjQ1MzI2OWRkOGRkYmZmYjk2NTY5NmY0YTJmNTk=
9
+ MTEyYjNjMzk3NWZkYTk4NTJhZTc2Y2QxODQ3YTQyNTU5NjQ4MGFkYWIyNmE2
10
+ ZTE4OWE0MmU0YWU3NzExN2YyYzBmYmNiMDhkMDUzYWQ4YTIwNGE3MjU5N2U0
11
+ NTFjNmViZjMyYTgwZjhmMDJlYmJjOTBlNmM3ZmI1ZGQ4M2M5NjY=
12
12
  data.tar.gz: !binary |-
13
- ZTg2MjViMGUwMzQ5NDVlMzlkZTYxNzJlZjAyMjQ2ZDliNzAyNTM3YmVkZDkw
14
- ZjI2MGNkMTdmYTQyZWFhODZiYTk2ZDBmYWJiY2RkNzgyN2Q2YzczNTY3ZTUz
15
- ZjI0ZTAyZDViOTFjYTAzNjg2NTJiMmIwMTEzZTUzN2Y2NjkzYmE=
13
+ ZjM5NWIyNDg1NGZlYTQ4NzVhNWJkOTM2NzEyZDQ4ZTQ5NjhlMDc0ZWFhM2I3
14
+ NjY1MmM2NGJlYTc1OTk4MTEzYWVlYzFkYTAyMGU0MWUxOTQzN2ViZGYyMzRh
15
+ YzY5ZjM3YTBhNDIwMDk0NDllZDQwMDBlYjY0NWM5MGIzMGU0NDY=
data/bin/scms CHANGED
@@ -130,7 +130,16 @@ Scms.build(Folders[:website], Folders[:config], options[:mode])
130
130
  Scms.copywebsite(Folders[:website], Folders[:destination]) if Folders[:destination] != ''
131
131
 
132
132
  if options[:watch]
133
- require "Listen"
133
+ require "filewatcher"
134
+ # I dont really want to use filewatcher but I can't get listen to watch the config file
135
+ # I'd use filewatcher to monitor directories but it crashes if a file id deleted
136
+ watcher = Thread.new {
137
+ puts "Watching yam files"
138
+ FileWatcher.new(["_config.yml"]).watch do |filename|
139
+ puts "Updated " + filename
140
+ Scms.build(Folders[:website], Folders[:config], options[:mode])
141
+ end
142
+ }
134
143
 
135
144
  psst = []
136
145
  #psst.push("_config.yml")# if File.exists?(configfile)
@@ -140,18 +149,15 @@ if options[:watch]
140
149
  psst.push("_source") if File.directory? "_source"
141
150
  psst.push("_resources") if File.directory? "_resources"
142
151
 
152
+ require "listen"
143
153
  puts "Setting up listen"
144
- listener = Listen.to(psst, force_polling: true ) do |modified, added, removed|
154
+ listener = Listen.to(psst, force_polling: true) do |modified, added, removed|
145
155
  puts "modified: #{modified}" if modified.length > 0
146
156
  puts "added: #{added}" if added.length > 0
147
157
  puts "removed: #{removed}" if removed.length > 0
148
158
 
149
159
  Scms.build(Folders[:website], Folders[:config], options[:mode]) if modified.length > 0
150
160
  end
151
- trap("INT"){
152
- puts "Closing file watcher"
153
- listener.stop
154
- }
155
161
  listener.start # not blocking
156
162
  sleep unless options[:server]
157
163
  end
@@ -1,44 +1,54 @@
1
1
  require 'webrick'
2
2
  require 'launchy'
3
+ require "scms/scms-utils.rb"
3
4
 
4
5
  module ScmsServer
5
6
  include WEBrick
6
7
 
7
8
  def ScmsServer.start(root_document, port, hostname="localhost")
8
9
 
9
- puts "Starting server: http://#{hostname}:#{port}"
10
- #:BindAddress
11
- server = HTTPServer.new(
12
- :DocumentRoot => root_document,
13
- :Port => port,
14
- :BindAddress => hostname
15
- )
16
-
17
- mime_types_file = File.expand_path('../../assets/mime.types', File.dirname(__FILE__))
18
- WEBrick::HTTPUtils::load_mime_types(mime_types_file)
19
-
20
- trap("INT"){
21
- puts "Closed http server"
22
- server.shutdown
23
- #exit!
24
- }
10
+ portopen = ScmsUtils.port_open? hostname, port
11
+ puts "Port Open: #{portopen}"
12
+
13
+ if !portopen
14
+ puts "Starting server: http://#{hostname}:#{port}"
15
+ #:BindAddress
16
+ server = HTTPServer.new(
17
+ :DocumentRoot => root_document,
18
+ :Port => port,
19
+ :BindAddress => hostname
20
+ )
21
+
22
+ mime_types_file = File.expand_path('../../assets/mime.types', File.dirname(__FILE__))
23
+ WEBrick::HTTPUtils::load_mime_types(mime_types_file)
24
+
25
+ trap("INT"){
26
+ puts "Closed http server"
27
+ server.shutdown
28
+ #exit!
29
+ }
30
+ else
31
+ puts "Server already running on port: #{port}"
32
+ end
25
33
 
26
34
  uri = "http://#{hostname}:#{port}"
27
35
  Launchy.open( uri ) do |exception|
28
36
  puts "Attempted to open #{uri} and failed because #{exception}"
29
37
  end
30
38
 
31
- begin
32
- server.start
33
- rescue SystemExit, Interrupt
34
- puts "Closing web brick"
35
- server.start
36
- rescue StandardError => e
37
- puts "StandardError"
38
- server.shutdown
39
- rescue Exception => e
40
- puts "scms-server exception"
41
- rais e
39
+ if !portopen
40
+ begin
41
+ server.start
42
+ rescue SystemExit, Interrupt
43
+ puts "Closing web brick"
44
+ server.start
45
+ rescue StandardError => e
46
+ puts "StandardError"
47
+ server.shutdown
48
+ rescue Exception => e
49
+ puts "scms-server exception"
50
+ rais e
51
+ end
42
52
  end
43
53
  end
44
54
 
@@ -3,11 +3,27 @@ module ScmsUtils
3
3
  require 'fileutils'
4
4
  require 'open-uri'
5
5
 
6
+ require 'socket'
7
+ require 'timeout'
8
+
9
+ def ScmsUtils.port_open?(ip, port, seconds=1)
10
+ Timeout::timeout(seconds) do
11
+ begin
12
+ TCPSocket.new(ip, port).close
13
+ true
14
+ rescue Errno::ECONNREFUSED, Errno::EHOSTUNREACH
15
+ false
16
+ end
17
+ end
18
+ rescue Timeout::Error
19
+ false
20
+ end
21
+
6
22
  def ScmsUtils.getsettings(yamlpath)
7
23
  ScmsUtils.log("Loading Config: #{ScmsUtils.uriEncode("file:///#{yamlpath}")}")
8
24
  config = nil
9
25
 
10
- ##http://snk.tuxfamily.org/log/yaml-json-validation-kwalify-ruby19.html
26
+ ##http://snk.tuxfamily.org/log/yaml-json-validation-kwalify-ruby19.html
11
27
  #'kwalify'
12
28
  #schema = Kwalify::Yaml.load_file('some_complex_schema.yaml')
13
29
  #validator = Kwalify::Validator.new(schema)
data/lib/scms/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Scms
2
- VERSION = "3.0.1"
2
+ VERSION = "3.0.2"
3
3
  end
data/scms.gemspec CHANGED
@@ -32,6 +32,7 @@ Gem::Specification.new do |spec|
32
32
  spec.add_dependency "sass"
33
33
  spec.add_dependency "packr"
34
34
  spec.add_dependency "listen"
35
+ spec.add_dependency "filewatcher"
35
36
  spec.add_dependency "webrick"
36
37
  spec.add_dependency "launchy"
37
38
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: scms
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.0.1
4
+ version: 3.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Courtenay Probert
@@ -80,6 +80,20 @@ dependencies:
80
80
  - - ! '>='
81
81
  - !ruby/object:Gem::Version
82
82
  version: '0'
83
+ - !ruby/object:Gem::Dependency
84
+ name: filewatcher
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - ! '>='
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
90
+ type: :runtime
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - ! '>='
95
+ - !ruby/object:Gem::Version
96
+ version: '0'
83
97
  - !ruby/object:Gem::Dependency
84
98
  name: webrick
85
99
  requirement: !ruby/object:Gem::Requirement