wiki_tips_post 0.0.3 → 0.0.4

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: be64c2dab2db4d95b168959c9ff769277d55bce1
4
- data.tar.gz: 9e13b27f8f776f490a72be3c18ce42bff8c24378
3
+ metadata.gz: ace29eb51e4c7b6407c740a9a2a5fd0ee4ca715f
4
+ data.tar.gz: 40449a0a175a9ff782f81a56b9cdc4903143d6cd
5
5
  SHA512:
6
- metadata.gz: 85eea3ca7fd1e3f0309682f44838016b776287425de5e0061c92a7f6c09d663b475aef7cc1801bbb08a1e8d28e613d2aa337620a1c84005e920fecbe3cf195c3
7
- data.tar.gz: 508cd2cbe098ceb7f7a4e81d0609e46c4ef8b4c5ff58639ecd471a12468ba363591c8d7c3cc5e07ea30bd47c7354b41ad8488366a3cbcc0c59d64b2dfb6c1ef5
6
+ metadata.gz: ba479deaf9e5bf676303e83f75f5c3a54fa5aadae2432edda2210238cb94677749603e6ebf18a473cb242e47d518b66cbccda2f50c093ecf73ab3e1d42f8cd23
7
+ data.tar.gz: d32d9b5e6f68ff5331d42f9973727e1f9bed806e8b240d15a30bbea7ae982663a128413bdada931244956c54d0be47e00bf84fb3d22c472fcc04bffb64ffc065
@@ -1,3 +1,3 @@
1
1
  module WikiTipsPost
2
- VERSION = "0.0.3"
2
+ VERSION = "0.0.4"
3
3
  end
@@ -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 Wiki Tips Index.md'
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.chomp(' ').reverse.chomp(' ').reverse.gsub(' ','_') + '.md'
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
@@ -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 title.md')
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, '#test_tag1.md')
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, '#test_tag2.md')
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, '#test_tag3.md')
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.3
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-19 00:00:00.000000000 Z
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 Wiki Tips Index.md
105
- - spec/fixtures/wiki/index_without_tag/Cloudops Wiki Tips Index.md
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 Wiki Tips Index.md
136
- - spec/fixtures/wiki/index_without_tag/Cloudops Wiki Tips Index.md
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