nanoc-neocities 0.1.1 → 0.1.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (4) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +8 -7
  3. data/lib/nanoc-neocities.rb +19 -14
  4. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: c451c9c2cbe22e5d830cefa46802952636ddd188335f34d918f749bd2f140057
4
- data.tar.gz: b134e94655e426838555e0a4c3645a1bacfcc8597f4d8408b3db5882b51b6bfc
3
+ metadata.gz: 37e9b3973ef2acc2feaac5cfb954b189c01604427d01564af88bae1cbaad81c2
4
+ data.tar.gz: b6409f078acc51c2e6015ae1077e8cc8845fbeed3de2cb5679dcef6b0b515a43
5
5
  SHA512:
6
- metadata.gz: 07d6bfe9990387c8ee884e69df2b32cc02620b3a6aaa51cf1ce2fc4225e74997f293248762262f047ba06d56ae327151761b0e85915cb432cca232da0954873b
7
- data.tar.gz: 3dcbf814630686dd8a1cb4cb4036e9574a3a446f9b823f51f1cbc5f698531318588456fd7ab64c9eabc50890621b9ab445d751c24ccddbd5708d066fd0a3e9bb
6
+ metadata.gz: f475e040548c27436b09fd659de3c036c243c66bf663bcc38a8b078fd11fa5527a1d54d4e0efd25ab9ac881c754b897dcefdbb2635e2f61538ce7ce3d34b3986
7
+ data.tar.gz: f279969041f12a7a408fe697239700df7d3bc9d4dfc2c05e76b7fb07b23574e147dd6f2e67523e38a9e85653f86b7c01497b51064a2a601b126d6d7447f696ca
data/README.md CHANGED
@@ -12,7 +12,7 @@ from your Nanoc site’s `lib/`.
12
12
 
13
13
  Or add `nanoc-neocities` to the `nanoc` group of your Gemfile:
14
14
 
15
- ```ruby
15
+ ```
16
16
  group :nanoc do
17
17
  gem 'nanoc-neocities'
18
18
  end
@@ -25,16 +25,17 @@ Available on [RubyGem](https://rubygems.org/gems/nanoc-neocities/).
25
25
  Add a deployment target to your `nanoc.yaml` file and provide the
26
26
  sitename (without the `.neocities.org` TLD) and your site API key:
27
27
 
28
- ```deploy:
29
- my-example-neocities:
28
+ ```
29
+ deploy:
30
+ my_neocities:
30
31
  kind: neocities
31
32
  sitename: example-site
32
33
  api_key: example-api-key
33
- filter :external, exec: 'wc'
34
+ prune_remote: true
34
35
  ```
35
36
 
36
- You can then run `nanoc deploy my-example-neocities` from inside your
37
- Nanoc site directory to deploy it to your configured Neocities™ site.
37
+ You can then run `nanoc deploy my_neocities` from inside your Nanoc
38
+ site directory to deploy it to your configured Neocities™ site.
38
39
 
39
40
  You can find the API key for your Neocities™ site on the Site
40
41
  settings page on the main Neocities™ website.
@@ -42,4 +43,4 @@ settings page on the main Neocities™ website.
42
43
  ---
43
44
 
44
45
  The project is licensed under the MIT License (see LICENSE).
45
- “Neocities” is a trademark of Neocities Ltd.
46
+ “Neocities” is a trademark of Neocities Ltd.
@@ -12,9 +12,10 @@ module Nanoc::Deploying::Deployers
12
12
  #
13
13
  # deploy:
14
14
  # default:
15
- # kind: neocities
16
- # api_key: 1234abcd
17
- # sitename: mysite
15
+ # kind: neocities
16
+ # api_key: 1234abcd
17
+ # sitename: mysite
18
+ # prune_remote: true
18
19
  #
19
20
  class NeocitiesDeployer < ::Nanoc::Deploying::Deployer
20
21
  identifier :neocities
@@ -42,8 +43,8 @@ module Nanoc::Deploying::Deployers
42
43
  end
43
44
 
44
45
  class UploadFailed < Generic
45
- def initialize(path)
46
- super("Failed to upload file #{path} to Neocities.")
46
+ def initialize(path, message)
47
+ super("Failed to upload file #{path} to Neocities: #{message}")
47
48
  end
48
49
  end
49
50
 
@@ -61,6 +62,7 @@ module Nanoc::Deploying::Deployers
61
62
 
62
63
  api_key = config.fetch(:api_key, '')
63
64
  sitename = config.fetch(:sitename, '')
65
+ prune = config.fetch(:prune_remote, true)
64
66
 
65
67
  client = Neocities::Client.new({api_key: api_key, sitename: sitename})
66
68
 
@@ -84,26 +86,29 @@ puts remote_files
84
86
  if upload[:result] == 'success'
85
87
  puts "Uploaded file “#{path}”."
86
88
  elsif upload[:error_type] == 'file_exists'
87
- puts "Existing file “#{path}” was identical. Skipping upload."
89
+ puts "Existing file “#{path}” is identical. Skipping upload."
88
90
  else
89
- raise Errors::UploadFailed.new(path)
91
+ raise Errors::UploadFailed.new(path, upload[:message] || 'unknown problem')
90
92
  end
91
93
  end
92
94
  }
93
95
 
94
96
  puts "Neocities site “#{sitename}” deployed."
95
97
 
96
- remote_files = client.list
97
- puts "Deleting orphaned files from Neocities site “#{sitename}”…"
98
+ if prune
99
+ remote_files = client.list
100
+ puts "Deleting orphaned files from Neocities site “#{sitename}”…"
98
101
 
99
- orphans = client.list[:files].map{|file| file[:path]} - Dir.glob("**/*")
102
+ orphans = client.list[:files].map{|file| file[:path]} - Dir.glob("**/*")
100
103
 
101
- for path in orphans
102
- puts "Deleting “#{path}”."
103
- unless client.delete(orphan)[:result] == 'success'
104
- raise Errors::DeleteOrphanFailed.new(path)
104
+ for path in orphans
105
+ puts "Deleting “#{path}”."
106
+ unless client.delete(orphan)[:result] == 'success'
107
+ raise Errors::DeleteOrphanFailed.new(path)
108
+ end
105
109
  end
106
110
  end
111
+
107
112
  end
108
113
  end
109
114
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: nanoc-neocities
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Daniel Aleksandersen
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-04-13 00:00:00.000000000 Z
11
+ date: 2019-04-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: nanoc