hexo_disqus_migrator 0.0.1 → 0.0.2

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: 190cc06190b2b89529f49d72291d72f7da02f96f
4
- data.tar.gz: 5f392ca5ab4899290099964df764294af11cb7f0
3
+ metadata.gz: e67ea82b4e5f6cd7e1da8a3296737786893923a6
4
+ data.tar.gz: 65324bc0a37b4119d46f377ceabadc21b497ff1a
5
5
  SHA512:
6
- metadata.gz: dcd58da42cfa460fd0de234d1189954395495cb22fb91448b698a8d1afd6365ed83f4698960edf89b931ead562a5110b8f59e042c440a278976f982139224714
7
- data.tar.gz: 18ee909d29eb20932e62ee39317dbf01ecab7c13e495f8144a9fbdf3d7bae36117cc942d31da9cdd79d17bb49d674f2574929bf0294a4ed0f65b61ab248554a4
6
+ metadata.gz: 4d0ac76d42176daf0fc3616839168173bd5d70006d259850abe459cd04350ccb5700abe7c739a9dd10ba4578648ece60e24ca1b7c8e4591b8ee4a5e19a106b06
7
+ data.tar.gz: a2ed7f9c76c537751b80c7e8e2edab01e5d250db6da4d6cf4380320ca60c5101ccea02083677185579dd271c58791e1a5690a9642bd1849d1bf29f7ad9853789
@@ -1,7 +1,7 @@
1
- require 'migrator/rules'
2
- require 'migrator/class_methods'
3
- require 'migrator/reports'
4
- require 'migrator/outputs'
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
- FIX_CHECKER.apply(m)
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
- FIX_CHECKER.apply(m)
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
- FIX_CHECKER.apply(m)
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
- FIX_CHECKER.apply(m)
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
- FIX_CHECKER.apply(m)
167
+ Migrator.fix_checker.apply(m)
136
168
  end
137
169
  end
138
170
 
@@ -1,3 +1,3 @@
1
- module Migrator
2
- VERSION = "0.0.1"
1
+ class Migrator
2
+ VERSION = '0.0.2'
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: hexo_disqus_migrator
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - TimNew