wiki_tips_post 0.0.3 → 0.0.4
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/wiki_tips_post/version.rb +1 -1
- data/lib/wiki_tips_post/wiki_post_helper.rb +7 -3
- data/spec/fixtures/wiki/index_with_tag/{Cloudops Wiki Tips Index.md → Cloudops-Wiki-Tips-Index.md} +0 -0
- data/spec/fixtures/wiki/index_without_tag/{Cloudops Wiki Tips Index.md → Cloudops-Wiki-Tips-Index.md} +0 -0
- data/spec/wiki_tips_post/wiki_post_helper_spec.rb +4 -5
- metadata +6 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ace29eb51e4c7b6407c740a9a2a5fd0ee4ca715f
|
4
|
+
data.tar.gz: 40449a0a175a9ff782f81a56b9cdc4903143d6cd
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ba479deaf9e5bf676303e83f75f5c3a54fa5aadae2432edda2210238cb94677749603e6ebf18a473cb242e47d518b66cbccda2f50c093ecf73ab3e1d42f8cd23
|
7
|
+
data.tar.gz: d32d9b5e6f68ff5331d42f9973727e1f9bed806e8b240d15a30bbea7ae982663a128413bdada931244956c54d0be47e00bf84fb3d22c472fcc04bffb64ffc065
|
@@ -2,7 +2,7 @@ require 'tmpdir'
|
|
2
2
|
|
3
3
|
module WikiTipsPost
|
4
4
|
WIKI_REPO='git@github.com:pivotal-cloudops/cloudops-tools.wiki.git'
|
5
|
-
INDEX_PAGE='Cloudops
|
5
|
+
INDEX_PAGE='Cloudops-Wiki-Tips-Index.md'
|
6
6
|
|
7
7
|
class WikiPostHelper
|
8
8
|
def initialize(title: title, tips: tips, tags: tags)
|
@@ -25,7 +25,7 @@ module WikiTipsPost
|
|
25
25
|
def link_to_tag(tag)
|
26
26
|
tag_path = File.join(
|
27
27
|
@tmp_dir,
|
28
|
-
'#' + tag
|
28
|
+
'#' + sanitize_wiki_page_title(tag) + '.md'
|
29
29
|
)
|
30
30
|
|
31
31
|
file_already_exists = File.exists?(tag_path)
|
@@ -72,7 +72,11 @@ module WikiTipsPost
|
|
72
72
|
private
|
73
73
|
|
74
74
|
def tip_path
|
75
|
-
File.join(@tmp_dir, @title + '.md')
|
75
|
+
File.join(@tmp_dir, sanitize_wiki_page_title(@title) + '.md')
|
76
|
+
end
|
77
|
+
|
78
|
+
def sanitize_wiki_page_title(title)
|
79
|
+
title.strip.gsub(/\W+/, '-')
|
76
80
|
end
|
77
81
|
end
|
78
82
|
end
|
data/spec/fixtures/wiki/index_with_tag/{Cloudops Wiki Tips Index.md → Cloudops-Wiki-Tips-Index.md}
RENAMED
File without changes
|
File without changes
|
@@ -19,7 +19,6 @@ module WikiTipsPost
|
|
19
19
|
end
|
20
20
|
|
21
21
|
describe "adding a tip" do
|
22
|
-
|
23
22
|
before do
|
24
23
|
FileUtils.cp_r fixture_path, tmp_dir
|
25
24
|
end
|
@@ -39,28 +38,28 @@ module WikiTipsPost
|
|
39
38
|
it 'adds new pages into the repo with subject and name' do
|
40
39
|
subject.add_new_page
|
41
40
|
|
42
|
-
tip_contents = File.read File.join(tmp_dir, 'test
|
41
|
+
tip_contents = File.read File.join(tmp_dir, 'test-title.md')
|
43
42
|
expect(tip_contents).to eq('test tips text')
|
44
43
|
end
|
45
44
|
|
46
45
|
describe 'creates tag pages' do
|
47
46
|
it 'when there is a space in between' do
|
48
47
|
need_index = subject.link_to_tag('test tag1')
|
49
|
-
tag_page_contents = File.read File.join(tmp_dir, '#
|
48
|
+
tag_page_contents = File.read File.join(tmp_dir, '#test-tag1.md')
|
50
49
|
expect(tag_page_contents).to eq("\n* [[ test title ]]")
|
51
50
|
expect(need_index).to be(true)
|
52
51
|
end
|
53
52
|
|
54
53
|
it 'when there is a space in front' do
|
55
54
|
need_index = subject.link_to_tag(' test tag2')
|
56
|
-
tag_page_contents = File.read File.join(tmp_dir, '#
|
55
|
+
tag_page_contents = File.read File.join(tmp_dir, '#test-tag2.md')
|
57
56
|
expect(tag_page_contents).to eq("\n* [[ test title ]]")
|
58
57
|
expect(need_index).to be(true)
|
59
58
|
end
|
60
59
|
|
61
60
|
it 'when there is a space in back' do
|
62
61
|
need_index = subject.link_to_tag('test tag3 ')
|
63
|
-
tag_page_contents = File.read File.join(tmp_dir, '#
|
62
|
+
tag_page_contents = File.read File.join(tmp_dir, '#test-tag3.md')
|
64
63
|
expect(tag_page_contents).to eq("\n* [[ test title ]]")
|
65
64
|
expect(need_index).to be(true)
|
66
65
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: wiki_tips_post
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Kai Xiang
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-03-
|
11
|
+
date: 2015-03-31 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -101,8 +101,8 @@ files:
|
|
101
101
|
- lib/wiki_tips_post/version.rb
|
102
102
|
- lib/wiki_tips_post/wiki_post_helper.rb
|
103
103
|
- spec/fixtures/wiki/index_with_tag/#test_tag1.md
|
104
|
-
- spec/fixtures/wiki/index_with_tag/Cloudops
|
105
|
-
- spec/fixtures/wiki/index_without_tag/Cloudops
|
104
|
+
- spec/fixtures/wiki/index_with_tag/Cloudops-Wiki-Tips-Index.md
|
105
|
+
- spec/fixtures/wiki/index_without_tag/Cloudops-Wiki-Tips-Index.md
|
106
106
|
- spec/spec_helper.rb
|
107
107
|
- spec/wiki_tips_post/wiki_post_helper_spec.rb
|
108
108
|
- wiki_tips_post.gemspec
|
@@ -132,7 +132,7 @@ specification_version: 4
|
|
132
132
|
summary: A tool helps to post tips into cloudops-tools wiki.
|
133
133
|
test_files:
|
134
134
|
- spec/fixtures/wiki/index_with_tag/#test_tag1.md
|
135
|
-
- spec/fixtures/wiki/index_with_tag/Cloudops
|
136
|
-
- spec/fixtures/wiki/index_without_tag/Cloudops
|
135
|
+
- spec/fixtures/wiki/index_with_tag/Cloudops-Wiki-Tips-Index.md
|
136
|
+
- spec/fixtures/wiki/index_without_tag/Cloudops-Wiki-Tips-Index.md
|
137
137
|
- spec/spec_helper.rb
|
138
138
|
- spec/wiki_tips_post/wiki_post_helper_spec.rb
|