github_exporter 0.1.1 → 0.1.2
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/CHANGELOG.md +5 -0
- data/README.md +17 -16
- data/lib/github_exporter/cli.rb +27 -18
- data/lib/github_exporter/exporter.rb +35 -12
- data/lib/github_exporter/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6fc1e7c83a170f3ee077d962091063ff630ef2f8
|
4
|
+
data.tar.gz: c327923292122eb610647300f209e30c1dd2750b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 35b642759f6a4e53125615c121dd46d7de1f76921fb303bf26ffda4db541fedc7d6f7226ce805ebbc95c6f7ff70eb58df6a4cc0e26e4dd7dcdb5d473d9329975
|
7
|
+
data.tar.gz: ee2d61ad0f4501cddcf0a5d161413d9cfb52bf9464228c907793081b4be7c143378b241c7e4f683dfbc2b49dd7f7da3f155d8dbd3c4ca5fa8cd6237db955a8e6
|
data/CHANGELOG.md
CHANGED
@@ -1,6 +1,11 @@
|
|
1
|
+
#### 0.1.2
|
2
|
+
|
3
|
+
- Add optional `--output-name` for pdf output (default to #{repository_name}.pdf)
|
4
|
+
|
1
5
|
#### 0.1.1
|
2
6
|
|
3
7
|
- Fix style with the help of rubocop
|
8
|
+
- Add full link to Github for sample screenshot to make it work with rubydoc.info
|
4
9
|
- Misc code cleanup
|
5
10
|
|
6
11
|
#### 0.1.0
|
data/README.md
CHANGED
@@ -25,30 +25,28 @@ gem install github_exporter
|
|
25
25
|
## Synopsis/Usage
|
26
26
|
|
27
27
|
```shell
|
28
|
+
|
28
29
|
Usage:
|
29
30
|
|
30
|
-
$github_exporter -e, --exts=EXT1 EXT2 EXT3 -u, --url=URL -theme=theme_name
|
31
|
+
$github_exporter -e, --exts=EXT1 EXT2 EXT3 -u, --url=URL -theme=theme_name --output-name=output_file.pdf
|
31
32
|
|
32
33
|
Example:
|
33
34
|
|
34
35
|
# Export the *.rb from the given repository
|
35
36
|
|
36
|
-
$github_exporter -e rb -u https://github.com/agilecreativity/
|
37
|
-
|
38
|
-
# Export the *.rb and also 'Gemfile' from a given directory 'filename_cleaner'
|
39
|
-
# Note: must be one directory directly relative to current directory
|
37
|
+
$github_exporter -e rb -u https://github.com/agilecreativity/github_exporter.git
|
40
38
|
|
41
|
-
|
39
|
+
# Export the *.rb and also 'Gemfile' from a 'github_exporter' directory
|
40
|
+
# Note: this directory must be directly below the current directory
|
42
41
|
|
43
|
-
|
44
|
-
# using 'solarized' theme
|
45
|
-
# Note: must be one directory directly relative to current directory
|
42
|
+
$github_exporter -e rb -f Gemfile -u github_exporter
|
46
43
|
|
44
|
+
# Same as previous command with the 'solarized' instead of 'default' colorscheme
|
47
45
|
$github_exporter -e rb -f Gemfile -u filename_cleaner -t solarized
|
48
46
|
|
49
47
|
Options:
|
50
48
|
|
51
|
-
-u, --url=URL # The full url of the github project to be cloned
|
49
|
+
-u, --url=URL # The full url of the github project to be cloned OR local directory name
|
52
50
|
|
53
51
|
-e, --exts=EXT1 EXT2 EXT3 .. # The list of extension names to be exported
|
54
52
|
# e.g. -e md rb java
|
@@ -56,11 +54,14 @@ Options:
|
|
56
54
|
-f, [--non-exts=one two three] # The list of file without extension to be exported
|
57
55
|
# e.g. -f Gemfile LICENSE
|
58
56
|
|
59
|
-
-t, [--theme=theme_name] # The theme to be used with vim_printer see :
|
57
|
+
-t, [--theme=theme_name] # The theme/colorscheme to be used with vim_printer see :help :colorscheme from inside Vim
|
60
58
|
# default: 'default'
|
61
59
|
# e.g. -t solarized
|
62
60
|
|
63
|
-
|
61
|
+
-o, [--output-name=output.pdf] # The output pdf filename (will default to 'repository_name'.pdf)
|
62
|
+
# e.g. -o repository_name.pdf
|
63
|
+
|
64
|
+
Export a given Github project or a local project directory to a single pdf file
|
64
65
|
|
65
66
|
```
|
66
67
|
|
@@ -111,11 +112,11 @@ Your final output is ./github_exporter.pdf
|
|
111
112
|
github_exporter -u https://github.com/agilecreativity/github_exporter.git --exts rb
|
112
113
|
```
|
113
114
|
|
114
|
-
Which generated the following [pdf output file](/samples/github_exporter_default_colorscheme.pdf)
|
115
|
+
Which generated the following [pdf output file](https://github.com/agilecreativity/github_exporter/raw/master/samples/github_exporter_default_colorscheme.pdf)
|
115
116
|
|
116
117
|
The example screenshot:
|
117
118
|
|
118
|
-

|
119
|
+

|
119
120
|
|
120
121
|
#### Use non-default colorscheme/theme for Vim
|
121
122
|
|
@@ -125,11 +126,11 @@ Use [seoul256][] colorscheme
|
|
125
126
|
github_exporter -u https://github.com/agilecreativity/github_exporter.git --exts rb --theme seoul256
|
126
127
|
```
|
127
128
|
|
128
|
-
Which generated the following [pdf output file](/samples/github_exporter_seoul256_colorscheme.pdf)
|
129
|
+
Which generated the following [pdf output file](https://github.com/agilecreativity/github_exporter/raw/master/samples/github_exporter_seoul256_colorscheme.pdf)
|
129
130
|
|
130
131
|
The example screenshot:
|
131
132
|
|
132
|
-

|
133
|
+

|
133
134
|
|
134
135
|
### Contributing
|
135
136
|
|
data/lib/github_exporter/cli.rb
CHANGED
@@ -5,15 +5,15 @@ require "pdfs2pdf"
|
|
5
5
|
require_relative "github_exporter"
|
6
6
|
module GithubExporter
|
7
7
|
class CLI < Thor
|
8
|
-
desc "export", "Export a given
|
8
|
+
desc "export", "Export a given Github project or a local project to a single pdf file"
|
9
9
|
method_option "url",
|
10
10
|
aliases: "-u",
|
11
|
-
desc: "The full url of the github project to be cloned",
|
11
|
+
desc: "The full url of the github project to be cloned or local project directory (mandatory)",
|
12
12
|
required: true
|
13
13
|
method_option "exts",
|
14
14
|
type: :array,
|
15
15
|
aliases: "-e",
|
16
|
-
desc: "The list of file extension to be exported",
|
16
|
+
desc: "The list of file extension to be exported (mandatory)",
|
17
17
|
required: true
|
18
18
|
method_option "non_exts",
|
19
19
|
type: :array,
|
@@ -25,11 +25,17 @@ module GithubExporter
|
|
25
25
|
aliases: "-t",
|
26
26
|
desc: "The theme to be used with vim_printer",
|
27
27
|
default: "default"
|
28
|
+
method_option "output_name",
|
29
|
+
type: :string,
|
30
|
+
aliases: "-o",
|
31
|
+
desc: "The output filename (optional)"
|
28
32
|
def export
|
29
33
|
exporter = GithubExporter::Exporter.new options[:url],
|
30
|
-
exts:
|
31
|
-
non_exts:
|
32
|
-
theme:
|
34
|
+
exts: options[:exts],
|
35
|
+
non_exts: options[:non_exts],
|
36
|
+
theme: options[:theme],
|
37
|
+
output_name: options[:output_name]
|
38
|
+
|
33
39
|
exporter.export
|
34
40
|
end
|
35
41
|
|
@@ -38,28 +44,28 @@ module GithubExporter
|
|
38
44
|
puts <<-EOS
|
39
45
|
Usage:
|
40
46
|
|
41
|
-
$github_exporter -
|
47
|
+
$github_exporter -u, --url=URL \
|
48
|
+
-e, --exts=EXT1 EXT2 EXT3 \
|
49
|
+
-t, --theme=theme_name \
|
50
|
+
-o, --output-name=output_file.pdf
|
42
51
|
|
43
52
|
Example:
|
44
53
|
|
45
54
|
# Export the *.rb from the given repository
|
46
55
|
|
47
|
-
$github_exporter -e rb -u https://github.com/agilecreativity/
|
56
|
+
$github_exporter -e rb -u https://github.com/agilecreativity/github_exporter.git
|
48
57
|
|
49
|
-
# Export the *.rb and also 'Gemfile' from a
|
50
|
-
# Note: must be
|
58
|
+
# Export the *.rb and also 'Gemfile' from a 'github_exporter' directory
|
59
|
+
# Note: this directory must be directly below the current directory
|
51
60
|
|
52
|
-
$github_exporter -e rb -f Gemfile -u
|
53
|
-
|
54
|
-
# Export the *.rb and also 'Gemfile' from a given directory 'filename_cleaner'
|
55
|
-
# using 'solarized' theme
|
56
|
-
# Note: must be one directory directly relative to current directory
|
61
|
+
$github_exporter -e rb -f Gemfile -u github_exporter
|
57
62
|
|
63
|
+
# Same as previous command with the 'solarized' instead of 'default' colorscheme
|
58
64
|
$github_exporter -e rb -f Gemfile -u filename_cleaner -t solarized
|
59
65
|
|
60
66
|
Options:
|
61
67
|
|
62
|
-
-u, --url=URL # The full url of the github project to be cloned
|
68
|
+
-u, --url=URL # The full url of the github project to be cloned OR local directory name
|
63
69
|
|
64
70
|
-e, --exts=EXT1 EXT2 EXT3 .. # The list of extension names to be exported
|
65
71
|
# e.g. -e md rb java
|
@@ -67,11 +73,14 @@ Options:
|
|
67
73
|
-f, [--non-exts=one two three] # The list of file without extension to be exported
|
68
74
|
# e.g. -f Gemfile LICENSE
|
69
75
|
|
70
|
-
-t, [--theme=theme_name] # The theme to be used with vim_printer see :
|
76
|
+
-t, [--theme=theme_name] # The theme/colorscheme to be used with vim_printer see :help :colorscheme from inside Vim
|
71
77
|
# default: 'default'
|
72
78
|
# e.g. -t solarized
|
73
79
|
|
74
|
-
|
80
|
+
-o, [--output-name=output.pdf] # The output pdf filename (will default to 'repository_name'.pdf)
|
81
|
+
# e.g. -o repository_name.pdf
|
82
|
+
|
83
|
+
Export a given Github project or a local project directory to a single pdf file
|
75
84
|
|
76
85
|
EOS
|
77
86
|
end
|
@@ -9,19 +9,23 @@ module GithubExporter
|
|
9
9
|
attr_reader :url,
|
10
10
|
:exts,
|
11
11
|
:non_exts,
|
12
|
-
:theme
|
12
|
+
:theme,
|
13
|
+
:output_name
|
14
|
+
|
13
15
|
attr_reader :base_dir,
|
14
16
|
:repo_name,
|
15
17
|
:output_path
|
16
|
-
|
18
|
+
|
19
|
+
# The initializer for Exporter
|
17
20
|
#
|
18
21
|
# @param [String] url the input URL like
|
19
|
-
# https://github.com/opal/opal.git or just the
|
22
|
+
# https://github.com/opal/opal.git or just the immediate folder name
|
20
23
|
# @param [Hash<Symbol,Object>] opts the option hash
|
21
24
|
#
|
22
25
|
# @option opts [Array<String>] :exts the list of file extension to be used
|
23
26
|
# @option opts [Array<String>] :non_exts the list of file without extension to be used
|
24
|
-
# @option opts [String] :theme the
|
27
|
+
# @option opts [String] :theme the colorscheme to use with `vim_printer`
|
28
|
+
# @option opts [String] :output_name the output filename if any
|
25
29
|
def initialize(url, opts = {})
|
26
30
|
@url = url
|
27
31
|
@base_dir = Dir.pwd
|
@@ -30,6 +34,7 @@ module GithubExporter
|
|
30
34
|
@theme = opts[:theme] || "default"
|
31
35
|
@repo_name = project_name(url)
|
32
36
|
@output_path = File.expand_path([base_dir, repo_name].join(File::SEPARATOR))
|
37
|
+
@output_name = pdf_filename(opts[:output_name]) || "#{@repo_name}.pdf"
|
33
38
|
end
|
34
39
|
|
35
40
|
# Print and export the source from a given URL to a pdf
|
@@ -46,13 +51,14 @@ module GithubExporter
|
|
46
51
|
|
47
52
|
def to_s
|
48
53
|
<<-EOT
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
54
|
+
url : #{url}
|
55
|
+
base_dir : #{base_dir}
|
56
|
+
exts : #{exts}
|
57
|
+
non_exts : #{non_exts}
|
58
|
+
repo_name : #{repo_name}
|
59
|
+
theme : #{theme}
|
60
|
+
output_path : #{output_path}
|
61
|
+
output_name : #{output_name}
|
56
62
|
EOT
|
57
63
|
end
|
58
64
|
|
@@ -113,7 +119,7 @@ module GithubExporter
|
|
113
119
|
|
114
120
|
def copy_output
|
115
121
|
generated_file = "#{output_dir}/pdfs2pdf_#{repo_name}.pdf"
|
116
|
-
destination_file = File.expand_path(File.dirname(output_dir) + "../../#{
|
122
|
+
destination_file = File.expand_path(File.dirname(output_dir) + "../../#{output_name}")
|
117
123
|
FileUtils.mv generated_file, destination_file if File.exist?(generated_file)
|
118
124
|
puts "Your final output is #{File.expand_path(destination_file)}"
|
119
125
|
end
|
@@ -143,6 +149,23 @@ module GithubExporter
|
|
143
149
|
name = URI(uri).path.split(File::SEPARATOR).last if uri
|
144
150
|
File.basename(name, ".*") if name
|
145
151
|
end
|
152
|
+
|
153
|
+
# Add/rename the file extension to pdf
|
154
|
+
#
|
155
|
+
# @param [String] filename input file
|
156
|
+
# @return [String,NilClass] output file with .pdf as extension or nil
|
157
|
+
def pdf_filename(filename)
|
158
|
+
return nil unless filename
|
159
|
+
extname = File.extname(filename)
|
160
|
+
basename = File.basename(filename, ".*")
|
161
|
+
if extname == ""
|
162
|
+
"#{filename}.pdf"
|
163
|
+
elsif extname != ".pdf"
|
164
|
+
"#{basename}.pdf"
|
165
|
+
else
|
166
|
+
filename
|
167
|
+
end
|
168
|
+
end
|
146
169
|
end
|
147
170
|
# robocop:enable All
|
148
171
|
end
|