skiff 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 ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: a580f986752329d6966ab3f9b18225aa76cfb316
4
+ data.tar.gz: 74c19e1e4f327035100376b4ad52b0d83cdacaa4
5
+ SHA512:
6
+ metadata.gz: 4b6627ef78e3c01e509874e27db17ea4e0fb0f7e7561fafc1c5104fe91fb7b5eb7c750ccc1f6016764a2e311432fd6633b18da87da84596c99b3cc35dbca9c68
7
+ data.tar.gz: 818fdc37043a9bce29542569cc0552e1fc40124cfb346f8370812f9aa09e48fdf54205380018faabf2f712b6d822dd1aaf50fba4cf0b74caa2aecb6092ff6c5b
data/.gitignore ADDED
@@ -0,0 +1,9 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --format documentation
2
+ --color
data/.travis.yml ADDED
@@ -0,0 +1,5 @@
1
+ sudo: false
2
+ language: ruby
3
+ rvm:
4
+ - 2.2.3
5
+ before_install: gem install bundler -v 1.12.4
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in skiff.gemspec
4
+ gemspec
data/README.md ADDED
@@ -0,0 +1,77 @@
1
+ # Skiff
2
+
3
+ ### This is Skiff
4
+ <br>
5
+
6
+ ![image](skiff.png)
7
+
8
+
9
+ He's very worried about probes...
10
+
11
+ ```
12
+ Lem: A cork?
13
+ Skiff: It's your best defense against the aliens' favorite form of research. The probe. You put it...
14
+ ```
15
+
16
+ This gem provides a simple interface to a DS18b20 temperature probe, installed on a Raspberry Pi via the One Wire interface.
17
+
18
+ ## Installation
19
+
20
+ Add this line to your application's Gemfile:
21
+
22
+ ```ruby
23
+ gem 'skiff'
24
+ ```
25
+
26
+ And then execute:
27
+
28
+ $ bundle
29
+
30
+ Or install it yourself as:
31
+
32
+ $ gem install skiff
33
+
34
+ ## Usage
35
+
36
+ # Under Raspbian, the temperature readings are typically
37
+ # written to /sys/bus/w1/devices, so that is the default location.
38
+ #
39
+ # If you need to change it, pass your location in when you create
40
+ # the ::Skiff::Manager like this:
41
+ # manager = ::Skiff::Manager.new your_probe_location
42
+
43
+ manager = ::Skiff::Manager.new
44
+
45
+ # to get a list of all the attached probes:
46
+
47
+ probes = manager.probes
48
+
49
+ # probes => ["28-0115649922ff", "28-021564c24bff"]
50
+
51
+ probe = manager.create_probe(probes.first)
52
+
53
+ # returns an instance of ::Skiff::Probe
54
+
55
+ # to get the raw temperature of a probe:
56
+
57
+ temperature = probe.temperature
58
+
59
+ # or in fahrenheit
60
+
61
+ fahrenheit = probe.fahrenheit
62
+
63
+ # and to get all the raw data
64
+
65
+ raw_data = probe.raw
66
+
67
+ ## Development
68
+
69
+ Don't like something? Need more functionality?
70
+
71
+ Fork it, write it, create a Pull Request.
72
+
73
+ Rinse and repeat.
74
+
75
+ ## Contributing
76
+
77
+ Bug reports and pull requests are welcome on GitHub at https://github.com/newellista/skiff.
data/Rakefile ADDED
@@ -0,0 +1,6 @@
1
+ require "bundler/gem_tasks"
2
+ require "rspec/core/rake_task"
3
+
4
+ RSpec::Core::RakeTask.new(:spec)
5
+
6
+ task :default => :spec
data/bin/console ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "skiff"
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
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,16 @@
1
+ module Skiff
2
+ class Manager
3
+ def intitialize(base_path = '/sys/bus/w1/devices')
4
+ @base_path = base_path
5
+ end
6
+
7
+ def probes
8
+ paths = Dir.glob(File.join(@base_path, "*"))
9
+ probes = paths.select { |path| path.include?("-") }.map { |path| path.split('/').last.strip }
10
+ end
11
+
12
+ def create_probe(probe_name)
13
+ ::Skiff::Probe.new(@base_path, probe_name)
14
+ end
15
+ end
16
+ end
@@ -0,0 +1,21 @@
1
+ module Skiff
2
+ class Probe
3
+ def self.initialize(base_path, name)
4
+ @full_path_name = File.join([base_path, name, "w1_slave"])
5
+ end
6
+
7
+ def fahrenheit
8
+ (temperature * 1.8) + 32.0
9
+ end
10
+
11
+ def raw
12
+ file_contents = File.read(@full_path_name)
13
+ end
14
+
15
+ def temperature
16
+ temperature_data = raw.split('t=').last
17
+ temperature = temperature_data.to_f / 1000
18
+ return temperature
19
+ end
20
+ end
21
+ end
@@ -0,0 +1,3 @@
1
+ module Skiff
2
+ VERSION = "0.1.0"
3
+ end
data/lib/skiff.rb ADDED
@@ -0,0 +1,6 @@
1
+ require "skiff/probe"
2
+ require "skiff/manager"
3
+ require "skiff/version"
4
+
5
+ module Skiff
6
+ end
data/skiff.gemspec ADDED
@@ -0,0 +1,25 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'skiff/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "skiff"
8
+ spec.version = Skiff::VERSION
9
+ spec.authors = ["Steve Newell"]
10
+ spec.email = ["newellista@gmail.com"]
11
+
12
+ spec.summary = %q{DS18b20 One-Wire temperature probe reader}
13
+ spec.description = %q{DS18b20 One-Wire temperature probe reader.}
14
+ spec.homepage = "https://github.com/newellista/skiff"
15
+ spec.license = "MIT"
16
+
17
+ spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
18
+ spec.bindir = "bin"
19
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
20
+ spec.require_paths = ["lib"]
21
+
22
+ spec.add_development_dependency "bundler", "~> 1.12"
23
+ spec.add_development_dependency "rake", "~> 10.0"
24
+ spec.add_development_dependency "rspec", "~> 3.0"
25
+ end
data/skiff.png ADDED
Binary file
metadata ADDED
@@ -0,0 +1,102 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: skiff
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Steve Newell
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2016-07-15 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: '1.12'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.12'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '10.0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '10.0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rspec
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '3.0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '3.0'
55
+ description: DS18b20 One-Wire temperature probe reader.
56
+ email:
57
+ - newellista@gmail.com
58
+ executables:
59
+ - console
60
+ - setup
61
+ extensions: []
62
+ extra_rdoc_files: []
63
+ files:
64
+ - ".gitignore"
65
+ - ".rspec"
66
+ - ".travis.yml"
67
+ - Gemfile
68
+ - README.md
69
+ - Rakefile
70
+ - bin/console
71
+ - bin/setup
72
+ - lib/skiff.rb
73
+ - lib/skiff/manager.rb
74
+ - lib/skiff/probe.rb
75
+ - lib/skiff/version.rb
76
+ - skiff.gemspec
77
+ - skiff.png
78
+ homepage: https://github.com/newellista/skiff
79
+ licenses:
80
+ - MIT
81
+ metadata: {}
82
+ post_install_message:
83
+ rdoc_options: []
84
+ require_paths:
85
+ - lib
86
+ required_ruby_version: !ruby/object:Gem::Requirement
87
+ requirements:
88
+ - - ">="
89
+ - !ruby/object:Gem::Version
90
+ version: '0'
91
+ required_rubygems_version: !ruby/object:Gem::Requirement
92
+ requirements:
93
+ - - ">="
94
+ - !ruby/object:Gem::Version
95
+ version: '0'
96
+ requirements: []
97
+ rubyforge_project:
98
+ rubygems_version: 2.4.8
99
+ signing_key:
100
+ specification_version: 4
101
+ summary: DS18b20 One-Wire temperature probe reader
102
+ test_files: []