yield 0.0.3 → 0.1.0

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: e110a49fbc1543025a325b8f2f6d1de9c32ffd03
4
- data.tar.gz: 878002a6f69b610556af6ddda461c37479653259
3
+ metadata.gz: ea16de90187bdc71533059a24947b51da99ed5f2
4
+ data.tar.gz: 19c46b8d1505910dd6da4fd3fec830da754ebbb6
5
5
  SHA512:
6
- metadata.gz: c9406ff6ede1349d5d987b533a805079fd431f4a8bdcde3d46b204a9342c9e77c58f9488d6c79d5e98673ffa3dd8b1a42cedafab58ed0b091bf2c719a664e9f9
7
- data.tar.gz: 84da1a0cde5f1245c394c626ec59c9e7ab65c3cc127579f5277df6700ea867d0f5e65220c19b4e1d6c8bbf1d111762bd0293a3376ba7cde364ef6aa6ceca0200
6
+ metadata.gz: b4fb3356e9d9b3a0a19da44650b58de061fe308406feb161d37fa4accc3ff94272bb4a5abb8ad04ca2afd256c97b2ce61816fcf2704919d0c042fe30687b5f5e
7
+ data.tar.gz: 22a9dc0dabb3ceab5faff97f0a23e15f5f2240d375ecef0d9936861966cb3a695fa0a5b9088b60b2602fc9632d9b9ee82c3e61acf6d62eeda4eade69b086cacb
data/Gemfile CHANGED
@@ -2,3 +2,8 @@ source 'https://rubygems.org'
2
2
 
3
3
  # Specify your gem's dependencies in yield.gemspec
4
4
  gemspec
5
+
6
+ gem "sinatra", "1.4.3"
7
+ gem "octokit", "1.25.0"
8
+ gem "thin", "1.5.1"
9
+ gem "launchy", "2.3.0"
data/README.md CHANGED
@@ -1,13 +1,12 @@
1
1
  # Yield
2
2
 
3
- Yield is a command line utility that generates a preview of README.md and markdown files using GitHub Flavored Markdown
4
- in your browser.
3
+ Yield is a command line utility that generates a preview of README.md and markdown files using GitHub Flavored Markdown in your browser. It parses your markdown files using [GitHub's Markdown API](http://developer.github.com/v3/markdown/), so you can preview it exactly how it will look on GitHub.
5
4
 
6
5
  ## Installation
7
6
 
8
7
  ### Dependencies
9
8
 
10
- * Ruby
9
+ * [Ruby v2.0.0](http://www.ruby-lang.org/en/)
11
10
  * [sinatra](http://sinatrarb.com)
12
11
  * [thin](http://code.macournoyer.com/thin/)
13
12
  * [octokit](http://octokit.github.io)
@@ -24,7 +23,7 @@ From the root of your project, or any folder containing a README.md file, run th
24
23
 
25
24
  ```bash
26
25
  $ yield
27
- -> yield is now serving your markdown at localhost:4567 using Thin...
26
+ =* Yield is serving your markdown at http://localhost:4000/
28
27
  ```
29
28
 
30
29
  You may also specify a path to a markdown file you'd like to render, such as:
@@ -33,7 +32,15 @@ You may also specify a path to a markdown file you'd like to render, such as:
33
32
  $ yield UPDATES.md
34
33
  ```
35
34
 
36
- Then navigate to [localhost:4567](http://localhost:4567) in your browser to view the preview of the file.
35
+ Then navigate to [localhost:4000](http://localhost:4000) in your browser to view the preview of the file.
36
+
37
+ You can stop the server by pressing Control+C.
38
+
39
+ ### Errors
40
+
41
+ #### API Rate Limit Exceeded
42
+
43
+ GitHub's API only allows only 60 unauthenticated requests per hour from a single IP address. If you are hitting this limit, then you must really like yield!
37
44
 
38
45
  ## Contributing
39
46
 
data/bin/yield CHANGED
@@ -2,11 +2,13 @@
2
2
 
3
3
  require_relative '../lib/yield'
4
4
 
5
+ `stty -echoctl`
6
+
5
7
  if ARGV.length == 1
6
8
  filename = ARGV[0]
7
- Yield::Markdown.render(filename)
9
+ Yield::Markdown.init(filename)
8
10
  else
9
- Yield::Markdown.render
11
+ Yield::Markdown.init
10
12
  end
11
13
 
12
14
  Yield::Markdown.run!
@@ -1,6 +1,8 @@
1
1
  require "sinatra"
2
2
  require "octokit"
3
3
  require "thin"
4
+ require "launchy"
5
+
4
6
  require_relative "yield/version"
5
7
 
6
8
 
@@ -2,52 +2,57 @@ module Yield
2
2
  class Markdown < Sinatra::Base
3
3
 
4
4
  set :server, %w[thin]
5
+ set :port, 4000
5
6
  @@content = nil
6
7
  @@filename = nil
7
8
 
9
+ def self.init(filename = 'README.md')
10
+ @@filename = filename.to_s
11
+ original_stdout = $stdout
12
+ $stdout = fake = StringIO.new
13
+ unless File.exist?(@@filename)
14
+ abort "Filename '#{@@filename}' doesn't exist."
15
+ end
16
+ end
17
+
8
18
  # Override run! method from Sinatra
9
19
  def self.run!(options = {})
10
20
  set options
11
21
  handler = detect_rack_handler
12
22
  handler_name = handler.name.gsub(/.*::/, '')
13
23
  server_settings = settings.respond_to?(:server_settings) ? settings.server_settings : {}
14
-
15
24
  handler.run self, server_settings.merge(:Port => port, :Host => bind) do |server|
16
25
  unless handler_name =~ /cgi/i
17
- $stderr.puts "-> yield is now serving your markdown " +
18
- "at localhost:#{port} using #{handler_name}..."
26
+ $stderr.puts "=* Yield is serving your markdown at http://localhost:#{port}/"
19
27
  end
20
28
  [:INT, :TERM].each { |sig| trap(sig) { quit!(server, handler_name) } }
21
29
  server.threaded = settings.threaded if server.respond_to? :threaded=
22
30
  set :running, true
31
+ open_in_browser
23
32
  yield server if block_given?
24
33
  end
25
34
  rescue Errno::EADDRINUSE
26
- $stderr.puts "-> Port #{port} is already being used!"
35
+ $stderr.puts "=* Port #{port} is already being used!"
27
36
  end
28
37
 
29
38
  # Override quit! method from Sinatra
30
39
  def self.quit!(server, handler_name)
31
40
  # Use Thin's hard #stop! if available, otherwise just #stop.
32
41
  server.respond_to?(:stop!) ? server.stop! : server.stop
33
- $stderr.puts "\n-> Stopping yield..." unless handler_name =~/cgi/i
42
+ $stderr.puts "=* Stopping yield..." unless handler_name =~/cgi/i
34
43
  end
35
44
 
36
- def self.render(filename = 'README.md')
37
- original_stdout = $stdout
38
- $stdout = fake = StringIO.new
45
+ get '/' do
46
+ @@content = Octokit.markdown(File.read(@@filename), mode: 'gfm')
47
+ erb :index, locals: { content: @@content, filename: @@filename }
48
+ end
39
49
 
40
- @@filename = filename
41
- begin
42
- @@content = Octokit.markdown(File.read(@@filename), mode: 'gfm')
43
- rescue Exception => e
44
- puts "Filename '#{@@filename}' doesn't exist."
45
- exit
46
- end
50
+ not_found do
51
+ erb :'404', locals: { filename: params[:filename] }
47
52
  end
48
53
 
49
- get '/' do
50
- erb :index, locals: { content: @@content, filename: @@filename }
54
+ def self.open_in_browser
55
+ Launchy.open("http://localhost:#{port}/")
51
56
  end
52
57
 
53
58
  end
@@ -1,3 +1,3 @@
1
1
  module Yield
2
- VERSION = "0.0.3"
2
+ VERSION = "0.1.0"
3
3
  end
@@ -0,0 +1,18 @@
1
+ <html>
2
+ <head>
3
+ <link rel="stylesheet" href="https://github.global.ssl.fastly.net/assets/github-c6ca95663cba6496fe7a5bdd98671b82cd956df3.css" />
4
+ <link rel="stylesheet" href="https://github.global.ssl.fastly.net/assets/github2-71386ba60dc4794e755db985b31f4dfc74dcd99d.css" />
5
+ <style>.page {margin:30px auto;width:784px;}</style>
6
+ </head>
7
+ <body>
8
+ <div class="page">
9
+ <div id="readme" class="clearfix announce instapaper_body md">
10
+ <span class="name"><span class="octicon octicon-book"></span> OOPS.md</span>
11
+ <article class="markdown-body entry-content">
12
+ <h2>Yield could not find your file</h2>
13
+ <p>Try going <a href="/">here</a>!</p>
14
+ </article>
15
+ </div>
16
+ </div>
17
+ </body>
18
+ </html>
@@ -2,7 +2,7 @@
2
2
  <head>
3
3
  <link rel="stylesheet" href="https://github.global.ssl.fastly.net/assets/github-c6ca95663cba6496fe7a5bdd98671b82cd956df3.css" />
4
4
  <link rel="stylesheet" href="https://github.global.ssl.fastly.net/assets/github2-71386ba60dc4794e755db985b31f4dfc74dcd99d.css" />
5
- <style>.page {margin:30px auto;width:920px;}</style>
5
+ <style>.page {margin:30px auto;width:784px;}</style>
6
6
  </head>
7
7
  <body>
8
8
  <div class="page">
@@ -11,7 +11,7 @@ Gem::Specification.new do |spec|
11
11
  spec.description = %q{A utility for previewing markdown files in GitHub Flavored Markdown.}
12
12
  spec.summary = %q{Yield is a command line utility written in Ruby that allows a user to render
13
13
  markdown files for previewing in a browser. It renders the markdown files using GitHub flavored
14
- markdown at http://localhost:4567 using Sinatra.}
14
+ markdown at http://localhost:4000/ using Sinatra and Thin.}
15
15
  spec.homepage = ""
16
16
  spec.license = "MIT"
17
17
 
@@ -23,7 +23,8 @@ Gem::Specification.new do |spec|
23
23
  spec.add_development_dependency "bundler", "~> 1.3"
24
24
  spec.add_development_dependency "rake"
25
25
 
26
- spec.add_dependency "sinatra"
27
- spec.add_dependency "octokit"
28
- spec.add_dependency "thin"
26
+ spec.add_dependency "sinatra", "1.4.3"
27
+ spec.add_dependency "octokit", "1.25.0"
28
+ spec.add_dependency "thin", "1.5.1"
29
+ spec.add_dependency "launchy", "2.3.0"
29
30
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: yield
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 0.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Casey Scarborough
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-08-07 00:00:00.000000000 Z
11
+ date: 2013-08-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -42,44 +42,58 @@ dependencies:
42
42
  name: sinatra
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
- - - '>='
45
+ - - '='
46
46
  - !ruby/object:Gem::Version
47
- version: '0'
47
+ version: 1.4.3
48
48
  type: :runtime
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
- - - '>='
52
+ - - '='
53
53
  - !ruby/object:Gem::Version
54
- version: '0'
54
+ version: 1.4.3
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: octokit
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
- - - '>='
59
+ - - '='
60
60
  - !ruby/object:Gem::Version
61
- version: '0'
61
+ version: 1.25.0
62
62
  type: :runtime
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
- - - '>='
66
+ - - '='
67
67
  - !ruby/object:Gem::Version
68
- version: '0'
68
+ version: 1.25.0
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: thin
71
71
  requirement: !ruby/object:Gem::Requirement
72
72
  requirements:
73
- - - '>='
73
+ - - '='
74
74
  - !ruby/object:Gem::Version
75
- version: '0'
75
+ version: 1.5.1
76
76
  type: :runtime
77
77
  prerelease: false
78
78
  version_requirements: !ruby/object:Gem::Requirement
79
79
  requirements:
80
- - - '>='
80
+ - - '='
81
81
  - !ruby/object:Gem::Version
82
- version: '0'
82
+ version: 1.5.1
83
+ - !ruby/object:Gem::Dependency
84
+ name: launchy
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - '='
88
+ - !ruby/object:Gem::Version
89
+ version: 2.3.0
90
+ type: :runtime
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - '='
95
+ - !ruby/object:Gem::Version
96
+ version: 2.3.0
83
97
  description: A utility for previewing markdown files in GitHub Flavored Markdown.
84
98
  email:
85
99
  - caseyscarborough@gmail.com
@@ -97,6 +111,7 @@ files:
97
111
  - lib/yield.rb
98
112
  - lib/yield/markdown.rb
99
113
  - lib/yield/version.rb
114
+ - lib/yield/views/404.erb
100
115
  - lib/yield/views/index.erb
101
116
  - yield.gemspec
102
117
  homepage: ''
@@ -119,10 +134,10 @@ required_rubygems_version: !ruby/object:Gem::Requirement
119
134
  version: '0'
120
135
  requirements: []
121
136
  rubyforge_project:
122
- rubygems_version: 2.0.5
137
+ rubygems_version: 2.0.3
123
138
  signing_key:
124
139
  specification_version: 4
125
140
  summary: Yield is a command line utility written in Ruby that allows a user to render
126
141
  markdown files for previewing in a browser. It renders the markdown files using
127
- GitHub flavored markdown at http://localhost:4567 using Sinatra.
142
+ GitHub flavored markdown at http://localhost:4000/ using Sinatra and Thin.
128
143
  test_files: []