renaming yaml file to yml

pull/6827/head
Gregor Schmidt 14 years ago
parent a9b541ca03
commit 1ad59f56d8
  1. 4
      .gitignore
  2. 86
      lib/cards.rb
  3. 0
      lib/labels.yml.default
  4. 22
      lib/tasks/install.rake

4
.gitignore vendored

@ -2,6 +2,6 @@
_site
_posts
assets/styles
lib/labels.yaml
lib/labels-malformed.yaml
lib/labels.yml
lib/labels-malformed.yml
graph.dot

@ -10,18 +10,18 @@ require 'uri/common'
module Cards
class TaskboardCards
include Redmine::I18n
begin
LABELS = YAML::load_file(File.dirname(__FILE__) + '/labels.yaml')
LABELS = YAML::load_file(File.dirname(__FILE__) + '/labels.yml')
rescue
LABELS = {}
end
def self.selected_label
return nil if not Setting.plugin_redmine_backlogs[:card_spec]
return LABELS[Setting.plugin_redmine_backlogs[:card_spec]]
end
def initialize(lang)
set_language_if_valid lang
@ -30,26 +30,26 @@ module Cards
raise "Label stock \"#{Setting.plugin_redmine_backlogs[:card_spec]}\" not found" unless label
label['papersize'].upcase!
geom = Prawn::Document::PageGeometry::SIZES[label['papersize']]
raise "Paper size '#{label['papersize']}' not supported" if geom.nil?
@paper_width = geom[0]
@paper_height = geom[1]
@top_margin = TaskboardCards.topts(label['top_margin'])
@vertical_pitch = TaskboardCards.topts(label['vertical_pitch'])
@height = TaskboardCards.topts(label['height'])
@left_margin = TaskboardCards.topts(label['left_margin'])
@horizontal_pitch = TaskboardCards.topts(label['horizontal_pitch'])
@width = TaskboardCards.topts(label['width'])
@across = label['across']
@down = label['down']
@inner_margin = TaskboardCards.topts(label['inner_margin']) || 1.mm
@pdf = Prawn::Document.new(
:page_layout => :portrait,
:left_margin => 0,
@ -69,10 +69,10 @@ module Cards
)
@pdf.font "DejaVuSans"
@cards = 0
end
def self.measurement(x)
x = "#{x}pt" if x =~ /[0-9]$/
return x
@ -101,7 +101,7 @@ module Cards
'misc-iso-templates.xml',
'misc-other-templates.xml',
'misc-us-templates.xml',
'pearl-iso-templates.xml',
'pearl-iso-templates.xml',
'uline-us-templates.xml',
'worldlabel-us-templates.xml',
'zweckform-iso-templates.xml'].each {|filename|
@ -135,20 +135,20 @@ module Cards
end
doc = REXML::Document.new(labels)
doc.elements.each('Glabels-templates/Template') do |specs|
label = nil
papersize = specs.attributes['size']
papersize = 'Letter' if papersize == 'US-Letter'
specs.elements.each('Label-rectangle') do |geom|
margin = nil
geom.elements.each('Markup-margin') do |m|
margin = m.attributes['size']
end
margin = "1mm" if margin.blank?
geom.elements.each('Layout') do |layout|
label = {
'inner_margin' => TaskboardCards.measurement(margin),
@ -165,9 +165,9 @@ module Cards
}
end
end
next if label.nil?
key = "#{specs.attributes['brand']} #{specs.attributes['part']}"
if TaskboardCards.malformed(label)
@ -175,7 +175,7 @@ module Cards
malformed_labels[key] = label
else
LABELS[key] = label if not LABELS[key] or LABELS[key]['source'] == 'glabel'
specs.elements.each('Alias') do |also|
key = "#{also.attributes['brand']} #{also.attributes['part']}"
LABELS[key] = label.dup if not LABELS[key] or LABELS[key]['source'] == 'glabel'
@ -183,11 +183,11 @@ module Cards
end
end
}
File.open(File.dirname(__FILE__) + '/labels.yaml', 'w') do |dump|
File.open(File.dirname(__FILE__) + '/labels.yml', 'w') do |dump|
YAML.dump(LABELS, dump)
end
File.open(File.dirname(__FILE__) + '/labels-malformed.yaml', 'w') do |dump|
File.open(File.dirname(__FILE__) + '/labels-malformed.yml', 'w') do |dump|
YAML.dump(malformed_labels, dump)
end
@ -200,29 +200,29 @@ module Cards
Setting.plugin_redmine_backlogs = s
end
end
attr_reader :pdf
def card(issue, type)
row = (@cards % @down) + 1
col = ((@cards / @down) % @across) + 1
@cards += 1
@pdf.start_new_page if row == 1 and col == 1 and @cards != 1
parent_story = issue.story
# card bounds
@pdf.bounding_box self.top_left(row, col), :width => @width, :height => @height do
@pdf.line_width = 0.5
@pdf.stroke do
@pdf.stroke_bounds
# card margin
@pdf.bounding_box [@inner_margin, @height - @inner_margin],
:width => @width - (2 * @inner_margin),
:height => @height - (2 * @inner_margin) do
scoresize = 0
@y = @pdf.bounds.height
@pdf.font_size(12) do
@ -230,13 +230,13 @@ module Cards
score ||= '?'
score = "#{score} #{type == :task ? l(:label_hours) : l(:label_points)}"
scoresize = @pdf.width_of(" #{score} ")
text_box(score, {
:width => scoresize,
:height => @pdf.font.height
}, pdf.bounds.width - scoresize)
end
@y = @pdf.bounds.height
pos = parent_story.position ? parent_story.position : l(:label_not_prioritized)
trail = (issue.self_and_ancestors.reverse.collect{|i| "#{i.tracker.name} ##{i.id}"}.join(" : ")) + " (#{pos})"
@ -247,8 +247,8 @@ module Cards
:style => :italic
})
end
@pdf.font_size(6) do
parent = (type == :task ? parent_story.subject : (issue.fixed_version ? issue.fixed_version.name : I18n.t(:backlogs_product_backlog)))
text_box parent, {
@ -256,21 +256,21 @@ module Cards
:height => @pdf.font.height
}
end
text_box issue.subject, {
:width => pdf.bounds.width,
:height => @pdf.font.height * 2
}
@pdf.line [0, @y], [pdf.bounds.width, @y]
@y -= 2
@pdf.font_size(8) do
text_box issue.description || issue.subject , {
:width => pdf.bounds.width,
:height => @y - 8
}
end
@pdf.font_size(6) do
category = issue.category ? "#{l(:field_category)}: #{issue.category.name}" : ''
catsize = @pdf.width_of(" #{category} ")
@ -283,24 +283,24 @@ module Cards
end
end
end
def add(story, add_tasks = true)
if add_tasks
story.descendants.each {|task|
card(task, :task)
}
end
card(story, :story)
end
def text_box(s, options, x = 0)
box = Prawn::Text::Box.new(s, options.merge(:overflow => :ellipses, :at => [x, @y], :document => @pdf))
box.render
@y -= (options[:height] + (options[:size] || @pdf.font_size) / 2)
return box
end
def self.topts(v)
return nil if v.class == NilClass
@ -319,7 +319,7 @@ module Cards
return Float(v).pt if units == 'pt'
raise "Unexpected units '#{units}'"
end
def top_left(row, col)
top = @paper_height - (@top_margin + @vertical_pitch * (row - 1))
left = @left_margin + (@horizontal_pitch * (col - 1))

@ -1,7 +1,7 @@
require 'fileutils'
namespace :redmine do
namespace :backlogs do
namespace :backlogs do
desc "Install and configure Redmine Backlogs"
task :install => :environment do |t|
@ -36,9 +36,9 @@ namespace :redmine do
print "\nCard labels could not be fetched (#{fetch_error}). Please try again later. Proceeding anyway...\n"
end
else
if ! File.exist?(File.dirname(__FILE__) + '/../labels.yaml')
if ! File.exist?(File.dirname(__FILE__) + '/../labels.yml')
print "Default labels installed\n"
FileUtils.cp(File.dirname(__FILE__) + '/../labels.yaml.default', File.dirname(__FILE__) + '/../labels.yaml')
FileUtils.cp(File.dirname(__FILE__) + '/../labels.yml.default', File.dirname(__FILE__) + '/../labels.yml')
end
end
settings[:card_spec] ||= Cards::TaskboardCards::LABELS.keys[0] unless Cards::TaskboardCards::LABELS.size == 0
@ -55,7 +55,7 @@ namespace :redmine do
print "Separate values with a space (e.g. 1 3): "
STDOUT.flush
selection = (STDIN.gets.chomp!).split(/\D+/)
# Check that all values correspond to an items in the list
invalid = false
invalid_value = nil
@ -69,7 +69,7 @@ namespace :redmine do
tracker_names << trackers[s.to_i-1].name
end
end
if invalid
puts "Oooops! You entered an invalid value (#{invalid_value}). Please try again."
else
@ -82,7 +82,7 @@ namespace :redmine do
settings[:story_trackers] = selection.map{ |s| trackers[s.to_i-1].id }
end
if !Task.tracker
# Check if there is at least one tracker available
puts "-----------------------------------------------------"
@ -98,7 +98,7 @@ namespace :redmine do
print "Choose one from above (or choose none to create a new tracker): "
STDOUT.flush
selection = (STDIN.gets.chomp!).split(/\D+/)
if selection.length > 0 and selection.first.to_i <= available_trackers.length
# If the user picked one, use that
print "You selected #{available_trackers[selection.first.to_i-1].name}. Is this correct? (y/n) "
@ -128,9 +128,9 @@ namespace :redmine do
# Necessary because adding key-value pairs one by one doesn't seem to work
Setting.plugin_redmine_backlogs = settings
puts "Story and task trackers are now set."
print "Migrating the database..."
STDOUT.flush
system('rake db:migrate_plugins --trace > redmine_backlogs_install.log')
@ -146,7 +146,7 @@ namespace :redmine do
puts "*******************************************************"
end
end
def create_new_tracker
repeat = true
puts "Creating a new task tracker."
@ -160,7 +160,7 @@ namespace :redmine do
end
print "You typed '#{name}'. Is this correct? (y/n) "
STDOUT.flush
if (STDIN.gets.chomp!).match("y")
tracker = Tracker.new(:name => name)
tracker.save!

Loading…
Cancel
Save