https://github.com/hyperoslo/obix
Ruby OBIX parser
https://github.com/hyperoslo/obix
Last synced: about 1 year ago
JSON representation
Ruby OBIX parser
- Host: GitHub
- URL: https://github.com/hyperoslo/obix
- Owner: hyperoslo
- License: other
- Created: 2013-01-03T09:15:12.000Z (over 13 years ago)
- Default Branch: master
- Last Pushed: 2014-10-10T21:46:23.000Z (over 11 years ago)
- Last Synced: 2024-05-09T16:36:25.415Z (about 2 years ago)
- Language: Ruby
- Homepage:
- Size: 500 KB
- Stars: 6
- Watchers: 11
- Forks: 2
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE.md
Awesome Lists containing this project
README
# OBIX
[](https://codeclimate.com/github/hyperoslo/obix)
Ruby OBIX parser.
## Installation
Add this line to your application's Gemfile:
gem 'obix'
And then execute:
$ bundle
Or install it yourself as:
$ gem install obix
## Usage
### Parse an object
```xml
```
```ruby
# thermostat.rb
thermostat = OBIX.parse file: "thermostat.xml"
thermostat.href # => "http://domain/thermostat/"
temperature = thermostat.objects.find { |obj| obj.name == "spaceTemp" }
temperature.val # => 67.2
```
### Build an object
```ruby
# thermostat.rb
object = OBIX::Builder.new do
obj href: "http://domain/thermostat" do
real name: "spaceTemp", unit: "obix:units/fahrenheit" val: 67.2
real name: "setpoint", unit: "obix:units/fahrenheit" val: 72.0
bool name: "furnaceOn", val: true
end
end
```
### Invoke an operation
```xml
```
```ruby
# furnace.rb
furnace = OBIX.parse file: "furnace.xml"
activate = furnace.objects.find { |obj| obj.name == "activate" }
activate.invoke
```
### Create a watch
```ruby
# Create a new watch...
watch = OBIX::Watch.make url: "http://domain/watchservice"
# ... or connect to an existing watch
watch = OBIX::Watch.connect url: "http://domain/watchservice/watch1"
# Add objects to the watch
watch.add ["/thermostat", "/furnace"]
# Remove objects from the watch
watch.remove ["/furnace"]
# Poll everything
watch.all
# Poll changes
watch.changes
# Delete the watch
watch.delete
```
### Query an object's history
```ruby
history = OBIX::History.new url: "http://domain/history"
history.query start: 2.year.ago, end: 1.year.ago
```
### Query alarms
```ruby
alarms = OBIX::Alarms.new url: "http://domain/alarmservice"
alarms.query start: 2.years.ago, end: 1.year.ago
```
## Contributing
1. Fork it
2. Create your feature branch (`git checkout -b my-new-feature`)
3. Commit your changes (`git commit -am 'Add some feature'`)
4. Push to the branch (`git push origin my-new-feature`)
5. Create new Pull Request
## Credits
Hyper made this. We're a digital communications agency with a passion for good code,
and if you're using this library we probably want to hire you.