zine 0.7.0 → 0.8.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
  SHA1:
3
- metadata.gz: 93524d954ddb98f46bfadc6715f4948043ac27c8
4
- data.tar.gz: 6cd531d59b6f636ed706c044743d254771e1c340
3
+ metadata.gz: db5b30774a28f16583540f93a394e24f5d34ae96
4
+ data.tar.gz: a2330b92a0df349f884af0dc46832f350440a50e
5
5
  SHA512:
6
- metadata.gz: bfab2b75d98d3cfde98e42533024cfb2edcd2d75d556143fd363149a34ea5de8e036a530db30179a9a6678986939dae50e4508daf94b3ea899e0e951a1dc2117
7
- data.tar.gz: 977940bf58cc38f453ff37a5079736ecafb3b27a26a4c170dd816aba2b4db5b4dd5a932b26170ad21de4f8843ded2359738a1a90c3276d1c749ceb1bc4fececc
6
+ metadata.gz: b1c8600ac22c3e08796fb98f5d5804bee2467254240849a1015a8ead613cbef10d110a726d665ac44a9f14a25683bf94830e130afa2c9af835b0f67c395d3c9e
7
+ data.tar.gz: ab65b753769cca93a4fde746ac14c1bc347daadb055ec8bca7e34751c4e244437f1975d93a346dbd5472bf01ae13d616a710a0bb994e2fb48354c2fb21e6154d
data/CHANGELOG.md CHANGED
@@ -107,3 +107,8 @@
107
107
 
108
108
  - caught an SFTP upload error where SFTP credentials aren't in the keychain
109
109
  - updated bundler
110
+
111
+ ## 0.8.0, October 2, 2017
112
+
113
+ - SFTP upload error wasn't caught in 0.7.0... TODO
114
+ - added a notice command, zine notice [FILE], which adds that file to the build queue without having to force a general build, so zine can be called in scripts to upload particular files (a rake script in Ripley, specifically)
data/README.md CHANGED
@@ -66,6 +66,7 @@ Commands:
66
66
  zine build # Build the site
67
67
  zine force # Build the site, forcing writes & uploads
68
68
  zine help [COMMAND] # Describe available commands or one specific command
69
+ zine notice POST # Build the site, then force the one POST
69
70
  zine nuke # Delete the build folder
70
71
  zine post TITLE # Create the file for a new blog post, titled TITLE
71
72
  zine site # Create the skeleton of a new site (overwriting files)
data/lib/zine.rb CHANGED
@@ -69,6 +69,45 @@ module Zine
69
69
  )
70
70
  end
71
71
 
72
+ # currently used to say yes on a script's behalf - in #notice
73
+ class MockHighlineYes
74
+ def ask(_question)
75
+ 'Y'
76
+ end
77
+ end
78
+
79
+ # Build the site, noticing this file as having changed
80
+ # Called by CLI#notice
81
+ def notice(file)
82
+ # build
83
+ init_templates
84
+ FileUtils.mkdir_p @options['directories']['build']
85
+ # posts_and_headlines_without_writing
86
+ posts = Zine::PostsAndHeadlines.new self, @options # starts watcher
87
+ posts_and_guard = posts.writeless
88
+ guard = posts_and_guard[:guard]
89
+
90
+ # give the file watchers something to notice
91
+ file_to_notice = File.join Dir.getwd,
92
+ @options['directories']['posts'],
93
+ file
94
+ posts.one_new_post file_to_notice
95
+ sleep 0.25
96
+ posts.one_new_post file_to_notice # overcome latency in the watcher...
97
+
98
+ # TODO: everywhere
99
+ guard.listener_array.each(&:stop)
100
+
101
+ # preview posts_and_guard -- no preview needed...
102
+ return if @options['upload']['method'] == 'none' ||
103
+ (guard.delete_array.empty? && guard.upload_array.empty?)
104
+ uploader = Zine::Upload.new @options['directories']['build'],
105
+ @options['upload'],
106
+ guard.delete_array,
107
+ guard.upload_array
108
+ uploader.upload_decision MockHighlineYes
109
+ end
110
+
72
111
  def write_markdown(default_name, src_dir, file)
73
112
  dir = Pathname(File.dirname(file)).relative_path_from(Pathname(src_dir))
74
113
  file_name = "#{File.basename(file, '.*')}.html"
@@ -83,7 +122,7 @@ module Zine
83
122
 
84
123
  def clean_option_paths
85
124
  directories = @options['directories']
86
- %w(assets posts styles templates).each do |dir|
125
+ %w[assets posts styles templates].each do |dir|
87
126
  directories[dir] = File.join directories['source'], directories[dir]
88
127
  end
89
128
  directories['blog'] = File.join directories['build'], directories['blog']
data/lib/zine/cli.rb CHANGED
@@ -37,6 +37,13 @@ module Zine
37
37
  puts Rainbow('Site built').green
38
38
  end
39
39
 
40
+ desc 'notice POST', 'Build the site, then force the one POST'
41
+ def notice(file)
42
+ init_site
43
+ @the_site.notice(file)
44
+ puts Rainbow('Site built').green
45
+ end
46
+
40
47
  desc 'nuke', 'Delete the build folder'
41
48
  def nuke
42
49
  init_site
data/lib/zine/upload.rb CHANGED
@@ -52,7 +52,6 @@ module Zine
52
52
  @credentials,
53
53
  @delete_file_array,
54
54
  @upload_file_array)
55
- puts '---', uploader.inspect, '---'
56
55
  uploader.upload
57
56
  end
58
57
 
@@ -25,9 +25,9 @@ module Zine
25
25
  delete
26
26
  deploy
27
27
  rescue Errno::ENETUNREACH
28
- puts Rainbow("Unable to connect to #{upload_options['host']}").red
28
+ puts Rainbow("Unable to connect to #{@host}").red
29
29
  rescue Net::SSH::AuthenticationFailed, NameError
30
- puts Rainbow("Authentication failed for #{upload_options['host']}").red
30
+ puts Rainbow("Authentication failed for #{@host}").red
31
31
  puts 'Check your credential file, and maybe run ssh-add?'
32
32
  end
33
33
 
@@ -40,8 +40,10 @@ module Zine
40
40
  end
41
41
 
42
42
  def delete
43
- Net::SFTP.start(@host, @credentials['username'],
44
- password: @credentials['password']) do |sftp|
43
+ Net::SFTP.start(@host,
44
+ @credentials['username'],
45
+ password: @credentials['password'],
46
+ auth_methods: %w[publickey password]) do |sftp|
45
47
  @delete_file_array.each do |rel_file_path|
46
48
  sftp.remove(File.join(@path, rel_file_path)).wait
47
49
  puts "Deleted #{rel_file_path}" if @verbose
@@ -50,8 +52,10 @@ module Zine
50
52
  end
51
53
 
52
54
  def deploy
53
- Net::SFTP.start(@host, @credentials['username'],
54
- password: @credentials['password']) do |sftp|
55
+ Net::SFTP.start(@host,
56
+ @credentials['username'],
57
+ password: @credentials['password'],
58
+ auth_methods: %w[publickey password]) do |sftp|
55
59
  deploy_directories sftp
56
60
  deploy_files sftp
57
61
  end
data/lib/zine/version.rb CHANGED
@@ -1,4 +1,4 @@
1
1
  module Zine
2
2
  # The version
3
- VERSION = '0.7.0'.freeze
3
+ VERSION = '0.8.0'.freeze
4
4
  end
data/lib/zine/watcher.rb CHANGED
@@ -5,6 +5,7 @@ module Zine
5
5
  # Watch files for changes
6
6
  class Watcher
7
7
  attr_reader :upload_array, :delete_array
8
+ attr_accessor :listener_array
8
9
 
9
10
  def initialize(posts_and_headlines, build_directory, source_directory)
10
11
  @posts_and_headlines = posts_and_headlines
@@ -12,6 +13,7 @@ module Zine
12
13
  @source_directory = File.join Dir.pwd, source_directory
13
14
  @upload_array = []
14
15
  @delete_array = []
16
+ @listener_array = []
15
17
  end
16
18
 
17
19
  # Build a delete list & an upload list for SSH from changes in build,
@@ -74,6 +76,7 @@ module Zine
74
76
  on_build_delete removed unless removed.empty?
75
77
  end
76
78
  listener.start
79
+ @listener_array << listener
77
80
  end
78
81
 
79
82
  def watch_source_dir
@@ -83,6 +86,7 @@ module Zine
83
86
  on_source_delete removed unless removed.empty?
84
87
  end
85
88
  listener.start
89
+ @listener_array << listener
86
90
  end
87
91
  end
88
92
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: zine
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.7.0
4
+ version: 0.8.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mike Kreuzer
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-09-30 00:00:00.000000000 Z
11
+ date: 2017-10-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler