lib/pdd.rb in pdd-0.3 vs lib/pdd.rb in pdd-0.4
- old
+ new
@@ -20,12 +20,14 @@
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.
require 'pdd/sources'
+require 'pdd/version'
require 'nokogiri'
require 'logger'
+require 'time'
# PDD main module.
# Author:: Yegor Bugayenko (yegor@teamed.io)
# Copyright:: Copyright (c) 2014 Yegor Bugayenko
# License:: MIT
@@ -58,10 +60,11 @@
# Ctor.
# +opts+:: Options
def initialize(opts)
@opts = opts
PDD.log = Logger.new(File::NULL) unless @opts.verbose?
+ PDD.log.info "my version is #{PDD::VERSION}"
end
# Generate XML.
def xml
dir = @opts.source? ? @opts[:source] : Dir.pwd
@@ -72,11 +75,11 @@
PDD.log.info "excluding #{p}"
end unless @opts[:exclude].nil?
sanitize(
Nokogiri::XML::Builder.new do |xml|
xml << '<?xml-stylesheet type="text/xsl" href="puzzles.xsl"?>'
- xml.puzzles do
+ xml.puzzles(version: PDD::VERSION, date: Time.now.utc.iso8601) do
sources.fetch.each do |source|
source.puzzles.each do |puzzle|
PDD.log.info "puzzle #{puzzle.props[:ticket]}:" \
"#{puzzle.props[:estimate]}/#{puzzle.props[:role]}" \
" at #{puzzle.props[:file]}"
@@ -103,9 +106,10 @@
xsd = Nokogiri::XML::Schema(
File.read(File.join(File.dirname(__FILE__), '../asserts/puzzles.xsd'))
)
errors = xsd.validate(Nokogiri::XML(xml)).map { |error| error.message }
errors.each { |e| PDD.log.error e }
+ PDD.log.error(xml) unless errors.empty?
fail SchemaError, errors.join('; ') unless errors.empty?
xml
end
end
end