codenize 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 +9 -0
- data/.rspec +2 -0
- data/.travis.yml +5 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +21 -0
- data/README.md +34 -0
- data/Rakefile +6 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/codenize.gemspec +28 -0
- data/exe/codenize +51 -0
- data/lib/codenize.rb +11 -0
- data/lib/codenize/client.rb +118 -0
- data/lib/codenize/logger.rb +17 -0
- data/lib/codenize/version.rb +3 -0
- data/lib/template/exe/_name.erb +18 -0
- data/lib/template/lib/_name.rb.erb +25 -0
- data/lib/template/lib/_name/cli.rb.erb +104 -0
- data/lib/template/lib/_name/client.rb.erb +78 -0
- data/lib/template/lib/_name/driver.rb.erb +37 -0
- data/lib/template/lib/_name/dsl.rb.erb +11 -0
- data/lib/template/lib/_name/dsl/context.rb.erb +73 -0
- data/lib/template/lib/_name/dsl/schema.yml.erb +26 -0
- data/lib/template/lib/_name/exporter.rb.erb +24 -0
- data/lib/template/lib/_name/ext/hash_ext.rb.erb +33 -0
- data/lib/template/lib/_name/ext/string_ext.rb.erb +28 -0
- data/lib/template/lib/_name/logger.rb.erb +28 -0
- data/lib/template/lib/_name/utils/diff.rb.erb +14 -0
- data/lib/template/lib/_name/utils/target_matcher.rb.erb +11 -0
- metadata +130 -0
    
        checksums.yaml
    ADDED
    
    | @@ -0,0 +1,7 @@ | |
| 1 | 
            +
            ---
         | 
| 2 | 
            +
            SHA1:
         | 
| 3 | 
            +
              metadata.gz: a94feed2fe084f6c08a51b5bd78ba38ad463b099
         | 
| 4 | 
            +
              data.tar.gz: ed15480c065734e37b61ee52029846aeed747de0
         | 
| 5 | 
            +
            SHA512:
         | 
| 6 | 
            +
              metadata.gz: b3a050ebcac39f82d690accb7cccff3e1d1a8533d26d5aed16001da28bb41ce4402306ba8ef318cd461eb68ebd1294f92fea4bb56dc2706146dcb61e29d747df
         | 
| 7 | 
            +
              data.tar.gz: ad572ddd4dcc820a6977c5d0d39a46b1b666b830543292278020ec7e040969868c96d703875f81ddfe6c421721a544af4c8d4daf259b0cac434f43feb8f8821f
         | 
    
        data/.gitignore
    ADDED
    
    
    
        data/.rspec
    ADDED
    
    
    
        data/.travis.yml
    ADDED
    
    
    
        data/Gemfile
    ADDED
    
    
    
        data/LICENSE.txt
    ADDED
    
    | @@ -0,0 +1,21 @@ | |
| 1 | 
            +
            The MIT License (MIT)
         | 
| 2 | 
            +
             | 
| 3 | 
            +
            Copyright (c) 2016 Genki Sugawara
         | 
| 4 | 
            +
             | 
| 5 | 
            +
            Permission is hereby granted, free of charge, to any person obtaining a copy
         | 
| 6 | 
            +
            of this software and associated documentation files (the "Software"), to deal
         | 
| 7 | 
            +
            in the Software without restriction, including without limitation the rights
         | 
| 8 | 
            +
            to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
         | 
| 9 | 
            +
            copies of the Software, and to permit persons to whom the Software is
         | 
| 10 | 
            +
            furnished to do so, subject to the following conditions:
         | 
| 11 | 
            +
             | 
| 12 | 
            +
            The above copyright notice and this permission notice shall be included in
         | 
| 13 | 
            +
            all copies or substantial portions of the Software.
         | 
| 14 | 
            +
             | 
| 15 | 
            +
            THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
         | 
| 16 | 
            +
            IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
         | 
| 17 | 
            +
            FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
         | 
| 18 | 
            +
            AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
         | 
| 19 | 
            +
            LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
         | 
| 20 | 
            +
            OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
         | 
| 21 | 
            +
            THE SOFTWARE.
         | 
    
        data/README.md
    ADDED
    
    | @@ -0,0 +1,34 @@ | |
| 1 | 
            +
            # Codenize
         | 
| 2 | 
            +
             | 
| 3 | 
            +
            Generate scaffold for [Codenize.tools](https://codenize.tools/).
         | 
| 4 | 
            +
             | 
| 5 | 
            +
            ## Installation
         | 
| 6 | 
            +
             | 
| 7 | 
            +
            Add this line to your application's Gemfile:
         | 
| 8 | 
            +
             | 
| 9 | 
            +
            ```ruby
         | 
| 10 | 
            +
            gem 'codenize'
         | 
| 11 | 
            +
            ```
         | 
| 12 | 
            +
             | 
| 13 | 
            +
            And then execute:
         | 
| 14 | 
            +
             | 
| 15 | 
            +
                $ bundle
         | 
| 16 | 
            +
             | 
| 17 | 
            +
            Or install it yourself as:
         | 
| 18 | 
            +
             | 
| 19 | 
            +
                $ gem install codenize
         | 
| 20 | 
            +
             | 
| 21 | 
            +
            ## Usage
         | 
| 22 | 
            +
             | 
| 23 | 
            +
            ```sh
         | 
| 24 | 
            +
            codenize -n hello
         | 
| 25 | 
            +
            cd hello
         | 
| 26 | 
            +
            sed -i.bak 's/TODO://' hello.gemspec
         | 
| 27 | 
            +
            sed -i.bak 's/spec.homepage/#spec.homepage/' hello.gemspec
         | 
| 28 | 
            +
            bundle exec ./exe/hello export hello.rb
         | 
| 29 | 
            +
            bundle exec ./exe/hello apply hello.rb
         | 
| 30 | 
            +
            ```
         | 
| 31 | 
            +
             | 
| 32 | 
            +
            ## Example implementation
         | 
| 33 | 
            +
             | 
| 34 | 
            +
            - https://github.com/winebarrel/ecman/commit/941555eee0ca59894efc9b3b3b52e8e66b5a63fa
         | 
    
        data/Rakefile
    ADDED
    
    
    
        data/bin/console
    ADDED
    
    | @@ -0,0 +1,14 @@ | |
| 1 | 
            +
            #!/usr/bin/env ruby
         | 
| 2 | 
            +
             | 
| 3 | 
            +
            require "bundler/setup"
         | 
| 4 | 
            +
            require "codenize"
         | 
| 5 | 
            +
             | 
| 6 | 
            +
            # You can add fixtures and/or initialization code here to make experimenting
         | 
| 7 | 
            +
            # with your gem easier. You can also use a different console, if you like.
         | 
| 8 | 
            +
             | 
| 9 | 
            +
            # (If you use this, don't forget to add pry to your Gemfile!)
         | 
| 10 | 
            +
            # require "pry"
         | 
| 11 | 
            +
            # Pry.start
         | 
| 12 | 
            +
             | 
| 13 | 
            +
            require "irb"
         | 
| 14 | 
            +
            IRB.start
         | 
    
        data/bin/setup
    ADDED
    
    
    
        data/codenize.gemspec
    ADDED
    
    | @@ -0,0 +1,28 @@ | |
| 1 | 
            +
            # coding: utf-8
         | 
| 2 | 
            +
            lib = File.expand_path('../lib', __FILE__)
         | 
| 3 | 
            +
            $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
         | 
| 4 | 
            +
            require 'codenize/version'
         | 
| 5 | 
            +
             | 
| 6 | 
            +
            Gem::Specification.new do |spec|
         | 
| 7 | 
            +
              spec.name          = 'codenize'
         | 
| 8 | 
            +
              spec.version       = Codenize::VERSION
         | 
| 9 | 
            +
              spec.authors       = ['Genki Sugawara']
         | 
| 10 | 
            +
              spec.email         = ['sugawara@cookpad.com']
         | 
| 11 | 
            +
             | 
| 12 | 
            +
              spec.summary       = %q{Generate scaffold for Codenize.tools.}
         | 
| 13 | 
            +
              spec.description   = %q{Generate scaffold for Codenize.tools.}
         | 
| 14 | 
            +
              spec.homepage      = 'https://github.com/winebarrel/codenize'
         | 
| 15 | 
            +
              spec.license       = 'MIT'
         | 
| 16 | 
            +
             | 
| 17 | 
            +
              spec.files         = `git ls-files -z`.split("\x0").reject do |f|
         | 
| 18 | 
            +
                f.match(%r{^(test|spec|features)/})
         | 
| 19 | 
            +
              end
         | 
| 20 | 
            +
              spec.bindir        = 'exe'
         | 
| 21 | 
            +
              spec.executables   = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
         | 
| 22 | 
            +
              spec.require_paths = ['lib']
         | 
| 23 | 
            +
             | 
| 24 | 
            +
              spec.add_dependency 'bundler'
         | 
| 25 | 
            +
              spec.add_dependency 'erbh'
         | 
| 26 | 
            +
              spec.add_development_dependency 'rake'
         | 
| 27 | 
            +
              spec.add_development_dependency 'rspec', '~> 3.0'
         | 
| 28 | 
            +
            end
         | 
    
        data/exe/codenize
    ADDED
    
    | @@ -0,0 +1,51 @@ | |
| 1 | 
            +
            #!/usr/bin/env ruby
         | 
| 2 | 
            +
            $: << File.expand_path('../../lib', __FILE__)
         | 
| 3 | 
            +
             | 
| 4 | 
            +
            require 'codenize'
         | 
| 5 | 
            +
            require 'optparse'
         | 
| 6 | 
            +
             | 
| 7 | 
            +
            Version = Codenize::VERSION
         | 
| 8 | 
            +
             | 
| 9 | 
            +
            def parse_options(argv)
         | 
| 10 | 
            +
              options = {
         | 
| 11 | 
            +
                dir: '.',
         | 
| 12 | 
            +
              }
         | 
| 13 | 
            +
             | 
| 14 | 
            +
              opt = OptionParser.new
         | 
| 15 | 
            +
              opt.on('-n', '--name NAME') {|v| options[:name]  = v    }
         | 
| 16 | 
            +
              opt.on('-d', '--dir PATH')  {|v| options[:dir]   = v    }
         | 
| 17 | 
            +
              opt.on('',   '--aws')       {    options[:aws]   = true }
         | 
| 18 | 
            +
              opt.on(''  , '--debug')     {    options[:debug] = true }
         | 
| 19 | 
            +
              opt.parse!(argv)
         | 
| 20 | 
            +
             | 
| 21 | 
            +
              unless options[:name]
         | 
| 22 | 
            +
                puts opt.help
         | 
| 23 | 
            +
                exit 1
         | 
| 24 | 
            +
              end
         | 
| 25 | 
            +
             | 
| 26 | 
            +
              options
         | 
| 27 | 
            +
            rescue => e
         | 
| 28 | 
            +
              $stderr.puts("[ERROR] #{e.message}")
         | 
| 29 | 
            +
              exit 1
         | 
| 30 | 
            +
            end
         | 
| 31 | 
            +
             | 
| 32 | 
            +
            def main(argv)
         | 
| 33 | 
            +
              options = parse_options(argv)
         | 
| 34 | 
            +
              client = Codenize::Client.new(options)
         | 
| 35 | 
            +
              logger = Codenize::Logger.instance
         | 
| 36 | 
            +
             | 
| 37 | 
            +
              if options[:debug]
         | 
| 38 | 
            +
                logger.set_debug(options[:debug])
         | 
| 39 | 
            +
              end
         | 
| 40 | 
            +
             | 
| 41 | 
            +
              client.generate
         | 
| 42 | 
            +
            rescue => e
         | 
| 43 | 
            +
              if options[:debug]
         | 
| 44 | 
            +
                raise e
         | 
| 45 | 
            +
              else
         | 
| 46 | 
            +
                $stderr.puts("[ERROR] #{e.message}")
         | 
| 47 | 
            +
                exit 1
         | 
| 48 | 
            +
              end
         | 
| 49 | 
            +
            end
         | 
| 50 | 
            +
             | 
| 51 | 
            +
            main(ARGV)
         | 
    
        data/lib/codenize.rb
    ADDED
    
    
| @@ -0,0 +1,118 @@ | |
| 1 | 
            +
            class Codenize::Client
         | 
| 2 | 
            +
              def initialize(options = {})
         | 
| 3 | 
            +
                @options = options
         | 
| 4 | 
            +
                @logger = Codenize::Logger.instance
         | 
| 5 | 
            +
              end
         | 
| 6 | 
            +
             | 
| 7 | 
            +
              def generate
         | 
| 8 | 
            +
                FileUtils.chdir(@options[:dir]) do
         | 
| 9 | 
            +
                  name = @options[:name]
         | 
| 10 | 
            +
             | 
| 11 | 
            +
                  if File.exist?(name)
         | 
| 12 | 
            +
                    raise "directory already exists: #{name}"
         | 
| 13 | 
            +
                  end
         | 
| 14 | 
            +
             | 
| 15 | 
            +
                  Bundler.with_clean_env do
         | 
| 16 | 
            +
                    sh 'bundle', 'gem', name or raise 'bundle gem faild'
         | 
| 17 | 
            +
                  end
         | 
| 18 | 
            +
             | 
| 19 | 
            +
                  FileUtils.chdir(name) do
         | 
| 20 | 
            +
                    update_files(name)
         | 
| 21 | 
            +
                    create_files(name)
         | 
| 22 | 
            +
                    @logger.info 'Adding generated code to git repo'
         | 
| 23 | 
            +
                    sh 'git', 'add', '.'
         | 
| 24 | 
            +
                  end
         | 
| 25 | 
            +
                end
         | 
| 26 | 
            +
              end
         | 
| 27 | 
            +
             | 
| 28 | 
            +
              private
         | 
| 29 | 
            +
             | 
| 30 | 
            +
              def update_files(name)
         | 
| 31 | 
            +
                update!("#{name}.gemspec") do |content|
         | 
| 32 | 
            +
                  content.sub!(/end\z/, ERBh.erbh(<<-EOS, aws: @options[:aws]))
         | 
| 33 | 
            +
              <%- if @aws -%>
         | 
| 34 | 
            +
              spec.add_dependency 'aws-sdk'
         | 
| 35 | 
            +
              <%- end -%>
         | 
| 36 | 
            +
              spec.add_dependency 'diffy'
         | 
| 37 | 
            +
              spec.add_dependency 'dslh', '>= 0.4.6'
         | 
| 38 | 
            +
              spec.add_dependency 'hashie'
         | 
| 39 | 
            +
              spec.add_dependency 'kwalify'
         | 
| 40 | 
            +
              #spec.add_dependency 'parallel'
         | 
| 41 | 
            +
              #spec.add_dependency 'pp_sort_hash'
         | 
| 42 | 
            +
              spec.add_dependency 'term-ansicolor'
         | 
| 43 | 
            +
              spec.add_dependency 'thor'
         | 
| 44 | 
            +
            end
         | 
| 45 | 
            +
                  EOS
         | 
| 46 | 
            +
                end
         | 
| 47 | 
            +
              end
         | 
| 48 | 
            +
             | 
| 49 | 
            +
              def create_files(name)
         | 
| 50 | 
            +
                base_dir = File.expand_path('../../template', __FILE__)
         | 
| 51 | 
            +
             | 
| 52 | 
            +
                Dir.glob("#{base_dir}/**/*.erb") do |tmpl|
         | 
| 53 | 
            +
                  path = tmpl.sub(%r|\A#{Regexp.escape(base_dir)}/|, '').split('/').map {|d|
         | 
| 54 | 
            +
                    replace_name(d, name)
         | 
| 55 | 
            +
                  }.join('/').sub(/\.erb\z/, '')
         | 
| 56 | 
            +
             | 
| 57 | 
            +
                  @logger.info("      create #{path}")
         | 
| 58 | 
            +
             | 
| 59 | 
            +
                  FileUtils.mkdir_p(File.dirname(path))
         | 
| 60 | 
            +
             | 
| 61 | 
            +
                  open(path, 'wb') do |file|
         | 
| 62 | 
            +
                    file.puts ERBh.erbh(File.read(tmpl),
         | 
| 63 | 
            +
                      name: name,
         | 
| 64 | 
            +
                      const_name: Bundler::Thor::Util.camel_case(name),
         | 
| 65 | 
            +
                      aws: @options[:aws],
         | 
| 66 | 
            +
                    ).strip
         | 
| 67 | 
            +
                  end
         | 
| 68 | 
            +
             | 
| 69 | 
            +
                  if path =~ %r|\Aexe/|
         | 
| 70 | 
            +
                    FileUtils.chmod(0755, path)
         | 
| 71 | 
            +
                  end
         | 
| 72 | 
            +
                end
         | 
| 73 | 
            +
              end
         | 
| 74 | 
            +
             | 
| 75 | 
            +
              def sh(*args)
         | 
| 76 | 
            +
                status = nil
         | 
| 77 | 
            +
             | 
| 78 | 
            +
                Open3::popen3(*args) do |stdin, stdout, stderr, wait_thr|
         | 
| 79 | 
            +
                  [stdin, stdout, stderr].each {|io| io.sync = true }
         | 
| 80 | 
            +
                  errmsg = ''
         | 
| 81 | 
            +
             | 
| 82 | 
            +
                  thr_out = Thread.start do
         | 
| 83 | 
            +
                    stdout.each do |line|
         | 
| 84 | 
            +
                      $stdout.print line
         | 
| 85 | 
            +
                    end
         | 
| 86 | 
            +
                  end
         | 
| 87 | 
            +
             | 
| 88 | 
            +
                  thr_err = Thread.start do
         | 
| 89 | 
            +
                    stderr.each do |line|
         | 
| 90 | 
            +
                      $stderr.print line
         | 
| 91 | 
            +
                      errmsg << line
         | 
| 92 | 
            +
                    end
         | 
| 93 | 
            +
                  end
         | 
| 94 | 
            +
             | 
| 95 | 
            +
                  wait_thr.join
         | 
| 96 | 
            +
                  thr_out.join
         | 
| 97 | 
            +
                  thr_err.join
         | 
| 98 | 
            +
                  status = wait_thr.value
         | 
| 99 | 
            +
                end
         | 
| 100 | 
            +
             | 
| 101 | 
            +
                status.success?
         | 
| 102 | 
            +
              end
         | 
| 103 | 
            +
             | 
| 104 | 
            +
              def update!(path)
         | 
| 105 | 
            +
                @logger.info("      update #{path}")
         | 
| 106 | 
            +
             | 
| 107 | 
            +
                content = File.read(path)
         | 
| 108 | 
            +
                yield(content.strip!)
         | 
| 109 | 
            +
             | 
| 110 | 
            +
                open(path, 'wb') do |file|
         | 
| 111 | 
            +
                  file.puts content.strip
         | 
| 112 | 
            +
                end
         | 
| 113 | 
            +
              end
         | 
| 114 | 
            +
             | 
| 115 | 
            +
              def replace_name(path, name)
         | 
| 116 | 
            +
                path.sub(/\A_name\b/, name)
         | 
| 117 | 
            +
              end
         | 
| 118 | 
            +
            end
         | 
| @@ -0,0 +1,17 @@ | |
| 1 | 
            +
            class Codenize::Logger < ::Logger
         | 
| 2 | 
            +
              include Singleton
         | 
| 3 | 
            +
             | 
| 4 | 
            +
              def initialize
         | 
| 5 | 
            +
                super($stdout)
         | 
| 6 | 
            +
             | 
| 7 | 
            +
                self.formatter = proc do |severity, datetime, progname, msg|
         | 
| 8 | 
            +
                  "#{msg}\n"
         | 
| 9 | 
            +
                end
         | 
| 10 | 
            +
             | 
| 11 | 
            +
                self.level = Logger::INFO
         | 
| 12 | 
            +
              end
         | 
| 13 | 
            +
             | 
| 14 | 
            +
              def set_debug(value)
         | 
| 15 | 
            +
                self.level = value ? Logger::DEBUG : Logger::INFO
         | 
| 16 | 
            +
              end
         | 
| 17 | 
            +
            end
         | 
| @@ -0,0 +1,18 @@ | |
| 1 | 
            +
            #!/usr/bin/env ruby
         | 
| 2 | 
            +
            $: << File.expand_path('../../lib', __FILE__)
         | 
| 3 | 
            +
             | 
| 4 | 
            +
            require 'thor'
         | 
| 5 | 
            +
            require '<%= @name %>'
         | 
| 6 | 
            +
            require '<%= @name %>/cli'
         | 
| 7 | 
            +
             | 
| 8 | 
            +
            debug = ARGV.any? {|i| i == '--debug' }
         | 
| 9 | 
            +
             | 
| 10 | 
            +
            begin
         | 
| 11 | 
            +
              <%= @const_name %>::CLI.start(ARGV)
         | 
| 12 | 
            +
            rescue => e
         | 
| 13 | 
            +
              if debug
         | 
| 14 | 
            +
                raise e
         | 
| 15 | 
            +
              else
         | 
| 16 | 
            +
                $stderr.puts "ERROR: #{e}".red
         | 
| 17 | 
            +
              end
         | 
| 18 | 
            +
            end
         | 
| @@ -0,0 +1,25 @@ | |
| 1 | 
            +
            <%- if @aws -%>
         | 
| 2 | 
            +
            require 'aws-sdk'
         | 
| 3 | 
            +
            <%- end -%>
         | 
| 4 | 
            +
            require 'diffy'
         | 
| 5 | 
            +
            require 'dslh'
         | 
| 6 | 
            +
            require 'hashie'
         | 
| 7 | 
            +
            require 'json'
         | 
| 8 | 
            +
            #require 'parallel'
         | 
| 9 | 
            +
            require 'pp'
         | 
| 10 | 
            +
            #require 'pp_sort_hash'
         | 
| 11 | 
            +
            require 'logger'
         | 
| 12 | 
            +
            require 'singleton'
         | 
| 13 | 
            +
            require 'term/ansicolor'
         | 
| 14 | 
            +
             | 
| 15 | 
            +
            require '<%= @name %>/version'
         | 
| 16 | 
            +
            #require '<%= @name %>/ext/hash_ext'
         | 
| 17 | 
            +
            require '<%= @name %>/ext/string_ext'
         | 
| 18 | 
            +
            require '<%= @name %>/logger'
         | 
| 19 | 
            +
            require '<%= @name %>/utils/diff'
         | 
| 20 | 
            +
            require '<%= @name %>/utils/target_matcher'
         | 
| 21 | 
            +
            require '<%= @name %>/client'
         | 
| 22 | 
            +
            require '<%= @name %>/driver'
         | 
| 23 | 
            +
            require '<%= @name %>/dsl'
         | 
| 24 | 
            +
            require '<%= @name %>/dsl/context'
         | 
| 25 | 
            +
            require '<%= @name %>/exporter'
         | 
| @@ -0,0 +1,104 @@ | |
| 1 | 
            +
            class <%= @const_name %>::CLI < Thor
         | 
| 2 | 
            +
              include <%= @const_name %>::Logger::Helper
         | 
| 3 | 
            +
             | 
| 4 | 
            +
              MAGIC_COMMENT = <<-EOS
         | 
| 5 | 
            +
              # -*- mode: ruby -*-
         | 
| 6 | 
            +
              # vi: set ft=ruby :
         | 
| 7 | 
            +
              EOS
         | 
| 8 | 
            +
             | 
| 9 | 
            +
              <%- if @aws -%>
         | 
| 10 | 
            +
              class_option :'access-key', aliases: '-k'
         | 
| 11 | 
            +
              class_option :'secret-key', aliases: '-s'
         | 
| 12 | 
            +
              class_option :region,       aliases: '-r'
         | 
| 13 | 
            +
             | 
| 14 | 
            +
              class_option :profile
         | 
| 15 | 
            +
              class_option :'credentials-path'
         | 
| 16 | 
            +
              <%- end -%>
         | 
| 17 | 
            +
             | 
| 18 | 
            +
              class_option :target
         | 
| 19 | 
            +
              class_option :color, type: :boolean, default: true
         | 
| 20 | 
            +
              class_option :debug, type: :boolean, default: false
         | 
| 21 | 
            +
             | 
| 22 | 
            +
              desc 'apply FILE', 'apply'
         | 
| 23 | 
            +
              option :'dry-run', type: :boolean, default: false
         | 
| 24 | 
            +
              def apply(file)
         | 
| 25 | 
            +
                cli = client(options)
         | 
| 26 | 
            +
             | 
| 27 | 
            +
                log(:info, "Apply `#{file}`")
         | 
| 28 | 
            +
                updated = client(options).apply(file)
         | 
| 29 | 
            +
             | 
| 30 | 
            +
                unless updated
         | 
| 31 | 
            +
                  log(:info, 'No change'.intense_blue)
         | 
| 32 | 
            +
                end
         | 
| 33 | 
            +
              end
         | 
| 34 | 
            +
             | 
| 35 | 
            +
              desc 'export [FILE]', 'export'
         | 
| 36 | 
            +
              def export(file = nil)
         | 
| 37 | 
            +
                cli = client(options)
         | 
| 38 | 
            +
                dsl = cli.export
         | 
| 39 | 
            +
             | 
| 40 | 
            +
                if file.nil? or file == '-'
         | 
| 41 | 
            +
                  puts dsl
         | 
| 42 | 
            +
                else
         | 
| 43 | 
            +
                  log(:info, "Export to `#{file}`")
         | 
| 44 | 
            +
                  open(file, 'wb') {|f| f.puts dsl }
         | 
| 45 | 
            +
                end
         | 
| 46 | 
            +
              end
         | 
| 47 | 
            +
             | 
| 48 | 
            +
              desc 'version', 'show version'
         | 
| 49 | 
            +
              def version
         | 
| 50 | 
            +
                puts <%= @const_name %>::VERSION
         | 
| 51 | 
            +
              end
         | 
| 52 | 
            +
             | 
| 53 | 
            +
              private
         | 
| 54 | 
            +
             | 
| 55 | 
            +
              def client(options)
         | 
| 56 | 
            +
                options = options.dup
         | 
| 57 | 
            +
                underscoreize!(options)
         | 
| 58 | 
            +
             | 
| 59 | 
            +
                String.colorize = options[:color]
         | 
| 60 | 
            +
                <%= @const_name %>::Logger.instance.set_debug(options[:debug])
         | 
| 61 | 
            +
             | 
| 62 | 
            +
                <%- if @aws -%>
         | 
| 63 | 
            +
                options[:aws] = {}
         | 
| 64 | 
            +
             | 
| 65 | 
            +
                [:access_key_id, :secret_access_key, :region].each do |key|
         | 
| 66 | 
            +
                  if value = options.delete(key)
         | 
| 67 | 
            +
                    options[:aws][key] = value
         | 
| 68 | 
            +
                  end
         | 
| 69 | 
            +
                end
         | 
| 70 | 
            +
             | 
| 71 | 
            +
                {
         | 
| 72 | 
            +
                  profile: :profile_name,
         | 
| 73 | 
            +
                  credentials_path: :path,
         | 
| 74 | 
            +
                }.each do |switch_key, option_key|
         | 
| 75 | 
            +
                  if value = options.delete(switch_key)
         | 
| 76 | 
            +
                    options[:aws][:credentials] ||= {}
         | 
| 77 | 
            +
                    options[:aws][:credentials][option_key] = value
         | 
| 78 | 
            +
                  end
         | 
| 79 | 
            +
                end
         | 
| 80 | 
            +
             | 
| 81 | 
            +
                Aws.config.update(options[:aws])
         | 
| 82 | 
            +
             | 
| 83 | 
            +
                if options[:debug]
         | 
| 84 | 
            +
                  Aws.config.update(
         | 
| 85 | 
            +
                    http_wire_trace: true,
         | 
| 86 | 
            +
                    logger: <%= @const_name %>::Logger.instance
         | 
| 87 | 
            +
                  )
         | 
| 88 | 
            +
                end
         | 
| 89 | 
            +
                <%- end -%>
         | 
| 90 | 
            +
             | 
| 91 | 
            +
                cli = <%= @const_name %>::Client.new(options)
         | 
| 92 | 
            +
              end
         | 
| 93 | 
            +
             | 
| 94 | 
            +
              def underscoreize!(options)
         | 
| 95 | 
            +
                options.keys.each do |key|
         | 
| 96 | 
            +
                  if key.to_s =~ /-/
         | 
| 97 | 
            +
                    if value = options.delete(key)
         | 
| 98 | 
            +
                      key = key.to_s.gsub('-', '_').to_sym
         | 
| 99 | 
            +
                      options[key] = value
         | 
| 100 | 
            +
                    end
         | 
| 101 | 
            +
                  end
         | 
| 102 | 
            +
                end
         | 
| 103 | 
            +
              end
         | 
| 104 | 
            +
            end
         | 
| @@ -0,0 +1,78 @@ | |
| 1 | 
            +
            class <%= @const_name %>::Client
         | 
| 2 | 
            +
              include <%= @const_name %>::Utils::TargetMatcher
         | 
| 3 | 
            +
             | 
| 4 | 
            +
              def initialize(options = {})
         | 
| 5 | 
            +
                @options = options
         | 
| 6 | 
            +
                # FIXME: create api client
         | 
| 7 | 
            +
                @client = @options[:client] # || YourService::Client.new
         | 
| 8 | 
            +
                @driver = <%= @const_name %>::Driver.new(@client, options)
         | 
| 9 | 
            +
                @exporter = <%= @const_name %>::Exporter.new(@client, @options)
         | 
| 10 | 
            +
              end
         | 
| 11 | 
            +
             | 
| 12 | 
            +
              def export
         | 
| 13 | 
            +
                expected = @exporter.export
         | 
| 14 | 
            +
                <%= @const_name %>::DSL.convert(expected)
         | 
| 15 | 
            +
              end
         | 
| 16 | 
            +
             | 
| 17 | 
            +
              def apply(file)
         | 
| 18 | 
            +
                expected = load_file(file)
         | 
| 19 | 
            +
                actual =  @exporter.export
         | 
| 20 | 
            +
             | 
| 21 | 
            +
                updated = walk(expected, actual)
         | 
| 22 | 
            +
             | 
| 23 | 
            +
                if @options[:dry_run]
         | 
| 24 | 
            +
                  false
         | 
| 25 | 
            +
                else
         | 
| 26 | 
            +
                  updated
         | 
| 27 | 
            +
                end
         | 
| 28 | 
            +
              end
         | 
| 29 | 
            +
             | 
| 30 | 
            +
              private
         | 
| 31 | 
            +
             | 
| 32 | 
            +
              def walk(expected, actual)
         | 
| 33 | 
            +
                # FIXME:
         | 
| 34 | 
            +
                warn 'FIXME: Client#walk() not implemented'.yellow
         | 
| 35 | 
            +
             | 
| 36 | 
            +
                # FIXME: this is an example
         | 
| 37 | 
            +
                expected = expected.fetch('server')
         | 
| 38 | 
            +
                actual = actual.fetch('server')
         | 
| 39 | 
            +
             | 
| 40 | 
            +
                updated = false
         | 
| 41 | 
            +
             | 
| 42 | 
            +
                expected.each do |name, expected_attrs|
         | 
| 43 | 
            +
                  next unless target?(name)
         | 
| 44 | 
            +
             | 
| 45 | 
            +
                  actual_attrs = actual.delete(name)
         | 
| 46 | 
            +
             | 
| 47 | 
            +
                  if actual_attrs
         | 
| 48 | 
            +
                    if expected_attrs != actual_attrs
         | 
| 49 | 
            +
                      @driver.update(name, expected_attrs, actual_attrs)
         | 
| 50 | 
            +
                      updated = true
         | 
| 51 | 
            +
                    end
         | 
| 52 | 
            +
                  else
         | 
| 53 | 
            +
                    @driver.create(name, expected_attrs)
         | 
| 54 | 
            +
                    updated = true
         | 
| 55 | 
            +
                  end
         | 
| 56 | 
            +
                end
         | 
| 57 | 
            +
             | 
| 58 | 
            +
                actual.each do |name, actual_attrs|
         | 
| 59 | 
            +
                  next unless target?(name)
         | 
| 60 | 
            +
                  @driver.delete(name, actual_attrs)
         | 
| 61 | 
            +
                  updated = true
         | 
| 62 | 
            +
                end
         | 
| 63 | 
            +
             | 
| 64 | 
            +
                updated
         | 
| 65 | 
            +
              end
         | 
| 66 | 
            +
             | 
| 67 | 
            +
              def load_file(file)
         | 
| 68 | 
            +
                if file.kind_of?(String)
         | 
| 69 | 
            +
                  open(file) do |f|
         | 
| 70 | 
            +
                    <%= @const_name %>::DSL.parse(f.read, file, @options)
         | 
| 71 | 
            +
                  end
         | 
| 72 | 
            +
                elsif file.respond_to?(:read)
         | 
| 73 | 
            +
                  <%= @const_name %>::DSL.parse(file.read, file.path, @options)
         | 
| 74 | 
            +
                else
         | 
| 75 | 
            +
                  raise TypeError, "can't convert #{file} into File"
         | 
| 76 | 
            +
                end
         | 
| 77 | 
            +
              end
         | 
| 78 | 
            +
            end
         | 
| @@ -0,0 +1,37 @@ | |
| 1 | 
            +
            class <%= @const_name %>::Driver
         | 
| 2 | 
            +
              include <%= @const_name %>::Logger::Helper
         | 
| 3 | 
            +
              include <%= @const_name %>::Utils::Diff
         | 
| 4 | 
            +
             | 
| 5 | 
            +
              def initialize(client, options = {})
         | 
| 6 | 
            +
                @client = client
         | 
| 7 | 
            +
                @options = options
         | 
| 8 | 
            +
              end
         | 
| 9 | 
            +
             | 
| 10 | 
            +
              def create(name, attrs)
         | 
| 11 | 
            +
                log(:info, "Create '#{name}'", color: :cyan)
         | 
| 12 | 
            +
             | 
| 13 | 
            +
                unless @options[:dry_run]
         | 
| 14 | 
            +
                  # FIXME:
         | 
| 15 | 
            +
                  warn 'FIXME: Driver#create() not implemented'.yellow
         | 
| 16 | 
            +
                end
         | 
| 17 | 
            +
              end
         | 
| 18 | 
            +
             | 
| 19 | 
            +
              def delete(name, attrs)
         | 
| 20 | 
            +
                log(:info, "Delete '#{name}'", color: :red)
         | 
| 21 | 
            +
             | 
| 22 | 
            +
                unless @options[:dry_run]
         | 
| 23 | 
            +
                  # FIXME:
         | 
| 24 | 
            +
                  warn 'FIXME: Driver#delete() not implemented'.yellow
         | 
| 25 | 
            +
                end
         | 
| 26 | 
            +
              end
         | 
| 27 | 
            +
             | 
| 28 | 
            +
              def update(name, attrs, old_attrs)
         | 
| 29 | 
            +
                log(:info, "Update '#{name}'", color: :green)
         | 
| 30 | 
            +
                log(:info, diff(old_attrs, attrs, color: @options[:color]), color: false)
         | 
| 31 | 
            +
             | 
| 32 | 
            +
                unless @options[:dry_run]
         | 
| 33 | 
            +
                  # FIXME:
         | 
| 34 | 
            +
                  warn 'FIXME: Driver#update() not implemented'.yellow
         | 
| 35 | 
            +
                end
         | 
| 36 | 
            +
              end
         | 
| 37 | 
            +
            end
         | 
| @@ -0,0 +1,73 @@ | |
| 1 | 
            +
            class <%= @const_name %>::DSL::Context
         | 
| 2 | 
            +
              include <%= @const_name %>::Logger::Helper
         | 
| 3 | 
            +
             | 
| 4 | 
            +
              SCHEMA_YML = File.expand_path('../schema.yml', __FILE__)
         | 
| 5 | 
            +
             | 
| 6 | 
            +
              def self.eval(dsl, path, options = {})
         | 
| 7 | 
            +
                self.new(path, options).eval(dsl)
         | 
| 8 | 
            +
              end
         | 
| 9 | 
            +
             | 
| 10 | 
            +
              def initialize(path, options = {})
         | 
| 11 | 
            +
                @path = path
         | 
| 12 | 
            +
                @options = options
         | 
| 13 | 
            +
                @result = {}
         | 
| 14 | 
            +
                @templates = {}
         | 
| 15 | 
            +
             | 
| 16 | 
            +
                @context = Hashie::Mash.new(
         | 
| 17 | 
            +
                  path: path,
         | 
| 18 | 
            +
                  options: options,
         | 
| 19 | 
            +
                )
         | 
| 20 | 
            +
              end
         | 
| 21 | 
            +
             | 
| 22 | 
            +
              def eval(dsl)
         | 
| 23 | 
            +
                scope_hook = proc do |scope|
         | 
| 24 | 
            +
                  scope.instance_eval(<<-'EOS')
         | 
| 25 | 
            +
                    def template(name, &block)
         | 
| 26 | 
            +
                      @templates[name.to_s] = block
         | 
| 27 | 
            +
                    end
         | 
| 28 | 
            +
             | 
| 29 | 
            +
                    def include_template(template_name, context = {})
         | 
| 30 | 
            +
                      tmpl = @templates[template_name.to_s]
         | 
| 31 | 
            +
             | 
| 32 | 
            +
                      unless tmpl
         | 
| 33 | 
            +
                        raise "Template '#{template_name}' is not defined"
         | 
| 34 | 
            +
                      end
         | 
| 35 | 
            +
             | 
| 36 | 
            +
                      context_orig = @context
         | 
| 37 | 
            +
                      @context = @context.merge(context)
         | 
| 38 | 
            +
                      instance_eval(&tmpl)
         | 
| 39 | 
            +
                      @context = context_orig
         | 
| 40 | 
            +
                    end
         | 
| 41 | 
            +
             | 
| 42 | 
            +
                    def context
         | 
| 43 | 
            +
                      @context
         | 
| 44 | 
            +
                    end
         | 
| 45 | 
            +
                  EOS
         | 
| 46 | 
            +
                end
         | 
| 47 | 
            +
             | 
| 48 | 
            +
                scope_vars = {templates: @templates, context: @context}
         | 
| 49 | 
            +
             | 
| 50 | 
            +
                begin
         | 
| 51 | 
            +
                  Dslh.eval(dsl, {
         | 
| 52 | 
            +
                    filename: @path,
         | 
| 53 | 
            +
                    allow_empty_args: true,
         | 
| 54 | 
            +
                    scope_hook: scope_hook,
         | 
| 55 | 
            +
                    scope_vars: scope_vars,
         | 
| 56 | 
            +
                    root_identify: true,
         | 
| 57 | 
            +
                    schema_path: SCHEMA_YML,
         | 
| 58 | 
            +
                  })
         | 
| 59 | 
            +
                rescue Dslh::ValidationError => e
         | 
| 60 | 
            +
                  if @options[:debug]
         | 
| 61 | 
            +
                    log(:debug, "Parsed DSL: \n" + e.data.pretty_inspect)
         | 
| 62 | 
            +
                  end
         | 
| 63 | 
            +
             | 
| 64 | 
            +
                  raise e
         | 
| 65 | 
            +
                end
         | 
| 66 | 
            +
              end
         | 
| 67 | 
            +
             | 
| 68 | 
            +
              private
         | 
| 69 | 
            +
             | 
| 70 | 
            +
              def template(name, &block)
         | 
| 71 | 
            +
                @templates[name.to_s] = block
         | 
| 72 | 
            +
              end
         | 
| 73 | 
            +
            end
         | 
| @@ -0,0 +1,26 @@ | |
| 1 | 
            +
            # FIXME: this is an example
         | 
| 2 | 
            +
            # see http://www.kuwata-lab.com/kwalify/ruby/users-guide.html
         | 
| 3 | 
            +
            type: map
         | 
| 4 | 
            +
            mapping:
         | 
| 5 | 
            +
              "server":
         | 
| 6 | 
            +
                type: seq
         | 
| 7 | 
            +
                sequence:
         | 
| 8 | 
            +
                  - type: map
         | 
| 9 | 
            +
                    mapping:
         | 
| 10 | 
            +
                      "_id":
         | 
| 11 | 
            +
                        type: str
         | 
| 12 | 
            +
                        required: yes
         | 
| 13 | 
            +
                      "middleware":
         | 
| 14 | 
            +
                        type: str
         | 
| 15 | 
            +
                        required: yes
         | 
| 16 | 
            +
                      "tag":
         | 
| 17 | 
            +
                        type: seq
         | 
| 18 | 
            +
                        sequence:
         | 
| 19 | 
            +
                          - type: map
         | 
| 20 | 
            +
                            mapping:
         | 
| 21 | 
            +
                              "key":
         | 
| 22 | 
            +
                                type: str
         | 
| 23 | 
            +
                                required: true
         | 
| 24 | 
            +
                              "value":
         | 
| 25 | 
            +
                                type: str
         | 
| 26 | 
            +
                                required: true
         | 
| @@ -0,0 +1,24 @@ | |
| 1 | 
            +
            class <%= @const_name %>::Exporter
         | 
| 2 | 
            +
              include <%= @const_name %>::Utils::TargetMatcher
         | 
| 3 | 
            +
             | 
| 4 | 
            +
              def initialize(client, options = {})
         | 
| 5 | 
            +
                @client = client
         | 
| 6 | 
            +
                @options = options
         | 
| 7 | 
            +
              end
         | 
| 8 | 
            +
             | 
| 9 | 
            +
              def export
         | 
| 10 | 
            +
                # FIXME:
         | 
| 11 | 
            +
                warn 'FIXME: Exporter#export() not implemented'.yellow
         | 
| 12 | 
            +
             | 
| 13 | 
            +
                # FIXME: this is an example
         | 
| 14 | 
            +
                {"server"=>
         | 
| 15 | 
            +
                  {"web"=>
         | 
| 16 | 
            +
                    {"middleware"=>"nginx",
         | 
| 17 | 
            +
                     "tag"=>
         | 
| 18 | 
            +
                      [{"key"=>"Name", "value"=>"web-001"}, {"key"=>"Role", "value"=>"Web"}]},
         | 
| 19 | 
            +
                   "database"=>
         | 
| 20 | 
            +
                    {"middleware"=>"mysql",
         | 
| 21 | 
            +
                     "tag"=>
         | 
| 22 | 
            +
                      [{"key"=>"Name", "value"=>"db-002"}, {"key"=>"Role", "value"=>"DB"}]}}}
         | 
| 23 | 
            +
              end
         | 
| 24 | 
            +
            end
         | 
| @@ -0,0 +1,33 @@ | |
| 1 | 
            +
            module <%= @const_name %>::Ext
         | 
| 2 | 
            +
              module HashExt
         | 
| 3 | 
            +
                def sort_array!
         | 
| 4 | 
            +
                  keys.each do |key|
         | 
| 5 | 
            +
                    value = self[key]
         | 
| 6 | 
            +
                    self[key] = sort_array0(value)
         | 
| 7 | 
            +
                  end
         | 
| 8 | 
            +
             | 
| 9 | 
            +
                  self
         | 
| 10 | 
            +
                end
         | 
| 11 | 
            +
             | 
| 12 | 
            +
                private
         | 
| 13 | 
            +
             | 
| 14 | 
            +
                def sort_array0(value)
         | 
| 15 | 
            +
                  case value
         | 
| 16 | 
            +
                  when Hash
         | 
| 17 | 
            +
                    new_value = {}
         | 
| 18 | 
            +
             | 
| 19 | 
            +
                    value.each do |k, v|
         | 
| 20 | 
            +
                      new_value[k] = sort_array0(v)
         | 
| 21 | 
            +
                    end
         | 
| 22 | 
            +
             | 
| 23 | 
            +
                    new_value
         | 
| 24 | 
            +
                  when Array
         | 
| 25 | 
            +
                    value.map {|v| sort_array0(v) }.sort_by(&:to_s)
         | 
| 26 | 
            +
                  else
         | 
| 27 | 
            +
                    value
         | 
| 28 | 
            +
                  end
         | 
| 29 | 
            +
                end
         | 
| 30 | 
            +
              end
         | 
| 31 | 
            +
            end
         | 
| 32 | 
            +
             | 
| 33 | 
            +
            Hash.send(:include, <%= @const_name %>::Ext::HashExt)
         | 
| @@ -0,0 +1,28 @@ | |
| 1 | 
            +
            module <%= @const_name %>::Ext
         | 
| 2 | 
            +
              module StringExt
         | 
| 3 | 
            +
                module ClassMethods
         | 
| 4 | 
            +
                  def colorize=(value)
         | 
| 5 | 
            +
                    @colorize = value
         | 
| 6 | 
            +
                  end
         | 
| 7 | 
            +
             | 
| 8 | 
            +
                  def colorize
         | 
| 9 | 
            +
                    @colorize
         | 
| 10 | 
            +
                  end
         | 
| 11 | 
            +
                end # ClassMethods
         | 
| 12 | 
            +
             | 
| 13 | 
            +
                Term::ANSIColor::Attribute.named_attributes.each do |attribute|
         | 
| 14 | 
            +
                  class_eval(<<-EOS, __FILE__, __LINE__ + 1)
         | 
| 15 | 
            +
                    def #{attribute.name}
         | 
| 16 | 
            +
                      if String.colorize
         | 
| 17 | 
            +
                        Term::ANSIColor.send(#{attribute.name.inspect}, self)
         | 
| 18 | 
            +
                      else
         | 
| 19 | 
            +
                        self
         | 
| 20 | 
            +
                      end
         | 
| 21 | 
            +
                    end
         | 
| 22 | 
            +
                  EOS
         | 
| 23 | 
            +
                end
         | 
| 24 | 
            +
              end
         | 
| 25 | 
            +
            end
         | 
| 26 | 
            +
             | 
| 27 | 
            +
            String.send(:include, <%= @const_name %>::Ext::StringExt)
         | 
| 28 | 
            +
            String.extend(<%= @const_name %>::Ext::StringExt::ClassMethods)
         | 
| @@ -0,0 +1,28 @@ | |
| 1 | 
            +
            class <%= @const_name %>::Logger < ::Logger
         | 
| 2 | 
            +
              include Singleton
         | 
| 3 | 
            +
             | 
| 4 | 
            +
              def initialize
         | 
| 5 | 
            +
                super($stdout)
         | 
| 6 | 
            +
             | 
| 7 | 
            +
                self.formatter = proc do |severity, datetime, progname, msg|
         | 
| 8 | 
            +
                  "#{msg}\n"
         | 
| 9 | 
            +
                end
         | 
| 10 | 
            +
             | 
| 11 | 
            +
                self.level = Logger::INFO
         | 
| 12 | 
            +
              end
         | 
| 13 | 
            +
             | 
| 14 | 
            +
              def set_debug(value)
         | 
| 15 | 
            +
                self.level = value ? Logger::DEBUG : Logger::INFO
         | 
| 16 | 
            +
              end
         | 
| 17 | 
            +
             | 
| 18 | 
            +
              module Helper
         | 
| 19 | 
            +
                def log(level, message, log_options = {})
         | 
| 20 | 
            +
                  global_option = @options || {}
         | 
| 21 | 
            +
                  message = "[#{level.to_s.upcase}] #{message}" unless level == :info
         | 
| 22 | 
            +
                  message << ' (dry-run)' if global_option[:dry_run]
         | 
| 23 | 
            +
                  message = message.send(log_options[:color]) if log_options[:color]
         | 
| 24 | 
            +
                  logger = global_option[:logger] || <%= @const_name %>::Logger.instance
         | 
| 25 | 
            +
                  logger.send(level, message)
         | 
| 26 | 
            +
                end
         | 
| 27 | 
            +
              end
         | 
| 28 | 
            +
            end
         | 
| @@ -0,0 +1,14 @@ | |
| 1 | 
            +
            class <%= @const_name %>::Utils
         | 
| 2 | 
            +
              module Diff
         | 
| 3 | 
            +
                def diff(obj1, obj2, options = {})
         | 
| 4 | 
            +
                  diffy = Diffy::Diff.new(
         | 
| 5 | 
            +
                    obj1.pretty_inspect,
         | 
| 6 | 
            +
                    obj2.pretty_inspect,
         | 
| 7 | 
            +
                    :diff => '-u'
         | 
| 8 | 
            +
                  )
         | 
| 9 | 
            +
             | 
| 10 | 
            +
                  diffy.to_s(options[:color] ? :color : :text).gsub(/\s+\z/m, '')
         | 
| 11 | 
            +
                end
         | 
| 12 | 
            +
                module_function :diff
         | 
| 13 | 
            +
              end
         | 
| 14 | 
            +
            end
         | 
    
        metadata
    ADDED
    
    | @@ -0,0 +1,130 @@ | |
| 1 | 
            +
            --- !ruby/object:Gem::Specification
         | 
| 2 | 
            +
            name: codenize
         | 
| 3 | 
            +
            version: !ruby/object:Gem::Version
         | 
| 4 | 
            +
              version: 0.1.0
         | 
| 5 | 
            +
            platform: ruby
         | 
| 6 | 
            +
            authors:
         | 
| 7 | 
            +
            - Genki Sugawara
         | 
| 8 | 
            +
            autorequire: 
         | 
| 9 | 
            +
            bindir: exe
         | 
| 10 | 
            +
            cert_chain: []
         | 
| 11 | 
            +
            date: 2016-12-04 00:00:00.000000000 Z
         | 
| 12 | 
            +
            dependencies:
         | 
| 13 | 
            +
            - !ruby/object:Gem::Dependency
         | 
| 14 | 
            +
              name: bundler
         | 
| 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: erbh
         | 
| 29 | 
            +
              requirement: !ruby/object:Gem::Requirement
         | 
| 30 | 
            +
                requirements:
         | 
| 31 | 
            +
                - - ">="
         | 
| 32 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 33 | 
            +
                    version: '0'
         | 
| 34 | 
            +
              type: :runtime
         | 
| 35 | 
            +
              prerelease: false
         | 
| 36 | 
            +
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 37 | 
            +
                requirements:
         | 
| 38 | 
            +
                - - ">="
         | 
| 39 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 40 | 
            +
                    version: '0'
         | 
| 41 | 
            +
            - !ruby/object:Gem::Dependency
         | 
| 42 | 
            +
              name: rake
         | 
| 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: rspec
         | 
| 57 | 
            +
              requirement: !ruby/object:Gem::Requirement
         | 
| 58 | 
            +
                requirements:
         | 
| 59 | 
            +
                - - "~>"
         | 
| 60 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 61 | 
            +
                    version: '3.0'
         | 
| 62 | 
            +
              type: :development
         | 
| 63 | 
            +
              prerelease: false
         | 
| 64 | 
            +
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 65 | 
            +
                requirements:
         | 
| 66 | 
            +
                - - "~>"
         | 
| 67 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 68 | 
            +
                    version: '3.0'
         | 
| 69 | 
            +
            description: Generate scaffold for Codenize.tools.
         | 
| 70 | 
            +
            email:
         | 
| 71 | 
            +
            - sugawara@cookpad.com
         | 
| 72 | 
            +
            executables:
         | 
| 73 | 
            +
            - codenize
         | 
| 74 | 
            +
            extensions: []
         | 
| 75 | 
            +
            extra_rdoc_files: []
         | 
| 76 | 
            +
            files:
         | 
| 77 | 
            +
            - ".gitignore"
         | 
| 78 | 
            +
            - ".rspec"
         | 
| 79 | 
            +
            - ".travis.yml"
         | 
| 80 | 
            +
            - Gemfile
         | 
| 81 | 
            +
            - LICENSE.txt
         | 
| 82 | 
            +
            - README.md
         | 
| 83 | 
            +
            - Rakefile
         | 
| 84 | 
            +
            - bin/console
         | 
| 85 | 
            +
            - bin/setup
         | 
| 86 | 
            +
            - codenize.gemspec
         | 
| 87 | 
            +
            - exe/codenize
         | 
| 88 | 
            +
            - lib/codenize.rb
         | 
| 89 | 
            +
            - lib/codenize/client.rb
         | 
| 90 | 
            +
            - lib/codenize/logger.rb
         | 
| 91 | 
            +
            - lib/codenize/version.rb
         | 
| 92 | 
            +
            - lib/template/exe/_name.erb
         | 
| 93 | 
            +
            - lib/template/lib/_name.rb.erb
         | 
| 94 | 
            +
            - lib/template/lib/_name/cli.rb.erb
         | 
| 95 | 
            +
            - lib/template/lib/_name/client.rb.erb
         | 
| 96 | 
            +
            - lib/template/lib/_name/driver.rb.erb
         | 
| 97 | 
            +
            - lib/template/lib/_name/dsl.rb.erb
         | 
| 98 | 
            +
            - lib/template/lib/_name/dsl/context.rb.erb
         | 
| 99 | 
            +
            - lib/template/lib/_name/dsl/schema.yml.erb
         | 
| 100 | 
            +
            - lib/template/lib/_name/exporter.rb.erb
         | 
| 101 | 
            +
            - lib/template/lib/_name/ext/hash_ext.rb.erb
         | 
| 102 | 
            +
            - lib/template/lib/_name/ext/string_ext.rb.erb
         | 
| 103 | 
            +
            - lib/template/lib/_name/logger.rb.erb
         | 
| 104 | 
            +
            - lib/template/lib/_name/utils/diff.rb.erb
         | 
| 105 | 
            +
            - lib/template/lib/_name/utils/target_matcher.rb.erb
         | 
| 106 | 
            +
            homepage: https://github.com/winebarrel/codenize
         | 
| 107 | 
            +
            licenses:
         | 
| 108 | 
            +
            - MIT
         | 
| 109 | 
            +
            metadata: {}
         | 
| 110 | 
            +
            post_install_message: 
         | 
| 111 | 
            +
            rdoc_options: []
         | 
| 112 | 
            +
            require_paths:
         | 
| 113 | 
            +
            - lib
         | 
| 114 | 
            +
            required_ruby_version: !ruby/object:Gem::Requirement
         | 
| 115 | 
            +
              requirements:
         | 
| 116 | 
            +
              - - ">="
         | 
| 117 | 
            +
                - !ruby/object:Gem::Version
         | 
| 118 | 
            +
                  version: '0'
         | 
| 119 | 
            +
            required_rubygems_version: !ruby/object:Gem::Requirement
         | 
| 120 | 
            +
              requirements:
         | 
| 121 | 
            +
              - - ">="
         | 
| 122 | 
            +
                - !ruby/object:Gem::Version
         | 
| 123 | 
            +
                  version: '0'
         | 
| 124 | 
            +
            requirements: []
         | 
| 125 | 
            +
            rubyforge_project: 
         | 
| 126 | 
            +
            rubygems_version: 2.5.1
         | 
| 127 | 
            +
            signing_key: 
         | 
| 128 | 
            +
            specification_version: 4
         | 
| 129 | 
            +
            summary: Generate scaffold for Codenize.tools.
         | 
| 130 | 
            +
            test_files: []
         |