paulsamuels / SBConstants

MIT License
311 stars 28 forks source link

@paulsamuels => Swift Support #2

Closed orta closed 10 years ago

orta commented 10 years ago

I want to use this in artsy/eidolon but I want to keep it as swifty as possible.

So I've added another flag to add support for outputting as swift and updated the README. You had a lot of training whitespace, so my editor cleaned those up as I was digging around in the source.

When I tried to just run it from master I couldn't get the templates to run, so I made the head / body instance vars because I couldn't figure out how the data gets passed through. Good old ruby.

Looks like this:

// Auto generated file from SBConstants - any changes may be lost

enum SegueIdentifier : String {
    case bid = "bid"
}

enum ViewControllerStoryboardIdentifier : String {
    case EnterYourBidDetails = "Enter Your Bid Details"
    case FulfillmentContainerViewController = "FulfillmentContainerViewController"
    case GetYourBidderDetails = "Get Your Bidder Details"
    case PlaceYourBid = "Place Your Bid"
    case SwipeCreditCard = "Swipe Credit Card"
}

random side-note, I also spent 2 years in the 3 years ago :)

paulsamuels commented 10 years ago

@orta Nice work!!!

I've not got the bandwidth to fully test at the moment as I don't have any projects with enough storyboard usage to make it worthwhile running the tool :(

Only question I have is what the reasoning behind the -w flag choice is?

orta commented 10 years ago

I couldn't do -sw and -s was already taken, so w was next in line, nothing too special.

I have no other apps with Storyboards, so I'm in a similar position :D

NachoSoto commented 10 years ago

I'd love to test this out, I just ran into this project thanks to @orta's tweet :)

But it's currently not working for me after gem install sbconstants:

(erb):2:in `method_missing': undefined local variable or method `head' for #<SBConstants::ConstantWriter:0x007f9e6399a9b8> (NameError)
    from /Users/NachoSoto/.rvm/rubies/ruby-2.1.0/lib/ruby/2.1.0/erb.rb:850:in `eval'
    from /Users/NachoSoto/.rvm/rubies/ruby-2.1.0/lib/ruby/2.1.0/erb.rb:850:in `result'
    from /Users/NachoSoto/.rvm/gems/ruby-2.1.0/gems/sbconstants-0.0.4/lib/sbconstants/constant_writer.rb:32:in `template_with_file'
    from /Users/NachoSoto/.rvm/gems/ruby-2.1.0/gems/sbconstants-0.0.4/lib/sbconstants/constant_writer.rb:22:in `header'
    from /Users/NachoSoto/.rvm/gems/ruby-2.1.0/gems/sbconstants-0.0.4/lib/sbconstants/constant_writer.rb:13:in `write'
    from /Users/NachoSoto/.rvm/gems/ruby-2.1.0/gems/sbconstants-0.0.4/lib/sbconstants/cli.rb:59:in `write'
    from /Users/NachoSoto/.rvm/gems/ruby-2.1.0/gems/sbconstants-0.0.4/lib/sbconstants/cli.rb:18:in `run'
    from /Users/NachoSoto/.rvm/gems/ruby-2.1.0/gems/sbconstants-0.0.4/lib/sbconstants/cli.rb:8:in `run'
    from /Users/NachoSoto/.rvm/gems/ruby-2.1.0/gems/sbconstants-0.0.4/bin/sbconstants:5:in `<top (required)>'
    from /Users/NachoSoto/.rvm/gems/ruby-2.1.0/bin/sbconstants:23:in `load'
    from /Users/NachoSoto/.rvm/gems/ruby-2.1.0/bin/sbconstants:23:in `<main>'
    from /Users/NachoSoto/.rvm/gems/ruby-2.1.0/bin/ruby_executable_hooks:15:in `eval'
    from /Users/NachoSoto/.rvm/gems/ruby-2.1.0/bin/ruby_executable_hooks:15:in `<main>'
orta commented 10 years ago

^ that error @NachoSoto is why I moved it to use @head

You can my version in your gemfile, and do a bundle exec ( see this PR for how I do it: https://github.com/artsy/eidolon/pull/28/files )

NachoSoto commented 10 years ago

Seems to work fine :)

orta commented 10 years ago

I've switched the swift enums to public, turns out that's pretty useful in trying to do anything.

orta commented 10 years ago

I've removed dashes from constant names too. Would you like me to take over maintaining this project?

paulsamuels commented 10 years ago

@orta I have no issue with you taking over maintenance - rather swamped with other commitments currently. What do we need to do?

orta commented 10 years ago

It's pretty easy, I'll need to be added as a gem admin, and have collaborator access to this repo.

gem owner sbconstants -a [first_name].therox@gmail.com should do the ruby bit, and the github stuffs easy.

paulsamuels commented 10 years ago

@orta done - let me know if you have any issues

orta commented 10 years ago

awesome, I've merged in #3 and updated the README with more examples. Merging.