Sha256: 9d59c24b45ee9cdac5ce119563b25bbd3d3796b21e9cc467087f03de606f43e2

Contents?: true

Size: 963 Bytes

Versions: 16

Compression:

Stored size: 963 Bytes

Contents

require 'json'


module Faalis
  module Generators
    module Concerns
      # This module Provide an argument for generator which
      # is needed by other `Concerns`.
      # Each Concern will have its own entry in scaffold json
      # file. For documentation on each entry checkout its concern class
      module JsonInput

        def self.included(base)
          # Name of the resource to create.
          base.argument :jsonfile , :type => :string, :required => true
        end

        private

        # Read the json file and returns its raw data
        def json_file_data
          path = File.expand_path(jsonfile)
          File.read(path)
        end

        # Return the hash related to json structure from cache or by
        # reading file.
        def resource_data
          if @data
            @data
          else
            @data = JSON.parse(json_file_data)
            @data
          end
        end


      end
    end
  end
end

Version data entries

16 entries across 16 versions & 1 rubygems

Version Path
faalis-1.0.0.alpha1 lib/faalis/generators/concerns/json_input.rb
faalis-1.0.0.alpha0 lib/faalis/generators/concerns/json_input.rb
faalis-0.26.3 lib/faalis/generators/concerns/json_input.rb
faalis-0.26.2 lib/faalis/generators/concerns/json_input.rb
faalis-0.26.1 lib/faalis/generators/concerns/json_input.rb
faalis-0.26.0 lib/faalis/generators/concerns/json_input.rb
faalis-0.25.1 lib/faalis/generators/concerns/json_input.rb
faalis-0.25.0 lib/faalis/generators/concerns/json_input.rb
faalis-0.24.4 lib/faalis/generators/concerns/json_input.rb
faalis-0.24.3 lib/faalis/generators/concerns/json_input.rb
faalis-0.24.2 lib/faalis/generators/concerns/json_input.rb
faalis-0.24.0 lib/faalis/generators/concerns/json_input.rb
faalis-0.23.0 lib/faalis/generators/concerns/json_input.rb
faalis-0.22.0 lib/faalis/generators/concerns/json_input.rb
faalis-0.21.1 lib/faalis/generators/concerns/json_input.rb
faalis-0.21.0 lib/faalis/generators/concerns/json_input.rb