daimyo 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +16 -0
- data/.rspec +3 -0
- data/.travis.yml +5 -0
- data/Gemfile +6 -0
- data/Gemfile.lock +80 -0
- data/LICENSE.txt +21 -0
- data/README.md +54 -0
- data/Rakefile +7 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/daimyo.gemspec +32 -0
- data/exe/daimyo +5 -0
- data/lib/daimyo.rb +19 -0
- data/lib/daimyo/cli.rb +44 -0
- data/lib/daimyo/client.rb +31 -0
- data/lib/daimyo/config.rb +18 -0
- data/lib/daimyo/export.rb +65 -0
- data/lib/daimyo/helper.rb +8 -0
- data/lib/daimyo/list.rb +35 -0
- data/lib/daimyo/projects.rb +16 -0
- data/lib/daimyo/publish.rb +88 -0
- data/lib/daimyo/version.rb +3 -0
- metadata +193 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 9265259a024470c9c242531e46c786f9c420a9543a4cf15d174a338ca6848731
|
4
|
+
data.tar.gz: 02535c451da3c659f6fb351317fad4dd1b8cb57d9d62075b809f02cc9f447180
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 23ba10234ed47839a8c6eff87aa33f22b870bd0542bc2111f8bc17380d65825095bc23b8968781eabe7cac28edc56cc8958bcf7cae91c3fe881a2d901e629bfd
|
7
|
+
data.tar.gz: fc6af58c9561dc615b602fefb239f007e9f64a0535391588060716df57fb49e496b84131d1b5039a449e3a8a532483eb3793d69f30594195386856b617c7aff3
|
data/.gitignore
ADDED
data/.rspec
ADDED
data/.travis.yml
ADDED
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,80 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
daimyo (0.0.2)
|
5
|
+
backlog_kit
|
6
|
+
diffy
|
7
|
+
ruby-progressbar
|
8
|
+
terminal-table
|
9
|
+
thor
|
10
|
+
|
11
|
+
GEM
|
12
|
+
remote: https://rubygems.org/
|
13
|
+
specs:
|
14
|
+
activesupport (5.2.2)
|
15
|
+
concurrent-ruby (~> 1.0, >= 1.0.2)
|
16
|
+
i18n (>= 0.7, < 2)
|
17
|
+
minitest (~> 5.1)
|
18
|
+
tzinfo (~> 1.1)
|
19
|
+
addressable (2.5.2)
|
20
|
+
public_suffix (>= 2.0.2, < 4.0)
|
21
|
+
backlog_kit (0.18.0)
|
22
|
+
activesupport (>= 4.2.7.1)
|
23
|
+
faraday (~> 0.15.4)
|
24
|
+
faraday_middleware (~> 0.12.2)
|
25
|
+
concurrent-ruby (1.1.4)
|
26
|
+
diff-lcs (1.3)
|
27
|
+
diffy (3.3.0)
|
28
|
+
faraday (0.15.4)
|
29
|
+
multipart-post (>= 1.2, < 3)
|
30
|
+
faraday_middleware (0.12.2)
|
31
|
+
faraday (>= 0.7.4, < 1.0)
|
32
|
+
hub (1.12.4)
|
33
|
+
i18n (1.4.0)
|
34
|
+
concurrent-ruby (~> 1.0)
|
35
|
+
minitest (5.11.3)
|
36
|
+
multipart-post (2.0.0)
|
37
|
+
octokit (4.13.0)
|
38
|
+
sawyer (~> 0.8.0, >= 0.5.3)
|
39
|
+
octorelease (0.0.6)
|
40
|
+
hub
|
41
|
+
octokit
|
42
|
+
public_suffix (3.0.3)
|
43
|
+
rake (10.5.0)
|
44
|
+
rspec (3.8.0)
|
45
|
+
rspec-core (~> 3.8.0)
|
46
|
+
rspec-expectations (~> 3.8.0)
|
47
|
+
rspec-mocks (~> 3.8.0)
|
48
|
+
rspec-core (3.8.0)
|
49
|
+
rspec-support (~> 3.8.0)
|
50
|
+
rspec-expectations (3.8.2)
|
51
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
52
|
+
rspec-support (~> 3.8.0)
|
53
|
+
rspec-mocks (3.8.0)
|
54
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
55
|
+
rspec-support (~> 3.8.0)
|
56
|
+
rspec-support (3.8.0)
|
57
|
+
ruby-progressbar (1.10.0)
|
58
|
+
sawyer (0.8.1)
|
59
|
+
addressable (>= 2.3.5, < 2.6)
|
60
|
+
faraday (~> 0.8, < 1.0)
|
61
|
+
terminal-table (1.8.0)
|
62
|
+
unicode-display_width (~> 1.1, >= 1.1.1)
|
63
|
+
thor (0.20.3)
|
64
|
+
thread_safe (0.3.6)
|
65
|
+
tzinfo (1.2.5)
|
66
|
+
thread_safe (~> 0.1)
|
67
|
+
unicode-display_width (1.4.1)
|
68
|
+
|
69
|
+
PLATFORMS
|
70
|
+
ruby
|
71
|
+
|
72
|
+
DEPENDENCIES
|
73
|
+
bundler (~> 1.16)
|
74
|
+
daimyo!
|
75
|
+
octorelease
|
76
|
+
rake (~> 10.0)
|
77
|
+
rspec (~> 3.0)
|
78
|
+
|
79
|
+
BUNDLED WITH
|
80
|
+
1.17.3
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2018 TODO: Write your name
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,54 @@
|
|
1
|
+
# Daimyo [![Build Status](https://travis-ci.org/inokappa/daimyo.svg?branch=master)](https://travis-ci.org/inokappa/daimyo)
|
2
|
+
|
3
|
+
## これなに
|
4
|
+
|
5
|
+
Backlog Wiki をオフラインで編集, 更新することを目的にした小さなツールです.
|
6
|
+
|
7
|
+
## インストール
|
8
|
+
|
9
|
+
```sh
|
10
|
+
gem 'daimyo', git: 'https://github.com/inokappa/daimyo.git'
|
11
|
+
```
|
12
|
+
|
13
|
+
## 使い方
|
14
|
+
|
15
|
+
### .daimyo.yml の作成
|
16
|
+
|
17
|
+
```yaml
|
18
|
+
space_id: 'your-space-name'
|
19
|
+
top_level_domain: 'jp'
|
20
|
+
api_key: 'your-api-key'
|
21
|
+
```
|
22
|
+
|
23
|
+
### プロジェクトの wiki を export
|
24
|
+
|
25
|
+
```sh
|
26
|
+
bundle exec daimyo export --project-id=your-backlog-project
|
27
|
+
```
|
28
|
+
|
29
|
+
### wiki を更新
|
30
|
+
|
31
|
+
```sh
|
32
|
+
# 編集による差分を表示 (あくまでもローカルマシン上の差分比較用のファイルと比較します)
|
33
|
+
bundle exec daimyo publish --project-id=your-backlog-project --dry-run
|
34
|
+
# 編集内容を Backlog に反映
|
35
|
+
bundle exec daimyo publish --project-id=your-backlog-project
|
36
|
+
```
|
37
|
+
|
38
|
+
## Todo
|
39
|
+
|
40
|
+
* 差分比較をローカルマシン上のファイル以外に, 実際の wiki とも比較出来るようにする (`--dry-run` する時に, `--remote` を付けるとか)
|
41
|
+
|
42
|
+
## Development
|
43
|
+
|
44
|
+
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
45
|
+
|
46
|
+
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
47
|
+
|
48
|
+
## Contributing
|
49
|
+
|
50
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/daimyo.
|
51
|
+
|
52
|
+
## License
|
53
|
+
|
54
|
+
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
data/Rakefile
ADDED
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "daimyo"
|
5
|
+
|
6
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
7
|
+
# with your gem easier. You can also use a different console, if you like.
|
8
|
+
|
9
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
10
|
+
# require "pry"
|
11
|
+
# Pry.start
|
12
|
+
|
13
|
+
require "irb"
|
14
|
+
IRB.start(__FILE__)
|
data/bin/setup
ADDED
data/daimyo.gemspec
ADDED
@@ -0,0 +1,32 @@
|
|
1
|
+
lib = File.expand_path('../lib', __FILE__)
|
2
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
3
|
+
require 'daimyo/version'
|
4
|
+
|
5
|
+
Gem::Specification.new do |spec|
|
6
|
+
spec.name = 'daimyo'
|
7
|
+
spec.version = Daimyo::VERSION
|
8
|
+
spec.authors = ['inokappa']
|
9
|
+
spec.email = ['inokappa at gmail.com']
|
10
|
+
|
11
|
+
spec.summary = %q{It is a tool to edit Markdown format file in local environment}
|
12
|
+
spec.description = %q{It is a tool to edit Markdown format file in local environment}
|
13
|
+
spec.homepage = 'https://github.com/inokappa/daimyo'
|
14
|
+
spec.license = 'MIT'
|
15
|
+
|
16
|
+
spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
|
17
|
+
`git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
18
|
+
end
|
19
|
+
spec.bindir = 'exe'
|
20
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
21
|
+
spec.require_paths = ['lib']
|
22
|
+
|
23
|
+
spec.add_development_dependency 'bundler', '~> 1.16'
|
24
|
+
spec.add_development_dependency 'octorelease'
|
25
|
+
spec.add_development_dependency 'rake', '~> 10.0'
|
26
|
+
spec.add_development_dependency 'rspec', '~> 3.0'
|
27
|
+
spec.add_dependency 'thor'
|
28
|
+
spec.add_dependency 'backlog_kit'
|
29
|
+
spec.add_dependency 'diffy'
|
30
|
+
spec.add_dependency 'terminal-table'
|
31
|
+
spec.add_dependency 'ruby-progressbar'
|
32
|
+
end
|
data/exe/daimyo
ADDED
data/lib/daimyo.rb
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
require 'thor'
|
2
|
+
require 'diffy'
|
3
|
+
require 'terminal-table'
|
4
|
+
require 'backlog_kit'
|
5
|
+
require 'ruby-progressbar'
|
6
|
+
|
7
|
+
require 'daimyo/config'
|
8
|
+
require 'daimyo/cli'
|
9
|
+
require 'daimyo/client'
|
10
|
+
require 'daimyo/export'
|
11
|
+
require 'daimyo/helper'
|
12
|
+
require 'daimyo/list'
|
13
|
+
require 'daimyo/projects'
|
14
|
+
require 'daimyo/publish'
|
15
|
+
require 'daimyo/version'
|
16
|
+
|
17
|
+
module Daimyo
|
18
|
+
# Your code goes here...
|
19
|
+
end
|
data/lib/daimyo/cli.rb
ADDED
@@ -0,0 +1,44 @@
|
|
1
|
+
require 'daimyo'
|
2
|
+
|
3
|
+
module Daimyo
|
4
|
+
class CLI < Thor
|
5
|
+
desc 'version', 'version print.'
|
6
|
+
def version
|
7
|
+
puts Daimyo::VERSION
|
8
|
+
end
|
9
|
+
|
10
|
+
desc 'list', 'Listing wiki page in project.'
|
11
|
+
option :project_id, type: :string, aliases: '-p', desc: 'Specify the project id or project key'
|
12
|
+
def list
|
13
|
+
raise 'Backlog プロジェクトキーを指定してください.' if options[:project_id].nil?
|
14
|
+
d = Daimyo::List.new
|
15
|
+
d.run(options[:project_id])
|
16
|
+
end
|
17
|
+
|
18
|
+
desc 'export', 'Export wiki page in project.'
|
19
|
+
option :project_id, type: :string, aliases: '-p', desc: 'Specify the project id or project key'
|
20
|
+
option :wiki_id, type: :string, aliases: '-i', desc: 'Specify the wiki id'
|
21
|
+
def export
|
22
|
+
raise 'Backlog プロジェクトキーを指定してください.' if options[:project_id].nil?
|
23
|
+
d = Daimyo::Export.new
|
24
|
+
d.run(options[:project_id], options[:wiki_id])
|
25
|
+
end
|
26
|
+
|
27
|
+
desc 'publish', 'Publish wiki page.'
|
28
|
+
option :project_id, type: :string, aliases: '-p', desc: 'Specify the project id or project key'
|
29
|
+
option :dry_run, type: :boolean, aliases: '-d', desc: 'Dryrun.'
|
30
|
+
option :local, type: :boolean, aliases: '-l', desc: 'Execute Dryrun using local files.'
|
31
|
+
def publish
|
32
|
+
raise 'Backlog プロジェクトキーを指定してください.' if options[:project_id].nil?
|
33
|
+
d = Daimyo::Publish.new(options)
|
34
|
+
d.run(options[:project_id], options[:dry_run])
|
35
|
+
end
|
36
|
+
|
37
|
+
desc 'projects', 'Listing project in saved spaces.'
|
38
|
+
def projects
|
39
|
+
d = Daimyo::Projects.new
|
40
|
+
d.run
|
41
|
+
end
|
42
|
+
|
43
|
+
end
|
44
|
+
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
require 'daimyo'
|
2
|
+
|
3
|
+
module Daimyo
|
4
|
+
class Client
|
5
|
+
include Daimyo::Config
|
6
|
+
|
7
|
+
def initialize
|
8
|
+
params = read_daimyo_yaml
|
9
|
+
@client ||= BacklogKit::Client.new(
|
10
|
+
space_id: params['space_id'],
|
11
|
+
api_key: params['api_key'],
|
12
|
+
top_level_domain: params['top_level_domain']
|
13
|
+
)
|
14
|
+
end
|
15
|
+
|
16
|
+
def list(project_id)
|
17
|
+
@client.get_wikis(project_id)
|
18
|
+
end
|
19
|
+
|
20
|
+
def export(wiki_id)
|
21
|
+
@client.get_wiki(wiki_id)
|
22
|
+
end
|
23
|
+
|
24
|
+
def publish(wiki_id, wiki_name, wiki_contents)
|
25
|
+
params = {}
|
26
|
+
params['name'] = wiki_name
|
27
|
+
params['content'] = wiki_contents
|
28
|
+
@client.update_wiki(wiki_id, params)
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
require 'yaml'
|
2
|
+
|
3
|
+
module Daimyo
|
4
|
+
module Config
|
5
|
+
def read_daimyo_yaml
|
6
|
+
$stdout.sync = true
|
7
|
+
begin
|
8
|
+
YAML.load_file('.daimyo.yml')
|
9
|
+
rescue Errno::ENOENT
|
10
|
+
puts '.daimyo.yml が存在していません.'
|
11
|
+
exit 1
|
12
|
+
rescue => ex
|
13
|
+
puts '.daimyo.yml の読み込みに失敗しました. ' + ex.message
|
14
|
+
exit 1
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,65 @@
|
|
1
|
+
require 'daimyo'
|
2
|
+
|
3
|
+
module Daimyo
|
4
|
+
class Export
|
5
|
+
def initialize
|
6
|
+
@wiki ||= Daimyo::Client.new
|
7
|
+
end
|
8
|
+
|
9
|
+
def run(project_id, wiki_id = nil)
|
10
|
+
ids = select_wiki_ids(project_id)
|
11
|
+
pb = ProgressBar.create(:format => "%a %b\u{15E7}%i %p%% %t",
|
12
|
+
:progress_mark => ' ',
|
13
|
+
:remainder_mark => "\u{FF65}",
|
14
|
+
:starting_at => 10,
|
15
|
+
:length => 50)
|
16
|
+
ids.each do |id|
|
17
|
+
wiki = @wiki.export(id).body
|
18
|
+
name = wiki.name
|
19
|
+
content = wiki.content
|
20
|
+
write_file(project_id, id, name, content)
|
21
|
+
pb.increment
|
22
|
+
sleep 0.1
|
23
|
+
end
|
24
|
+
pb.finish
|
25
|
+
end
|
26
|
+
|
27
|
+
private
|
28
|
+
|
29
|
+
def select_wiki_ids(project_id)
|
30
|
+
@wiki.list(project_id).body.map { |w| w.id }
|
31
|
+
end
|
32
|
+
|
33
|
+
def write_file(project_id, id, name, content)
|
34
|
+
path = define_directory_path(project_id, name)
|
35
|
+
create_wiki_directory(path)
|
36
|
+
filename = id.to_s + '_' + define_file_path(name) + '.md'
|
37
|
+
file_path = path + '/' + filename
|
38
|
+
File.open(file_path, 'w') do |f|
|
39
|
+
f.puts(content.gsub("\r\n", "\n"))
|
40
|
+
end
|
41
|
+
|
42
|
+
original_file_path = path + '/' + '.' + filename
|
43
|
+
File.open(original_file_path, 'w') do |f|
|
44
|
+
f.puts(content.gsub("\r\n", "\n"))
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
def create_wiki_directory(path)
|
49
|
+
FileUtils.mkdir_p(path) unless FileTest.exist?(path)
|
50
|
+
path
|
51
|
+
end
|
52
|
+
|
53
|
+
def define_directory_path(project_id, name)
|
54
|
+
space = @wiki.instance_variable_get(:@client).instance_variable_get(:@space_id)
|
55
|
+
return space + '/' + project_id unless name.include?('/')
|
56
|
+
space + '/' + project_id + '/' + File.dirname(name) # 最後の 1 要素をファイル名とする
|
57
|
+
end
|
58
|
+
|
59
|
+
def define_file_path(name)
|
60
|
+
return name unless name.include?('/')
|
61
|
+
File.basename(name) # 最後の 1 要素をファイル名とする
|
62
|
+
end
|
63
|
+
|
64
|
+
end
|
65
|
+
end
|
data/lib/daimyo/list.rb
ADDED
@@ -0,0 +1,35 @@
|
|
1
|
+
require 'daimyo'
|
2
|
+
|
3
|
+
module Daimyo
|
4
|
+
class List
|
5
|
+
include Daimyo::Helper
|
6
|
+
|
7
|
+
def initialize
|
8
|
+
@wiki ||= Daimyo::Client.new
|
9
|
+
end
|
10
|
+
|
11
|
+
def run(project_id)
|
12
|
+
wikis = []
|
13
|
+
res = @wiki.list(project_id)
|
14
|
+
res.body.each do |w|
|
15
|
+
wiki = []
|
16
|
+
wiki << w.id
|
17
|
+
wiki << w.name
|
18
|
+
wiki << w.created
|
19
|
+
wiki << w.updated
|
20
|
+
wikis << wiki
|
21
|
+
end
|
22
|
+
|
23
|
+
output_table(wikis)
|
24
|
+
end
|
25
|
+
|
26
|
+
def output_table(wikis)
|
27
|
+
table = Terminal::Table.new(:headings => ['ID',
|
28
|
+
'Name',
|
29
|
+
'Created',
|
30
|
+
'Updated'],
|
31
|
+
:rows => wikis)
|
32
|
+
puts table
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
@@ -0,0 +1,88 @@
|
|
1
|
+
require 'daimyo'
|
2
|
+
|
3
|
+
module Daimyo
|
4
|
+
class Publish < Client
|
5
|
+
include Daimyo::Helper
|
6
|
+
|
7
|
+
def initialize(params = nil)
|
8
|
+
@wiki ||= Daimyo::Client.new
|
9
|
+
@is_local = params[:local] unless params.nil?
|
10
|
+
end
|
11
|
+
|
12
|
+
def search_files(project_id)
|
13
|
+
space = @wiki.instance_variable_get(:@client).instance_variable_get(:@space_id)
|
14
|
+
paths = Dir.glob(space + '/' + project_id + '/**/*')
|
15
|
+
|
16
|
+
diffy_paths = []
|
17
|
+
paths.each do |path|
|
18
|
+
diffy_path = []
|
19
|
+
if path.include?('.md')
|
20
|
+
path_array = path.split('/')
|
21
|
+
original_file_path = '.' + path_array[-1]
|
22
|
+
path_array.pop
|
23
|
+
original_path = path_array.join('/') + '/' + original_file_path
|
24
|
+
diffy_path << original_path
|
25
|
+
else
|
26
|
+
diffy_path << path
|
27
|
+
end
|
28
|
+
diffy_path << path
|
29
|
+
diffy_paths << diffy_path
|
30
|
+
end
|
31
|
+
diffy_paths
|
32
|
+
end
|
33
|
+
|
34
|
+
def read_file(path)
|
35
|
+
File.open(path, 'r') do |file|
|
36
|
+
file.read
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
def run(project_id, dry_run)
|
41
|
+
files = search_files(project_id)
|
42
|
+
|
43
|
+
diff_files = []
|
44
|
+
files.each do |file|
|
45
|
+
if file[0].include?('.md')
|
46
|
+
original = read_file(file[0])
|
47
|
+
latest = read_file(file[1])
|
48
|
+
diff_file = []
|
49
|
+
if original != latest
|
50
|
+
diff_file << file[1]
|
51
|
+
diff_file << original
|
52
|
+
diff_file << latest
|
53
|
+
diff_files << diff_file
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
58
|
+
diff_files.each do |diff_file|
|
59
|
+
puts diff_print_header(diff_file[0], @is_local)
|
60
|
+
path_array = diff_file[0].split('/')
|
61
|
+
wiki_id = path_array[-1].split('_')[0]
|
62
|
+
|
63
|
+
if @is_local
|
64
|
+
puts Diffy::Diff.new(diff_file[1], diff_file[2],
|
65
|
+
:include_diff_info => false, :context => 1).to_s(:color)
|
66
|
+
|
67
|
+
else
|
68
|
+
wiki_content = @wiki.export(wiki_id).body.content.gsub("\r\n", "\n")
|
69
|
+
puts Diffy::Diff.new(wiki_content, diff_file[2],
|
70
|
+
:include_diff_info => false, :context => 1).to_s(:color)
|
71
|
+
end
|
72
|
+
|
73
|
+
# Todo: このへん直す!
|
74
|
+
path_array.shift
|
75
|
+
path_array.shift
|
76
|
+
wiki_name = path_array[-1].split('_')[1].gsub(/.md/, '')
|
77
|
+
# Todo: このへん直す!
|
78
|
+
path_array.pop
|
79
|
+
if path_array.length > 0
|
80
|
+
wiki_name = path_array.join('/') + '/' + wiki_name
|
81
|
+
else
|
82
|
+
wiki_name
|
83
|
+
end
|
84
|
+
@wiki.publish(wiki_id, wiki_name, diff_file[2]) if dry_run.nil?
|
85
|
+
end
|
86
|
+
end
|
87
|
+
end
|
88
|
+
end
|
metadata
ADDED
@@ -0,0 +1,193 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: daimyo
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.2
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- inokappa
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2019-01-03 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.16'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.16'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: octorelease
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rake
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '10.0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '10.0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: rspec
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '3.0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '3.0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: thor
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ">="
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
76
|
+
type: :runtime
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - ">="
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: backlog_kit
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - ">="
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '0'
|
90
|
+
type: :runtime
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - ">="
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '0'
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: diffy
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - ">="
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: '0'
|
104
|
+
type: :runtime
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - ">="
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: '0'
|
111
|
+
- !ruby/object:Gem::Dependency
|
112
|
+
name: terminal-table
|
113
|
+
requirement: !ruby/object:Gem::Requirement
|
114
|
+
requirements:
|
115
|
+
- - ">="
|
116
|
+
- !ruby/object:Gem::Version
|
117
|
+
version: '0'
|
118
|
+
type: :runtime
|
119
|
+
prerelease: false
|
120
|
+
version_requirements: !ruby/object:Gem::Requirement
|
121
|
+
requirements:
|
122
|
+
- - ">="
|
123
|
+
- !ruby/object:Gem::Version
|
124
|
+
version: '0'
|
125
|
+
- !ruby/object:Gem::Dependency
|
126
|
+
name: ruby-progressbar
|
127
|
+
requirement: !ruby/object:Gem::Requirement
|
128
|
+
requirements:
|
129
|
+
- - ">="
|
130
|
+
- !ruby/object:Gem::Version
|
131
|
+
version: '0'
|
132
|
+
type: :runtime
|
133
|
+
prerelease: false
|
134
|
+
version_requirements: !ruby/object:Gem::Requirement
|
135
|
+
requirements:
|
136
|
+
- - ">="
|
137
|
+
- !ruby/object:Gem::Version
|
138
|
+
version: '0'
|
139
|
+
description: It is a tool to edit Markdown format file in local environment
|
140
|
+
email:
|
141
|
+
- inokappa at gmail.com
|
142
|
+
executables:
|
143
|
+
- daimyo
|
144
|
+
extensions: []
|
145
|
+
extra_rdoc_files: []
|
146
|
+
files:
|
147
|
+
- ".gitignore"
|
148
|
+
- ".rspec"
|
149
|
+
- ".travis.yml"
|
150
|
+
- Gemfile
|
151
|
+
- Gemfile.lock
|
152
|
+
- LICENSE.txt
|
153
|
+
- README.md
|
154
|
+
- Rakefile
|
155
|
+
- bin/console
|
156
|
+
- bin/setup
|
157
|
+
- daimyo.gemspec
|
158
|
+
- exe/daimyo
|
159
|
+
- lib/daimyo.rb
|
160
|
+
- lib/daimyo/cli.rb
|
161
|
+
- lib/daimyo/client.rb
|
162
|
+
- lib/daimyo/config.rb
|
163
|
+
- lib/daimyo/export.rb
|
164
|
+
- lib/daimyo/helper.rb
|
165
|
+
- lib/daimyo/list.rb
|
166
|
+
- lib/daimyo/projects.rb
|
167
|
+
- lib/daimyo/publish.rb
|
168
|
+
- lib/daimyo/version.rb
|
169
|
+
homepage: https://github.com/inokappa/daimyo
|
170
|
+
licenses:
|
171
|
+
- MIT
|
172
|
+
metadata: {}
|
173
|
+
post_install_message:
|
174
|
+
rdoc_options: []
|
175
|
+
require_paths:
|
176
|
+
- lib
|
177
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
178
|
+
requirements:
|
179
|
+
- - ">="
|
180
|
+
- !ruby/object:Gem::Version
|
181
|
+
version: '0'
|
182
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
183
|
+
requirements:
|
184
|
+
- - ">="
|
185
|
+
- !ruby/object:Gem::Version
|
186
|
+
version: '0'
|
187
|
+
requirements: []
|
188
|
+
rubyforge_project:
|
189
|
+
rubygems_version: 2.7.6
|
190
|
+
signing_key:
|
191
|
+
specification_version: 4
|
192
|
+
summary: It is a tool to edit Markdown format file in local environment
|
193
|
+
test_files: []
|