tldrb 0.0.1

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.
Files changed (5) hide show
  1. checksums.yaml +7 -0
  2. data/COPYING +20 -0
  3. data/README.md +17 -0
  4. data/bin/tldrb +69 -0
  5. metadata +83 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: bbe243753aab8a748547f3537b3a4ff9f98e048a
4
+ data.tar.gz: 49320da1b677795d437bb991694ccbbd90b7cd14
5
+ SHA512:
6
+ metadata.gz: 88d977f468481b90431cb3fa689379aabc79c00f629bf21c5753628ba3a98db462a441c5113fda6ef6e4948b99dc161e7d05ac521139246c5e83f713732dccb3
7
+ data.tar.gz: b4dc7bbadb89ff7a90aae77539f0246a8921c55c92e0116d5f92aa885563501c43767ef879ffa469323dab096f65d9346f6557d2cd7266d163d97822fe594f68
data/COPYING ADDED
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2015 Ryan S. Northrup
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,17 @@
1
+ # tldrb
2
+
3
+ > Ruby client for [tldr](https://github.com/tldr-pages/tldr), built
4
+ with [Ruby on Bales](https://github.com/YellowApple/bales).
5
+ MIT-licensed.
6
+
7
+ - Install
8
+
9
+ `gem install tldrb`
10
+
11
+ - Get a tldr for "foo"
12
+
13
+ `tldrb foo`
14
+
15
+ - Get a tldr for "foo" on a specific OS ['linux', 'sunos', 'osx']
16
+
17
+ `tldrb foo -o osx`
data/bin/tldrb ADDED
@@ -0,0 +1,69 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'bales'
4
+ require 'rest-client'
5
+
6
+ module Tldrb; end
7
+
8
+ module Tldrb::Functions
9
+ def get_page(query, platform)
10
+ url = "https://raw.github.com/tldr-pages/tldr/master/pages/" \
11
+ "#{platform}/#{query}.md"
12
+ response = RestClient.get url
13
+
14
+ response.to_str
15
+ rescue RestClient::Exception
16
+ nil
17
+ end
18
+
19
+ def my_platform
20
+ platform = Gem::Platform.local.os
21
+ # TODO: suggest upstream use of "darwin" instead of "osx", since
22
+ # "darwin" is what is actually used by OS X internally"
23
+ platform = 'osx' if platform == 'darwin'
24
+ return platform
25
+ end
26
+
27
+ def supported_platforms
28
+ # TODO: check for supported platforms dynamically
29
+ ['linux', 'osx', 'sunos']
30
+ end
31
+ end
32
+
33
+ class Tldrb::Application < Bales::Application
34
+ version "0.0.1"
35
+ summary "tldr client in Ruby"
36
+ description "Ruby client for tldr " \
37
+ "(<https://github.com/tldr-pages/tldr>). Implemented with " \
38
+ "the Ruby on Bales command-line app framework " \
39
+ "(<https://github.com/YellowApple/bales>)."
40
+
41
+ # TODO: implement opt value checking in Bales
42
+ option :platform,
43
+ short_form: '-o',
44
+ long_form: '--os',
45
+ type: String,
46
+ description: "Override the operating system [linux, osx, sunos]"
47
+
48
+ action do |query, platform: nil|
49
+ unless query.class == String
50
+ Tldrb::Command::Help.run
51
+ return
52
+ end
53
+ extend Tldrb::Functions
54
+
55
+ platform = my_platform if platform.nil?
56
+
57
+ result = get_page query, platform
58
+ result = get_page query, 'common' if result.nil?
59
+
60
+ if result.nil?
61
+ puts "Couldn't find a tldr for '#{query}'."
62
+ else
63
+ # TODO: markdown formatting
64
+ puts result
65
+ end
66
+ end
67
+
68
+ parse_and_run
69
+ end
metadata ADDED
@@ -0,0 +1,83 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: tldrb
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Ryan S. Northrup
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2015-08-08 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bales
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '0.0'
20
+ - - ">="
21
+ - !ruby/object:Gem::Version
22
+ version: 0.0.3
23
+ type: :runtime
24
+ prerelease: false
25
+ version_requirements: !ruby/object:Gem::Requirement
26
+ requirements:
27
+ - - "~>"
28
+ - !ruby/object:Gem::Version
29
+ version: '0.0'
30
+ - - ">="
31
+ - !ruby/object:Gem::Version
32
+ version: 0.0.3
33
+ - !ruby/object:Gem::Dependency
34
+ name: rest-client
35
+ requirement: !ruby/object:Gem::Requirement
36
+ requirements:
37
+ - - "~>"
38
+ - !ruby/object:Gem::Version
39
+ version: '1.8'
40
+ type: :runtime
41
+ prerelease: false
42
+ version_requirements: !ruby/object:Gem::Requirement
43
+ requirements:
44
+ - - "~>"
45
+ - !ruby/object:Gem::Version
46
+ version: '1.8'
47
+ description: Ruby client for tldr (<https://github.com/tldr-pages/tldr>). Implemented
48
+ with the Ruby on Bales command-line app framework (<https://github.com/YellowApple/bales>).
49
+ email:
50
+ - rnorthrup@newleaders.com
51
+ executables:
52
+ - tldrb
53
+ extensions: []
54
+ extra_rdoc_files: []
55
+ files:
56
+ - COPYING
57
+ - README.md
58
+ - bin/tldrb
59
+ homepage: https://github.com/YellowApple/tldrb
60
+ licenses:
61
+ - MIT
62
+ metadata: {}
63
+ post_install_message:
64
+ rdoc_options: []
65
+ require_paths:
66
+ - lib
67
+ required_ruby_version: !ruby/object:Gem::Requirement
68
+ requirements:
69
+ - - ">="
70
+ - !ruby/object:Gem::Version
71
+ version: '0'
72
+ required_rubygems_version: !ruby/object:Gem::Requirement
73
+ requirements:
74
+ - - ">="
75
+ - !ruby/object:Gem::Version
76
+ version: '0'
77
+ requirements: []
78
+ rubyforge_project:
79
+ rubygems_version: 2.4.6
80
+ signing_key:
81
+ specification_version: 4
82
+ summary: tldr client in Ruby
83
+ test_files: []