qiita-build 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 +14 -0
- data/.rspec +1 -0
- data/.travis.yml +3 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +40 -0
- data/Rakefile +7 -0
- data/bin/qiita-build +10 -0
- data/lib/qiita-build.rb +3 -0
- data/lib/qiita/build/builder.rb +15 -0
- data/lib/qiita/build/command.rb +49 -0
- data/lib/qiita/build/version.rb +5 -0
- data/qiita-build.gemspec +26 -0
- data/spec/fixtures/item.md +5 -0
- data/spec/fixtures/template.md +5 -0
- data/spec/qiita/build/builder_spec.rb +37 -0
- data/spec/spec_helper.rb +4 -0
- metadata +136 -0
    
        checksums.yaml
    ADDED
    
    | @@ -0,0 +1,7 @@ | |
| 1 | 
            +
            ---
         | 
| 2 | 
            +
            SHA1:
         | 
| 3 | 
            +
              metadata.gz: 02510d5cf8aa538ae3201949cc6a72ceeeaf536e
         | 
| 4 | 
            +
              data.tar.gz: 97a4b0f00d40e66f20bf8d155ddb968955c61fa9
         | 
| 5 | 
            +
            SHA512:
         | 
| 6 | 
            +
              metadata.gz: c867f39ab7d82abc996bca52a1ea9fa69018cb358caa3325659d67829184ad32dd0d59aeb6e74315b1c4579f0746be2e56d7496a90425c2e3476db8bcd4c8cd5
         | 
| 7 | 
            +
              data.tar.gz: ce85abf2560c557eb02678b8bf43932b3d8a624e7d22b405983fb7341b1033c91cf70354e79ac006bcf9581d93e575aa07ca163d25c66003cb721d228bf46383
         | 
    
        data/.gitignore
    ADDED
    
    
    
        data/.rspec
    ADDED
    
    | @@ -0,0 +1 @@ | |
| 1 | 
            +
            --color
         | 
    
        data/.travis.yml
    ADDED
    
    
    
        data/Gemfile
    ADDED
    
    
    
        data/LICENSE.txt
    ADDED
    
    | @@ -0,0 +1,22 @@ | |
| 1 | 
            +
            Copyright (c) 2015 Naoto Kaneko
         | 
| 2 | 
            +
             | 
| 3 | 
            +
            MIT License
         | 
| 4 | 
            +
             | 
| 5 | 
            +
            Permission is hereby granted, free of charge, to any person obtaining
         | 
| 6 | 
            +
            a copy of this software and associated documentation files (the
         | 
| 7 | 
            +
            "Software"), to deal in the Software without restriction, including
         | 
| 8 | 
            +
            without limitation the rights to use, copy, modify, merge, publish,
         | 
| 9 | 
            +
            distribute, sublicense, and/or sell copies of the Software, and to
         | 
| 10 | 
            +
            permit persons to whom the Software is furnished to do so, subject to
         | 
| 11 | 
            +
            the following conditions:
         | 
| 12 | 
            +
             | 
| 13 | 
            +
            The above copyright notice and this permission notice shall be
         | 
| 14 | 
            +
            included in all copies or substantial portions of the Software.
         | 
| 15 | 
            +
             | 
| 16 | 
            +
            THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
         | 
| 17 | 
            +
            EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
         | 
| 18 | 
            +
            MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
         | 
| 19 | 
            +
            NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
         | 
| 20 | 
            +
            LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
         | 
| 21 | 
            +
            OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
         | 
| 22 | 
            +
            WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
         | 
    
        data/README.md
    ADDED
    
    | @@ -0,0 +1,40 @@ | |
| 1 | 
            +
            # qiita-build
         | 
| 2 | 
            +
             | 
| 3 | 
            +
            Qiita item builder from a template and stdin
         | 
| 4 | 
            +
             | 
| 5 | 
            +
            ## Installation
         | 
| 6 | 
            +
             | 
| 7 | 
            +
            ```
         | 
| 8 | 
            +
            $ gem install qiita-build
         | 
| 9 | 
            +
            ```
         | 
| 10 | 
            +
             | 
| 11 | 
            +
            ## Usage
         | 
| 12 | 
            +
             | 
| 13 | 
            +
            Given a below template,
         | 
| 14 | 
            +
             | 
| 15 | 
            +
            ```
         | 
| 16 | 
            +
            # 自己紹介
         | 
| 17 | 
            +
            * 氏名: %{fullname}
         | 
| 18 | 
            +
            * ニックネーム: %{nickname}
         | 
| 19 | 
            +
            * 居住地: %{location}
         | 
| 20 | 
            +
            * 生年月日: %{birthday}
         | 
| 21 | 
            +
            ```
         | 
| 22 | 
            +
             | 
| 23 | 
            +
            `qiita-build` will build an item from the template and stdin, like this.
         | 
| 24 | 
            +
             | 
| 25 | 
            +
            ```
         | 
| 26 | 
            +
            $ echo '{"fullname": "Naoto Kanekoo", "nickname": "naoty", "location": "Tokyo", "birthday": "1987/6/2"}' | qiita-build -a <ACCESS TOKEN> -t <TEAM> <TEMPLATE ID>
         | 
| 27 | 
            +
            # 自己紹介
         | 
| 28 | 
            +
            * 氏名: Naoto Kaneko
         | 
| 29 | 
            +
            * ニックネーム: naoty
         | 
| 30 | 
            +
            * 居住地: Tokyo
         | 
| 31 | 
            +
            * 生年月日: 1987/6/2
         | 
| 32 | 
            +
            ```
         | 
| 33 | 
            +
             | 
| 34 | 
            +
            ## Contributing
         | 
| 35 | 
            +
             | 
| 36 | 
            +
            1. Fork it ( https://github.com/[my-github-username]/qiita-build/fork )
         | 
| 37 | 
            +
            2. Create your feature branch (`git checkout -b my-new-feature`)
         | 
| 38 | 
            +
            3. Commit your changes (`git commit -am 'Add some feature'`)
         | 
| 39 | 
            +
            4. Push to the branch (`git push origin my-new-feature`)
         | 
| 40 | 
            +
            5. Create a new Pull Request
         | 
    
        data/Rakefile
    ADDED
    
    
    
        data/bin/qiita-build
    ADDED
    
    
    
        data/lib/qiita-build.rb
    ADDED
    
    
| @@ -0,0 +1,49 @@ | |
| 1 | 
            +
            require "json"
         | 
| 2 | 
            +
            require "optparse"
         | 
| 3 | 
            +
            require "qiita"
         | 
| 4 | 
            +
             | 
| 5 | 
            +
            module Qiita
         | 
| 6 | 
            +
              module Build
         | 
| 7 | 
            +
                class Command
         | 
| 8 | 
            +
                  def initialize(stdin, argv)
         | 
| 9 | 
            +
                    @options = {}
         | 
| 10 | 
            +
                    @json = JSON.parse(stdin)
         | 
| 11 | 
            +
                    @argv = parse_options!(argv)
         | 
| 12 | 
            +
                  end
         | 
| 13 | 
            +
             | 
| 14 | 
            +
                  def run
         | 
| 15 | 
            +
                    client = Qiita::Client.new(team: team, access_token: access_token)
         | 
| 16 | 
            +
                    response = client.get_template(template_id)
         | 
| 17 | 
            +
                    template = response.body["body"]
         | 
| 18 | 
            +
                    puts Builder.new.build(template: template, json: @json)
         | 
| 19 | 
            +
                  end
         | 
| 20 | 
            +
             | 
| 21 | 
            +
                  private
         | 
| 22 | 
            +
             | 
| 23 | 
            +
                  def parse_options!(options)
         | 
| 24 | 
            +
                    option_parser.on("-a VAL", "--access-token=VAL") { |v| @options[:access_token] = v }
         | 
| 25 | 
            +
                    option_parser.on("-t VAL", "--team=VAL") { |v| @options[:team] = v }
         | 
| 26 | 
            +
                    argv = option_parser.parse!(options)
         | 
| 27 | 
            +
                    argv.delete(access_token)
         | 
| 28 | 
            +
                    argv.delete(team)
         | 
| 29 | 
            +
                    argv
         | 
| 30 | 
            +
                  end
         | 
| 31 | 
            +
             | 
| 32 | 
            +
                  def option_parser
         | 
| 33 | 
            +
                    @option_parser ||= OptionParser.new
         | 
| 34 | 
            +
                  end
         | 
| 35 | 
            +
             | 
| 36 | 
            +
                  def access_token
         | 
| 37 | 
            +
                    @options[:access_token]
         | 
| 38 | 
            +
                  end
         | 
| 39 | 
            +
             | 
| 40 | 
            +
                  def team
         | 
| 41 | 
            +
                    @options[:team]
         | 
| 42 | 
            +
                  end
         | 
| 43 | 
            +
             | 
| 44 | 
            +
                  def template_id
         | 
| 45 | 
            +
                    @template_id ||= @argv.pop
         | 
| 46 | 
            +
                  end
         | 
| 47 | 
            +
                end
         | 
| 48 | 
            +
              end
         | 
| 49 | 
            +
            end
         | 
    
        data/qiita-build.gemspec
    ADDED
    
    | @@ -0,0 +1,26 @@ | |
| 1 | 
            +
            # coding: utf-8
         | 
| 2 | 
            +
            lib = File.expand_path("../lib", __FILE__)
         | 
| 3 | 
            +
            $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
         | 
| 4 | 
            +
            require "qiita/build/version"
         | 
| 5 | 
            +
             | 
| 6 | 
            +
            Gem::Specification.new do |spec|
         | 
| 7 | 
            +
              spec.name          = "qiita-build"
         | 
| 8 | 
            +
              spec.version       = Qiita::Build::VERSION
         | 
| 9 | 
            +
              spec.authors       = ["Naoto Kaneko"]
         | 
| 10 | 
            +
              spec.email         = ["naoty.k@gmail.com"]
         | 
| 11 | 
            +
              spec.summary       = %q{Qiita item builder from a template and stdin}
         | 
| 12 | 
            +
              spec.homepage      = "https://github.com/naoty/qiita-build"
         | 
| 13 | 
            +
              spec.license       = "MIT"
         | 
| 14 | 
            +
             | 
| 15 | 
            +
              spec.files         = `git ls-files -z`.split("\x0")
         | 
| 16 | 
            +
              spec.executables   = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
         | 
| 17 | 
            +
              spec.test_files    = spec.files.grep(%r{^(test|spec|features)/})
         | 
| 18 | 
            +
              spec.require_paths = ["lib"]
         | 
| 19 | 
            +
             | 
| 20 | 
            +
              spec.add_dependency "qiita"
         | 
| 21 | 
            +
             | 
| 22 | 
            +
              spec.add_development_dependency "bundler", "~> 1.7"
         | 
| 23 | 
            +
              spec.add_development_dependency "rake", "~> 10.0"
         | 
| 24 | 
            +
              spec.add_development_dependency "rspec"
         | 
| 25 | 
            +
              spec.add_development_dependency "pry"
         | 
| 26 | 
            +
            end
         | 
| @@ -0,0 +1,37 @@ | |
| 1 | 
            +
            require "spec_helper"
         | 
| 2 | 
            +
             | 
| 3 | 
            +
            RSpec.describe Qiita::Build::Builder do
         | 
| 4 | 
            +
              let(:fixture_path) do
         | 
| 5 | 
            +
                path = File.expand_path("../../fixtures", __dir__)
         | 
| 6 | 
            +
                Pathname.new(path)
         | 
| 7 | 
            +
              end
         | 
| 8 | 
            +
             | 
| 9 | 
            +
              let(:builder) do
         | 
| 10 | 
            +
                described_class.new
         | 
| 11 | 
            +
              end
         | 
| 12 | 
            +
             | 
| 13 | 
            +
              describe "#build" do
         | 
| 14 | 
            +
                let(:template) do
         | 
| 15 | 
            +
                  fixture_path.join("template.md").read
         | 
| 16 | 
            +
                end
         | 
| 17 | 
            +
             | 
| 18 | 
            +
                let(:item) do
         | 
| 19 | 
            +
                  fixture_path.join("item.md").read
         | 
| 20 | 
            +
                end
         | 
| 21 | 
            +
             | 
| 22 | 
            +
                let(:json) do
         | 
| 23 | 
            +
                  {
         | 
| 24 | 
            +
                    fullname: "Naoto Kaneko",
         | 
| 25 | 
            +
                    nickname: "naoty",
         | 
| 26 | 
            +
                    location: "Tokyo",
         | 
| 27 | 
            +
                    birthday: "1987/6/2"
         | 
| 28 | 
            +
                  }
         | 
| 29 | 
            +
                end
         | 
| 30 | 
            +
             | 
| 31 | 
            +
                subject do
         | 
| 32 | 
            +
                  builder.build(template: template, json: json)
         | 
| 33 | 
            +
                end
         | 
| 34 | 
            +
             | 
| 35 | 
            +
                it { is_expected.to eq item }
         | 
| 36 | 
            +
              end
         | 
| 37 | 
            +
            end
         | 
    
        data/spec/spec_helper.rb
    ADDED
    
    
    
        metadata
    ADDED
    
    | @@ -0,0 +1,136 @@ | |
| 1 | 
            +
            --- !ruby/object:Gem::Specification
         | 
| 2 | 
            +
            name: qiita-build
         | 
| 3 | 
            +
            version: !ruby/object:Gem::Version
         | 
| 4 | 
            +
              version: 0.1.0
         | 
| 5 | 
            +
            platform: ruby
         | 
| 6 | 
            +
            authors:
         | 
| 7 | 
            +
            - Naoto Kaneko
         | 
| 8 | 
            +
            autorequire: 
         | 
| 9 | 
            +
            bindir: bin
         | 
| 10 | 
            +
            cert_chain: []
         | 
| 11 | 
            +
            date: 2015-01-02 00:00:00.000000000 Z
         | 
| 12 | 
            +
            dependencies:
         | 
| 13 | 
            +
            - !ruby/object:Gem::Dependency
         | 
| 14 | 
            +
              name: qiita
         | 
| 15 | 
            +
              requirement: !ruby/object:Gem::Requirement
         | 
| 16 | 
            +
                requirements:
         | 
| 17 | 
            +
                - - ">="
         | 
| 18 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 19 | 
            +
                    version: '0'
         | 
| 20 | 
            +
              type: :runtime
         | 
| 21 | 
            +
              prerelease: false
         | 
| 22 | 
            +
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 23 | 
            +
                requirements:
         | 
| 24 | 
            +
                - - ">="
         | 
| 25 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 26 | 
            +
                    version: '0'
         | 
| 27 | 
            +
            - !ruby/object:Gem::Dependency
         | 
| 28 | 
            +
              name: bundler
         | 
| 29 | 
            +
              requirement: !ruby/object:Gem::Requirement
         | 
| 30 | 
            +
                requirements:
         | 
| 31 | 
            +
                - - "~>"
         | 
| 32 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 33 | 
            +
                    version: '1.7'
         | 
| 34 | 
            +
              type: :development
         | 
| 35 | 
            +
              prerelease: false
         | 
| 36 | 
            +
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 37 | 
            +
                requirements:
         | 
| 38 | 
            +
                - - "~>"
         | 
| 39 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 40 | 
            +
                    version: '1.7'
         | 
| 41 | 
            +
            - !ruby/object:Gem::Dependency
         | 
| 42 | 
            +
              name: rake
         | 
| 43 | 
            +
              requirement: !ruby/object:Gem::Requirement
         | 
| 44 | 
            +
                requirements:
         | 
| 45 | 
            +
                - - "~>"
         | 
| 46 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 47 | 
            +
                    version: '10.0'
         | 
| 48 | 
            +
              type: :development
         | 
| 49 | 
            +
              prerelease: false
         | 
| 50 | 
            +
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 51 | 
            +
                requirements:
         | 
| 52 | 
            +
                - - "~>"
         | 
| 53 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 54 | 
            +
                    version: '10.0'
         | 
| 55 | 
            +
            - !ruby/object:Gem::Dependency
         | 
| 56 | 
            +
              name: rspec
         | 
| 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: pry
         | 
| 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: 
         | 
| 84 | 
            +
            email:
         | 
| 85 | 
            +
            - naoty.k@gmail.com
         | 
| 86 | 
            +
            executables:
         | 
| 87 | 
            +
            - qiita-build
         | 
| 88 | 
            +
            extensions: []
         | 
| 89 | 
            +
            extra_rdoc_files: []
         | 
| 90 | 
            +
            files:
         | 
| 91 | 
            +
            - ".gitignore"
         | 
| 92 | 
            +
            - ".rspec"
         | 
| 93 | 
            +
            - ".travis.yml"
         | 
| 94 | 
            +
            - Gemfile
         | 
| 95 | 
            +
            - LICENSE.txt
         | 
| 96 | 
            +
            - README.md
         | 
| 97 | 
            +
            - Rakefile
         | 
| 98 | 
            +
            - bin/qiita-build
         | 
| 99 | 
            +
            - lib/qiita-build.rb
         | 
| 100 | 
            +
            - lib/qiita/build/builder.rb
         | 
| 101 | 
            +
            - lib/qiita/build/command.rb
         | 
| 102 | 
            +
            - lib/qiita/build/version.rb
         | 
| 103 | 
            +
            - qiita-build.gemspec
         | 
| 104 | 
            +
            - spec/fixtures/item.md
         | 
| 105 | 
            +
            - spec/fixtures/template.md
         | 
| 106 | 
            +
            - spec/qiita/build/builder_spec.rb
         | 
| 107 | 
            +
            - spec/spec_helper.rb
         | 
| 108 | 
            +
            homepage: https://github.com/naoty/qiita-build
         | 
| 109 | 
            +
            licenses:
         | 
| 110 | 
            +
            - MIT
         | 
| 111 | 
            +
            metadata: {}
         | 
| 112 | 
            +
            post_install_message: 
         | 
| 113 | 
            +
            rdoc_options: []
         | 
| 114 | 
            +
            require_paths:
         | 
| 115 | 
            +
            - lib
         | 
| 116 | 
            +
            required_ruby_version: !ruby/object:Gem::Requirement
         | 
| 117 | 
            +
              requirements:
         | 
| 118 | 
            +
              - - ">="
         | 
| 119 | 
            +
                - !ruby/object:Gem::Version
         | 
| 120 | 
            +
                  version: '0'
         | 
| 121 | 
            +
            required_rubygems_version: !ruby/object:Gem::Requirement
         | 
| 122 | 
            +
              requirements:
         | 
| 123 | 
            +
              - - ">="
         | 
| 124 | 
            +
                - !ruby/object:Gem::Version
         | 
| 125 | 
            +
                  version: '0'
         | 
| 126 | 
            +
            requirements: []
         | 
| 127 | 
            +
            rubyforge_project: 
         | 
| 128 | 
            +
            rubygems_version: 2.4.5
         | 
| 129 | 
            +
            signing_key: 
         | 
| 130 | 
            +
            specification_version: 4
         | 
| 131 | 
            +
            summary: Qiita item builder from a template and stdin
         | 
| 132 | 
            +
            test_files:
         | 
| 133 | 
            +
            - spec/fixtures/item.md
         | 
| 134 | 
            +
            - spec/fixtures/template.md
         | 
| 135 | 
            +
            - spec/qiita/build/builder_spec.rb
         | 
| 136 | 
            +
            - spec/spec_helper.rb
         |