Class: PostCss::Socket
- Inherits:
-
Object
- Object
- PostCss::Socket
- Defined in:
- lib/jekyll-postcss/socket.rb
Defined Under Namespace
Classes: PostCssRuntimeError
Constant Summary collapse
- START_SCRIPT =
File.("../../bin/command", __dir__)
- POSTCSS_SCRIPT =
File.("../../bin/postcss", __dir__)
Instance Method Summary collapse
-
#initialize ⇒ Socket
constructor
A new instance of Socket.
- #read ⇒ Object
- #write(data) ⇒ Object
Constructor Details
#initialize ⇒ Socket
Returns a new instance of Socket.
12 13 14 |
# File 'lib/jekyll-postcss/socket.rb', line 12 def initialize start_dev_server if development? end |
Instance Method Details
#read ⇒ Object
26 27 28 29 30 31 32 33 34 |
# File 'lib/jekyll-postcss/socket.rb', line 26 def read if development? decode(@postcss.gets.chomp) else raise "You must call PostCss#write before calling PostCss#read" if @compiled_css.nil? decode(@compiled_css) end end |
#write(data) ⇒ Object
16 17 18 19 20 21 22 23 24 |
# File 'lib/jekyll-postcss/socket.rb', line 16 def write(data) if development? @postcss.puts encode(data) else @compiled_css = `#{POSTCSS_SCRIPT} '#{encode(data)}'` end nil end |