staticz 1.0.5 → 1.0.8

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 23c5d47878cb2aa50e4da152b27c555e57c39f37d7eb82f11d5037aca6533626
4
- data.tar.gz: a3b6dd663415f4e37fefa0dadce8e5a26195c61d0259b906675fb0319d65b412
3
+ metadata.gz: 9dc81074383e9eddcace7b5105ee493ff6c60747a4786d7ae1cff8bee14c34e1
4
+ data.tar.gz: 8334be7d7d23c672a9437681503b777758eb34c23eaa08fd61d546c327e702e9
5
5
  SHA512:
6
- metadata.gz: 427e1feb7625a5300b1295b22314739d22b19dd91b2dc048f3303fd172ac6a66c36b6aab9ff02e6208e12f5450dd7735ace76331b4f594ca05f11de62b321ae2
7
- data.tar.gz: 37bcad9605a3bc4fd96502a8fe1c86915e2a0d58928720875c0e24138334ece1e71e91f39f5d696341a01c4ed3bb980e27c9da4ca82f4c90e027d2782cfb439f
6
+ metadata.gz: eb3a9a6af3a70575c0c2f231950dc2ef6cf695e4e00bc76badea2d1cb82c64984feccb2c4825996b423de6ccf7fc19887f059acb67d178fecf17e5c9015fde7c
7
+ data.tar.gz: f035fe31cfa792756132f0a52148a8b62f2983ceead70b6c2688b889fb1163d490d785aa023d9e48712166e901e4ab446b9e1b5b5e17016330f360e3b8fb1574
data/lib/builder.rb CHANGED
@@ -1,3 +1,5 @@
1
+ require_relative "modules/lib_loader"
2
+
1
3
  module Staticz
2
4
  class Builder
3
5
  def initialize
@@ -7,6 +9,8 @@ module Staticz
7
9
  private
8
10
 
9
11
  def build
12
+ Staticz::Modules::LibLoader.load_files
13
+
10
14
  Dir.mkdir('build') unless File.exist?('build')
11
15
 
12
16
  Staticz::Manifest.instance.build
@@ -0,0 +1,18 @@
1
+ module Staticz
2
+ module Modules
3
+ class LibLoader
4
+ def self.load_files
5
+ return if !Dir.exist? "lib"
6
+
7
+ Dir["lib/**/*.rb"].each do |rb_file|
8
+ begin
9
+ load rb_file
10
+ rescue SyntaxError => e
11
+ puts Colors.in_red("Could not load #{rb_file}:")
12
+ puts Colors.in_red(e.message)
13
+ end
14
+ end
15
+ end
16
+ end
17
+ end
18
+ end
@@ -14,7 +14,7 @@ module Staticz
14
14
  function checkForChanges() {
15
15
  console.log("Check for file changes");
16
16
  var response = new XMLHttpRequest();
17
- response.open("GET", "api/test", true);
17
+ response.open("GET", "api/hash", true);
18
18
  response.onload = function() {
19
19
  if (response.status === 200) {
20
20
  if (!hash) {
data/lib/server.rb CHANGED
@@ -20,7 +20,7 @@ module Staticz
20
20
  ]
21
21
  }
22
22
  end
23
- map "/api/test" do
23
+ map "/api/hash" do
24
24
  run lambda { |env|
25
25
  [
26
26
  200,
@@ -64,10 +64,13 @@ module Staticz
64
64
  private
65
65
 
66
66
  def listen_to_file_changes
67
- listener = Listen.to('src') do |modified, added, removed|
67
+ folders = ["src"]
68
+ folders << "lib" if Dir.exist? "lib"
69
+
70
+ listener = Listen.to(*folders) do |modified, added, removed|
68
71
  file_names = (modified + added + removed)
69
72
  .map do |file|
70
- file.gsub "#{Dir.pwd}/src/", ""
73
+ file.gsub "#{Dir.pwd}/", ""
71
74
  end
72
75
  .join(", ")
73
76
 
data/lib/settings.rb CHANGED
@@ -17,3 +17,11 @@ module Staticz
17
17
  end
18
18
  end
19
19
  end
20
+
21
+ def development?
22
+ Staticz::Settings.development?
23
+ end
24
+
25
+ def production?
26
+ Staticz::Settings.production?
27
+ end
data/lib/utils/helpers.rb CHANGED
@@ -1,10 +1,10 @@
1
- def render(component, &block)
1
+ def render(component, locals: {}, &block)
2
2
  engine = ::Haml::Engine.new(File.read("src/#{component}.haml"))
3
3
 
4
4
  if block
5
- engine.render({}, &block)
5
+ engine.render(Object.new, locals, &block)
6
6
  else
7
- engine.render
7
+ engine.render(Object.new, locals)
8
8
  end
9
9
  end
10
10
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: staticz
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.5
4
+ version: 1.0.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - Philipp Schlesinger
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-05-27 00:00:00.000000000 Z
11
+ date: 2022-06-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: haml
@@ -129,6 +129,7 @@ files:
129
129
  - lib/manifest/compilable/simple_file.rb
130
130
  - lib/manifest/manifest.rb
131
131
  - lib/manifest/sub.rb
132
+ - lib/modules/lib_loader.rb
132
133
  - lib/modules/reload.rb
133
134
  - lib/server.rb
134
135
  - lib/settings.rb