wiki_tips_post 0.0.2 → 0.0.3
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
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: be64c2dab2db4d95b168959c9ff769277d55bce1
|
4
|
+
data.tar.gz: 9e13b27f8f776f490a72be3c18ce42bff8c24378
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 85eea3ca7fd1e3f0309682f44838016b776287425de5e0061c92a7f6c09d663b475aef7cc1801bbb08a1e8d28e613d2aa337620a1c84005e920fecbe3cf195c3
|
7
|
+
data.tar.gz: 508cd2cbe098ceb7f7a4e81d0609e46c4ef8b4c5ff58639ecd471a12468ba363591c8d7c3cc5e07ea30bd47c7354b41ad8488366a3cbcc0c59d64b2dfb6c1ef5
|
data/bin/{wiki_tips_post → tip}
RENAMED
File without changes
|
@@ -5,7 +5,7 @@ module WikiTipsPost
|
|
5
5
|
class HelperCommand < Mothership
|
6
6
|
|
7
7
|
desc "Show Help"
|
8
|
-
input :command, :
|
8
|
+
input :command, argument: :optional
|
9
9
|
def help
|
10
10
|
if name = input[:command]
|
11
11
|
if cmd = @@commands[name.gsub("-", "_").to_sym]
|
@@ -19,26 +19,23 @@ module WikiTipsPost
|
|
19
19
|
end
|
20
20
|
|
21
21
|
desc "Post tip on cloudops wiki with tags"
|
22
|
-
input
|
23
|
-
input
|
24
|
-
input
|
25
|
-
input
|
22
|
+
input(:tip) { ask("what is your tip:") }
|
23
|
+
input(:title) { ask ("what is the title of your tip:") }
|
24
|
+
input(:tags) { ask("what are the tags for this tip (e.g. ruby,cf) :") }
|
25
|
+
input(:file)
|
26
26
|
def post
|
27
|
-
begin
|
28
|
-
tag_array = input[:tags].split(',')
|
29
|
-
rescue StandardError => e
|
30
|
-
puts "Wrong tag format, it should be string split with ,"
|
31
|
-
end
|
32
|
-
|
33
|
-
tip_content = nil
|
34
27
|
if input[:file]
|
35
28
|
tip_content = File.read File.expand_path(input[:file])
|
29
|
+
else
|
30
|
+
tip_content = input[:tip]
|
36
31
|
end
|
37
32
|
|
33
|
+
tag_array = input[:tags].split(',')
|
34
|
+
|
38
35
|
@wikiposter = WikiPostHelper.new(
|
39
36
|
:title => input[:title],
|
40
|
-
:tips => tip_content
|
41
|
-
:tags => tag_array
|
37
|
+
:tips => tip_content,
|
38
|
+
:tags => tag_array,
|
42
39
|
)
|
43
40
|
|
44
41
|
puts "\ncloning repo..."
|
@@ -62,6 +59,4 @@ module WikiTipsPost
|
|
62
59
|
end
|
63
60
|
end
|
64
61
|
end
|
65
|
-
|
66
62
|
end
|
67
|
-
|
@@ -1,8 +1,7 @@
|
|
1
1
|
require 'tmpdir'
|
2
2
|
|
3
3
|
module WikiTipsPost
|
4
|
-
|
5
|
-
WIKI_REPO='git@github.com:pivotal-cf/cloudops-tools.wiki.git'
|
4
|
+
WIKI_REPO='git@github.com:pivotal-cloudops/cloudops-tools.wiki.git'
|
6
5
|
INDEX_PAGE='Cloudops Wiki Tips Index.md'
|
7
6
|
|
8
7
|
class WikiPostHelper
|
@@ -20,12 +19,12 @@ module WikiTipsPost
|
|
20
19
|
end
|
21
20
|
|
22
21
|
def add_new_page
|
23
|
-
File.write(tip_path, @tips)
|
22
|
+
File.write(tip_path, @tips)
|
24
23
|
end
|
25
24
|
|
26
25
|
def link_to_tag(tag)
|
27
26
|
tag_path = File.join(
|
28
|
-
@tmp_dir,
|
27
|
+
@tmp_dir,
|
29
28
|
'#' + tag.chomp(' ').reverse.chomp(' ').reverse.gsub(' ','_') + '.md'
|
30
29
|
)
|
31
30
|
|
@@ -40,15 +39,14 @@ module WikiTipsPost
|
|
40
39
|
tag_link = "* [[ ##{ tag.gsub(' ', '_') } ]]"
|
41
40
|
index_page_path = File.join(@tmp_dir, INDEX_PAGE)
|
42
41
|
index_page_contents = File.read(index_page_path)
|
43
|
-
|
44
|
-
unless index_page_contents.
|
45
|
-
new_index_page_contents = index_page_contents.strip + "\n" + tag_link
|
42
|
+
|
43
|
+
unless index_page_contents.include?(tag_link)
|
44
|
+
new_index_page_contents = index_page_contents.strip + "\n" + tag_link
|
46
45
|
content = new_index_page_contents.split("\n").sort
|
47
46
|
content.delete("Category with Tags:")
|
48
47
|
content.insert 0, "Category with Tags:"
|
49
48
|
final_content = content.join("\n")
|
50
49
|
File.open(index_page_path, 'w') { |f| f.write final_content }
|
51
|
-
|
52
50
|
end
|
53
51
|
end
|
54
52
|
|
@@ -32,7 +32,7 @@ module WikiTipsPost
|
|
32
32
|
let(:fixture_path) { path_for_fixture('wiki/index_without_tag/.') }
|
33
33
|
|
34
34
|
it 'prepares the git repo in a tmp directory' do
|
35
|
-
expect(kernel).to receive(:system).with("git clone git@github.com:pivotal-
|
35
|
+
expect(kernel).to receive(:system).with("git clone git@github.com:pivotal-cloudops/cloudops-tools.wiki.git #{tmp_dir}")
|
36
36
|
subject.prepare_repo
|
37
37
|
end
|
38
38
|
|
@@ -57,7 +57,7 @@ module WikiTipsPost
|
|
57
57
|
expect(tag_page_contents).to eq("\n* [[ test title ]]")
|
58
58
|
expect(need_index).to be(true)
|
59
59
|
end
|
60
|
-
|
60
|
+
|
61
61
|
it 'when there is a space in back' do
|
62
62
|
need_index = subject.link_to_tag('test tag3 ')
|
63
63
|
tag_page_contents = File.read File.join(tmp_dir, '#test_tag3.md')
|
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.3
|
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-
|
11
|
+
date: 2015-03-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -84,7 +84,7 @@ description: And orgnize it with tags.
|
|
84
84
|
email:
|
85
85
|
- kxiang@pivotal.io
|
86
86
|
executables:
|
87
|
-
-
|
87
|
+
- tip
|
88
88
|
extensions: []
|
89
89
|
extra_rdoc_files: []
|
90
90
|
files:
|
@@ -94,7 +94,7 @@ files:
|
|
94
94
|
- LICENSE.txt
|
95
95
|
- README.md
|
96
96
|
- Rakefile
|
97
|
-
- bin/
|
97
|
+
- bin/tip
|
98
98
|
- lib/wiki_tips_post.rb
|
99
99
|
- lib/wiki_tips_post/helper_command.rb
|
100
100
|
- lib/wiki_tips_post/kernel_wrapper.rb
|