jekyll_github_sample 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 +7 -0
- data/.gitignore +37 -0
- data/Gemfile +3 -0
- data/Gemfile.lock +83 -0
- data/README.md +39 -0
- data/Rakefile +5 -0
- data/jekyll_github_sample.gemspec +26 -0
- data/lib/jekyll_github_sample.rb +4 -0
- data/lib/jekyll_github_sample/code_tag.rb +46 -0
- data/lib/jekyll_github_sample/file_helper.rb +34 -0
- data/lib/jekyll_github_sample/reference_tag.rb +19 -0
- data/lib/jekyll_github_sample/text_utils.rb +22 -0
- data/lib/jekyll_github_sample/version.rb +3 -0
- data/spec/lib/jekyll_github_sample/file_helper_spec.rb +23 -0
- data/spec/lib/jekyll_github_sample/text_utils_spec.rb +36 -0
- data/spec/spec_helper.rb +4 -0
- metadata +129 -0
    
        checksums.yaml
    ADDED
    
    | @@ -0,0 +1,7 @@ | |
| 1 | 
            +
            ---
         | 
| 2 | 
            +
            SHA1:
         | 
| 3 | 
            +
              metadata.gz: e15fe8ebc87794c54e191923c1b9de31f3625f3f
         | 
| 4 | 
            +
              data.tar.gz: 63f7e2b7fdcf92b69b93d27977f60705da18d500
         | 
| 5 | 
            +
            SHA512:
         | 
| 6 | 
            +
              metadata.gz: 2a2e8c914656e384509428f445dbe201fe38120223fd56d4dc9f24b5e3d0159d51a5b8bf0a7597cfeee40de40787dfe466baaf357f8a3e5336c543f2d1647734
         | 
| 7 | 
            +
              data.tar.gz: 717a53467bdd19f5e302896a532f74d671af26c5a740c6202a0c81c0d1bcb4becf5cc46b6db2dc31f0319b6519118df299130e56d8f03eaba0c5e53fa370a4cd
         | 
    
        data/.gitignore
    ADDED
    
    | @@ -0,0 +1,37 @@ | |
| 1 | 
            +
            *.gem
         | 
| 2 | 
            +
            *.rbc
         | 
| 3 | 
            +
            /.config
         | 
| 4 | 
            +
            /coverage/
         | 
| 5 | 
            +
            /InstalledFiles
         | 
| 6 | 
            +
            /pkg/
         | 
| 7 | 
            +
            /spec/reports/
         | 
| 8 | 
            +
            /test/tmp/
         | 
| 9 | 
            +
            /test/version_tmp/
         | 
| 10 | 
            +
            /tmp/
         | 
| 11 | 
            +
             | 
| 12 | 
            +
            ## Specific to RubyMotion:
         | 
| 13 | 
            +
            .dat*
         | 
| 14 | 
            +
            .repl_history
         | 
| 15 | 
            +
            build/
         | 
| 16 | 
            +
             | 
| 17 | 
            +
            ## Specific to Rubymine
         | 
| 18 | 
            +
            .idea/*
         | 
| 19 | 
            +
             | 
| 20 | 
            +
            ## Documentation cache and generated files:
         | 
| 21 | 
            +
            /.yardoc/
         | 
| 22 | 
            +
            /_yardoc/
         | 
| 23 | 
            +
            /doc/
         | 
| 24 | 
            +
            /rdoc/
         | 
| 25 | 
            +
             | 
| 26 | 
            +
            ## Environment normalisation:
         | 
| 27 | 
            +
            /.bundle/
         | 
| 28 | 
            +
            /lib/bundler/man/
         | 
| 29 | 
            +
             | 
| 30 | 
            +
            # for a library or gem, you might want to ignore these files since the code is
         | 
| 31 | 
            +
            # intended to run in multiple environments; otherwise, check them in:
         | 
| 32 | 
            +
            # Gemfile.lock
         | 
| 33 | 
            +
            .ruby-version
         | 
| 34 | 
            +
            .ruby-gemset
         | 
| 35 | 
            +
             | 
| 36 | 
            +
            # unless supporting rvm < 1.11.0 or doing something fancy, ignore this:
         | 
| 37 | 
            +
            .rvmrc
         | 
    
        data/Gemfile
    ADDED
    
    
    
        data/Gemfile.lock
    ADDED
    
    | @@ -0,0 +1,83 @@ | |
| 1 | 
            +
            PATH
         | 
| 2 | 
            +
              remote: .
         | 
| 3 | 
            +
              specs:
         | 
| 4 | 
            +
                jekyll_github_sample (0.1.0)
         | 
| 5 | 
            +
                  activesupport (~> 4.0)
         | 
| 6 | 
            +
                  jekyll (~> 1.0)
         | 
| 7 | 
            +
             | 
| 8 | 
            +
            GEM
         | 
| 9 | 
            +
              remote: https://rubygems.org/
         | 
| 10 | 
            +
              specs:
         | 
| 11 | 
            +
                activesupport (4.1.1)
         | 
| 12 | 
            +
                  i18n (~> 0.6, >= 0.6.9)
         | 
| 13 | 
            +
                  json (~> 1.7, >= 1.7.7)
         | 
| 14 | 
            +
                  minitest (~> 5.1)
         | 
| 15 | 
            +
                  thread_safe (~> 0.1)
         | 
| 16 | 
            +
                  tzinfo (~> 1.1)
         | 
| 17 | 
            +
                blankslate (2.1.2.4)
         | 
| 18 | 
            +
                classifier (1.3.4)
         | 
| 19 | 
            +
                  fast-stemmer (>= 1.0.0)
         | 
| 20 | 
            +
                colorator (0.1)
         | 
| 21 | 
            +
                commander (4.1.6)
         | 
| 22 | 
            +
                  highline (~> 1.6.11)
         | 
| 23 | 
            +
                diff-lcs (1.2.5)
         | 
| 24 | 
            +
                fast-stemmer (1.0.2)
         | 
| 25 | 
            +
                ffi (1.9.3)
         | 
| 26 | 
            +
                highline (1.6.21)
         | 
| 27 | 
            +
                i18n (0.6.9)
         | 
| 28 | 
            +
                jekyll (1.5.1)
         | 
| 29 | 
            +
                  classifier (~> 1.3)
         | 
| 30 | 
            +
                  colorator (~> 0.1)
         | 
| 31 | 
            +
                  commander (~> 4.1.3)
         | 
| 32 | 
            +
                  liquid (~> 2.5.5)
         | 
| 33 | 
            +
                  listen (~> 1.3)
         | 
| 34 | 
            +
                  maruku (= 0.7.0)
         | 
| 35 | 
            +
                  pygments.rb (~> 0.5.0)
         | 
| 36 | 
            +
                  redcarpet (~> 2.3.0)
         | 
| 37 | 
            +
                  safe_yaml (~> 1.0)
         | 
| 38 | 
            +
                  toml (~> 0.1.0)
         | 
| 39 | 
            +
                json (1.8.1)
         | 
| 40 | 
            +
                liquid (2.5.5)
         | 
| 41 | 
            +
                listen (1.3.1)
         | 
| 42 | 
            +
                  rb-fsevent (>= 0.9.3)
         | 
| 43 | 
            +
                  rb-inotify (>= 0.9)
         | 
| 44 | 
            +
                  rb-kqueue (>= 0.2)
         | 
| 45 | 
            +
                maruku (0.7.0)
         | 
| 46 | 
            +
                minitest (5.3.4)
         | 
| 47 | 
            +
                parslet (1.5.0)
         | 
| 48 | 
            +
                  blankslate (~> 2.0)
         | 
| 49 | 
            +
                posix-spawn (0.3.8)
         | 
| 50 | 
            +
                pygments.rb (0.5.4)
         | 
| 51 | 
            +
                  posix-spawn (~> 0.3.6)
         | 
| 52 | 
            +
                  yajl-ruby (~> 1.1.0)
         | 
| 53 | 
            +
                rake (10.3.2)
         | 
| 54 | 
            +
                rb-fsevent (0.9.4)
         | 
| 55 | 
            +
                rb-inotify (0.9.4)
         | 
| 56 | 
            +
                  ffi (>= 0.5.0)
         | 
| 57 | 
            +
                rb-kqueue (0.2.2)
         | 
| 58 | 
            +
                  ffi (>= 0.5.0)
         | 
| 59 | 
            +
                redcarpet (2.3.0)
         | 
| 60 | 
            +
                rspec (2.14.1)
         | 
| 61 | 
            +
                  rspec-core (~> 2.14.0)
         | 
| 62 | 
            +
                  rspec-expectations (~> 2.14.0)
         | 
| 63 | 
            +
                  rspec-mocks (~> 2.14.0)
         | 
| 64 | 
            +
                rspec-core (2.14.8)
         | 
| 65 | 
            +
                rspec-expectations (2.14.5)
         | 
| 66 | 
            +
                  diff-lcs (>= 1.1.3, < 2.0)
         | 
| 67 | 
            +
                rspec-mocks (2.14.6)
         | 
| 68 | 
            +
                safe_yaml (1.0.3)
         | 
| 69 | 
            +
                thread_safe (0.3.4)
         | 
| 70 | 
            +
                toml (0.1.1)
         | 
| 71 | 
            +
                  parslet (~> 1.5.0)
         | 
| 72 | 
            +
                tzinfo (1.2.0)
         | 
| 73 | 
            +
                  thread_safe (~> 0.1)
         | 
| 74 | 
            +
                yajl-ruby (1.1.0)
         | 
| 75 | 
            +
             | 
| 76 | 
            +
            PLATFORMS
         | 
| 77 | 
            +
              ruby
         | 
| 78 | 
            +
             | 
| 79 | 
            +
            DEPENDENCIES
         | 
| 80 | 
            +
              bundler
         | 
| 81 | 
            +
              jekyll_github_sample!
         | 
| 82 | 
            +
              rake
         | 
| 83 | 
            +
              rspec
         | 
    
        data/README.md
    ADDED
    
    | @@ -0,0 +1,39 @@ | |
| 1 | 
            +
            jekyll-github-sample
         | 
| 2 | 
            +
            ====================
         | 
| 3 | 
            +
             | 
| 4 | 
            +
            Two Jekyll Liquid tags to display a code sample from a file in a public Github repo and provide a reference to it.
         | 
| 5 | 
            +
             | 
| 6 | 
            +
            # Install
         | 
| 7 | 
            +
             | 
| 8 | 
            +
            Add the github_sample_tag.rb file to your Jekyll project _plugins directory.
         | 
| 9 | 
            +
             | 
| 10 | 
            +
            # Live Examples
         | 
| 11 | 
            +
             | 
| 12 | 
            +
            A [write up](https://bwillis.github.io/2014/05/28/include-github-repo-code-in-jekyll/) on my Jekyll blog including samples referencing this repo's code, meta.
         | 
| 13 | 
            +
             | 
| 14 | 
            +
            # github_sample Usage
         | 
| 15 | 
            +
            ```
         | 
| 16 | 
            +
            github_sample URL_WITH_USERNAME_REPO_AND_FILE <START_LINE_NUMBER> <END_LINE_NUMBER>
         | 
| 17 | 
            +
            ```
         | 
| 18 | 
            +
             | 
| 19 | 
            +
             * URL_WITH_USERNAME_REPO_AND_FILE - the full path to the Github repo file, prefer a file with the commitish in it so it won't change when recompiling occurs
         | 
| 20 | 
            +
             * START_LINE_NUMBER - (optional) number that is the first line to include (0 based)
         | 
| 21 | 
            +
             * END_LINE_NUMBER - (optional) number that is the last line to include, if excluded will read to end of file
         | 
| 22 | 
            +
             | 
| 23 | 
            +
            # github_reference Usage
         | 
| 24 | 
            +
            ```
         | 
| 25 | 
            +
            {% github_sample_ref URL_WITH_USERNAME_REPO_AND_FILE %}
         | 
| 26 | 
            +
            ```
         | 
| 27 | 
            +
             | 
| 28 | 
            +
             * URL_WITH_USERNAME_REPO_AND_FILE - the full path to the Github repo file, prefer a file with the commitish in it so it won't change when recompiling occurs
         | 
| 29 | 
            +
             | 
| 30 | 
            +
            # Example Usage
         | 
| 31 | 
            +
             | 
| 32 | 
            +
            This is how you would display, reference and highlight code in your Jekyll post.
         | 
| 33 | 
            +
             | 
| 34 | 
            +
            ```
         | 
| 35 | 
            +
            {% github_sample_ref /bwillis/versioncake/989237901cb873f96df12be48cbf1239be496bd7/Appraisals %}
         | 
| 36 | 
            +
            {% highlight ruby %}
         | 
| 37 | 
            +
            {% github_sample /bwillis/versioncake/989237901cb873f96df12be48cbf1239be496bd7/Appraisals 0 5 %}
         | 
| 38 | 
            +
            {% endhighlight %}
         | 
| 39 | 
            +
            ```
         | 
    
        data/Rakefile
    ADDED
    
    
| @@ -0,0 +1,26 @@ | |
| 1 | 
            +
            # -*- encoding: utf-8 -*-
         | 
| 2 | 
            +
            $:.push File.expand_path('../lib', __FILE__)
         | 
| 3 | 
            +
            require 'jekyll_github_sample/version'
         | 
| 4 | 
            +
             | 
| 5 | 
            +
            Gem::Specification.new do |s|
         | 
| 6 | 
            +
              s.name        = 'jekyll_github_sample'
         | 
| 7 | 
            +
              s.version     = JekyllGithubSample::VERSION
         | 
| 8 | 
            +
              s.license     = 'MIT'
         | 
| 9 | 
            +
              s.authors     = ['Ben Willis']
         | 
| 10 | 
            +
              s.email       = ['benjamin.willis@gmail.com']
         | 
| 11 | 
            +
              s.homepage    = 'http://bwillis.github.io/jekyll-github-sample'
         | 
| 12 | 
            +
              s.summary     = %q{Include a sample of a Github repo file.}
         | 
| 13 | 
            +
              s.description = %q{Easily reference and include a Github repo file in your post.}
         | 
| 14 | 
            +
             | 
| 15 | 
            +
              s.files         = `git ls-files -z`.split("\x0")
         | 
| 16 | 
            +
              s.test_files    = `git ls-files -- {spec}/*`.split('\n')
         | 
| 17 | 
            +
              s.require_paths = ['lib']
         | 
| 18 | 
            +
             | 
| 19 | 
            +
              s.add_dependency 'activesupport', '~> 4.0'
         | 
| 20 | 
            +
              s.add_dependency 'jekyll',        '~> 1.0'
         | 
| 21 | 
            +
             | 
| 22 | 
            +
              s.add_development_dependency 'rspec'
         | 
| 23 | 
            +
              s.add_development_dependency 'bundler'
         | 
| 24 | 
            +
              s.add_development_dependency 'rake'
         | 
| 25 | 
            +
             | 
| 26 | 
            +
            end
         | 
| @@ -0,0 +1,46 @@ | |
| 1 | 
            +
            require 'cgi'
         | 
| 2 | 
            +
            require 'open-uri'
         | 
| 3 | 
            +
            require 'active_support'
         | 
| 4 | 
            +
            require 'liquid'
         | 
| 5 | 
            +
             | 
| 6 | 
            +
            module JekyllGithubSample
         | 
| 7 | 
            +
              class CodeTag < ::Liquid::Tag
         | 
| 8 | 
            +
             | 
| 9 | 
            +
                include TextUtils
         | 
| 10 | 
            +
             | 
| 11 | 
            +
                def initialize(tag_name, params, tokens)
         | 
| 12 | 
            +
                  github_file_path, @line_start, @line_end = params.split
         | 
| 13 | 
            +
                  @github_file                             = FileHelper.new(github_file_path)
         | 
| 14 | 
            +
                  @line_start, @line_end                   = determine_line_numbers(@line_start, @line_end)
         | 
| 15 | 
            +
                  super
         | 
| 16 | 
            +
                end
         | 
| 17 | 
            +
             | 
| 18 | 
            +
                def render(context)
         | 
| 19 | 
            +
                  all_lines = cache.fetch(@github_file.raw_uri) do
         | 
| 20 | 
            +
                    open(@github_file.raw_uri).readlines
         | 
| 21 | 
            +
                  end
         | 
| 22 | 
            +
                  lines     = all_lines[@line_start..@line_end]
         | 
| 23 | 
            +
                  lines     = remove_common_indentation(lines)
         | 
| 24 | 
            +
                  lines.join
         | 
| 25 | 
            +
                end
         | 
| 26 | 
            +
             | 
| 27 | 
            +
                private
         | 
| 28 | 
            +
             | 
| 29 | 
            +
                def cache
         | 
| 30 | 
            +
                  @@cache ||= ActiveSupport::Cache::MemoryStore.new
         | 
| 31 | 
            +
                end
         | 
| 32 | 
            +
             | 
| 33 | 
            +
                def determine_line_numbers(first, last)
         | 
| 34 | 
            +
                  if first.nil? && last.nil?
         | 
| 35 | 
            +
                    first = 0
         | 
| 36 | 
            +
                    last  = -1
         | 
| 37 | 
            +
                  elsif last.nil?
         | 
| 38 | 
            +
                    last = first
         | 
| 39 | 
            +
                  end
         | 
| 40 | 
            +
             | 
| 41 | 
            +
                  [first.to_i, last.to_i]
         | 
| 42 | 
            +
                end
         | 
| 43 | 
            +
              end
         | 
| 44 | 
            +
            end
         | 
| 45 | 
            +
             | 
| 46 | 
            +
            Liquid::Template.register_tag('github_sample', JekyllGithubSample::CodeTag)
         | 
| @@ -0,0 +1,34 @@ | |
| 1 | 
            +
            module JekyllGithubSample
         | 
| 2 | 
            +
              class FileHelper
         | 
| 3 | 
            +
             | 
| 4 | 
            +
                GITHUB_RAW_URI = 'https://raw.githubusercontent.com/'
         | 
| 5 | 
            +
                GITHUB_URI     = 'https://github.com/'
         | 
| 6 | 
            +
                WEB_URI_PART = 'blob'
         | 
| 7 | 
            +
             | 
| 8 | 
            +
                attr_reader :filename, :user, :project_name
         | 
| 9 | 
            +
             | 
| 10 | 
            +
                def initialize(path)
         | 
| 11 | 
            +
                  @path = path
         | 
| 12 | 
            +
                  parts = @path.split('/').delete_if { |e| e.empty? }
         | 
| 13 | 
            +
                  if parts.include? WEB_URI_PART
         | 
| 14 | 
            +
                    @user, @project_name, @blob, @commitish_or_branch = parts[0..3]
         | 
| 15 | 
            +
                    @filename = File.join(parts[4..-1])
         | 
| 16 | 
            +
                  else
         | 
| 17 | 
            +
                    @user, @project_name, @commitish_or_branch = parts[0..2]
         | 
| 18 | 
            +
                    @filename = File.join(parts[3..-1])
         | 
| 19 | 
            +
                  end
         | 
| 20 | 
            +
                end
         | 
| 21 | 
            +
             | 
| 22 | 
            +
                def user_uri
         | 
| 23 | 
            +
                  File.join(GITHUB_URI, @user)
         | 
| 24 | 
            +
                end
         | 
| 25 | 
            +
             | 
| 26 | 
            +
                def web_uri
         | 
| 27 | 
            +
                  File.join(GITHUB_URI, @user, @project_name, WEB_URI_PART, @commitish_or_branch, @filename)
         | 
| 28 | 
            +
                end
         | 
| 29 | 
            +
             | 
| 30 | 
            +
                def raw_uri
         | 
| 31 | 
            +
                  File.join(GITHUB_RAW_URI, @user, @project_name, @commitish_or_branch, @filename)
         | 
| 32 | 
            +
                end
         | 
| 33 | 
            +
              end
         | 
| 34 | 
            +
            end
         | 
| @@ -0,0 +1,19 @@ | |
| 1 | 
            +
            module JekyllGithubSample
         | 
| 2 | 
            +
              class ReferenceTag < CodeTag
         | 
| 3 | 
            +
             | 
| 4 | 
            +
                def render(context)
         | 
| 5 | 
            +
                  <<MARKUP.strip
         | 
| 6 | 
            +
            <div class="github-sample-reference">
         | 
| 7 | 
            +
              <div class="author-info">
         | 
| 8 | 
            +
                <a href="#{@github_file.web_uri}">This Github Sample</a> is by <a href="#{@github_file.user_uri}">#{@github_file.user}</a>
         | 
| 9 | 
            +
              </div>
         | 
| 10 | 
            +
              <div class="meta-info">
         | 
| 11 | 
            +
                #{@github_file.filename} <a href="#{@github_file.web_uri}">view</a> <a href="#{@github_file.raw_uri}">raw</a>
         | 
| 12 | 
            +
              </div>
         | 
| 13 | 
            +
            </div>
         | 
| 14 | 
            +
            MARKUP
         | 
| 15 | 
            +
                end
         | 
| 16 | 
            +
              end
         | 
| 17 | 
            +
            end
         | 
| 18 | 
            +
             | 
| 19 | 
            +
            Liquid::Template.register_tag('github_sample_ref', JekyllGithubSample::ReferenceTag)
         | 
| @@ -0,0 +1,22 @@ | |
| 1 | 
            +
            module JekyllGithubSample
         | 
| 2 | 
            +
              module TextUtils
         | 
| 3 | 
            +
             | 
| 4 | 
            +
                INDEN_REGEX = /^\s+/
         | 
| 5 | 
            +
             | 
| 6 | 
            +
                def remove_common_indentation(lines)
         | 
| 7 | 
            +
                  leading_spaces = []
         | 
| 8 | 
            +
                  lines.each do |line|
         | 
| 9 | 
            +
                    next if line.length == 1
         | 
| 10 | 
            +
                    if indentation_match = line.match(INDEN_REGEX)
         | 
| 11 | 
            +
                      leading_spaces << indentation_match[0].length
         | 
| 12 | 
            +
                    else
         | 
| 13 | 
            +
                      leading_spaces << 0
         | 
| 14 | 
            +
                    end
         | 
| 15 | 
            +
                  end
         | 
| 16 | 
            +
             | 
| 17 | 
            +
                  lines.collect do |line|
         | 
| 18 | 
            +
                    line.length == 1 ? line : line[leading_spaces.min..-1]
         | 
| 19 | 
            +
                  end
         | 
| 20 | 
            +
                end
         | 
| 21 | 
            +
              end
         | 
| 22 | 
            +
            end
         | 
| @@ -0,0 +1,23 @@ | |
| 1 | 
            +
            require 'spec_helper'
         | 
| 2 | 
            +
             | 
| 3 | 
            +
            describe JekyllGithubSample::FileHelper do
         | 
| 4 | 
            +
             | 
| 5 | 
            +
              let(:path) { '/bwillis/versioncake/blob/master/lib/versioncake/configuration.rb' }
         | 
| 6 | 
            +
             | 
| 7 | 
            +
              subject { JekyllGithubSample::FileHelper.new(path) }
         | 
| 8 | 
            +
             | 
| 9 | 
            +
              context '#initialize' do
         | 
| 10 | 
            +
                it 'does not fail to initialize with the path' do
         | 
| 11 | 
            +
                  expect {
         | 
| 12 | 
            +
                    subject
         | 
| 13 | 
            +
                  }.not_to raise_error
         | 
| 14 | 
            +
                end
         | 
| 15 | 
            +
              end
         | 
| 16 | 
            +
             | 
| 17 | 
            +
              its(:user_uri)     { should == 'https://github.com/bwillis' }
         | 
| 18 | 
            +
              its(:web_uri)      { should == 'https://github.com/bwillis/versioncake/blob/master/lib/versioncake/configuration.rb' }
         | 
| 19 | 
            +
              its(:raw_uri)      { should == 'https://raw.githubusercontent.com/bwillis/versioncake/master/lib/versioncake/configuration.rb' }
         | 
| 20 | 
            +
              its(:filename)     { should == 'lib/versioncake/configuration.rb' }
         | 
| 21 | 
            +
              its(:user)         { should == 'bwillis' }
         | 
| 22 | 
            +
              its(:project_name) { should == 'versioncake' }
         | 
| 23 | 
            +
            end
         | 
| @@ -0,0 +1,36 @@ | |
| 1 | 
            +
            require 'spec_helper'
         | 
| 2 | 
            +
             | 
| 3 | 
            +
            describe JekyllGithubSample::TextUtils do
         | 
| 4 | 
            +
             | 
| 5 | 
            +
              let(:text_utils) { class Tester; include JekyllGithubSample::TextUtils; end.new }
         | 
| 6 | 
            +
             | 
| 7 | 
            +
              context '#remove_common_indentation' do
         | 
| 8 | 
            +
                let(:lines) {[
         | 
| 9 | 
            +
                 '   def method',
         | 
| 10 | 
            +
                 '     a = 1',
         | 
| 11 | 
            +
                 '   end'
         | 
| 12 | 
            +
                ]}
         | 
| 13 | 
            +
                subject { text_utils.remove_common_indentation(lines) }
         | 
| 14 | 
            +
             | 
| 15 | 
            +
                it 'removes 3 spaces of common indentation' do
         | 
| 16 | 
            +
                  should =~ [
         | 
| 17 | 
            +
                    'def method',
         | 
| 18 | 
            +
                    '  a = 1',
         | 
| 19 | 
            +
                    'end'
         | 
| 20 | 
            +
                  ]
         | 
| 21 | 
            +
                end
         | 
| 22 | 
            +
             | 
| 23 | 
            +
                context 'for lines with no common indentation' do
         | 
| 24 | 
            +
                  let(:lines) { [
         | 
| 25 | 
            +
                      'def new_method',
         | 
| 26 | 
            +
                      '  raise',
         | 
| 27 | 
            +
                      'end'
         | 
| 28 | 
            +
                  ] }
         | 
| 29 | 
            +
             | 
| 30 | 
            +
                  it 'does nothing to the indentation' do
         | 
| 31 | 
            +
                    should =~ lines
         | 
| 32 | 
            +
                  end
         | 
| 33 | 
            +
                end
         | 
| 34 | 
            +
              end
         | 
| 35 | 
            +
             | 
| 36 | 
            +
            end
         | 
    
        data/spec/spec_helper.rb
    ADDED
    
    
    
        metadata
    ADDED
    
    | @@ -0,0 +1,129 @@ | |
| 1 | 
            +
            --- !ruby/object:Gem::Specification
         | 
| 2 | 
            +
            name: jekyll_github_sample
         | 
| 3 | 
            +
            version: !ruby/object:Gem::Version
         | 
| 4 | 
            +
              version: 0.1.0
         | 
| 5 | 
            +
            platform: ruby
         | 
| 6 | 
            +
            authors:
         | 
| 7 | 
            +
            - Ben Willis
         | 
| 8 | 
            +
            autorequire: 
         | 
| 9 | 
            +
            bindir: bin
         | 
| 10 | 
            +
            cert_chain: []
         | 
| 11 | 
            +
            date: 2014-05-29 00:00:00.000000000 Z
         | 
| 12 | 
            +
            dependencies:
         | 
| 13 | 
            +
            - !ruby/object:Gem::Dependency
         | 
| 14 | 
            +
              name: activesupport
         | 
| 15 | 
            +
              requirement: !ruby/object:Gem::Requirement
         | 
| 16 | 
            +
                requirements:
         | 
| 17 | 
            +
                - - "~>"
         | 
| 18 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 19 | 
            +
                    version: '4.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.0'
         | 
| 27 | 
            +
            - !ruby/object:Gem::Dependency
         | 
| 28 | 
            +
              name: jekyll
         | 
| 29 | 
            +
              requirement: !ruby/object:Gem::Requirement
         | 
| 30 | 
            +
                requirements:
         | 
| 31 | 
            +
                - - "~>"
         | 
| 32 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 33 | 
            +
                    version: '1.0'
         | 
| 34 | 
            +
              type: :runtime
         | 
| 35 | 
            +
              prerelease: false
         | 
| 36 | 
            +
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 37 | 
            +
                requirements:
         | 
| 38 | 
            +
                - - "~>"
         | 
| 39 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 40 | 
            +
                    version: '1.0'
         | 
| 41 | 
            +
            - !ruby/object:Gem::Dependency
         | 
| 42 | 
            +
              name: rspec
         | 
| 43 | 
            +
              requirement: !ruby/object:Gem::Requirement
         | 
| 44 | 
            +
                requirements:
         | 
| 45 | 
            +
                - - ">="
         | 
| 46 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 47 | 
            +
                    version: '0'
         | 
| 48 | 
            +
              type: :development
         | 
| 49 | 
            +
              prerelease: false
         | 
| 50 | 
            +
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 51 | 
            +
                requirements:
         | 
| 52 | 
            +
                - - ">="
         | 
| 53 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 54 | 
            +
                    version: '0'
         | 
| 55 | 
            +
            - !ruby/object:Gem::Dependency
         | 
| 56 | 
            +
              name: bundler
         | 
| 57 | 
            +
              requirement: !ruby/object:Gem::Requirement
         | 
| 58 | 
            +
                requirements:
         | 
| 59 | 
            +
                - - ">="
         | 
| 60 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 61 | 
            +
                    version: '0'
         | 
| 62 | 
            +
              type: :development
         | 
| 63 | 
            +
              prerelease: false
         | 
| 64 | 
            +
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 65 | 
            +
                requirements:
         | 
| 66 | 
            +
                - - ">="
         | 
| 67 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 68 | 
            +
                    version: '0'
         | 
| 69 | 
            +
            - !ruby/object:Gem::Dependency
         | 
| 70 | 
            +
              name: rake
         | 
| 71 | 
            +
              requirement: !ruby/object:Gem::Requirement
         | 
| 72 | 
            +
                requirements:
         | 
| 73 | 
            +
                - - ">="
         | 
| 74 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 75 | 
            +
                    version: '0'
         | 
| 76 | 
            +
              type: :development
         | 
| 77 | 
            +
              prerelease: false
         | 
| 78 | 
            +
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 79 | 
            +
                requirements:
         | 
| 80 | 
            +
                - - ">="
         | 
| 81 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 82 | 
            +
                    version: '0'
         | 
| 83 | 
            +
            description: Easily reference and include a Github repo file in your post.
         | 
| 84 | 
            +
            email:
         | 
| 85 | 
            +
            - benjamin.willis@gmail.com
         | 
| 86 | 
            +
            executables: []
         | 
| 87 | 
            +
            extensions: []
         | 
| 88 | 
            +
            extra_rdoc_files: []
         | 
| 89 | 
            +
            files:
         | 
| 90 | 
            +
            - ".gitignore"
         | 
| 91 | 
            +
            - Gemfile
         | 
| 92 | 
            +
            - Gemfile.lock
         | 
| 93 | 
            +
            - README.md
         | 
| 94 | 
            +
            - Rakefile
         | 
| 95 | 
            +
            - jekyll_github_sample.gemspec
         | 
| 96 | 
            +
            - lib/jekyll_github_sample.rb
         | 
| 97 | 
            +
            - lib/jekyll_github_sample/code_tag.rb
         | 
| 98 | 
            +
            - lib/jekyll_github_sample/file_helper.rb
         | 
| 99 | 
            +
            - lib/jekyll_github_sample/reference_tag.rb
         | 
| 100 | 
            +
            - lib/jekyll_github_sample/text_utils.rb
         | 
| 101 | 
            +
            - lib/jekyll_github_sample/version.rb
         | 
| 102 | 
            +
            - spec/lib/jekyll_github_sample/file_helper_spec.rb
         | 
| 103 | 
            +
            - spec/lib/jekyll_github_sample/text_utils_spec.rb
         | 
| 104 | 
            +
            - spec/spec_helper.rb
         | 
| 105 | 
            +
            homepage: http://bwillis.github.io/jekyll-github-sample
         | 
| 106 | 
            +
            licenses:
         | 
| 107 | 
            +
            - MIT
         | 
| 108 | 
            +
            metadata: {}
         | 
| 109 | 
            +
            post_install_message: 
         | 
| 110 | 
            +
            rdoc_options: []
         | 
| 111 | 
            +
            require_paths:
         | 
| 112 | 
            +
            - lib
         | 
| 113 | 
            +
            required_ruby_version: !ruby/object:Gem::Requirement
         | 
| 114 | 
            +
              requirements:
         | 
| 115 | 
            +
              - - ">="
         | 
| 116 | 
            +
                - !ruby/object:Gem::Version
         | 
| 117 | 
            +
                  version: '0'
         | 
| 118 | 
            +
            required_rubygems_version: !ruby/object:Gem::Requirement
         | 
| 119 | 
            +
              requirements:
         | 
| 120 | 
            +
              - - ">="
         | 
| 121 | 
            +
                - !ruby/object:Gem::Version
         | 
| 122 | 
            +
                  version: '0'
         | 
| 123 | 
            +
            requirements: []
         | 
| 124 | 
            +
            rubyforge_project: 
         | 
| 125 | 
            +
            rubygems_version: 2.2.2
         | 
| 126 | 
            +
            signing_key: 
         | 
| 127 | 
            +
            specification_version: 4
         | 
| 128 | 
            +
            summary: Include a sample of a Github repo file.
         | 
| 129 | 
            +
            test_files: []
         |