blink1-patterns 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
data/.gitignore ADDED
@@ -0,0 +1,18 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
18
+ bin
data/.ruby-version ADDED
@@ -0,0 +1 @@
1
+ 1.9.3-p362-railsexpress
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in blink1-patterns.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2013 Michael Schmidt
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,29 @@
1
+ # Blink1::Patterns
2
+
3
+ TODO: Write a gem description
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ gem 'blink1-patterns'
10
+
11
+ And then execute:
12
+
13
+ $ bundle
14
+
15
+ Or install it yourself as:
16
+
17
+ $ gem install blink1-patterns
18
+
19
+ ## Usage
20
+
21
+ TODO: Write usage instructions here
22
+
23
+ ## Contributing
24
+
25
+ 1. Fork it
26
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
27
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
28
+ 4. Push to the branch (`git push origin my-new-feature`)
29
+ 5. Create new Pull Request
data/Rakefile ADDED
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
data/bin/breath ADDED
@@ -0,0 +1,16 @@
1
+ #!/usr/bin/env ruby
2
+ #
3
+ # This file was generated by Bundler.
4
+ #
5
+ # The application 'breath' is installed as part of a gem, and
6
+ # this file is here to facilitate running it.
7
+ #
8
+
9
+ require 'pathname'
10
+ ENV['BUNDLE_GEMFILE'] ||= File.expand_path("../../Gemfile",
11
+ Pathname.new(__FILE__).realpath)
12
+
13
+ require 'rubygems'
14
+ require 'bundler/setup'
15
+
16
+ load Gem.bin_path('blink1-patterns', 'breath')
data/bin/police ADDED
@@ -0,0 +1,16 @@
1
+ #!/usr/bin/env ruby
2
+ #
3
+ # This file was generated by Bundler.
4
+ #
5
+ # The application 'police' is installed as part of a gem, and
6
+ # this file is here to facilitate running it.
7
+ #
8
+
9
+ require 'pathname'
10
+ ENV['BUNDLE_GEMFILE'] ||= File.expand_path("../../Gemfile",
11
+ Pathname.new(__FILE__).realpath)
12
+
13
+ require 'rubygems'
14
+ require 'bundler/setup'
15
+
16
+ load Gem.bin_path('blink1-patterns', 'police')
@@ -0,0 +1,21 @@
1
+ # -*- encoding: utf-8 -*-
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'blink1-patterns/version'
5
+
6
+ Gem::Specification.new do |gem|
7
+ gem.name = "blink1-patterns"
8
+ gem.version = Blink::Patterns::VERSION
9
+ gem.authors = ["Michael Schmidt"]
10
+ gem.email = ["michael.j.schmidt@gmail.com"]
11
+ gem.description = %q{Common Blink Patterns}
12
+ gem.summary = %q{A collection of patterns for the Blink(1) indicator light}
13
+
14
+ gem.files = `git ls-files`.split($/)
15
+ gem.executables = gem.files.grep(%r{^exe/}).map{ |f| File.basename(f) }
16
+ gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
17
+ gem.require_paths = ["lib"]
18
+ gem.bindir = 'exe'
19
+
20
+ gem.add_dependency('rb-blink1')
21
+ end
data/exe/breath ADDED
@@ -0,0 +1,5 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "blink1-patterns"
4
+
5
+ Blink::Patterns.breath
data/exe/police ADDED
@@ -0,0 +1,5 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "blink1-patterns"
4
+
5
+ Blink::Patterns.police
@@ -0,0 +1,5 @@
1
+ module Blink
2
+ module Patterns
3
+ VERSION = "0.0.1"
4
+ end
5
+ end
@@ -0,0 +1,47 @@
1
+ require "blink1"
2
+
3
+ module Blink
4
+ module Patterns
5
+
6
+ def self.breath(hex_color = "#0000ff", length = 5, depth = 0.3)
7
+ brightness = [0.0000, 0.0293, 0.1427, 0.4128, 0.8459, 1.0000, 0.8336, 0.5159, 0.2334, 0.0574, 0.0141, 0.0000]
8
+ interval = [1.5, 1.0, 1.0, 1.0, 1.2, 1.5, 1.2, 1.2, 1.2, 1.2, 1.2, 0.0]
9
+ stretch = length / interval.inject(:+)
10
+
11
+ Blink1.open do |blink|
12
+ (0..11).each do |pos|
13
+ color = Blink::Patterns.darken(hex_color, (1 - brightness[pos]) * depth)
14
+ duration = stretch * interval[pos] * 1000
15
+ blink.write_pattern_line(duration, *color, pos)
16
+ end
17
+ blink.play(0)
18
+ end
19
+ end
20
+
21
+ def self.police
22
+ Blink1.open do |blink|
23
+ blink.write_pattern_line(500, *Blink::Patterns.to_rgb("#000000"), 0)
24
+ blink.write_pattern_line(100, *Blink::Patterns.to_rgb("#ff0000"), 1)
25
+ blink.write_pattern_line(500, *Blink::Patterns.to_rgb("#000000"), 2)
26
+ blink.write_pattern_line(100, *Blink::Patterns.to_rgb("#0000ff"), 3)
27
+ blink.write_pattern_line(0, 0, 0, 0, 4)
28
+ blink.write_pattern_line(0, 0, 0, 0, 5)
29
+ blink.write_pattern_line(0, 0, 0, 0, 6)
30
+ blink.write_pattern_line(0, 0, 0, 0, 7)
31
+ blink.write_pattern_line(0, 0, 0, 0, 8)
32
+ blink.write_pattern_line(0, 0, 0, 0, 9)
33
+ blink.write_pattern_line(0, 0, 0, 0, 10)
34
+ blink.write_pattern_line(0, 0, 0, 0, 11)
35
+ blink.play(0)
36
+ end
37
+ end
38
+
39
+ def self.to_rgb(hex_color)
40
+ hex_color.gsub('#','').scan(/../).map {|color| color.hex}
41
+ end
42
+
43
+ def self.darken(hex_color, amount=0.4)
44
+ to_rgb(hex_color).map { |c| (c * (1 - amount)).round }
45
+ end
46
+ end
47
+ end
metadata ADDED
@@ -0,0 +1,82 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: blink1-patterns
3
+ version: !ruby/object:Gem::Version
4
+ prerelease:
5
+ version: 0.0.1
6
+ platform: ruby
7
+ authors:
8
+ - Michael Schmidt
9
+ autorequire:
10
+ bindir: exe
11
+ cert_chain: []
12
+ date: 2013-02-17 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: rb-blink1
16
+ requirement: !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
21
+ version: '0'
22
+ type: :runtime
23
+ version_requirements: !ruby/object:Gem::Requirement
24
+ none: false
25
+ requirements:
26
+ - - ! '>='
27
+ - !ruby/object:Gem::Version
28
+ version: '0'
29
+ prerelease: false
30
+ description: Common Blink Patterns
31
+ email:
32
+ - michael.j.schmidt@gmail.com
33
+ executables:
34
+ - breath
35
+ - police
36
+ extensions: []
37
+ extra_rdoc_files: []
38
+ files:
39
+ - .gitignore
40
+ - .ruby-version
41
+ - Gemfile
42
+ - LICENSE.txt
43
+ - README.md
44
+ - Rakefile
45
+ - blink1-patterns.gemspec
46
+ - exe/breath
47
+ - exe/police
48
+ - lib/blink1-patterns.rb
49
+ - lib/blink1-patterns/version.rb
50
+ - bin/breath
51
+ - bin/police
52
+ homepage:
53
+ licenses: []
54
+ post_install_message:
55
+ rdoc_options: []
56
+ require_paths:
57
+ - lib
58
+ required_ruby_version: !ruby/object:Gem::Requirement
59
+ none: false
60
+ requirements:
61
+ - - ! '>='
62
+ - !ruby/object:Gem::Version
63
+ segments:
64
+ - 0
65
+ hash: 1706872555753575638
66
+ version: '0'
67
+ required_rubygems_version: !ruby/object:Gem::Requirement
68
+ none: false
69
+ requirements:
70
+ - - ! '>='
71
+ - !ruby/object:Gem::Version
72
+ segments:
73
+ - 0
74
+ hash: 1706872555753575638
75
+ version: '0'
76
+ requirements: []
77
+ rubyforge_project:
78
+ rubygems_version: 1.8.23
79
+ signing_key:
80
+ specification_version: 3
81
+ summary: A collection of patterns for the Blink(1) indicator light
82
+ test_files: []