github-readme 0.1.0.pre

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 11bacbace0a51057e17a85845d98b9ea192b896d
4
+ data.tar.gz: 8b7ba7e7619724171a9b4baf9544932de94dd166
5
+ SHA512:
6
+ metadata.gz: 3d363f96098b0fde3ba46d7b507d68820c3f0b8a67438781f2471344cf94c238a65756617a2d7d0c336d05982a393e4a107bb8734f8dd86bf6c0eee52b3420f0
7
+ data.tar.gz: 97d7bdfa7501b54428b35bf7f1ff7a511be793fe76f98e1fc2d604f83b121e7f2d6c3156e9b36b9bf014a2576b1b49d8c640d302968e9ba6f4054f4663034a36
data/.gitignore ADDED
@@ -0,0 +1,38 @@
1
+ *.gem
2
+ *.rbc
3
+ /.config
4
+ /coverage/
5
+ /InstalledFiles
6
+ /pkg/
7
+ /spec/reports/
8
+ /spec/examples.txt
9
+ /test/tmp/
10
+ /test/version_tmp/
11
+ /tmp/
12
+
13
+ ## Specific to RubyMotion:
14
+ .dat*
15
+ .repl_history
16
+ build/
17
+
18
+ ## Documentation cache and generated files:
19
+ /.yardoc/
20
+ /_yardoc/
21
+ /doc/
22
+ /rdoc/
23
+
24
+ ## Environment normalization:
25
+ /.bundle/
26
+ /vendor/bundle
27
+ /lib/bundler/man/
28
+
29
+ # for a library or gem, you might want to ignore these files since the code is
30
+ # intended to run in multiple environments; otherwise, check them in:
31
+ # Gemfile.lock
32
+ # .ruby-version
33
+ # .ruby-gemset
34
+
35
+ # unless supporting rvm < 1.11.0 or doing something fancy, ignore this:
36
+ .rvmrc
37
+
38
+ *-readme.md
data/.travis.yml ADDED
@@ -0,0 +1,7 @@
1
+ language: ruby
2
+ rvm: 2.2
3
+ install: bundle install
4
+ script: bundle exec github-readme
5
+ after_script:
6
+ - bundle exec github-readme dkhamsing/awesome_bot
7
+ - cat dkhamsing-awesome_bot-readme.md
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in GitHubReadme.gemspec
4
+ gemspec
@@ -0,0 +1,23 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'github-readme/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = GitHubReadme::PRODUCT
8
+ spec.version = GitHubReadme::VERSION
9
+ spec.authors = ["dkhamsing"]
10
+ spec.email = ["dkhamsing8@gmail.com"]
11
+
12
+ spec.summary = 'Get the README from a GitHub repository'
13
+ spec.description = spec.summary
14
+ spec.homepage = 'https://github.com/dkhamsing/github-readme'
15
+ spec.license = 'MIT'
16
+
17
+ spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
18
+ spec.bindir = 'bin'
19
+ spec.executables = [GitHubReadme::PRODUCT]
20
+ spec.require_paths = ['lib']
21
+
22
+ spec.add_runtime_dependency 'octokit', '~> 4.2.0' # github
23
+ end
data/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2016
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,38 @@
1
+ # github-readme
2
+
3
+ Get the README from a GitHub repository :octocat:
4
+
5
+ ## Installation
6
+
7
+ ```shell
8
+ $ gem install github-readme --pre
9
+ ```
10
+
11
+ ## Usage
12
+
13
+ ### Command Line
14
+
15
+ ```shell
16
+ $ github-readme dkhamsing/awesome_bot
17
+ Gettin README for dkhamsing/awesome_bot ...
18
+ Writing dkhamsing-awesome_bot-readme.md
19
+ ```
20
+
21
+ ### Library
22
+
23
+ ```shell
24
+ $ irb
25
+ irb(main):001:0> require 'github-readme'
26
+ => true
27
+ irb(main):002:0> GitHubReadme::get 'postmates/PMJSON'
28
+ => {=> {"name"=>"README.md", "readme"=>"# PMJSON\n\n[![Version](https://...", "summary"=>"PMJSON provides a pure-Swift strongly-typed JSON encoder/decoder as well as a set of convenience methods for converting to/from Foundation objects and for decoding JSON structures.", "error"=>nil}
29
+ ```
30
+
31
+ ## Contact
32
+
33
+ - [github.com/dkhamsing](https://github.com/dkhamsing)
34
+ - [twitter.com/dkhamsing](https://twitter.com/dkhamsing)
35
+
36
+ ## License
37
+
38
+ This project is available under the MIT license. See the [LICENSE](LICENSE) file for more info.
data/Rakefile ADDED
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
data/bin/github-readme ADDED
@@ -0,0 +1,5 @@
1
+ #!/usr/bin/env ruby
2
+ $LOAD_PATH.push File.expand_path('../../lib', __FILE__)
3
+
4
+ require 'github-readme'
5
+ GitHubReadme.cli
@@ -0,0 +1,5 @@
1
+ # Get a GitHub repo README
2
+ require 'github-readme/cli'
3
+
4
+ module GitHubReadme
5
+ end
@@ -0,0 +1,40 @@
1
+ # Command line interface
2
+ module GitHubReadme
3
+ require 'github-readme/version'
4
+ require 'github-readme/get'
5
+
6
+ class << self
7
+ def cli
8
+ puts "#{PRODUCT} #{VERSION}"
9
+
10
+ if ARGV.count == 0
11
+ usage
12
+ exit
13
+ end
14
+
15
+ cli_repo = ARGV[0]
16
+
17
+ unless cli_repo.include? '/'
18
+ usage
19
+ exit
20
+ end
21
+
22
+ repo = cli_repo.sub 'https://github.com/', ''
23
+ r = get repo
24
+
25
+ e = r['error']
26
+ unless e.nil?
27
+ puts "Error: #{e}" unless e.nil?
28
+ exit 1
29
+ end
30
+
31
+ f = repo.gsub( '/', '-') + '-readme.md'
32
+ puts "Writing #{f} ⚡️"
33
+ File.open(f, 'w') { |f| f.write r['readme'] }
34
+ end
35
+
36
+ def usage
37
+ puts "Usage: #{PRODUCT} <GitHub Repo>"
38
+ end
39
+ end
40
+ end
@@ -0,0 +1,72 @@
1
+ # Get the README
2
+ module GitHubReadme
3
+ require 'octokit'
4
+
5
+ class << self
6
+ def client
7
+ Octokit
8
+ end
9
+
10
+ def get(repo, client_input = nil)
11
+ cl =
12
+ if client_input.nil?
13
+ client
14
+ else
15
+ client_input
16
+ end
17
+
18
+ github cl, repo
19
+ end
20
+
21
+ def github(client, repo)
22
+ begin
23
+ r = client.readme repo
24
+ rescue => e
25
+ # puts "Error: #{e}"
26
+ return {
27
+ 'name' => nil,
28
+ 'readme' => nil,
29
+ 'summary' => nil,
30
+ 'error' => e
31
+ }
32
+ end
33
+
34
+ name = r['name']
35
+
36
+ content = r['content']
37
+ if content.nil?
38
+ readme = nil
39
+ summary = nil
40
+ error = "No README"
41
+ else
42
+ readme = Base64.decode64 content unless content.nil?
43
+ summary = summarize readme
44
+ error = nil
45
+ end
46
+
47
+ {
48
+ 'name' => name,
49
+ 'readme' => readme,
50
+ 'summary' => summary,
51
+ 'error' => error
52
+ }
53
+ end
54
+
55
+ def summarize(readme, number_of_lines = 1)
56
+ return nil if readme.nil?
57
+
58
+ separator = "\n"
59
+ lines = readme.split separator
60
+ d = []
61
+ lines[1..-1].each do |l|
62
+ unless (l.include? '==') || (l.include? '[') || (l.include? '#') || (l.include? '<')
63
+ d.push l if l.length > 0
64
+ end
65
+ break if d.count == number_of_lines
66
+ end
67
+
68
+ d.join separator
69
+ end
70
+
71
+ end
72
+ end
@@ -0,0 +1,5 @@
1
+ module GitHubReadme
2
+ VERSION = '0.1.0.pre'
3
+
4
+ PRODUCT = 'github-readme'
5
+ end
metadata ADDED
@@ -0,0 +1,71 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: github-readme
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0.pre
5
+ platform: ruby
6
+ authors:
7
+ - dkhamsing
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2016-02-23 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: octokit
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ~>
18
+ - !ruby/object:Gem::Version
19
+ version: 4.2.0
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ~>
25
+ - !ruby/object:Gem::Version
26
+ version: 4.2.0
27
+ description: Get the README from a GitHub repository
28
+ email:
29
+ - dkhamsing8@gmail.com
30
+ executables:
31
+ - github-readme
32
+ extensions: []
33
+ extra_rdoc_files: []
34
+ files:
35
+ - .gitignore
36
+ - .travis.yml
37
+ - Gemfile
38
+ - GitHubReadme.gemspec
39
+ - LICENSE
40
+ - README.md
41
+ - Rakefile
42
+ - bin/github-readme
43
+ - lib/github-readme.rb
44
+ - lib/github-readme/cli.rb
45
+ - lib/github-readme/get.rb
46
+ - lib/github-readme/version.rb
47
+ homepage: https://github.com/dkhamsing/github-readme
48
+ licenses:
49
+ - MIT
50
+ metadata: {}
51
+ post_install_message:
52
+ rdoc_options: []
53
+ require_paths:
54
+ - lib
55
+ required_ruby_version: !ruby/object:Gem::Requirement
56
+ requirements:
57
+ - - '>='
58
+ - !ruby/object:Gem::Version
59
+ version: '0'
60
+ required_rubygems_version: !ruby/object:Gem::Requirement
61
+ requirements:
62
+ - - '>'
63
+ - !ruby/object:Gem::Version
64
+ version: 1.3.1
65
+ requirements: []
66
+ rubyforge_project:
67
+ rubygems_version: 2.0.14
68
+ signing_key:
69
+ specification_version: 4
70
+ summary: Get the README from a GitHub repository
71
+ test_files: []