Sha256: 54a4e6809b4933cbde672fafe25241c9c2d78f85b62c7f3cb1149ce98ea89f3c

Contents?: true

Size: 765 Bytes

Versions: 1

Compression:

Stored size: 765 Bytes

Contents

module Mvp
  module Iteration
    CONFIG_FILE = File.join(Rails.root, '.iteration')

    class << self
      def write(json)
        _file = File.open( CONFIG_FILE, "w+" )
        _file.write(JSON.pretty_generate(json))
        _file.close

        @config = json
      end

      def read
        @config ||= begin
                      JSON.parse( IO.read(CONFIG_FILE), symbolize_names: false )
                    rescue
                      write({'version' => '0.0.1'})
                    end
      end

      def bump!(bump)
        config = read
        config['version'] = Semantic::Version.new(config['version']).increment!(bump.downcase.to_sym).to_s
        write(config)
      end

      def version
        read["version"]
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
minimum-viable-product-0.0.2 config/initializers/iteration.rb