github-markdown-server 0.0.2 → 0.0.3

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: b494d220af9950651041ea55cf4d4b20280ced3e
4
- data.tar.gz: 7e6c5f2599a92bd9a76d2b068458d2d1eee31dae
3
+ metadata.gz: 6698f6b08e38b1fdb375313348dfc3992b5c5f41
4
+ data.tar.gz: 1068e064418e8b05d1f0b336ac19e87fe6d4fd49
5
5
  SHA512:
6
- metadata.gz: 13a669ea9878cd574e06cd36b33f8468032c0ceb5741e947caa8a6f033fa40bb0070ded07f419dd558265dd3db8be3792104a1458311401123259bd991dcd938
7
- data.tar.gz: 09fe4e4def06aa10f73b1b7028ce9a7375c6a477e513c26f0427da45a1fc7dec98fb0fbc846824d8f696b6a38a303a95ae3a13beffc668a31f6a4914230c44aa
6
+ metadata.gz: 23e38cfdccdf8507e7d9cf092627b8bb56f95ee53918b9608fa368aa55f453e872d9eb4bb7eb7cdcbdef9bd694fe5e06cc1645c29f8ca987d631185cdbbf7c48
7
+ data.tar.gz: 7895ab83a06b42785c6f1a8bb2e6ba1f237baab5440c5551128f86563765886c18565007a2d39ea357bbb88956ec7ad1df18b25a4d4d9b4093048a5d1272ba75
data/.gitignore CHANGED
@@ -1 +1,2 @@
1
1
  *.gem
2
+ Gemfile.lock
data/.travis.yml ADDED
@@ -0,0 +1,5 @@
1
+ language: ruby
2
+ rvm:
3
+ - "1.9"
4
+ - "2.0"
5
+ - "2.1"
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Dependencies managed in github-markdown-server.gemspec
4
+ gemspec
data/README.md CHANGED
@@ -3,7 +3,16 @@
3
3
  Use your favorite editor to edit a markdown file, Run the server and open the file.
4
4
  Saving in your editor updates instantly in the browser.
5
5
 
6
- github-markdown-server is built on top of [github-markdown-preview](https://github.com/dmarcotte/github-markdown-preview).
6
+ github-markdown-server is built on top of [github-markdown-preview](https://github.com/dmarcotte/github-markdown-preview) and [live.js](http://www.livejs.com/).
7
+
8
+ [![Gem Version](https://badge.fury.io/rb/github-markdown-server.svg)](http://badge.fury.io/rb/github-markdown-server)
9
+ [![Build Status](https://travis-ci.org/arkarkark/github-markdown-server.svg)](https://travis-ci.org/arkarkark/github-markdown-server)
10
+
11
+ ## Installation
12
+
13
+ ```shell
14
+ gem install github-markdown-server
15
+ ```
7
16
 
8
17
  ## Usage
9
18
 
data/Rakefile ADDED
@@ -0,0 +1,10 @@
1
+ require "bundler/gem_tasks"
2
+
3
+ require "rake/testtask"
4
+ Rake::TestTask.new do |t|
5
+ t.libs << "test"
6
+ t.test_files = FileList["test/**/*_test.rb"]
7
+ t.verbose = true
8
+ end
9
+
10
+ task :default => ["test"]
@@ -47,5 +47,4 @@ options = {
47
47
  :directory => directory,
48
48
  :file_name => file_name,
49
49
  }
50
- p "go on #{server_port}"
51
50
  GithubMarkdownServer::Server.new(options)
@@ -9,7 +9,6 @@
9
9
 
10
10
  (defvar github-markdown-servers '() "The servers we have running.")
11
11
  (defvar github-markdown-server-port 7494 "The next available server port.")
12
- (defvar github-markdown-server-browser "Google Chrome" "Application to use with osx's open -a to open files.")
13
12
 
14
13
  (defun git-base (&optional file-name)
15
14
  "Get the base of a git repository for FILE-NAME (or the current buffer)."
@@ -54,8 +53,8 @@
54
53
  (concat "lsof -n -i4TCP:" (number-to-string github-markdown-server-port) " | grep LISTEN"))))
55
54
  (setq github-markdown-server-port (+ github-markdown-server-port 1)))
56
55
 
57
- (message (concat "starting github-markdown-server on port:" (number-to-string (cdr server))))
58
- (setq server (cons base github-markdown-server-port))))
56
+ (setq server (cons base github-markdown-server-port)))
57
+ (message (concat "starting github-markdown-server on port:" (number-to-string (cdr server)))))
59
58
  (call-process-shell-command
60
59
  (concat "github-markdown-server"
61
60
  " --directory=" (shell-quote-argument (car server))
@@ -71,22 +70,31 @@
71
70
  (defun view-file-in-browser (&optional file-name)
72
71
  "Open up file on github or via a local markdown server.
73
72
  FILE-NAME will be current buffer if not specified.
74
- Prefix arg \[universal-argument] to not run local server."
73
+ Prefix arg \[universal-argument] to not run local server for markdown files."
75
74
  (interactive (list (buffer-file-name)))
76
75
  (if (and (not current-prefix-arg) (string-match "\.md$" file-name))
77
76
  (github-markdown-serve file-name)
78
77
  (call-process-shell-command
79
- (concat "open -a " (shell-quote-argument github-markdown-server-browser) " \"$("
78
+ ;; open it with the default webbrowser The Mac::InternetConfig stuff)
79
+ ;; open either on github or a local file (the remove.origin.url stuff)
80
+ (concat "open -a \"$(VERSIONER_PERL_PREFER_32_BIT=1 "
81
+ "perl -MMac::InternetConfig -le 'print +(GetICHelper \"http\")[1]')\" \"$("
80
82
  "perl -e 'use File::Basename; $f = shift @ARGV; $d = dirname($f); $b = basename($f); "
81
83
  "$o = `git -C $d config --get remote.origin.url`; "
82
- "if ($o =~ qr(!git(@|://)github.com[:/]!)) { "
84
+ "if ($o =~ qr!git(@|://)github.com[:/]!) { "
83
85
  " $o =~ s!git(@|://)github.com[:/](.*).git$!https://github.com/$2!; "
84
86
  "} else { $o = \"\" }"
85
87
  "$p = `git -C $d rev-parse --show-prefix`; "
86
88
  "chomp($o, $p); "
87
- "if ($o) { print \"$o/blob/master/$p$b\n\"; } else { print \"file://$f\" }' "
88
- (shell-quote-argument (buffer-file-name)) ")\"")
89
- nil 0)))
89
+ "if ($o) { print \"$o/blob/master/$p$b\"; } else { print \"file://$f\" }' "
90
+ (shell-quote-argument (buffer-file-name)) ")#L"
91
+ (if (region-active-p)
92
+ (concat
93
+ (number-to-string (line-number-at-pos (region-beginning))) "-"
94
+ (number-to-string (line-number-at-pos (region-end))))
95
+ (number-to-string (line-number-at-pos)))
96
+ "\"")
97
+ nil 0)))
90
98
 
91
99
  (provide 'github-markdown-server)
92
100
  ;;; github-markdown-server ends here
@@ -16,10 +16,10 @@ module GithubMarkdownServer
16
16
  url = "http://localhost:#{port}/"
17
17
 
18
18
  if !File.directory?(@directory)
19
- @directory = File.dirname(@directory)
19
+ @directory = File.dirname(@file_name)
20
20
  end
21
21
 
22
- url += @file_name[@directory.length + 1..-1]
22
+ url = url + @file_name[@directory.length + 1..-1] if @file_name != @directory
23
23
 
24
24
  server_options = {
25
25
  :Port => port,
@@ -1,3 +1,3 @@
1
1
  module GithubMarkdownServer
2
- VERSION = '0.0.2'
2
+ VERSION = '0.0.3'
3
3
  end
@@ -0,0 +1,19 @@
1
+ require 'minitest/autorun'
2
+
3
+ class TestBin < Minitest::Test
4
+ def setup
5
+ @gms_scipt = File.join(File.dirname(__FILE__), '..', 'bin', 'github-markdown-server')
6
+ end
7
+
8
+ def test_bad_params
9
+ IO.popen("bundle exec #{@gms_scipt} --nonsense") do |io|
10
+ assert_match(/.*invalid option: --nonsense.*/, io.read, 'invalid option: --nonsense')
11
+ end
12
+ end
13
+
14
+ def test_version_ouput
15
+ IO.popen("bundle exec #{@gms_scipt} -v") do |io|
16
+ assert_match(GithubMarkdownServer::VERSION, io.read, '-v call should output version')
17
+ end
18
+ end
19
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: github-markdown-server
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Alex K (wtwf.com)
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-11-29 00:00:00.000000000 Z
11
+ date: 2014-12-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: github-markdown-preview
@@ -80,8 +80,11 @@ extensions: []
80
80
  extra_rdoc_files: []
81
81
  files:
82
82
  - ".gitignore"
83
+ - ".travis.yml"
84
+ - Gemfile
83
85
  - LICENSE
84
86
  - README.md
87
+ - Rakefile
85
88
  - bin/github-markdown-server
86
89
  - contrib/github-markdown-server.el
87
90
  - data/image/favicon.ico
@@ -91,6 +94,7 @@ files:
91
94
  - lib/github-markdown-server/resources.rb
92
95
  - lib/github-markdown-server/server.rb
93
96
  - lib/github-markdown-server/version.rb
97
+ - test/github-markdown-server_test.rb
94
98
  homepage: https://github.com/arkarkark/github-markdown-server
95
99
  licenses:
96
100
  - MIT
@@ -116,4 +120,5 @@ signing_key:
116
120
  specification_version: 4
117
121
  summary: Use your favorite editor to edit a markdown file, Run the server and open
118
122
  the file. Saving in your editor updates instantly in the browser.
119
- test_files: []
123
+ test_files:
124
+ - test/github-markdown-server_test.rb