github_exporter 0.1.1 → 0.1.2

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: b9e584930fb1946cb9a0682f911a9d21c9bc85f0
4
- data.tar.gz: ad760387610116c613c82c4ef844222695445139
3
+ metadata.gz: 6fc1e7c83a170f3ee077d962091063ff630ef2f8
4
+ data.tar.gz: c327923292122eb610647300f209e30c1dd2750b
5
5
  SHA512:
6
- metadata.gz: 6d55a11d36965350712b82bb0e435c1fcc645b36f26c52d6f947fd018c0ff7c48ef049a04cada4b4254279d86529f738996336e2c3a5ce1bcb80a3dc7b6ecd74
7
- data.tar.gz: 32f9bfe213494a87eb9a6c756d36c4b58d52b6e5c792b43772054ef2b9b8a5be816e7fb132fb6d0682dce7d4e84ec093ce8fe6cfd5c5ee27cec3402c8f561310
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/filename_cleaner.git
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
- $github_exporter -e rb -f Gemfile -u filename_cleaner
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
- # Export the *.rb and also 'Gemfile' from a given directory 'filename_cleaner'
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 :h :colorscheme from Vim
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
- Export a given URL or project to a single pdf file
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
- ![](/samples/github_exporter_default_colorscheme.png)
119
+ ![](https://github.com/agilecreativity/github_exporter/raw/master/samples/github_exporter_default_colorscheme.png)
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
- ![](/samples/github_exporter_seoul256_colorscheme.png)
133
+ ![](https://github.com/agilecreativity/github_exporter/raw/master/samples/github_exporter_seoul256_colorscheme.png)
133
134
 
134
135
  ### Contributing
135
136
 
@@ -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 URL or project to a single pdf file"
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: options[:exts],
31
- non_exts: options[:non_exts],
32
- theme: options[: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 -e, --exts=EXT1 EXT2 EXT3 -u, --url=URL -theme=theme_name
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/filename_cleaner.git
56
+ $github_exporter -e rb -u https://github.com/agilecreativity/github_exporter.git
48
57
 
49
- # Export the *.rb and also 'Gemfile' from a given directory 'filename_cleaner'
50
- # Note: must be one directory directly relative to current directory
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 filename_cleaner
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 :h :colorscheme from Vim
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
- Export a given URL or project to a single pdf file
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
- # Constructor for Executor
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 immediat folder name
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 theme to use for `vim_printer`
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
- url : #{url}
50
- base_dir : #{base_dir}
51
- exts : #{exts}
52
- non_exts : #{non_exts}
53
- repo_name : #{repo_name}
54
- theme : #{theme}
55
- output_path : #{output_path}
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) + "../../#{repo_name}.pdf")
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
@@ -1,3 +1,3 @@
1
1
  module GithubExporter
2
- VERSION = "0.1.1"
2
+ VERSION = "0.1.2"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: github_exporter
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Burin Choomnuan