cuporter 0.3.13 → 0.3.14

Sign up to get free protection for your applications and to get access to all the features.
data/Rakefile CHANGED
@@ -65,7 +65,7 @@ namespace :cuporter do
65
65
 
66
66
  spec = Gem::Specification.new do |s|
67
67
  s.name = 'cuporter'
68
- s.version = '0.3.13'
68
+ s.version = '0.3.14'
69
69
  s.rubyforge_project = s.name
70
70
 
71
71
  s.platform = Gem::Platform::RUBY
@@ -80,8 +80,7 @@ namespace :cuporter do
80
80
  s.required_ruby_version = '>= 1.8.6'
81
81
  s.add_dependency('nokogiri', '>= 1.4.1')
82
82
  s.add_dependency('gherkin', '>= 1.0.0')
83
- s.default_executable = "cuporter"
84
- s.executables = [s.default_executable]
83
+ s.executables = ["cuporter"]
85
84
 
86
85
  s.files = %w(LICENSE README.textile Rakefile) +
87
86
  FileList["config/**/*", "lib/**/*.{rb,xslt}", "bin/*", "public/**/*.{css,js,gif}"].to_a
@@ -1,6 +1,7 @@
1
1
  # Copyright 2010 ThoughtWorks, Inc. Licensed under the MIT License
2
2
  $LOAD_PATH.unshift( File.expand_path("#{File.dirname(__FILE__)}"))
3
3
  require 'cuporter/extensions/string'
4
+ require 'cuporter/extensions/file'
4
5
  require 'cuporter/logging'
5
6
  require 'cuporter/node'
6
7
  require 'cuporter/formatters/text'
@@ -0,0 +1,26 @@
1
+ # Copyright 2011 ThoughtWorks, Inc. Licensed under the MIT License
2
+ module FileExtensions
3
+
4
+ # BOM may be included at first position by windows editors or due to
5
+ # other file encoding related reasons.
6
+ BOM = "\xEF\xBB\xBF"
7
+ # codepoint: U+FEFF
8
+ # hex: ef bb bf
9
+ # octal: \357\273\277
10
+ def without_byte_order_mark(path)
11
+ content = read(path)
12
+ if RUBY_VERSION =~ /^1.8/
13
+ content.slice!(0..2) if content[0..2] == BOM
14
+ else
15
+ BOM.force_encoding("UTF-8")
16
+ unless Encoding.compatible?(content, BOM)
17
+ raise "Encoding #{content.encoding} of file '#{path}' is incompatible for comparison with #{BOM.encoding}"
18
+ end
19
+ content.slice!(0) if content[0] == BOM
20
+ end
21
+ content
22
+ end
23
+
24
+ end
25
+
26
+ File.extend(FileExtensions)
@@ -10,12 +10,13 @@ module Cuporter
10
10
  def initialize(file)
11
11
  @file = file
12
12
  @current_tags = []
13
- @lines = File.read(@file).split(/\n/)
13
+ @lines = File.without_byte_order_mark(@file).split(/\n/)
14
14
  @lang = Language.new(@lines.first)
15
15
  end
16
16
  attr_reader :lang
17
17
  attr_writer :root
18
18
 
19
+
19
20
  def file_relative_path
20
21
  @file_relative_path ||= @file.sub(/^.*#{@root}\//,"#{@root}/")
21
22
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cuporter
3
3
  version: !ruby/object:Gem::Version
4
- hash: 9
4
+ hash: 15
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 3
9
- - 13
10
- version: 0.3.13
9
+ - 14
10
+ version: 0.3.14
11
11
  platform: ruby
12
12
  authors:
13
13
  - Tim Camper
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2011-07-05 00:00:00 Z
18
+ date: 2011-07-11 00:00:00 Z
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
21
21
  name: nokogiri
@@ -73,6 +73,7 @@ files:
73
73
  - lib/cuporter/document/assets.rb
74
74
  - lib/cuporter/document/html_document.rb
75
75
  - lib/cuporter/document.rb
76
+ - lib/cuporter/extensions/file.rb
76
77
  - lib/cuporter/extensions/nokogiri.rb
77
78
  - lib/cuporter/extensions/string.rb
78
79
  - lib/cuporter/feature_parser/language.rb