Sha256: 2864b2241d942eb328ea767665fb27a13e90bf822fe5bc71a2f2aa4c7f0bcd77

Contents?: true

Size: 1.97 KB

Versions: 1

Compression:

Stored size: 1.97 KB

Contents

require 'open-uri'

module Arduino
  module Library
    DEFAULT_ARDUINO_LIBRARY_INDEX_URL  =
      'http://downloads.arduino.cc/libraries/library_index.json.gz'
    DEFAULT_ARDUINO_LIBRARY_PATH       =
      ENV['ARDUINO_CUSTOM_LIBRARY_PATH'] || (ENV['HOME'] + '/Documents/Arduino/Libraries')
    DEFAULT_ARDUINO_LIBRARY_INDEX_PATH =
      ENV['ARDUINO_LIBRARY_INDEX_PATH'] ||
        (ENV['HOME'] + '/Documents/Arduino/Libraries/index.json.gz')
  end
end

require 'arduino/library/version'
require 'arduino/library/utilities'
require 'arduino/library/types'
# noinspection RubyResolve
require 'arduino/library/model'
require 'arduino/library/database'
require 'arduino/library/default_database'

module Arduino
  module Library
    # @param [String] file_or_url — either a local file, or URL, can be gzipped
    def db_from(file_or_url)
      Database.new(file_or_url)
    end

    def db_default
      DefaultDatabase.instance
    end

    #
    # +file_or_url+ can be a JSON file name, a .properties file name, or
    # a URL to either of the above.
    #
    # @param [String] file_or_url
    def library_from(file_or_url)
      Arduino::Library::Model.from(file_or_url)
    end

    # +opts+ is a Hash that you can use to pass attributes with values, any
    # number of them. All matching results are returned as models.
    #
    #   name: 'AudioZero'
    #   author: /konstantin/i              - regexp supported
    #   architectures: [ 'avr' ]           - array is matched if it's a subset
    #   version: proc do |value|           — or a proc for max flexibility
    #     value.start_with?('1.') )
    #   end
    #
    # @param [Database] database db instance (or skip it to use the default)
    # @param [Hash] opts hash of attribute names and values to match
    # @return Array<Model> array of models that match
    def search(database = db_default, **opts)
      Arduino::Library::Model.database = database
      database.search(**opts)
    end
  end
end

Arduino::Library.extend(Arduino::Library)

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
arduino-library-0.3.2 lib/arduino/library.rb