cheatly 0.0.5 → 0.0.6
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 +5 -13
- data/.travis.yml +7 -0
- data/README.md +15 -2
- data/Rakefile +12 -0
- data/bin/cheatly +3 -10
- data/cheatly.gemspec +4 -2
- data/completion/README.md +6 -0
- data/completion/cheatly.bash +17 -0
- data/lib/cheatly/adapter/file.rb +31 -0
- data/lib/cheatly/adapter/github.rb +29 -0
- data/lib/{cheatly.rb → cheatly/cli.rb} +27 -50
- data/lib/cheatly/sheet.rb +4 -60
- data/lib/cheatly/version.rb +1 -1
- data/sheets/help.yml +17 -5
- data/sheets/markdown.yml +50 -0
- data/test/sheet_test.rb +14 -0
- data/test/test_helper.rb +2 -0
- metadata +52 -14
    
        checksums.yaml
    CHANGED
    
    | @@ -1,15 +1,7 @@ | |
| 1 1 | 
             
            ---
         | 
| 2 | 
            -
             | 
| 3 | 
            -
              metadata.gz:  | 
| 4 | 
            -
             | 
| 5 | 
            -
              data.tar.gz: !binary |-
         | 
| 6 | 
            -
                NmE0ZGQ2ZDY3ZmRmMjYxY2YzNzk5ZGQ1N2ExMzAwNTljNTIwOGJmNA==
         | 
| 2 | 
            +
            SHA1:
         | 
| 3 | 
            +
              metadata.gz: 421926d9ff00815422d160384717b4662abf87a7
         | 
| 4 | 
            +
              data.tar.gz: 9c59d3a7dc556d9d590303257a3f92bcec4bdac8
         | 
| 7 5 | 
             
            SHA512:
         | 
| 8 | 
            -
              metadata.gz:  | 
| 9 | 
            -
             | 
| 10 | 
            -
                OGI1MzdkNjc2YjVkN2VhMzllY2Q4M2NlNDAxYmU0ZjFlODZlYTZmYTAyMzc1
         | 
| 11 | 
            -
                NmFmOTEwOWY0NDY3MjQ1YWM3NzJlNzZjYjEwYzdkNDNhOWZhYWM=
         | 
| 12 | 
            -
              data.tar.gz: !binary |-
         | 
| 13 | 
            -
                MjIzMTJiNDBkMzQwMzU5MWIxYzc3Zjc3MWQyZjI5ZDFiYTIyZGM2OTJkN2E3
         | 
| 14 | 
            -
                ZWQxMGY0MDU5NDM1OTNhZWIzMzYzMDJhNjQwNWY3Y2JlOGVlMjgwZDQzMDBm
         | 
| 15 | 
            -
                YmJiNmQ2NDQ4NThlNGM2MzE2OWI3ODI1NzUwZDg4M2ZkMDgxNTQ=
         | 
| 6 | 
            +
              metadata.gz: 85f518f577e4c910a5e3ffd815bb23d93406c2fbb04a1665f98012408cd51439827aece7acefa34d8ddb1f6da20f010c1983ba21b0ddce9a0a9f387f9bb60f98
         | 
| 7 | 
            +
              data.tar.gz: c1691f0f69cae08f3963fde38a5ebde04a8ceaf84fe782c63e77a3f9587ab1764a380b05b7d90086ed95fe5dcf51ceeaed6c21f9d895bb7d7713882aaa447fc6
         | 
    
        data/.travis.yml
    ADDED
    
    
    
        data/README.md
    CHANGED
    
    | @@ -1,5 +1,7 @@ | |
| 1 1 | 
             
            # Cheatly
         | 
| 2 2 |  | 
| 3 | 
            +
            [](https://travis-ci.org/arthurnn/cheatly)
         | 
| 4 | 
            +
             | 
| 3 5 | 
             
            This is a command line toolset to handle the cheat-sheets reposity located at [sheets](https://github.com/arthurnn/cheatly/tree/master/sheets) folder.
         | 
| 4 6 |  | 
| 5 7 | 
             
            This gem is not a fork but inspired by [defunkt/cheat](https://github.com/defunkt/cheat). However instead of using a full server to store the sheets, it uses github as central repository, making more reliable and easy to add new ones.
         | 
| @@ -9,8 +11,9 @@ This gem is not a fork but inspired by [defunkt/cheat](https://github.com/defunk | |
| 9 11 | 
             
            Submit a PR, adding a file to `sheets` folder, with the cheat-sheet name.
         | 
| 10 12 |  | 
| 11 13 | 
             
            1. Fork it
         | 
| 12 | 
            -
             | 
| 13 | 
            -
             | 
| 14 | 
            +
            1. `cheatly create name` (replacing name with name of the sheet)
         | 
| 15 | 
            +
            1. `cheatly show --local NAME` to test your new sheet
         | 
| 16 | 
            +
            1. Create new Pull Request
         | 
| 14 17 |  | 
| 15 18 | 
             
            ## Installation
         | 
| 16 19 |  | 
| @@ -38,6 +41,16 @@ Submit a PR, adding a file to `sheets` folder, with the cheat-sheet name. | |
| 38 41 | 
             
            4. Push to the branch (`git push origin my-new-feature`)
         | 
| 39 42 | 
             
            5. Create new Pull Request
         | 
| 40 43 |  | 
| 44 | 
            +
            ## Build from source
         | 
| 45 | 
            +
             | 
| 46 | 
            +
            Building from source will allow you to test changes to your code locally before pushing it back to origin.
         | 
| 47 | 
            +
             | 
| 48 | 
            +
            1. `git clone https://github.com/arthurnn/cheatly.git`
         | 
| 49 | 
            +
            2. `cd cheatly`
         | 
| 50 | 
            +
            3. `bundle exec rake install`
         | 
| 51 | 
            +
             | 
| 52 | 
            +
            Repeat steps 3-4 to check modified code.
         | 
| 53 | 
            +
             | 
| 41 54 |  | 
| 42 55 | 
             
            [](https://bitdeli.com/free "Bitdeli Badge")
         | 
| 43 56 |  | 
    
        data/Rakefile
    CHANGED
    
    
    
        data/bin/cheatly
    CHANGED
    
    | @@ -1,11 +1,4 @@ | |
| 1 1 | 
             
            #!/usr/bin/env ruby
         | 
| 2 | 
            -
             | 
| 3 | 
            -
             | 
| 4 | 
            -
             | 
| 5 | 
            -
            rescue LoadError
         | 
| 6 | 
            -
              require 'rubygems'
         | 
| 7 | 
            -
              require 'cheatly'
         | 
| 8 | 
            -
            end
         | 
| 9 | 
            -
             | 
| 10 | 
            -
            c = Cheatly::CLI.new(ARGV)
         | 
| 11 | 
            -
            c.process
         | 
| 2 | 
            +
            $:.unshift File.expand_path("../../lib", __FILE__)
         | 
| 3 | 
            +
            require 'cheatly/cli'
         | 
| 4 | 
            +
            Cheatly::CLI.start
         | 
    
        data/cheatly.gemspec
    CHANGED
    
    | @@ -18,9 +18,11 @@ Gem::Specification.new do |spec| | |
| 18 18 | 
             
              spec.test_files    = spec.files.grep(%r{^(test|spec|features)/})
         | 
| 19 19 | 
             
              spec.require_paths = ["lib"]
         | 
| 20 20 |  | 
| 21 | 
            -
              spec.add_dependency " | 
| 21 | 
            +
              spec.add_dependency "octokit", "~> 2.6.1"
         | 
| 22 22 | 
             
              spec.add_dependency "pager", "~> 1.0.1"
         | 
| 23 | 
            +
              spec.add_dependency "thor", "~> 0.18.1"
         | 
| 23 24 |  | 
| 24 | 
            -
              spec.add_development_dependency "bundler", " | 
| 25 | 
            +
              spec.add_development_dependency "bundler", ">= 1.3"
         | 
| 25 26 | 
             
              spec.add_development_dependency "rake"
         | 
| 27 | 
            +
              spec.add_development_dependency "minitest", "~> 5.0.8"
         | 
| 26 28 | 
             
            end
         | 
| @@ -0,0 +1,17 @@ | |
| 1 | 
            +
            _cheatly_complete() {
         | 
| 2 | 
            +
                local cur prev commands lists
         | 
| 3 | 
            +
                COMPREPLY=()
         | 
| 4 | 
            +
                cur="${COMP_WORDS[COMP_CWORD]}"
         | 
| 5 | 
            +
                prev="${COMP_WORDS[COMP_CWORD-1]}"
         | 
| 6 | 
            +
                local IFS=$'\n'
         | 
| 7 | 
            +
             | 
| 8 | 
            +
                if [ $COMP_CWORD -eq 1 ]; then
         | 
| 9 | 
            +
                    commands=`cheatly | sed -n 's/.* \$ cheatly \([a-z]*\).*$/\1/p'`
         | 
| 10 | 
            +
                    COMPREPLY=( $( compgen -W '${commands}' -- ${cur} ) )
         | 
| 11 | 
            +
                elif [[ $COMP_CWORD -eq 2 && "$prev" == show ]]; then
         | 
| 12 | 
            +
                    lists=`cheatly list | sed -n 's/  \(.*\)$/\1/p'`
         | 
| 13 | 
            +
                    COMPREPLY=( $( compgen -W '${lists}' -- ${cur} ) )
         | 
| 14 | 
            +
                fi
         | 
| 15 | 
            +
            }
         | 
| 16 | 
            +
            complete -F _cheatly_complete cheatly
         | 
| 17 | 
            +
             | 
| @@ -0,0 +1,31 @@ | |
| 1 | 
            +
            require "tempfile"
         | 
| 2 | 
            +
            require "yaml"
         | 
| 3 | 
            +
             | 
| 4 | 
            +
            module Cheatly
         | 
| 5 | 
            +
              module Adapter
         | 
| 6 | 
            +
                class File
         | 
| 7 | 
            +
                  def find(name)
         | 
| 8 | 
            +
                    path = "sheets/#{name}.yml"
         | 
| 9 | 
            +
                    sheet_yaml = ::File.read(path)
         | 
| 10 | 
            +
                    yml = YAML.load(sheet_yaml).first
         | 
| 11 | 
            +
                    [yml.first, yml.last]
         | 
| 12 | 
            +
                  end
         | 
| 13 | 
            +
             | 
| 14 | 
            +
                  def all
         | 
| 15 | 
            +
                    Dir["sheets/*.yml"].map { |f| f.scan(/sheets\/(.*).yml/)[0][0] }
         | 
| 16 | 
            +
                  end
         | 
| 17 | 
            +
             | 
| 18 | 
            +
                  def create(name, body)
         | 
| 19 | 
            +
                    body = {name => body}.to_yaml
         | 
| 20 | 
            +
                    f = ::File.new("sheets/#{name}.yml", "w")
         | 
| 21 | 
            +
                    f.write(body)
         | 
| 22 | 
            +
                    f.close
         | 
| 23 | 
            +
                  end
         | 
| 24 | 
            +
             | 
| 25 | 
            +
                  def update(name, body)
         | 
| 26 | 
            +
                    ::File.delete("sheets/#{name}.yml")
         | 
| 27 | 
            +
                    create(name, body)
         | 
| 28 | 
            +
                  end
         | 
| 29 | 
            +
                end
         | 
| 30 | 
            +
              end
         | 
| 31 | 
            +
            end
         | 
| @@ -0,0 +1,29 @@ | |
| 1 | 
            +
            require "base64"
         | 
| 2 | 
            +
            require "yaml"
         | 
| 3 | 
            +
             | 
| 4 | 
            +
            require "octokit"
         | 
| 5 | 
            +
             | 
| 6 | 
            +
            module Cheatly
         | 
| 7 | 
            +
              module Adapter
         | 
| 8 | 
            +
                class GitHub
         | 
| 9 | 
            +
                  FOLDER = 'sheets'
         | 
| 10 | 
            +
                  REPO = 'arthurnn/cheatly'
         | 
| 11 | 
            +
             | 
| 12 | 
            +
                  def find(path)
         | 
| 13 | 
            +
                    response = Octokit.contents(REPO, path: "#{FOLDER}/#{path}.yml")
         | 
| 14 | 
            +
                    sheet_yaml = Base64.decode64(response.content)
         | 
| 15 | 
            +
                    yml = YAML.load(sheet_yaml).first
         | 
| 16 | 
            +
                    [yml.first, yml.last]
         | 
| 17 | 
            +
                  end
         | 
| 18 | 
            +
             | 
| 19 | 
            +
                  def all
         | 
| 20 | 
            +
                    response = Octokit.contents(REPO, path: "#{FOLDER}")
         | 
| 21 | 
            +
                    response.map { |f| f.name.gsub(/\.[a-z]+\z/, '') }
         | 
| 22 | 
            +
                  end
         | 
| 23 | 
            +
             | 
| 24 | 
            +
                  def create
         | 
| 25 | 
            +
                    raise NotImplementedError
         | 
| 26 | 
            +
                  end
         | 
| 27 | 
            +
                end
         | 
| 28 | 
            +
              end
         | 
| 29 | 
            +
            end
         | 
| @@ -1,45 +1,19 @@ | |
| 1 | 
            -
            require " | 
| 2 | 
            -
            require " | 
| 3 | 
            -
            require " | 
| 4 | 
            -
            require " | 
| 1 | 
            +
            require "cheatly/version"
         | 
| 2 | 
            +
            require "cheatly/sheet"
         | 
| 3 | 
            +
            require "cheatly/adapter/file"
         | 
| 4 | 
            +
            require "cheatly/adapter/github"
         | 
| 5 5 |  | 
| 6 | 
            -
            require "httparty"
         | 
| 7 6 | 
             
            require "pager"
         | 
| 8 | 
            -
             | 
| 9 | 
            -
            require "cheatly/sheet"
         | 
| 10 | 
            -
            require "cheatly/version"
         | 
| 7 | 
            +
            require "thor"
         | 
| 11 8 |  | 
| 12 9 | 
             
            module Cheatly
         | 
| 13 | 
            -
              class CLI
         | 
| 10 | 
            +
              class CLI < Thor
         | 
| 14 11 | 
             
                include Pager
         | 
| 15 12 |  | 
| 16 | 
            -
                 | 
| 17 | 
            -
                  @command = args.shift || "help"
         | 
| 18 | 
            -
                  @handle = args.first
         | 
| 19 | 
            -
             | 
| 20 | 
            -
                  if "help" == @command
         | 
| 21 | 
            -
                    @handle = @command
         | 
| 22 | 
            -
                    @command = "show"
         | 
| 23 | 
            -
                  end
         | 
| 24 | 
            -
             | 
| 25 | 
            -
                  @options = {}
         | 
| 26 | 
            -
                  op_parser = OptionParser.new do |opts|
         | 
| 27 | 
            -
                    opts.on("-l", "--local", "Run using local file system") do |v|
         | 
| 28 | 
            -
                      @options[:local] = v
         | 
| 29 | 
            -
                    end
         | 
| 30 | 
            -
                  end
         | 
| 31 | 
            -
                  op_parser.parse! args
         | 
| 32 | 
            -
                end
         | 
| 13 | 
            +
                class_option :local, type: :boolean, aliases: "-l", desc: "Run using local file system"
         | 
| 33 14 |  | 
| 34 | 
            -
                 | 
| 35 | 
            -
             | 
| 36 | 
            -
                    Sheet.with_file_adapter
         | 
| 37 | 
            -
                  else
         | 
| 38 | 
            -
                    Sheet
         | 
| 39 | 
            -
                  end
         | 
| 40 | 
            -
                end
         | 
| 41 | 
            -
             | 
| 42 | 
            -
                def sheet(handle)
         | 
| 15 | 
            +
                desc "show SHEET_NAME", "show a cheat sheet"
         | 
| 16 | 
            +
                def show(handle)
         | 
| 43 17 | 
             
                  sheet = model.find(handle)
         | 
| 44 18 | 
             
                  unless sheet
         | 
| 45 19 | 
             
                    puts "Sheet not found, run 'cheatly list' to see the availables."
         | 
| @@ -50,6 +24,7 @@ module Cheatly | |
| 50 24 | 
             
                  puts sheet.to_s
         | 
| 51 25 | 
             
                end
         | 
| 52 26 |  | 
| 27 | 
            +
                desc "list sheets", "list all available sheets"
         | 
| 53 28 | 
             
                def list
         | 
| 54 29 | 
             
                  sheets = model.all
         | 
| 55 30 | 
             
                  page
         | 
| @@ -59,18 +34,35 @@ module Cheatly | |
| 59 34 | 
             
                  end
         | 
| 60 35 | 
             
                end
         | 
| 61 36 |  | 
| 37 | 
            +
                desc "create SHEET_NAME", "create a new sheet cheat"
         | 
| 62 38 | 
             
                def create(handle)
         | 
| 63 39 | 
             
                  sheet = Sheet.with_file_adapter.new(handle)
         | 
| 64 40 | 
             
                  sheet.body = write_to_tempfile(handle)
         | 
| 65 41 | 
             
                  sheet.save
         | 
| 66 42 | 
             
                end
         | 
| 67 43 |  | 
| 44 | 
            +
                desc "edit SHEET_NAME", "edit an existent sheet cheat"
         | 
| 68 45 | 
             
                def edit(handle)
         | 
| 69 46 | 
             
                  sheet = Sheet.with_file_adapter.find(handle)
         | 
| 70 47 | 
             
                  sheet.body = write_to_tempfile(handle, sheet.body)
         | 
| 71 48 | 
             
                  sheet.save
         | 
| 72 49 | 
             
                end
         | 
| 73 50 |  | 
| 51 | 
            +
                desc "help", "help"
         | 
| 52 | 
            +
                def help
         | 
| 53 | 
            +
                  show('help')
         | 
| 54 | 
            +
                end
         | 
| 55 | 
            +
             | 
| 56 | 
            +
                private
         | 
| 57 | 
            +
             | 
| 58 | 
            +
                def model
         | 
| 59 | 
            +
                  if options[:local]
         | 
| 60 | 
            +
                    Sheet.with_file_adapter
         | 
| 61 | 
            +
                  else
         | 
| 62 | 
            +
                    Sheet
         | 
| 63 | 
            +
                  end
         | 
| 64 | 
            +
                end
         | 
| 65 | 
            +
             | 
| 74 66 | 
             
                def write_to_tempfile(title, body = nil)
         | 
| 75 67 | 
             
                  tempfile = Tempfile.new(title + '.yml')
         | 
| 76 68 | 
             
                  tempfile.write(body) if body
         | 
| @@ -85,20 +77,5 @@ module Cheatly | |
| 85 77 | 
             
                def editor
         | 
| 86 78 | 
             
                  ENV['VISUAL'] || ENV['EDITOR'] || "nano"
         | 
| 87 79 | 
             
                end
         | 
| 88 | 
            -
             | 
| 89 | 
            -
                def process
         | 
| 90 | 
            -
                  case @command
         | 
| 91 | 
            -
                  when "show"
         | 
| 92 | 
            -
                    sheet(@handle)
         | 
| 93 | 
            -
                  when "list"
         | 
| 94 | 
            -
                    list
         | 
| 95 | 
            -
                  when "new"
         | 
| 96 | 
            -
                    create(@handle)
         | 
| 97 | 
            -
                  when "edit"
         | 
| 98 | 
            -
                    edit(@handle)
         | 
| 99 | 
            -
                  else
         | 
| 100 | 
            -
                    puts "Command [#{@command}] not found :-( . You can try running 'cheatly list' to check the available commands. "
         | 
| 101 | 
            -
                  end
         | 
| 102 | 
            -
                end
         | 
| 103 80 | 
             
              end
         | 
| 104 81 | 
             
            end
         | 
    
        data/lib/cheatly/sheet.rb
    CHANGED
    
    | @@ -30,8 +30,8 @@ module Cheatly | |
| 30 30 | 
             
                def self.find(handle)
         | 
| 31 31 | 
             
                  t, b = adapter.find(handle)
         | 
| 32 32 | 
             
                  Sheet.new(t, b, persisted: true)
         | 
| 33 | 
            -
                rescue  | 
| 34 | 
            -
                   | 
| 33 | 
            +
                rescue RuntimeError => e
         | 
| 34 | 
            +
                  puts e.message
         | 
| 35 35 | 
             
                end
         | 
| 36 36 |  | 
| 37 37 | 
             
                def self.all
         | 
| @@ -40,11 +40,11 @@ module Cheatly | |
| 40 40 | 
             
                end
         | 
| 41 41 |  | 
| 42 42 | 
             
                def self.adapter
         | 
| 43 | 
            -
                  @adapter ||=  | 
| 43 | 
            +
                  @adapter ||= Cheatly::Adapter::GitHub.new
         | 
| 44 44 | 
             
                end
         | 
| 45 45 |  | 
| 46 46 | 
             
                def self.with_file_adapter
         | 
| 47 | 
            -
                  @adapter =  | 
| 47 | 
            +
                  @adapter = Cheatly::Adapter::File.new
         | 
| 48 48 | 
             
                  self
         | 
| 49 49 | 
             
                end
         | 
| 50 50 |  | 
| @@ -54,60 +54,4 @@ module Cheatly | |
| 54 54 | 
             
                    self.class.adapter
         | 
| 55 55 | 
             
                  end
         | 
| 56 56 | 
             
              end
         | 
| 57 | 
            -
             | 
| 58 | 
            -
              class FileAdapter
         | 
| 59 | 
            -
                def find(name)
         | 
| 60 | 
            -
                  path = "sheets/#{name}.yml"
         | 
| 61 | 
            -
                  sheet_yaml = File.read(path)
         | 
| 62 | 
            -
                  yml = YAML.load(sheet_yaml).first
         | 
| 63 | 
            -
                  [yml.first, yml.last]
         | 
| 64 | 
            -
                end
         | 
| 65 | 
            -
             | 
| 66 | 
            -
                def all
         | 
| 67 | 
            -
                  Dir["sheets/*.yml"].map { |f| f.scan(/sheets\/(.*).yml/)[0][0] }
         | 
| 68 | 
            -
                end
         | 
| 69 | 
            -
             | 
| 70 | 
            -
                def create(name, body)
         | 
| 71 | 
            -
                  body = {name => body}.to_yaml
         | 
| 72 | 
            -
                  f = File.new "sheets/#{name}.yml", "w"
         | 
| 73 | 
            -
                  f.write(body)
         | 
| 74 | 
            -
                  f.close
         | 
| 75 | 
            -
                end
         | 
| 76 | 
            -
             | 
| 77 | 
            -
                def update(name, body)
         | 
| 78 | 
            -
                  File.delete "sheets/#{name}.yml"
         | 
| 79 | 
            -
                  create(name, body)
         | 
| 80 | 
            -
                end
         | 
| 81 | 
            -
              end
         | 
| 82 | 
            -
             | 
| 83 | 
            -
              class GithubAdapter
         | 
| 84 | 
            -
                include HTTParty
         | 
| 85 | 
            -
                base_uri 'https://api.github.com'
         | 
| 86 | 
            -
             | 
| 87 | 
            -
                def headers
         | 
| 88 | 
            -
                  { :headers => {"User-Agent" => "Cheatly Gem"} }
         | 
| 89 | 
            -
                end
         | 
| 90 | 
            -
             | 
| 91 | 
            -
                def base_path
         | 
| 92 | 
            -
                  "/repos/arthurnn/cheatly/contents/sheets"
         | 
| 93 | 
            -
                end
         | 
| 94 | 
            -
             | 
| 95 | 
            -
                def find(path)
         | 
| 96 | 
            -
                  response = self.class.get("#{base_path}/#{path}.yml", headers)
         | 
| 97 | 
            -
                  json = JSON.parse(response.body)
         | 
| 98 | 
            -
                  sheet_yaml = Base64.decode64(json["content"])
         | 
| 99 | 
            -
                  yml = YAML.load(sheet_yaml).first
         | 
| 100 | 
            -
                  [yml.first, yml.last]
         | 
| 101 | 
            -
                end
         | 
| 102 | 
            -
             | 
| 103 | 
            -
                def all
         | 
| 104 | 
            -
                  response = self.class.get(base_path, headers)
         | 
| 105 | 
            -
                  json = JSON.parse(response.body)
         | 
| 106 | 
            -
                  json.map { |entry| entry["name"].gsub('.yml', '') }
         | 
| 107 | 
            -
                end
         | 
| 108 | 
            -
             | 
| 109 | 
            -
                def create
         | 
| 110 | 
            -
                  raise NotImplementedError
         | 
| 111 | 
            -
                end
         | 
| 112 | 
            -
              end
         | 
| 113 57 | 
             
            end
         | 
    
        data/lib/cheatly/version.rb
    CHANGED
    
    
    
        data/sheets/help.yml
    CHANGED
    
    | @@ -1,6 +1,18 @@ | |
| 1 1 | 
             
            ---
         | 
| 2 | 
            -
            help:  | 
| 3 | 
            -
               | 
| 4 | 
            -
               | 
| 5 | 
            -
               | 
| 6 | 
            -
             | 
| 2 | 
            +
            help: |
         | 
| 3 | 
            +
              cheatly help
         | 
| 4 | 
            +
              ------------
         | 
| 5 | 
            +
              usage: $ cheatly list
         | 
| 6 | 
            +
                     To list the available sheets
         | 
| 7 | 
            +
             | 
| 8 | 
            +
                     $ cheatly show (sheetname)
         | 
| 9 | 
            +
                     To see the sheet
         | 
| 10 | 
            +
             | 
| 11 | 
            +
                     To create a new sheet local:
         | 
| 12 | 
            +
                       1. Clone the project: https://github.com/arthurnn/cheatly
         | 
| 13 | 
            +
                       2. $ cheatly create (sheetname)
         | 
| 14 | 
            +
                       3. Create a PR
         | 
| 15 | 
            +
             | 
| 16 | 
            +
                     $ cheatly help
         | 
| 17 | 
            +
                     To see this
         | 
| 18 | 
            +
                     happy cheating !
         | 
    
        data/sheets/markdown.yml
    ADDED
    
    | @@ -0,0 +1,50 @@ | |
| 1 | 
            +
            ---
         | 
| 2 | 
            +
            markdown: |
         | 
| 3 | 
            +
             Headings:
         | 
| 4 | 
            +
             | 
| 5 | 
            +
               # h1      => <h1>h1</h1>
         | 
| 6 | 
            +
               ## h2     => <h2>h2</h2>
         | 
| 7 | 
            +
               ...
         | 
| 8 | 
            +
               ###### h6 => <h6>h6</h6>
         | 
| 9 | 
            +
             | 
| 10 | 
            +
             Paragraphs
         | 
| 11 | 
            +
             | 
| 12 | 
            +
               Separate paragraphs with double newlines.  => <p>Separate paragraphs with double newlines.</p>
         | 
| 13 | 
            +
             | 
| 14 | 
            +
               This is a second paragraph.                => <p>This is a second paragraph.
         | 
| 15 | 
            +
               This is not a third paragraph.             => This is not a third paragraph.</p>
         | 
| 16 | 
            +
             | 
| 17 | 
            +
             Blockquotes:
         | 
| 18 | 
            +
                                              => <blockquote>
         | 
| 19 | 
            +
               > This is a quote.             =>   <p>This is a quote. You can use multiple lines.</p>
         | 
| 20 | 
            +
               > You can use multiple lines.  => </blockquote>
         | 
| 21 | 
            +
             | 
| 22 | 
            +
             Code:
         | 
| 23 | 
            +
             | 
| 24 | 
            +
               `code goes here` => <code>code goes here</code>
         | 
| 25 | 
            +
             | 
| 26 | 
            +
              Lists:
         | 
| 27 | 
            +
                         =>   <ul>
         | 
| 28 | 
            +
               * item 1  =>     <li>item 1</li>
         | 
| 29 | 
            +
               * item 2  =>     <li>item 2</li>
         | 
| 30 | 
            +
               * item 3  =>     <li>item 3</li>
         | 
| 31 | 
            +
                         =>   </ul>
         | 
| 32 | 
            +
             | 
| 33 | 
            +
                         =>   <ol>
         | 
| 34 | 
            +
               1. item 1 =>     <li>item 1</li>
         | 
| 35 | 
            +
               1. item 2 =>     <li>item 2</li>
         | 
| 36 | 
            +
               1. item 3 =>     <li>item 3</li>
         | 
| 37 | 
            +
                         =>   </ol>
         | 
| 38 | 
            +
             | 
| 39 | 
            +
             Inline:
         | 
| 40 | 
            +
             | 
| 41 | 
            +
               *emphasis* => <em>emphasis</em>
         | 
| 42 | 
            +
               **strong** => <strong>strong</strong>
         | 
| 43 | 
            +
             | 
| 44 | 
            +
             Links:
         | 
| 45 | 
            +
             | 
| 46 | 
            +
               [Text to display](http://example.com/)  => <a href='http://example.com'>Text to display</a>
         | 
| 47 | 
            +
             | 
| 48 | 
            +
             Images:
         | 
| 49 | 
            +
             | 
| 50 | 
            +
                => <img src='/path/to/image.jpg alt='alt text' />
         | 
    
        data/test/sheet_test.rb
    ADDED
    
    | @@ -0,0 +1,14 @@ | |
| 1 | 
            +
            require 'test_helper'
         | 
| 2 | 
            +
             | 
| 3 | 
            +
            class SheetTest < MiniTest::Test
         | 
| 4 | 
            +
              def test_sheet_find
         | 
| 5 | 
            +
                sheet = Cheatly::Sheet.find("bash")
         | 
| 6 | 
            +
                assert sheet
         | 
| 7 | 
            +
              end
         | 
| 8 | 
            +
             | 
| 9 | 
            +
              def test_sheet_list
         | 
| 10 | 
            +
                sheets = Cheatly::Sheet.all
         | 
| 11 | 
            +
                assert sheets.is_a?(Array)
         | 
| 12 | 
            +
                assert sheets.any?
         | 
| 13 | 
            +
              end
         | 
| 14 | 
            +
            end
         | 
    
        data/test/test_helper.rb
    ADDED
    
    
    
        metadata
    CHANGED
    
    | @@ -1,29 +1,29 @@ | |
| 1 1 | 
             
            --- !ruby/object:Gem::Specification
         | 
| 2 2 | 
             
            name: cheatly
         | 
| 3 3 | 
             
            version: !ruby/object:Gem::Version
         | 
| 4 | 
            -
              version: 0.0. | 
| 4 | 
            +
              version: 0.0.6
         | 
| 5 5 | 
             
            platform: ruby
         | 
| 6 6 | 
             
            authors:
         | 
| 7 7 | 
             
            - Arthur Neves
         | 
| 8 8 | 
             
            autorequire: 
         | 
| 9 9 | 
             
            bindir: bin
         | 
| 10 10 | 
             
            cert_chain: []
         | 
| 11 | 
            -
            date: 2013-12- | 
| 11 | 
            +
            date: 2013-12-24 00:00:00.000000000 Z
         | 
| 12 12 | 
             
            dependencies:
         | 
| 13 13 | 
             
            - !ruby/object:Gem::Dependency
         | 
| 14 | 
            -
              name:  | 
| 14 | 
            +
              name: octokit
         | 
| 15 15 | 
             
              requirement: !ruby/object:Gem::Requirement
         | 
| 16 16 | 
             
                requirements:
         | 
| 17 17 | 
             
                - - ~>
         | 
| 18 18 | 
             
                  - !ruby/object:Gem::Version
         | 
| 19 | 
            -
                    version:  | 
| 19 | 
            +
                    version: 2.6.1
         | 
| 20 20 | 
             
              type: :runtime
         | 
| 21 21 | 
             
              prerelease: false
         | 
| 22 22 | 
             
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 23 23 | 
             
                requirements:
         | 
| 24 24 | 
             
                - - ~>
         | 
| 25 25 | 
             
                  - !ruby/object:Gem::Version
         | 
| 26 | 
            -
                    version:  | 
| 26 | 
            +
                    version: 2.6.1
         | 
| 27 27 | 
             
            - !ruby/object:Gem::Dependency
         | 
| 28 28 | 
             
              name: pager
         | 
| 29 29 | 
             
              requirement: !ruby/object:Gem::Requirement
         | 
| @@ -39,33 +39,61 @@ dependencies: | |
| 39 39 | 
             
                  - !ruby/object:Gem::Version
         | 
| 40 40 | 
             
                    version: 1.0.1
         | 
| 41 41 | 
             
            - !ruby/object:Gem::Dependency
         | 
| 42 | 
            -
              name:  | 
| 42 | 
            +
              name: thor
         | 
| 43 43 | 
             
              requirement: !ruby/object:Gem::Requirement
         | 
| 44 44 | 
             
                requirements:
         | 
| 45 45 | 
             
                - - ~>
         | 
| 46 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 47 | 
            +
                    version: 0.18.1
         | 
| 48 | 
            +
              type: :runtime
         | 
| 49 | 
            +
              prerelease: false
         | 
| 50 | 
            +
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 51 | 
            +
                requirements:
         | 
| 52 | 
            +
                - - ~>
         | 
| 53 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 54 | 
            +
                    version: 0.18.1
         | 
| 55 | 
            +
            - !ruby/object:Gem::Dependency
         | 
| 56 | 
            +
              name: bundler
         | 
| 57 | 
            +
              requirement: !ruby/object:Gem::Requirement
         | 
| 58 | 
            +
                requirements:
         | 
| 59 | 
            +
                - - '>='
         | 
| 46 60 | 
             
                  - !ruby/object:Gem::Version
         | 
| 47 61 | 
             
                    version: '1.3'
         | 
| 48 62 | 
             
              type: :development
         | 
| 49 63 | 
             
              prerelease: false
         | 
| 50 64 | 
             
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 51 65 | 
             
                requirements:
         | 
| 52 | 
            -
                - -  | 
| 66 | 
            +
                - - '>='
         | 
| 53 67 | 
             
                  - !ruby/object:Gem::Version
         | 
| 54 68 | 
             
                    version: '1.3'
         | 
| 55 69 | 
             
            - !ruby/object:Gem::Dependency
         | 
| 56 70 | 
             
              name: rake
         | 
| 57 71 | 
             
              requirement: !ruby/object:Gem::Requirement
         | 
| 58 72 | 
             
                requirements:
         | 
| 59 | 
            -
                - -  | 
| 73 | 
            +
                - - '>='
         | 
| 60 74 | 
             
                  - !ruby/object:Gem::Version
         | 
| 61 75 | 
             
                    version: '0'
         | 
| 62 76 | 
             
              type: :development
         | 
| 63 77 | 
             
              prerelease: false
         | 
| 64 78 | 
             
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 65 79 | 
             
                requirements:
         | 
| 66 | 
            -
                - -  | 
| 80 | 
            +
                - - '>='
         | 
| 67 81 | 
             
                  - !ruby/object:Gem::Version
         | 
| 68 82 | 
             
                    version: '0'
         | 
| 83 | 
            +
            - !ruby/object:Gem::Dependency
         | 
| 84 | 
            +
              name: minitest
         | 
| 85 | 
            +
              requirement: !ruby/object:Gem::Requirement
         | 
| 86 | 
            +
                requirements:
         | 
| 87 | 
            +
                - - ~>
         | 
| 88 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 89 | 
            +
                    version: 5.0.8
         | 
| 90 | 
            +
              type: :development
         | 
| 91 | 
            +
              prerelease: false
         | 
| 92 | 
            +
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 93 | 
            +
                requirements:
         | 
| 94 | 
            +
                - - ~>
         | 
| 95 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 96 | 
            +
                    version: 5.0.8
         | 
| 69 97 | 
             
            description: A cheat-sheet cli for a cheat repository
         | 
| 70 98 | 
             
            email:
         | 
| 71 99 | 
             
            - arthurnn@gmail.com
         | 
| @@ -75,13 +103,18 @@ extensions: [] | |
| 75 103 | 
             
            extra_rdoc_files: []
         | 
| 76 104 | 
             
            files:
         | 
| 77 105 | 
             
            - .gitignore
         | 
| 106 | 
            +
            - .travis.yml
         | 
| 78 107 | 
             
            - Gemfile
         | 
| 79 108 | 
             
            - LICENSE.txt
         | 
| 80 109 | 
             
            - README.md
         | 
| 81 110 | 
             
            - Rakefile
         | 
| 82 111 | 
             
            - bin/cheatly
         | 
| 83 112 | 
             
            - cheatly.gemspec
         | 
| 84 | 
            -
            -  | 
| 113 | 
            +
            - completion/README.md
         | 
| 114 | 
            +
            - completion/cheatly.bash
         | 
| 115 | 
            +
            - lib/cheatly/adapter/file.rb
         | 
| 116 | 
            +
            - lib/cheatly/adapter/github.rb
         | 
| 117 | 
            +
            - lib/cheatly/cli.rb
         | 
| 85 118 | 
             
            - lib/cheatly/sheet.rb
         | 
| 86 119 | 
             
            - lib/cheatly/version.rb
         | 
| 87 120 | 
             
            - sheets/assertions.yml
         | 
| @@ -89,10 +122,13 @@ files: | |
| 89 122 | 
             
            - sheets/exceptions.yml
         | 
| 90 123 | 
             
            - sheets/gem_release.yml
         | 
| 91 124 | 
             
            - sheets/help.yml
         | 
| 125 | 
            +
            - sheets/markdown.yml
         | 
| 92 126 | 
             
            - sheets/migrations.yml
         | 
| 93 127 | 
             
            - sheets/sprintf.yml
         | 
| 94 128 | 
             
            - sheets/status_codes.yml
         | 
| 95 129 | 
             
            - sheets/strftime.yml
         | 
| 130 | 
            +
            - test/sheet_test.rb
         | 
| 131 | 
            +
            - test/test_helper.rb
         | 
| 96 132 | 
             
            homepage: ''
         | 
| 97 133 | 
             
            licenses:
         | 
| 98 134 | 
             
            - MIT
         | 
| @@ -103,18 +139,20 @@ require_paths: | |
| 103 139 | 
             
            - lib
         | 
| 104 140 | 
             
            required_ruby_version: !ruby/object:Gem::Requirement
         | 
| 105 141 | 
             
              requirements:
         | 
| 106 | 
            -
              - -  | 
| 142 | 
            +
              - - '>='
         | 
| 107 143 | 
             
                - !ruby/object:Gem::Version
         | 
| 108 144 | 
             
                  version: '0'
         | 
| 109 145 | 
             
            required_rubygems_version: !ruby/object:Gem::Requirement
         | 
| 110 146 | 
             
              requirements:
         | 
| 111 | 
            -
              - -  | 
| 147 | 
            +
              - - '>='
         | 
| 112 148 | 
             
                - !ruby/object:Gem::Version
         | 
| 113 149 | 
             
                  version: '0'
         | 
| 114 150 | 
             
            requirements: []
         | 
| 115 151 | 
             
            rubyforge_project: 
         | 
| 116 | 
            -
            rubygems_version: 2.1. | 
| 152 | 
            +
            rubygems_version: 2.1.11
         | 
| 117 153 | 
             
            signing_key: 
         | 
| 118 154 | 
             
            specification_version: 4
         | 
| 119 155 | 
             
            summary: A cheat-sheet cli for a cheat repository
         | 
| 120 | 
            -
            test_files: | 
| 156 | 
            +
            test_files:
         | 
| 157 | 
            +
            - test/sheet_test.rb
         | 
| 158 | 
            +
            - test/test_helper.rb
         |