millworker 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- data.tar.gz.sig +0 -0
- data/History.txt +7 -0
- data/README.md +1 -1
- data/bin/millworker +33 -25
- data/lib/millworker/version.rb +1 -1
- metadata +2 -2
- metadata.gz.sig +0 -0
data.tar.gz.sig
CHANGED
Binary file
|
data/History.txt
CHANGED
data/README.md
CHANGED
@@ -23,7 +23,7 @@ command terminal and typed `tweet_id.rb RFID_TAG_ID_HERE`.
|
|
23
23
|
|
24
24
|
Install the millworker gem (see below for instructions).
|
25
25
|
|
26
|
-
In order read from the correct port on your computer, we need to do a bit of
|
26
|
+
In order to read from the correct port on your computer, we need to do a bit of
|
27
27
|
setup.
|
28
28
|
|
29
29
|
```bash
|
data/bin/millworker
CHANGED
@@ -35,7 +35,10 @@ def config
|
|
35
35
|
end
|
36
36
|
|
37
37
|
def serial_port
|
38
|
-
|
38
|
+
return @serial_port unless @serial_port.nil?
|
39
|
+
@serial_port ||= SerialPort.new(SERIAL_PORT || config[:serial_port],{"baud" => 9600, "parity" => SerialPort::NONE, "data_bits" => 8})
|
40
|
+
@serial_port.read_timeout = 1000
|
41
|
+
@serial_port
|
39
42
|
end
|
40
43
|
|
41
44
|
|
@@ -72,9 +75,11 @@ command :start do |c|
|
|
72
75
|
c.switch :stdin, desc: 'Read input from STDIN (command line) instead of a serial port.'
|
73
76
|
|
74
77
|
c.action do |g, options, args|
|
75
|
-
Dante::Runner.new('millworker')
|
76
|
-
|
77
|
-
|
78
|
+
runner = Dante::Runner.new('millworker')
|
79
|
+
|
80
|
+
runner.execute(daemonize: !options[:stdin],
|
81
|
+
pid_path: PID_PATH,
|
82
|
+
log_path: DAEMON_LOG_PATH) {
|
78
83
|
|
79
84
|
FileUtils.mkdir_p(LOG_DIR) unless File.directory?(LOG_DIR)
|
80
85
|
logger = Logger.new(LOG_PATH)
|
@@ -83,27 +88,30 @@ command :start do |c|
|
|
83
88
|
|
84
89
|
loop do
|
85
90
|
data = input.gets
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
91
|
+
next if data.nil? || data.empty?
|
92
|
+
|
93
|
+
# Take off newline from serial read
|
94
|
+
data.strip!
|
95
|
+
logger.info "received: '#{data.inspect}'"
|
96
|
+
|
97
|
+
# Take off start & end of text unicode characters
|
98
|
+
rfid_id = data.slice(/\u0002(.*)\u0003/, 1)
|
99
|
+
next if rfid_id.nil?
|
100
|
+
|
101
|
+
# Read task list in every time so the daemon does not need to be
|
102
|
+
# restarted after changes
|
103
|
+
tasks = Dir["#{TASKS_DIR}/*"]
|
104
|
+
|
105
|
+
if tasks.empty?
|
106
|
+
logger.warn "No tasks to execute in '#{TASKS_DIR}'. Skipping."
|
107
|
+
next
|
108
|
+
else
|
109
|
+
tasks.each do |task|
|
110
|
+
command = "#{task} #{data}"
|
111
|
+
|
112
|
+
execute(command) { |result|
|
113
|
+
logger.info("executed: '#{command}', result: #{result}")
|
114
|
+
}
|
107
115
|
end
|
108
116
|
end
|
109
117
|
end
|
data/lib/millworker/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: millworker
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -36,7 +36,7 @@ cert_chain:
|
|
36
36
|
L1dHTHNEVk9tZ0orZzR4b09pQ2U5WkVrZGE4SytsL0YKeVhXcUluUmxGSWxU
|
37
37
|
dXdGVHhqMjZqYXVCb3NrQlBvejViZmtaRmphVlJoeVVuUm5Ha2E2Nmx2Y0RP
|
38
38
|
R2ZrUlpXUQpOVkFESkE9PQotLS0tLUVORCBDRVJUSUZJQ0FURS0tLS0tCg==
|
39
|
-
date: 2012-09-
|
39
|
+
date: 2012-09-19 00:00:00.000000000 Z
|
40
40
|
dependencies:
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: gli
|
metadata.gz.sig
CHANGED
Binary file
|