├── .gitignore ├── Gemfile ├── LICENSE ├── README.md ├── Rakefile ├── assets ├── batch-correct-demo.gif └── batch-correct-demo.mov ├── bin ├── batch-correct └── cocoapods-readme ├── circle.yml ├── cocoapods-readme.gemspec ├── lib ├── cocoapods-readme.rb └── cocoapods-readme │ ├── batch.rb │ ├── cli.rb │ ├── constants.rb │ ├── correct.rb │ ├── diff.rb │ └── github.rb └── test └── readme_test.rb /.gitignore: -------------------------------------------------------------------------------- 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 | bin/temp-* 39 | -------------------------------------------------------------------------------- /Gemfile: -------------------------------------------------------------------------------- 1 | source 'https://rubygems.org' 2 | 3 | # Specify your gem's dependencies in frankenstein.gemspec 4 | gemspec 5 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 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. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # cocoapods-readme 2 | 3 |

One day I’ll make a bot that looks through the READMEs of all Pods, looks to see if it uses “Cocoapods” and PRs “CocoaPods” :D

— Ørta (@orta) February 10, 2016
4 | 5 | Well [Orta](https://github.com/orta), `cocoapods-readme` is here to help :smile: 6 | 7 | [![CircleCI](https://img.shields.io/circleci/project/dkhamsing/cocoapods-readme.svg)](https://circleci.com/gh/dkhamsing/cocoapods-readme) 8 | 9 | ## Installation 10 | 11 | ```shell 12 | $ git clone https://github.com/dkhamsing/cocoapods-readme.git 13 | $ cd cocoapods-readme/ 14 | $ rake install 15 | ``` 16 | 17 | This project is based on [`frankenstein`](https://github.com/dkhamsing/frankenstein) and requires GitHub credentials in [.netrc](https://github.com/octokit/octokit.rb#using-a-netrc-file). 18 | 19 | ## Usage 20 | 21 | ### `cocoapods-readme` 22 | 23 | ```shell 24 | cocoapods-readme 25 | ``` 26 | 27 | ``` 28 | $ cocoapods-readme Rentlio/SwiftRestModel 29 | cocoapods-readme 0.1.0 30 | Checking Rentlio/SwiftRestModel ... 31 | Found misspelling of "CocoaPods" 🔴🤓 32 | 1. You can use [Cocoapods](http://cocoapods.org) to install `SwiftRestModel` by adding it to your `Podfile`: 33 | 2. You'll need to install [Cocoapods](http://cocoapods.org) first. 34 | Open pull request? (y/n) y 35 | Forking to ReadmeCritic/SwiftRestModel ... 36 | Committing change... 37 | Opening pull request... 38 | Done: https://github.com/Rentlio/SwiftRestModel/pull/6 39 | ``` 40 | 41 | ### `batch-correct` 42 | 43 | ```shell 44 | batch-correct 45 | ``` 46 | 47 | `file` contains a [list of repos](https://github.com/dkhamsing/all_specs_repos), one repo per line. 48 | 49 | ![](assets/batch-correct-demo.gif) 50 | 51 | ## Examples 52 | 53 | `cocopoads-readme` is being used by [ReadmeCritic](https://github.com/issues?utf8=✓&q=cocoapods+author%3AReadmeCritic), here are some pull request examples: 54 | 55 | https://github.com/foursquare/FSQCellManifest/pull/2 56 | 57 | ```diff 58 | If your minimum iOS version requirement is 8.0 or greater, Carthage is the recommended way to integrate FSQCellManifest with your app. 59 | Add `github "foursquare/FSQCellManifest"` to your Cartfile and follow the instructions from [Carthage's README](https://github.com/Carthage/Carthage) for adding Carthage-built frameworks to your project. 60 | 61 | -## Cocoapods 62 | +## CocoaPods 63 | 64 | -If you use Cocoapods, you can add `pod 'FSQCellManifest', '~> [desired version here]'` to your Podfile. Further instructions on setting up and using Cocoapods can be found on [their website](https://cocoapods.org) 65 | +If you use CocoaPods, you can add `pod 'FSQCellManifest', '~> [desired version here]'` to your Podfile. Further instructions on setting up and using CocoaPods can be found on [their website](https://cocoapods.org) 66 | 67 | ## Manual Installation 68 | 69 | You can also simply add the objc files in the `FSQCellManifest` directoryto your 70 | 71 | ## FSQMessageForwarder 72 | 73 | -FSQCellManifest also requires [FSQMessageForwarder](https://github.com/foursquare/FSQMessageForwarder) to work. If you are using Carthage or Cocoapods, this should be taken care of for you automatically. Otherwise you will need to manually add that repo to your project as well (e.g. via git submodules or manually copying the files into your repo). 74 | +FSQCellManifest also requires [FSQMessageForwarder](https://github.com/foursquare/FSQMessageForwarder) to work. If you are using Carthage or CocoaPods, this should be taken care of for you automatically. Otherwise you will need to manually add that repo to your project as well (e.g. via git submodules or manually copying the files into your repo). 75 | ``` 76 | 77 | https://github.com/GenerallyHelpfulSoftware/SVGgh/pull/21 78 | 79 | ```diff 80 | 81 | The included library assumes ARC style memory management. It's also been arbitrarily set to support iOS 7 and up. I've moved to using newer code annotations such as *nullable* so it requires a recent version of Xcode to compile. Supports both traditional and module based framework includes. 82 | 83 | -Originally, this was distributed as a static library, but that is not a modern way to use it. So the enclosed project will build a framework, and most developers will probably find the use of **Cocoapods** more enjoyable. Requires Cocoapods 0.39 or above. 84 | +Originally, this was distributed as a static library, but that is not a modern way to use it. So the enclosed project will build a framework, and most developers will probably find the use of **CocoaPods** more enjoyable. Requires CocoaPods 0.39 or above. 85 | 86 | -I've enabled **IB_DESIGNABLE** for the view classes for environments with a minimum OS version of iOS 8 and above. This will allow artwork and widgets to be visible in Interface Builder. Cocoapods users should put ````use_frameworks!```` in their Podfile. 87 | +I've enabled **IB_DESIGNABLE** for the view classes for environments with a minimum OS version of iOS 8 and above. This will allow artwork and widgets to be visible in Interface Builder. CocoaPods users should put ````use_frameworks!```` in their Podfile. 88 | 89 | The segmented control is not ready for use in tvOS apps. 90 | 91 | If you just want to use the code in your app and are uninterested in the underly 92 | * SVGToPDFConverter.h A class to convert the renderer's contents to a PDF. 93 | * SVGPrinter.h A class to send a renderer's contents to a printer. 94 | 95 | -####If you are familiar with using Cocoapods and using it in your project 96 | +####If you are familiar with using CocoaPods and using it in your project 97 | * Insert ````pod 'SVGgh'```` into your PodFile 98 | • If you set your deployment target to iOS 8 or above, you should insert 99 | ````use_frameworks!```` in your Podfile. 100 | 101 | -* Go through the standard procedures for updating your Xcode workspace via Cocoapods. ````pod update````, ````pod install````, etc. 102 | +* Go through the standard procedures for updating your Xcode workspace via CocoaPods. ````pod update````, ````pod install````, etc. 103 | 104 | -####If you are not using Cocoapods 105 | +####If you are not using CocoaPods 106 | ``` 107 | 108 | ## Contact 109 | 110 | - [github.com/dkhamsing](https://github.com/dkhamsing) 111 | - [twitter.com/dkhamsing](https://twitter.com/dkhamsing) 112 | 113 | ## License 114 | 115 | This project is available under the MIT license. See the [LICENSE](LICENSE) file for more info. 116 | -------------------------------------------------------------------------------- /Rakefile: -------------------------------------------------------------------------------- 1 | require 'bundler/gem_tasks' 2 | -------------------------------------------------------------------------------- /assets/batch-correct-demo.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dkhamsing/cocoapods-readme/58d3e57ec2863c6de6af51c9e39c1ddaee8778ae/assets/batch-correct-demo.gif -------------------------------------------------------------------------------- /assets/batch-correct-demo.mov: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dkhamsing/cocoapods-readme/58d3e57ec2863c6de6af51c9e39c1ddaee8778ae/assets/batch-correct-demo.mov -------------------------------------------------------------------------------- /bin/batch-correct: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby 2 | $LOAD_PATH.push File.expand_path('../../lib', __FILE__) 3 | 4 | require 'cocoapods-readme' 5 | CocoapodsReadme.batch 6 | -------------------------------------------------------------------------------- /bin/cocoapods-readme: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby 2 | $LOAD_PATH.push File.expand_path('../../lib', __FILE__) 3 | 4 | require 'cocoapods-readme' 5 | CocoapodsReadme.cli 6 | -------------------------------------------------------------------------------- /circle.yml: -------------------------------------------------------------------------------- 1 | machine: 2 | ruby: 3 | version: 2.2.0 4 | test: 5 | pre: 6 | - rake install 7 | override: 8 | - cocoapods-readme 9 | - ruby test/readme_test.rb 10 | general: 11 | artifacts: 12 | - log.txt 13 | -------------------------------------------------------------------------------- /cocoapods-readme.gemspec: -------------------------------------------------------------------------------- 1 | # coding: utf-8 2 | lib = File.expand_path('../lib', __FILE__) 3 | $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib) 4 | require 'cocoapods-readme/constants' 5 | 6 | Gem::Specification.new do |spec| 7 | spec.name = CocoapodsReadme::PRODUCT 8 | spec.version = CocoapodsReadme::VERSION 9 | spec.authors = ["dkhamsing"] 10 | spec.email = ["dkhamsing8@gmail.com"] 11 | 12 | spec.summary = CocoapodsReadme::PRODUCT_DESCRIPTION 13 | spec.description = CocoapodsReadme::PRODUCT_DESCRIPTION 14 | spec.homepage = CocoapodsReadme::PRODUCT_URL 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 = [CocoapodsReadme::PRODUCT, CocoapodsReadme::BATCH] 20 | spec.require_paths = ['lib'] 21 | 22 | spec.add_runtime_dependency 'octokit', '~> 4.2.0' #github 23 | spec.add_dependency 'netrc' 24 | spec.add_dependency 'differ', '~> 0.1.2' 25 | end 26 | -------------------------------------------------------------------------------- /lib/cocoapods-readme.rb: -------------------------------------------------------------------------------- 1 | # Correct the spelling of CocoaPods in a README 2 | require 'cocoapods-readme/cli' 3 | require 'cocoapods-readme/batch' 4 | 5 | module CocoapodsReadme 6 | end 7 | -------------------------------------------------------------------------------- /lib/cocoapods-readme/batch.rb: -------------------------------------------------------------------------------- 1 | # Batch correcting 2 | module CocoapodsReadme 3 | require 'cocoapods-readme/constants' 4 | require 'cocoapods-readme/correct' 5 | 6 | class << self 7 | COMMAND = BATCH 8 | OPTION_ABUSE = 'abuse' 9 | 10 | def batch 11 | puts "#{PRODUCT} #{VERSION}" 12 | 13 | unless github_creds 14 | puts 'GitHub credentials are required in .netrc https://github.com/octokit/octokit.rb#using-a-netrc-file' 15 | exit 16 | end 17 | 18 | opt_abuse = "--#{OPTION_ABUSE}" 19 | if ARGV.count == 0 20 | puts "Usage: #{COMMAND} [#{opt_abuse}] \n"\ 21 | " file \t list of repos, one repo per line \n"\ 22 | " #{opt_abuse} \t skip pull requests (abuse detected)" 23 | exit 24 | end 25 | 26 | filename = ARGV[0] 27 | begin 28 | c = File.read filename 29 | rescue => e 30 | puts "file open error: #{e}" 31 | exit 32 | end 33 | 34 | repos = c.split( "\n") 35 | .select { |r| r.include? '/' } 36 | .map { |l| l.sub 'https://github.com/', ''} 37 | 38 | File.open(LOG_FILE, 'a') { |f| f.puts '' } 39 | repos.each.with_index do |repo, i| 40 | log = File.read LOG_FILE 41 | 42 | print "#{i+1}/#{repos.count}. #{repo}: " 43 | 44 | if log.include? repo 45 | puts "Skipping, already in log" 46 | next 47 | end 48 | 49 | # log the repo 50 | File.open(LOG_FILE, 'a') { |f| f.puts repo } 51 | 52 | correct repo, PULL_REQUEST_DESCRIPTION, true, (ARGV.include? opt_abuse) 53 | end 54 | end # def 55 | end # class 56 | end # module 57 | -------------------------------------------------------------------------------- /lib/cocoapods-readme/cli.rb: -------------------------------------------------------------------------------- 1 | # Command line interface 2 | module CocoapodsReadme 3 | require 'cocoapods-readme/constants' 4 | require 'cocoapods-readme/correct' 5 | 6 | class << self 7 | def cli 8 | puts "#{PRODUCT} #{VERSION}" 9 | 10 | unless github_creds 11 | puts 'GitHub credentials are required in .netrc https://github.com/octokit/octokit.rb#using-a-netrc-file' 12 | exit 13 | end 14 | 15 | if ARGV.count == 0 16 | puts "Usage: #{PRODUCT} \n"\ 17 | " i.e. #{PRODUCT} AFNetworking/AFNetworking" 18 | exit 19 | end 20 | 21 | cli_repo = ARGV[0] 22 | repo = cli_repo.sub 'https://github.com/', '' 23 | puts "Checking #{repo} ..." 24 | 25 | File.open(LOG_FILE, 'a') { |f| f.puts '' } 26 | log = File.read LOG_FILE 27 | 28 | if log.include? repo 29 | puts "Skipping #{repo}, already in log" 30 | exit 31 | end 32 | 33 | # log the repo 34 | File.open(LOG_FILE, 'a') { |f| f.puts repo } 35 | 36 | correct repo, PULL_REQUEST_DESCRIPTION 37 | end # def 38 | end # class 39 | end # module 40 | -------------------------------------------------------------------------------- /lib/cocoapods-readme/constants.rb: -------------------------------------------------------------------------------- 1 | # Constants 2 | module CocoapodsReadme 3 | VERSION = '0.1.0' 4 | 5 | LOG_FILE = 'temp-log-readmes' 6 | 7 | BATCH = 'batch-correct' 8 | 9 | PRODUCT = 'cocoapods-readme' 10 | PRODUCT_DESCRIPTION = 'Correct the spelling of CocoaPods in a README' 11 | PRODUCT_URL = 'https://github.com/dkhamsing/cocoapods-readme' 12 | 13 | PULL_REQUEST_COMMIT_MESSAGE = 'Correct the spelling of CocoaPods in README' 14 | PULL_REQUEST_TITLE = PULL_REQUEST_COMMIT_MESSAGE 15 | PULL_REQUEST_DESCRIPTION = %q[ 16 | This pull request corrects the spelling of **CocoaPods** 🤓 17 | https://github.com/CocoaPods/shared_resources/tree/master/media 18 | 19 | 20 | 21 | Created with [`cocoapods-readme`](https://github.com/dkhamsing/cocoapods-readme). 22 | ] 23 | end 24 | -------------------------------------------------------------------------------- /lib/cocoapods-readme/correct.rb: -------------------------------------------------------------------------------- 1 | # Correct README 2 | module CocoapodsReadme 3 | require 'cocoapods-readme/diff' 4 | require 'cocoapods-readme/github' 5 | 6 | class << self 7 | def correct(repo, description, auto=false, abuse=false) 8 | c = github_client 9 | readme, content = github_readme c, repo 10 | 11 | if readme.nil? 12 | puts 'No README 😢' 13 | return 14 | end 15 | 16 | nogood = 'Cocoapods' 17 | nogood2 = 'cocoa pods' 18 | nogood3 = 'Cocoa Pods' 19 | # ^ hmm we can do better 20 | 21 | correct = 'CocoaPods' 22 | 23 | issues = (content.include? nogood) || (content.include? nogood2) || (content.include? nogood3) 24 | 25 | unless issues 26 | puts 'No issues ✅' 27 | return 28 | end 29 | 30 | if abuse 31 | puts 'abuse mode on, correct later 🔵' 32 | fname = 'temp-abuse-todo' 33 | File.open(fname, 'a') { |f| f.puts repo } 34 | 35 | left = c.rate_limit.remaining 36 | puts "GitHub rate limit remaining: #{left}" 37 | 38 | if left < 300 39 | puts "Let's take a break 😅 (resets in #{c.rate_limit['resets_in']}s)" 40 | exit 41 | end 42 | return 43 | end 44 | 45 | content_corrected = content.gsub(nogood, correct) 46 | .gsub(nogood2, correct) 47 | .gsub(nogood3, correct) 48 | changes = Differ.diff(content_corrected, content).changes 49 | 50 | puts "Found misspelling of \"#{correct}\" 🔴 🤓" 51 | 52 | changes.each_with_index do |c, i| 53 | puts "#{i+1}. #{c.delete}" 54 | end 55 | 56 | unless auto 57 | print "Open pull request? (y/n) " 58 | user_input = STDIN.gets.chomp 59 | exit unless user_input.downcase == 'y' 60 | end 61 | 62 | default_branch = github_default_branch c, repo 63 | file_updated = 'temp-corrected' 64 | File.write file_updated, content_corrected 65 | pull_url = github_pull_request(repo, 66 | default_branch, 67 | readme, 68 | file_updated, 69 | PULL_REQUEST_COMMIT_MESSAGE, 70 | PULL_REQUEST_TITLE, 71 | description, 72 | nil) 73 | puts "Done: #{pull_url}" 74 | 75 | if auto 76 | left = c.rate_limit.remaining 77 | puts "GitHub rate limit remaining: #{left}" 78 | 79 | if left < 100 80 | puts "Yeesh, let's take a break 🤔" 81 | exit 82 | end 83 | 84 | pause = left > 1000 ? Random.new.rand(30..60) : 300 85 | puts "Pausing for #{pause}s ... 😴" 86 | sleep pause 87 | end 88 | end # def 89 | end # class 90 | end 91 | -------------------------------------------------------------------------------- /lib/cocoapods-readme/diff.rb: -------------------------------------------------------------------------------- 1 | # String diffs 2 | module CocoapodsReadme 3 | require 'differ' 4 | require 'differ/string' 5 | 6 | # Diff change 7 | class Differ::Diff 8 | def changes 9 | @raw.reject { |e| e.is_a? String } 10 | end 11 | end 12 | end 13 | -------------------------------------------------------------------------------- /lib/cocoapods-readme/github.rb: -------------------------------------------------------------------------------- 1 | # GitHub helper 2 | module CocoapodsReadme 3 | GITHUB_API_BASE = 'https://api.github.com/' 4 | GITHUB_RAW_CONTENT_URL = 'https://raw.githubusercontent.com/' 5 | 6 | GITHUB_CREDS_ERROR = 'Missing GitHub credentials in .netrc' 7 | 8 | NETRC_GITHUB_MACHINE = 'api.github.com' 9 | 10 | class << self 11 | require 'octokit' 12 | require 'netrc' 13 | require 'json' 14 | 15 | def github_client 16 | Octokit::Client.new(netrc: true) 17 | end 18 | 19 | def github_default_branch(client, repo) 20 | r = github_repo client, repo 21 | r['default_branch'] 22 | end 23 | 24 | def github_fork(client, repo) 25 | client.fork(repo) 26 | end 27 | 28 | def github_netrc 29 | n = Netrc.read 30 | n[NETRC_GITHUB_MACHINE] 31 | end 32 | 33 | def github_creds 34 | !(github_netrc.nil?) 35 | end 36 | 37 | def github_netrc_username 38 | n = github_netrc 39 | n[0] 40 | end 41 | 42 | def github_pull_request(repo, 43 | branch, 44 | readme, 45 | filename, 46 | commit_message, 47 | pull_title, 48 | description, 49 | log) 50 | forker = github_netrc_username 51 | fork = repo.gsub(%r{.*\/}, "#{forker}/") 52 | log.verbose "Fork: #{fork}" unless log == nil 53 | 54 | github = github_client 55 | 56 | # fork 57 | puts "Forking to #{fork} ..." 58 | forked_repo = nil 59 | while forked_repo.nil? 60 | forked_repo = github_fork(github, repo) 61 | sleep 2 62 | log.verbose 'Forking repo.. sleep' unless log == nil 63 | end 64 | 65 | # commit change 66 | puts 'Committing change...' 67 | ref = "heads/#{branch}" 68 | 69 | begin 70 | githubref = github.ref(fork, ref) 71 | 72 | rescue StandardError => e 73 | puts "Error: #{e}" 74 | delay = 3 75 | puts "Trying again in #{delay} seconds..." 76 | sleep delay 77 | githubref = github.ref(fork, ref) 78 | end 79 | 80 | sha_latest_commit = githubref.object.sha 81 | sha_base_tree = github.commit(fork, sha_latest_commit).commit.tree.sha 82 | file_name = readme 83 | my_content = File.read(filename) 84 | 85 | blob_sha = github.create_blob(fork, Base64.encode64(my_content), 'base64') 86 | sha_new_tree = github.create_tree(fork, 87 | [{ path: file_name, 88 | mode: '100644', 89 | type: 'blob', 90 | sha: blob_sha }], 91 | base_tree: sha_base_tree).sha 92 | sha_new_commit = github.create_commit(fork, 93 | commit_message, 94 | sha_new_tree, 95 | sha_latest_commit).sha 96 | updated_ref = github.update_ref(fork, ref, sha_new_commit) 97 | log.verbose "Updated ref: #{updated_ref}" unless log == nil 98 | log.verbose "Sent commit to fork #{fork}" unless log == nil 99 | 100 | # create pull request 101 | puts 'Opening pull request...' 102 | head = "#{forker}:#{branch}" 103 | log.verbose "Set head to #{head}" unless log == nil 104 | 105 | begin 106 | created = github.create_pull_request(repo, 107 | branch, 108 | head, 109 | pull_title, 110 | description) 111 | 112 | puts "Deleting fork..." 113 | github.delete_repo fork 114 | 115 | return created[:html_url] 116 | rescue StandardError => e 117 | puts 'Could not create pull request' 118 | puts "error #{e}" 119 | exit if e.to_s.include? 'abuse' 120 | return nil 121 | end 122 | end 123 | 124 | def github_readme(client, repo) 125 | begin 126 | r = client.readme repo 127 | rescue StandardError => e 128 | return [nil, e] 129 | end 130 | 131 | name = r['name'] 132 | content = r['content'] 133 | decoded = Base64.decode64 content unless content.nil? 134 | 135 | [name, decoded] 136 | end 137 | 138 | def github_repo(client, repo) 139 | client.repo(repo) 140 | end 141 | end # class 142 | end 143 | -------------------------------------------------------------------------------- /test/readme_test.rb: -------------------------------------------------------------------------------- 1 | require 'cocoapods-readme' 2 | 3 | REPO = 'dkarchive/test-readme-correct' 4 | LOGFILE = 'log.txt' 5 | 6 | def log(string) 7 | puts string 8 | File.open(LOGFILE, 'a') { |f| f.puts string } 9 | end 10 | 11 | log "Testing retrieval of README for #{REPO}" 12 | 13 | c = Octokit 14 | _, readme = CocoapodsReadme::github_readme c, REPO 15 | 16 | if readme.nil? 17 | log "Could not get README" 18 | exit 19 | end 20 | 21 | log '- README begin -----------------------' 22 | log readme 23 | log '- README end -----------------------' 24 | 25 | log 'Retrieved README ✅' 26 | --------------------------------------------------------------------------------