foresite 1.2.0 → 1.3.0

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: 5f29318fc927950483a0152c49fe8e735c37ff973b4d149a51b6ce005f7f6207
4
- data.tar.gz: 152396f93cb282709e9f455429a4ecaf079a4e3ba7fdb7386e18297998d359df
3
+ metadata.gz: 31f026a8d80bce2b57fbe4b909cb3c6490ca50debf834de0636c7b713749fe83
4
+ data.tar.gz: 0b450e5e2639cb57ece5ae26810c8b467a6d91bc269ffcb1f96bb4e2f18fd716
5
5
  SHA512:
6
- metadata.gz: f78b29800c68377c4d92c8da49c75cae51ae1a991b8a596bfede5e40fc2d4e592f9c07fe9f9e7d34799f87cf00648be7654cfc0bf9118ad6c9f9901615aee549
7
- data.tar.gz: 5b5c3d8d13eabca810587354b17a16ac01573548f89436b3a91bd0f3b16a25a4165c42302d3684665804f8c714fe25cd8adc35b03fb16fb4b80fd96d58a6dc9c
6
+ metadata.gz: 5ab2348a5bb8eb90c0707a4ace0921e586a15d7d2838d72f4841fe39165a3912c129593ca4b5075dde9b62ad94a114cf4170865fb89781d2c3ec8f40d24b4c16
7
+ data.tar.gz: 543c72aad677e681b17b12eae7c43a927fbe1417b98c1cf0838fc9f9b343e55ae3730308ce679cf522cf698bedc8c3cddbb56a67f713355af1768b55d54566f0
data/README.md CHANGED
@@ -107,6 +107,10 @@ In this example, the `index.html` will contain:
107
107
  </ul>
108
108
  ```
109
109
 
110
+ ### 5. Watch files and build automatically
111
+
112
+ Run `foresite watch` to detect changes to markdown or ERB files, build will run automatically. Useful for previewing content locally.
113
+
110
114
  ## Development
111
115
 
112
116
  1. Clone
data/lib/foresite/cli.rb CHANGED
@@ -12,6 +12,11 @@ module Foresite
12
12
  true
13
13
  end
14
14
 
15
+ desc "version", "Displays version"
16
+ def version
17
+ $stdout.puts(Foresite::VERSION)
18
+ end
19
+
15
20
  desc "init", "Initializes foresite in current directory"
16
21
  long_desc <<-LONGDESC
17
22
  Initializes foresite in the current directory.
@@ -117,5 +122,28 @@ module Foresite
117
122
 
118
123
  $stdout.puts("Created #{Foresite.relative_path(index_html_path)}")
119
124
  end
125
+
126
+ desc "watch", "Watches markdown and templates files and runs `build` when they change"
127
+ long_desc <<-LONGDESC
128
+ See `build` help for more information
129
+ LONGDESC
130
+
131
+ # @todo How might we test this?
132
+ def watch
133
+ dirs_to_watch = [
134
+ Foresite::DIRNAME_MARKDOWN,
135
+ Foresite::DIRNAME_ERB
136
+ ]
137
+
138
+ $stdout.puts("Watching #{dirs_to_watch.map { "./#{_1}" }.join(", ")} for changes... (Ctrl+C to exit)")
139
+
140
+ Filewatcher.new(dirs_to_watch).watch do |changes|
141
+ changes.each do |filename, event|
142
+ $stdout.puts("#{File.basename(filename)} #{event}")
143
+ end
144
+
145
+ build
146
+ end
147
+ end
120
148
  end
121
149
  end
@@ -14,7 +14,7 @@ module Foresite
14
14
  @path = path
15
15
  vars.each do |k, v|
16
16
  if k.is_a?(Symbol)
17
- instance_variable_set("@#{k}".to_sym, v)
17
+ instance_variable_set(:"@#{k}", v)
18
18
  end
19
19
  end
20
20
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Foresite
4
- VERSION = "1.2.0"
4
+ VERSION = "1.3.0"
5
5
  end
data/lib/foresite.rb CHANGED
@@ -1,8 +1,9 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require "erb"
4
- require "thor"
4
+ require "filewatcher"
5
5
  require "kramdown"
6
+ require "thor"
6
7
  require "zeitwerk"
7
8
 
8
9
  loader = Zeitwerk::Loader.for_gem
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: foresite
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.0
4
+ version: 1.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Carl Wiedemann
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-02-12 00:00:00.000000000 Z
11
+ date: 2024-01-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: kramdown
@@ -52,6 +52,20 @@ dependencies:
52
52
  - - "~>"
53
53
  - !ruby/object:Gem::Version
54
54
  version: '2.6'
55
+ - !ruby/object:Gem::Dependency
56
+ name: filewatcher
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '2.1'
62
+ type: :runtime
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '2.1'
55
69
  - !ruby/object:Gem::Dependency
56
70
  name: rspec
57
71
  requirement: !ruby/object:Gem::Requirement