staticz 1.0.8 → 1.0.10

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: 9dc81074383e9eddcace7b5105ee493ff6c60747a4786d7ae1cff8bee14c34e1
4
- data.tar.gz: 8334be7d7d23c672a9437681503b777758eb34c23eaa08fd61d546c327e702e9
3
+ metadata.gz: 3f4c779f303f2e6bfa06e6135323e61e4c089067361d4239d6c53903c239ae02
4
+ data.tar.gz: 8958a5a56ed411ef10584076a57994a67786cda23bf6d3f0d012d77cf7954ae3
5
5
  SHA512:
6
- metadata.gz: eb3a9a6af3a70575c0c2f231950dc2ef6cf695e4e00bc76badea2d1cb82c64984feccb2c4825996b423de6ccf7fc19887f059acb67d178fecf17e5c9015fde7c
7
- data.tar.gz: f035fe31cfa792756132f0a52148a8b62f2983ceead70b6c2688b889fb1163d490d785aa023d9e48712166e901e4ab446b9e1b5b5e17016330f360e3b8fb1574
6
+ metadata.gz: 2e49f8abff572d050666d143a4a6bbf555e2d97dfbb9d0614950dd3f93ce1d8121e34c4dac74f730fc5b8e7c6d199a675c493074881ff1f74c3a3d6aefd4ecb6
7
+ data.tar.gz: 510b452f0dbd668b955ecd56f34e8ef468c42cec49e061968784d0eb9b1917572b1f78d6e5afa56c41635aa035a55c734583c544138eda6486ee30b3d5271e58
@@ -16,10 +16,8 @@ module Staticz
16
16
  end
17
17
 
18
18
  def create_link_function
19
- end
20
-
21
- def path_method_name
22
- "no path created"
19
+ link_path = "/#{name}"
20
+ Object.send(:define_method, path_method_name) { link_path }
23
21
  end
24
22
 
25
23
  def tile_type_name = "File"
@@ -19,7 +19,7 @@ module Staticz
19
19
  end
20
20
 
21
21
  def path_method_name
22
- "#{path.gsub(/[\/-]/, "_")}_path"
22
+ "#{path.gsub(/[.\/-]/, "_")}_path"
23
23
  end
24
24
 
25
25
  def valid?
@@ -35,8 +35,15 @@ module Staticz
35
35
  end
36
36
 
37
37
  def create_link_function
38
- link_path = "#{name}.#{build_file_ending}"
39
- Object.send(:define_method, path_method_name) { link_path }
38
+ link_path = "/#{name}.#{build_file_ending}"
39
+ shortened_link_path = "/#{name}"
40
+ Object.send(:define_method, path_method_name) do |shorten: false|
41
+ if shorten
42
+ shortened_link_path
43
+ else
44
+ link_path
45
+ end
46
+ end
40
47
  end
41
48
 
42
49
  def print(indentation)
@@ -56,12 +56,16 @@ module Staticz
56
56
  def build
57
57
  load "#{Dir.pwd}/manifest.rb"
58
58
 
59
+ create_link_functions
60
+
59
61
  elements.each do |e|
60
- e.create_link_function
62
+ e.build
61
63
  end
64
+ end
62
65
 
66
+ def create_link_functions
63
67
  elements.each do |e|
64
- e.build
68
+ e.create_link_function
65
69
  end
66
70
  end
67
71
 
data/lib/server.rb CHANGED
@@ -46,6 +46,7 @@ module Staticz
46
46
  build_manifest
47
47
 
48
48
  Thread.new { listen_to_file_changes }
49
+ Thread.new { listen_to_manifest_changes }
49
50
  thin_server.start
50
51
  end
51
52
 
@@ -68,25 +69,36 @@ module Staticz
68
69
  folders << "lib" if Dir.exist? "lib"
69
70
 
70
71
  listener = Listen.to(*folders) do |modified, added, removed|
71
- file_names = (modified + added + removed)
72
- .map do |file|
73
- file.gsub "#{Dir.pwd}/", ""
74
- end
75
- .join(", ")
72
+ trigger_rebuild(modified, added, removed)
73
+ end
74
+ listener.start
75
+ end
76
76
 
77
- $stdout.clear_screen
78
- puts "#{file_names} changed, rebuilding..."
79
- build_manifest
80
- puts "Rebuilding successful"
77
+ def listen_to_manifest_changes
78
+ listener = Listen.to("./", only: /^manifest.rb$/) do |modified, added, removed|
79
+ trigger_rebuild(modified, added, removed)
81
80
  end
82
81
  listener.start
83
82
  end
84
83
 
85
- def build_manifest
86
- Staticz::Modules::Reload.generate_hash
84
+ def trigger_rebuild(modified, added, removed)
85
+ file_names = (modified + added + removed)
86
+ .map do |file|
87
+ file.gsub "#{Dir.pwd}/", ""
88
+ end
89
+ .join(", ")
87
90
 
91
+ $stdout.clear_screen
92
+ puts "#{file_names} changed, rebuilding..."
93
+ build_manifest
94
+ puts "Rebuilding successful"
95
+ end
96
+
97
+ def build_manifest
88
98
  Staticz::Builder.new
89
99
  Staticz::Manifest.instance.print
100
+
101
+ Staticz::Modules::Reload.generate_hash
90
102
  end
91
103
  end
92
104
  end
data/lib/staticz.rb CHANGED
@@ -27,7 +27,12 @@ module Staticz
27
27
  Staticz::Settings.development!
28
28
  Staticz::Server.new
29
29
  when 'manifest'
30
+ Staticz::Settings.development!
31
+
30
32
  load "#{Dir.pwd}/manifest.rb"
33
+ Staticz::Modules::LibLoader.load_files
34
+ Staticz::Manifest.instance.create_link_functions
35
+
31
36
  Staticz::Manifest.instance.print
32
37
  when 'build'
33
38
  Staticz::Settings.production!
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.8
4
+ version: 1.0.10
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-06-04 00:00:00.000000000 Z
11
+ date: 2022-06-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: haml