hexo_disqus_migrator 0.0.1 → 0.0.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.
- checksums.yaml +4 -4
- data/lib/migrator/migrator.rb +4 -4
- data/lib/migrator/migrator/class_methods.rb +0 -26
- data/lib/migrator/migrator/rules.rb +37 -5
- data/lib/migrator/version.rb +2 -2
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e67ea82b4e5f6cd7e1da8a3296737786893923a6
|
4
|
+
data.tar.gz: 65324bc0a37b4119d46f377ceabadc21b497ff1a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4d0ac76d42176daf0fc3616839168173bd5d70006d259850abe459cd04350ccb5700abe7c739a9dd10ba4578648ece60e24ca1b7c8e4591b8ee4a5e19a106b06
|
7
|
+
data.tar.gz: a2ed7f9c76c537751b80c7e8e2edab01e5d250db6da4d6cf4380320ca60c5101ccea02083677185579dd271c58791e1a5690a9642bd1849d1bf29f7ad9853789
|
data/lib/migrator/migrator.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
1
|
+
require_relative 'migrator/rules'
|
2
|
+
require_relative 'migrator/class_methods'
|
3
|
+
require_relative 'migrator/reports'
|
4
|
+
require_relative 'migrator/outputs'
|
5
5
|
|
6
6
|
class Migrator
|
7
7
|
extend Rules
|
@@ -5,29 +5,7 @@ class Migrator
|
|
5
5
|
ROOT = Pathname.new ROOT_PATH
|
6
6
|
POSTS_FOLDER = Pathname.new File.join(Dir.pwd, 'source/_posts')
|
7
7
|
|
8
|
-
VERIFIER = Rule.new(:valid_checker, false) do
|
9
|
-
setup_match { |m| m.isnt?(:ignored) }
|
10
|
-
setup_action do |m|
|
11
|
-
local_file = Migrator.local_path m.new_path
|
12
8
|
|
13
|
-
if local_file.exist?
|
14
|
-
m.tags << :valid
|
15
|
-
else
|
16
|
-
m.tags << :invalid
|
17
|
-
m.output = false
|
18
|
-
end
|
19
|
-
end
|
20
|
-
end
|
21
|
-
|
22
|
-
FIX_CHECKER = Rule.new(:fix_checker, false) do
|
23
|
-
setup_match { |m| m.is?(:broken) }
|
24
|
-
setup_match { |m| m.isnt?(:fixed) }
|
25
|
-
setup_match { |m| Migrator.local_path(m.new_path).exist? }
|
26
|
-
setup_action do |m|
|
27
|
-
m.tags << :fixed
|
28
|
-
true
|
29
|
-
end
|
30
|
-
end
|
31
9
|
|
32
10
|
def root
|
33
11
|
ROOT
|
@@ -50,10 +28,6 @@ class Migrator
|
|
50
28
|
base_name.split('-')
|
51
29
|
end
|
52
30
|
|
53
|
-
def verifier
|
54
|
-
VERIFIER
|
55
|
-
end
|
56
|
-
|
57
31
|
def delegate_to_class(*names)
|
58
32
|
names.each do |name|
|
59
33
|
define_method name do |*args|
|
@@ -1,5 +1,37 @@
|
|
1
1
|
class Migrator
|
2
2
|
module Rules
|
3
|
+
VERIFIER = Rule.new(:valid_checker, false) do
|
4
|
+
setup_match { |m| m.isnt?(:ignored) }
|
5
|
+
setup_action do |m|
|
6
|
+
local_file = Migrator.local_path m.new_path
|
7
|
+
|
8
|
+
if local_file.exist?
|
9
|
+
m.tags << :valid
|
10
|
+
else
|
11
|
+
m.tags << :invalid
|
12
|
+
m.output = false
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
FIX_CHECKER = Rule.new(:fix_checker, false) do
|
18
|
+
setup_match { |m| m.is?(:broken) }
|
19
|
+
setup_match { |m| m.isnt?(:fixed) }
|
20
|
+
setup_match { |m| Migrator.local_path(m.new_path).exist? }
|
21
|
+
setup_action do |m|
|
22
|
+
m.tags << :fixed
|
23
|
+
true
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
def verifier
|
28
|
+
VERIFIER
|
29
|
+
end
|
30
|
+
|
31
|
+
def fix_checker
|
32
|
+
FIX_CHECKER
|
33
|
+
end
|
34
|
+
|
3
35
|
RULES = []
|
4
36
|
|
5
37
|
def rules
|
@@ -53,7 +85,7 @@ class Migrator
|
|
53
85
|
setup_action do |m|
|
54
86
|
m.new_path = m.new_path.gsub(/^\/[^\/]+\//, '/blog/')
|
55
87
|
m.output = true
|
56
|
-
|
88
|
+
Migrator.fix_checker.apply(m)
|
57
89
|
end
|
58
90
|
end
|
59
91
|
|
@@ -66,7 +98,7 @@ class Migrator
|
|
66
98
|
setup_action do |m|
|
67
99
|
m.new_path = m.new_path.sub(/\/\d\d\d\d-\d\d-\d\d-/, '/')
|
68
100
|
m.output = true
|
69
|
-
|
101
|
+
Migrator.fix_checker.apply(m)
|
70
102
|
end
|
71
103
|
end
|
72
104
|
|
@@ -85,7 +117,7 @@ class Migrator
|
|
85
117
|
|
86
118
|
m.output = true
|
87
119
|
m.new_path = File.join('/', 'public', 'timestamp_path', m.basename.to_s)
|
88
|
-
|
120
|
+
Migrator.fix_checker.apply(m)
|
89
121
|
end
|
90
122
|
end
|
91
123
|
end
|
@@ -103,7 +135,7 @@ class Migrator
|
|
103
135
|
m.new_path = Migrator.to_url m.local_path.parent.children.first.to_s
|
104
136
|
m.confident = false
|
105
137
|
m.output = true
|
106
|
-
|
138
|
+
Migrator.fix_checker.apply(m)
|
107
139
|
end
|
108
140
|
end
|
109
141
|
|
@@ -132,7 +164,7 @@ class Migrator
|
|
132
164
|
|
133
165
|
m.confident = false
|
134
166
|
m.output = true
|
135
|
-
|
167
|
+
Migrator.fix_checker.apply(m)
|
136
168
|
end
|
137
169
|
end
|
138
170
|
|
data/lib/migrator/version.rb
CHANGED
@@ -1,3 +1,3 @@
|
|
1
|
-
|
2
|
-
VERSION =
|
1
|
+
class Migrator
|
2
|
+
VERSION = '0.0.2'
|
3
3
|
end
|