ghpreview 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -14,6 +14,7 @@ module GHPreview
14
14
  @md_filepath = md_filepath
15
15
  @md_filename = md_filepath.split('/').last
16
16
  @md_filedir = md_filepath.split('/').unshift('.').uniq[0..-2].join('/')
17
+ @http = HTTPClient.new
17
18
  generate_template_with_fingerprinted_stylesheet_links
18
19
 
19
20
  options[:watch] ? listen : open
@@ -31,22 +32,25 @@ module GHPreview
31
32
  html = markdown_to_html
32
33
  html = wrap_content_with_full_document(html)
33
34
  File.open(HTML_FILEPATH, 'w') { |f| f << html }
34
- `open #{HTML_FILEPATH}`
35
+ if RUBY_PLATFORM =~ /linux/
36
+ command = 'xdg-open'
37
+ else
38
+ command = 'open'
39
+ end
40
+ `#{command} #{HTML_FILEPATH}`
35
41
  end
36
42
 
37
43
  private
38
44
 
39
45
  def markdown_to_html
40
46
  markdown = File.read(@md_filepath)
41
- client = HTTPClient.new
42
- message = client.post API_URI, body: markdown, header: {'Content-Type' => 'text/plain'}
47
+ message = @http.post API_URI, body: markdown, header: {'Content-Type' => 'text/plain'}
43
48
  message.body
44
49
  end
45
50
 
46
51
  def generate_template_with_fingerprinted_stylesheet_links
47
52
  if stale_template?(STYLED_TEMPLATE_FILEPATH)
48
- uri = URI.parse(HOMEPAGE)
49
- stylesheet_links = uri.read.split("\n").select do |line|
53
+ stylesheet_links = @http.get(HOMEPAGE).body.split("\n").select do |line|
50
54
  line =~ /https:.*github.*\.css/
51
55
  end.join
52
56
 
@@ -1,3 +1,3 @@
1
1
  module GHPreview
2
- VERSION = "0.0.1"
2
+ VERSION = "0.0.2"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ghpreview
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors: