Class: Chibineko::TestCase
- Inherits:
-
Object
- Object
- Chibineko::TestCase
- Defined in:
- lib/chibineko/testcase.rb
Constant Summary collapse
- URL_REGEXP =
%r{^http://chibineko.jp/t/[^/]*$}
Instance Attribute Summary collapse
-
#items ⇒ Object
Returns the value of attribute items.
-
#source ⇒ Object
Returns the value of attribute source.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(content, src = nil) ⇒ TestCase
constructor
A new instance of TestCase.
Constructor Details
#initialize(content, src = nil) ⇒ TestCase
Returns a new instance of TestCase.
18 19 20 21 22 23 24 |
# File 'lib/chibineko/testcase.rb', line 18 def initialize(content, src=nil) self.source = src csv = CSV.new(content, return_headers: false, headers: :first_row) self.items = csv.to_enum.with_index(1).map { |row,line| TestItem.new(row,source,line) } end |
Instance Attribute Details
#items ⇒ Object
Returns the value of attribute items.
17 18 19 |
# File 'lib/chibineko/testcase.rb', line 17 def items @items end |
#source ⇒ Object
Returns the value of attribute source.
17 18 19 |
# File 'lib/chibineko/testcase.rb', line 17 def source @source end |
Class Method Details
.load_from_file(file_path) ⇒ Object
12 13 14 15 |
# File 'lib/chibineko/testcase.rb', line 12 def load_from_file(file_path) content = File.read(file_path, encoding: "UTF-8") new(content,File.(file_path)) end |
.retrieve(testcase_url) ⇒ Object
5 6 7 8 9 10 11 |
# File 'lib/chibineko/testcase.rb', line 5 def retrieve(testcase_url) uri = URI.parse( testcase_url + "/test_case.csv?encode=utf-8") content = Net::HTTP.get(uri) # Content-Type: text/csv; charset=utf-8 # But some japanese charactors was not read. new(content.encode("UTF-8", "UTF-8"), testcase_url) end |