Skip to content
This repository has been archived by the owner on Jul 6, 2021. It is now read-only.

Add Data Tables #14

Closed
wants to merge 8 commits into from
Closed

Add Data Tables #14

wants to merge 8 commits into from

Conversation

jowers
Copy link
Contributor

@jowers jowers commented Feb 16, 2015

I've added a failing feature for this one - I think we'll need a few more features, but I've kept it simple for now - just a single row. I've also guessed at a tcl proc name - I suspect that will have to change once I've thought about it a bit more.

The other types that I think we'll definitely need are:

| heading_1 | heading_2 |
| data 1    | data 2    |

| heading_1 | data 1 |
| heading_2 | data 2 |

and, of course, something with multiple values in:

| heading_1 | heading_2 |
| row_1 1   | row_1 2   |
| row_2 1   | row_2 2   |
| row_3 1   | row_3 2   |

@jowers jowers changed the title Initial failing feature - may have change the tcl function later Add Data Tables Feb 16, 2015
@mattwynne
Copy link
Contributor

Looks good. Do you need any help on the Ruby side?

@jowers
Copy link
Contributor Author

jowers commented Feb 17, 2015

I've got a starting point for the ruby, I suspect I'll need to you tidy it up and "rubify" it though. I've started with:

def data_table(arg)
  @arguments << arg.raw
end

In the ArgumentList class, and proved that I'm getting that passed through to the tcl. Given that it's not in a "tcl" format, I suppose I should modify it in the ruby first before passing it through... I'll have a go at that next.
Once I start writing that much ruby code, should I have ruby unit tests somewhere?

@mattwynne
Copy link
Contributor

Yeah that looks right. I think there's one spec for the StepDefinitions class, so you might be able to use that if you want a smaller lever. Run the specs with rake or rspec.

I think that #raw is going to give you an Array of Array of String which should translate into tcl primitives OK. Let's see...

@jowers
Copy link
Contributor Author

jowers commented Feb 17, 2015

I think this will come back to the old tcl phrase of "everything's a string" - In the tcl, I'm getting:

[["first_column", "second_column"]]

I need to find out how to turn a string into at least a list so I can try to do something with it...

@jowers
Copy link
Contributor Author

jowers commented Feb 17, 2015

Ok, I've got something that kind of works in tcl, although I'm not that pleased/proud of it:

proc _convert_ruby_raw_to_tcl_lists {raw} {
  set raw [regsub -all {,} $raw ""]
  set raw [regsub -all {\[} $raw "{"]
  set raw [regsub -all {\]} $raw "}"]
  set raw [lindex $raw 0]

  return $raw
}

That results in a tcl list of lists which I can work with (arrays in tcl are a bit of a pain). I was thinking that in the "raw" form, a list of lists would be a good start, and then for getting hashes, we can use a dict.

It's pretty messy using regsubs (and likely to break as soon as there is a table with any of these characters in). Do you think it makes more sense to get the ruby to pass through the data in "tcl list" format - i.e. to convert:

[["first_column", "second_column"]]

into

{"first_column" "second_column"}

?

@mattwynne
Copy link
Contributor

@jowers do you think this will do for now, if we tidy up the commits?

I think we could add the table helper methods in later iterations.

@jowers
Copy link
Contributor Author

jowers commented Feb 19, 2015

Yep, I think so.

@jowers jowers mentioned this pull request Feb 19, 2015
@jowers
Copy link
Contributor Author

jowers commented Feb 23, 2015

I think we're ready to merge this one back. I've added a section to the README explaining the use of tables in step definitions (as a side note, we probably need to edit the README as it's now a bit sprawling and could do with a few sub-headings - I suspect my use of tenses is all over the place).

Does the automatic merge thing in github do all the squashing of comments for you?

@mattwynne
Copy link
Contributor

Yes, I think it's ready. The GitHub merge button does not squash commits. If you want to use that, the right thing to do is to use git rebase -i master, squash / tidy the commits in the branch manually, do a git push origin +data-tables to force-push it. You'll see the newly tidied commit history on this PR, then you can merge it in.

@mattwynne
Copy link
Contributor

Otherwise, just use git checkout master && git merge data-tables --squash as usual.

@jowers
Copy link
Contributor Author

jowers commented Feb 24, 2015

Ok, merged this one as well.

I guess I should do another release now that we have these 2 in place. IIRC, I need to do the following for that:

  • Update the version file with the new version
  • bundle build
  • bundle release

Is that all, or have I forgotten something?

@mattwynne
Copy link
Contributor

It's rake build and rake release but I will also need to give you release karma on rubygems.org. I'll put some instructions up for that.

@aslakhellesoy
Copy link

Always a good idea to put release instructions in CONTRIBUTING.md

mattwynne added a commit that referenced this pull request Feb 27, 2015
@mattwynne
Copy link
Contributor

Yeah so @jowers if you look in https://github.com/cucumber-ltd/bbc-a11y/blob/master/CONTRIBUTING.md you'll see what you need to do to get release karma.

@jowers
Copy link
Contributor Author

jowers commented Mar 2, 2015

I've just released v0.0.4 to rubygems. Closing pull request.

@jowers jowers closed this Mar 2, 2015
@mattwynne
Copy link
Contributor

mattwynne commented Mar 2, 2015 via email

@jowers jowers deleted the data-tables branch March 2, 2015 21:24
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants