Module: Printr
- Defined in:
- lib/printr.rb,
lib/printr/engine.rb,
lib/printr/version.rb,
lib/generators/printr/views_generator.rb,
lib/generators/printr/install_generator.rb
Defined Under Namespace
Modules: Generators
Classes: Engine, Machine
Constant Summary
collapse
- VERSION =
"0.5.1"
- @@encoding =
'ISO-8859-15'
- @@debug =
false
- @@serial_baud_rate =
9600
- @@scope =
'printr'
- @@printr_source =
:yaml
- @@logger =
STDOUT
- @@sanitize_tokens =
[]
- @@codes =
{
:initialize => "\e@",
:papercut => "\x1DV\x00"
}
- @@printrs =
{}
- @@conf =
{}
Class Method Summary
collapse
Class Method Details
.get_printers ⇒ Object
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
|
# File 'lib/printr.rb', line 57
def self.get_printers
Printr.log "Getting Printers"
if @@printr_source == :yaml then
Printr.log "printr_source == :yaml"
@@conf = YAML::load(File.open("#{::Rails.root.to_s}/config/printrs.yml"))
elsif @@printr_source.class == Hash then
if @@printr_source[:active_record] then
Printr.log "printr_source == :active_record"
@@printr_source[:active_record][:class_name].all.each do |p|
key = p.send(@@printr_source[:active_record][:name]).to_sym
Printr.log "conf[#{key}] = #{p.send(@@printr_source[:active_record][:path])}"
@@conf[key] = p.send(@@printr_source[:active_record][:path])
end
end
end
return self.open_printers
end
|
.log(text) ⇒ Object
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
|
# File 'lib/printr.rb', line 39
def self.log(text)
return if not Printr.debug
text = "[Printr] #{text}" if not text.include?('[Printr]')
if @@logger == STDOUT
@@logger.puts
else
if @@logger.respond_to? :info
@@logger.info text
elsif @@logger.respond_to? :puts
@@logger.puts text
else
puts text
end
end
end
|
.new ⇒ Object
36
37
38
|
# File 'lib/printr.rb', line 36
def self.new
return Printr::Machine.new
end
|
.open_printers ⇒ Object
74
75
76
77
78
79
80
|
# File 'lib/printr.rb', line 74
def self.open_printers
@@conf.each do |key,value|
@@printrs[key] = value
end
Printr.log "open_printers returning: " + @@printrs.inspect
@@printrs
end
|
.setup {|_self| ... } ⇒ Object
54
55
56
|
# File 'lib/printr.rb', line 54
def self.setup
yield self
end
|