millworker 0.1.3 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- data.tar.gz.sig +5 -3
- data/History.txt +12 -0
- data/Manifest.txt +2 -1
- data/bin/millworker +4 -3
- data/example_tasks/log_to_csv.rb.example +49 -0
- data/example_tasks/sf_logger.rb.example +121 -0
- data/lib/millworker/version.rb +1 -1
- metadata +4 -3
- metadata.gz.sig +4 -2
- data/example_tasks/log_to_csv.rb +0 -14
data.tar.gz.sig
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
-
�
|
2
|
-
��
|
3
|
-
|
1
|
+
��#�(��6A�T*��ut�V�u�#��+�J�T&d�@�ؽ3����M�!�/w|i����
|
2
|
+
�{��7�4T=A�ċ�테(j6BQx�._m�+z*g���8Y��J�q�t�y��
|
3
|
+
Ek�˚wT:�g*
|
4
|
+
_�66�pKBj���KM���d�oM��d�SA���Ot �+�n�J��I���r���Z҃
|
5
|
+
Vh�抸ek��p�Ör!GT��~6��)ǚ�)
|
data/History.txt
CHANGED
@@ -1,3 +1,15 @@
|
|
1
|
+
=== 0.2.0 / 2012-10-19
|
2
|
+
|
3
|
+
* 2 minor enhancements:
|
4
|
+
|
5
|
+
* Added Salesforce "checking logger" script
|
6
|
+
* Only execute tasks which do not end in ".example"
|
7
|
+
|
8
|
+
* 2 bug fixes:
|
9
|
+
|
10
|
+
* Added documentation for log_to_csv.rb.example script
|
11
|
+
* Rename all example tasks to end in ".example"
|
12
|
+
|
1
13
|
=== 0.1.3 / 2012-09-18
|
2
14
|
|
3
15
|
* 1 bug fix:
|
data/Manifest.txt
CHANGED
data/bin/millworker
CHANGED
@@ -61,7 +61,7 @@ command :setup do |c|
|
|
61
61
|
File.open(CONFIG_PATH, "w") {|f| f.write({serial_port: port_name}.to_yaml)}
|
62
62
|
|
63
63
|
puts "Copying example tasks to #{TASKS_DIR}"
|
64
|
-
Dir["#{EXAMPLE_TASKS_DIR}
|
64
|
+
Dir["#{EXAMPLE_TASKS_DIR}/*.example"].map { |file|
|
65
65
|
FileUtils.cp file, TASKS_DIR
|
66
66
|
FileUtils.chmod 0755, "#{TASKS_DIR}/#{File.basename(file)}"
|
67
67
|
}
|
@@ -99,14 +99,15 @@ command :start do |c|
|
|
99
99
|
next if rfid_id.nil?
|
100
100
|
|
101
101
|
# Read task list in every time so the daemon does not need to be
|
102
|
-
# restarted after changes
|
103
|
-
tasks = Dir["#{TASKS_DIR}/*"]
|
102
|
+
# restarted after changes (ignore '.example' tasks)
|
103
|
+
tasks = Dir["#{TASKS_DIR}/*"].reject {|task| task[/\.example/]}
|
104
104
|
|
105
105
|
if tasks.empty?
|
106
106
|
logger.warn "No tasks to execute in '#{TASKS_DIR}'. Skipping."
|
107
107
|
next
|
108
108
|
else
|
109
109
|
tasks.each do |task|
|
110
|
+
|
110
111
|
command = "#{task} #{rfid_id}"
|
111
112
|
|
112
113
|
execute(command) { |result|
|
@@ -0,0 +1,49 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
# Overview
|
4
|
+
# ========
|
5
|
+
#
|
6
|
+
# Logs the identifier passed in with a timestamp of when it occurred to a CSV
|
7
|
+
# file named "millworker_log.csv".
|
8
|
+
#
|
9
|
+
# NOTE: Please read the 'Requirements' section before attempting to use this
|
10
|
+
# script as it will outline any customizations you must do or software you
|
11
|
+
# need to install in order for it to work properly.
|
12
|
+
#
|
13
|
+
# NOTE: You must rename this file so the filename does not end in ".example".
|
14
|
+
# The instructions below assume you have only removed the ".example" when
|
15
|
+
# you renamed the file.
|
16
|
+
#
|
17
|
+
# Usage
|
18
|
+
# =====
|
19
|
+
#
|
20
|
+
# ./log_to_csv.rb [BADGE ID HERE]
|
21
|
+
#
|
22
|
+
# Example
|
23
|
+
# ======
|
24
|
+
#
|
25
|
+
# ./log_to_csv.rb 12345
|
26
|
+
#
|
27
|
+
#
|
28
|
+
# Requirements
|
29
|
+
# ============
|
30
|
+
#
|
31
|
+
# - There are no requirements for this script outside of using Ruby 1.9.3+.
|
32
|
+
# However, if you would like to customize where the "millworker_log.csv" file
|
33
|
+
# is written, you can set the "MILLWORKER_CSV_DIR" environment variable to
|
34
|
+
# the full path to a directory you'd like it written to
|
35
|
+
# (default: $HOME/Desktop).
|
36
|
+
|
37
|
+
require 'csv'
|
38
|
+
|
39
|
+
CSV_FILENAME = "millworker_log.csv"
|
40
|
+
CSV_DIR = ENV["MILLWORKER_CSV_DIR"] || File.expand_path("#{ENV['HOME']}/Desktop")
|
41
|
+
CSV_PATH = "#{CSV_DIR}/#{CSV_FILENAME}"
|
42
|
+
|
43
|
+
when_new_file = !File.exists?(CSV_PATH)
|
44
|
+
|
45
|
+
CSV_OPTIONS = {headers: %w(timestamp card_id),
|
46
|
+
write_headers: when_new_file,
|
47
|
+
force_quotes: true
|
48
|
+
}
|
49
|
+
CSV.open(CSV_PATH, "a+", CSV_OPTIONS) {|csv| csv << [Time.now, ARGV[0]]}
|
@@ -0,0 +1,121 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
# Overview
|
4
|
+
# ========
|
5
|
+
#
|
6
|
+
# Logs a "Checkin" event in Salesforce for the person with the specified
|
7
|
+
# badge number (a unique identifier passed in as an argument).
|
8
|
+
#
|
9
|
+
# NOTE: Please read the 'Requirements' section before attempting to use this
|
10
|
+
# script as it will outline any customizations you must do or software you
|
11
|
+
# need to install in order for it to work properly.
|
12
|
+
#
|
13
|
+
# NOTE: You must rename this file so the filename does not end in ".example".
|
14
|
+
# The instructions below assume you have only removed the ".example" when
|
15
|
+
# you renamed the file.
|
16
|
+
#
|
17
|
+
# Usage
|
18
|
+
# =====
|
19
|
+
#
|
20
|
+
# ./sf_checkin_logger.rb [BADGE ID HERE]
|
21
|
+
#
|
22
|
+
# Example
|
23
|
+
# ======
|
24
|
+
#
|
25
|
+
# ./sf_checkin_logger.rb 12345
|
26
|
+
#
|
27
|
+
#
|
28
|
+
# Requirements
|
29
|
+
# ============
|
30
|
+
#
|
31
|
+
# Script modification requirements
|
32
|
+
# --------------------------------
|
33
|
+
# - You must set the hostname, username, etc variables in the code below
|
34
|
+
# (denoted with "CUSTOM SETTINGS BELOW HERE" and
|
35
|
+
# "CUSTOM SETTINGS ABOVE HERE" lines)
|
36
|
+
#
|
37
|
+
# Software requirements:
|
38
|
+
# ----------------------
|
39
|
+
# - the databasedotcom ruby gem (run `gem install databasedotcom`)
|
40
|
+
#
|
41
|
+
# Requirements on Salesforce:
|
42
|
+
# ---------------------------
|
43
|
+
# - API access must be set up
|
44
|
+
# - Account credentials (security token, password, etc)
|
45
|
+
# - Custom "Check_in__c" object with the following fields (at a minimum)
|
46
|
+
# - Person__c
|
47
|
+
# - stores the Id of the Account to associate the checkin with
|
48
|
+
# - Check_In_Time_Date__c
|
49
|
+
# - stores a timestamp of when the "checkin" occurred
|
50
|
+
# - Incident__c
|
51
|
+
# - boolean field which was a required field of the system this was
|
52
|
+
# originally written for
|
53
|
+
# - Paid_Shift__c
|
54
|
+
# - boolean field which was a required field of the system this was
|
55
|
+
# originally written for
|
56
|
+
|
57
|
+
|
58
|
+
# CUSTOM SETTINGS BELOW HERE
|
59
|
+
hostname = "CHANGE_ME" # eg: "test.salesforce.com"
|
60
|
+
username = "CHANGE_ME" # eg: "jdoe@example.com"
|
61
|
+
password = "CHANGE_ME" # eg: "password"
|
62
|
+
security_token = "CHANGE_ME" # eg: "Ejy3282382923dsjsj"
|
63
|
+
client_secret = "CHANGE_ME" # eg: "74439232ds2832"
|
64
|
+
client_id = "CHANGE_ME" # eg: '3MVG9-REALLY-LONG-STRING-HERE'
|
65
|
+
# CUSTOM SETTINGS ABOVE HERE
|
66
|
+
|
67
|
+
# NOTE: No changes should be necessary below this line!
|
68
|
+
|
69
|
+
[hostname,
|
70
|
+
username,
|
71
|
+
password,
|
72
|
+
security_token,
|
73
|
+
client_secret,
|
74
|
+
client_id
|
75
|
+
].each {|custom_setting|
|
76
|
+
if custom_setting == "CHANGE_ME"
|
77
|
+
$stderr.puts "Please verify all custom settings have been updated. Exiting."
|
78
|
+
exit 3
|
79
|
+
end
|
80
|
+
}
|
81
|
+
|
82
|
+
begin
|
83
|
+
require 'databasedotcom'
|
84
|
+
include Databasedotcom
|
85
|
+
rescue LoadError
|
86
|
+
$stderr.puts "You must install the 'databasedotcom' gem (run `gem install databasedotcom`). Exiting."
|
87
|
+
exit 1
|
88
|
+
end
|
89
|
+
|
90
|
+
badge_id = ARGV[0]
|
91
|
+
|
92
|
+
client = Client.new(host: hostname,
|
93
|
+
client_secret: client_secret,
|
94
|
+
client_id: client_id,
|
95
|
+
debugging: false)
|
96
|
+
|
97
|
+
client.authenticate :username => "info@mnmill.org.sandbox", :password => "#{password}#{security_token}"
|
98
|
+
|
99
|
+
Account = client.materialize("Account")
|
100
|
+
CheckIn = client.materialize("Check_in__c")
|
101
|
+
|
102
|
+
account = Account.find_by_Id_Badge__c(badge_id)
|
103
|
+
checkin_time = DateTime.now
|
104
|
+
|
105
|
+
if account.nil?
|
106
|
+
$stderr.puts "Could not find account with ID of #{badge_id}. Exiting."
|
107
|
+
exit 1
|
108
|
+
end
|
109
|
+
|
110
|
+
checkin = CheckIn.new(:Person__c => account.Id,
|
111
|
+
:Check_In_Time_Date__c => checkin_time,
|
112
|
+
:Incident__c => false,
|
113
|
+
:Paid_Shift__c => false)
|
114
|
+
|
115
|
+
if checkin.save
|
116
|
+
$stdout.puts "Checkin for #{account.Name} (ID: #{account.Id}) logged to Salesforce at '#{checkin_time.to_s}'"
|
117
|
+
exit 0
|
118
|
+
else
|
119
|
+
$stderr.puts "Checkin for #{account.Name} (ID: #{account.Id}) was not saved successfully for some reason. Please manually verify the script is functioning correctly. Exiting."
|
120
|
+
exit 2
|
121
|
+
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.
|
4
|
+
version: 0.2.0
|
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-
|
39
|
+
date: 2012-10-19 00:00:00.000000000 Z
|
40
40
|
dependencies:
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: gli
|
@@ -209,7 +209,8 @@ files:
|
|
209
209
|
- README.md
|
210
210
|
- Rakefile
|
211
211
|
- bin/millworker
|
212
|
-
- example_tasks/log_to_csv.rb
|
212
|
+
- example_tasks/log_to_csv.rb.example
|
213
|
+
- example_tasks/sf_logger.rb.example
|
213
214
|
- lib/millworker.rb
|
214
215
|
- lib/millworker/version.rb
|
215
216
|
- spec/spec.opts
|
metadata.gz.sig
CHANGED
@@ -1,2 +1,4 @@
|
|
1
|
-
|
2
|
-
|
1
|
+
�I2o������7f�8=��f:��}:��}��li�N���1�͋����}��V�a�̾�A���C/� ��]��S�T��"GE���g�i
|
2
|
+
� ��+j��]װ���q
|
3
|
+
MJN�M0'�ӗ%z��+簢}#^=�PƊ��3=�*��C
|
4
|
+
�c��_�2����.�c2�&(�xa���}_��0E+��g>Yx0@��
|
data/example_tasks/log_to_csv.rb
DELETED
@@ -1,14 +0,0 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
require 'csv'
|
3
|
-
|
4
|
-
CSV_FILENAME = "millworker_log.csv"
|
5
|
-
CSV_DIR = ENV["MILLWORKER_CSV_DIR"] || File.expand_path("#{ENV['HOME']}/Desktop")
|
6
|
-
CSV_PATH = "#{CSV_DIR}/#{CSV_FILENAME}"
|
7
|
-
|
8
|
-
when_new_file = !File.exists?(CSV_PATH)
|
9
|
-
|
10
|
-
CSV_OPTIONS = {headers: %w(timestamp card_id),
|
11
|
-
write_headers: when_new_file,
|
12
|
-
force_quotes: true
|
13
|
-
}
|
14
|
-
CSV.open(CSV_PATH, "a+", CSV_OPTIONS) {|csv| csv << [Time.now, ARGV[0]]}
|