Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

.liftoffrc #51

Closed
wants to merge 20 commits into from
Closed

.liftoffrc #51

wants to merge 20 commits into from

Conversation

mokagio
Copy link
Contributor

@mokagio mokagio commented Jan 14, 2014

Here's a first draft of the .liftoffrc feature. See #47.

The file is a simple JSON, the turn_on_all_options method looks for it first on pwd, then on ~, and if it doesn't find it falls back to the default set of settings.

I think JSON is a natural and smart option for this, but other format could be valid as well, YAML maybe?

Some things left to do

  • .liftoffrc validation
  • Nicer output for the user
  • Update README
  • Write in "proper" Ruby

Feedbacks? (Please forgive my Ruby)


Some new tasks after the first code review round.

  • Use parenthesis for methods names.
  • Use instance methods rather than class.
  • Use YAML instead of JSON.
  • Refactor options getter method to override default option with ~ options, the override those with pwd options.
  • Create file with default options
  • .rspec + Rakefile update
  • Restore liftoff -a behaviour, and plug options inspection on just liftoff.

Forgot something!

  • Remove DEFAULT_INDENTATION_LEVEL

@mokagio
Copy link
Contributor Author

mokagio commented Jan 14, 2014

Another thing to do is

@gfontenot
Copy link
Member

Hey man, thanks for submitting this. Just wanted to let you know that we're not ignoring it. Trying to find time to respond to it properly.

@mokagio
Copy link
Contributor Author

mokagio commented Jan 15, 2014

:) no problems and no rush, liftoff works well already anyway 👍

@mokagio
Copy link
Contributor Author

mokagio commented Jan 30, 2014

@gfontenot, @21x9 I'd say it's done. Wanna take a look?

It would be nice if some of your thoughtbot Ruby guys could take a look at it as well, to check the write in proper Ruby point.

@@ -2,3 +2,5 @@ source 'https://rubygems.org'

# Specify your gem's dependencies in liftoff.gemspec
gemspec

gem "rspec"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is rendering oddly in GitHub, but you need a newline at the end of this file. I'm also not sure that the spec gem shouldn't be in the development group in the gemspec.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep, I realised I was missing the :test group only later when I set up Travis.

@gfontenot
Copy link
Member

Took a spin through this, and it's a great start. A few general notes:

  • Instead of using the conditional assignments for getting the options in Launchpad, why not move that same thing back into OptionsHelper? That way, all you have to do to get the default options is get them from a single place. The Launchpad shouldn't care how the options are generated.
  • OptionsHelper might be better named as DefaultOptions or something similar. As I noted earlier, instead of using class methods, we should be using instance methods.
  • I'm not sold on JSON as the file format for the config file, honestly. I'm almost thinking that YAML will be a lighter weight solution that's easier to expand upon. I can easily see a future where we let users define a default directory structure, and that would be much easier in YAML.
  • I'm wondering if this is going to need to be smarter than it currently is. As implemented here, it falls back on a per-file basis, but it should probably fall back on a per-option basis. If I have 1 project that uses 2 spaces instead of 4, I should be able to have a simple local liftoffrc that defines that key, and then all of the other keys fall back to the global config or the default config.'
  • Stylistically, we're trying to use parens for method arguments everywhere, so if you could match that, it would fit in better.
  • Holy crap this project has a test in it now! We should probably have more of those.

Pumped about how much this is going to improve liftoff, man. Thanks for lending a hand.

@gfontenot
Copy link
Member

Last thing that I just thought of: Instead of having the defaults written out in code, it would probably be best to have a lib/defaults/liftoffrc file to read from for the defaults.

@mokagio
Copy link
Contributor Author

mokagio commented Jan 31, 2014

Thanks for the code review, I learn a new bunch of stuff in like 5 minutes. Awesome!

Last thing that I just thought of: Instead of having the defaults written out in code, it would probably be best to have a lib/defaults/liftoffrc file to read from for the defaults.

Great idea! It could also work as reference for users to look at when rolling out their own settings.

@mokagio
Copy link
Contributor Author

mokagio commented Jan 31, 2014

Oh! Also... 👍 👍 for the YAML, it made sense to me to use JSON for simple key-value settings, but YAML is definitely better for describing a directory structure, plus there's less to write.

@@ -1 +1,8 @@
require "bundler/gem_tasks"

desc "Runs the tests for the project"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The changes to this file can be like this instead, to avoid calling system:

require "rspec/core/rake_task"

task :default => :spec

If you want color, I'd add --color to a .rspec file in the root of the project.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice! That's awesome thanks!

One question? Would you check-in the .rspec? Or is stuff like that
considered user specific so it shouldn't be added?

Cheers :)

On Friday, January 31, 2014, Gabe Berke-Williams notifications@github.com
wrote:

In Rakefile:

@@ -1 +1,8 @@
require "bundler/gem_tasks"
+
+desc "Runs the tests for the project"

The changes to this file can be like this instead, to avoid calling system
:

require "rspec/core/rake_task"

task :default => :spec

If you want color, I'd add --color to a .rspec file in the root of the
project.

Reply to this email directly or view it on GitHubhttps://github.com//pull/51/files#r9346409
.

Giò

"Be a yardstick of quality. Some people aren't used to an environment
where excellence is expected" S.J.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think that's up to @gfontenot. If he doesn't want to merge it, you can make a ~/.rspec file just on your computer, and RSpec will always check that.

@mokagio mokagio closed this Feb 4, 2014
@mokagio mokagio reopened this Feb 4, 2014
@mokagio
Copy link
Contributor Author

mokagio commented Feb 6, 2014

Yo! Got a bit more time this week and did some work done!

Now .liftoffrc uses YAML format, liftoff does a smart options lookup, and liftoff -a works as it did before, setting everything to the default values.

@gfontenot

OptionsHelper might be better named as DefaultOptions or something similar. As I noted earlier, instead of using class methods, we should be using instance methods.

It made sense to me to use that name to be in line with GitHelper and XcodeHelper. Although GitHelper is now FileManager right? And DefaultOptions speaks a bit more of what that class do... So yeah, I'm gonna change it.

I also made some comments regarding some doubts I have.

@gfontenot
Copy link
Member

Awesome, yeah. The move from GitHelper to FileManager was prompted by me looking at the current naming convention and not being super happy with them. I'll take a look at this in full tomorrow and I'll brainstorm on the naming.

@mokagio
Copy link
Contributor Author

mokagio commented Feb 6, 2014

👍 I like DefaultOptions more than OptionsHelper, but I'm still not super happy. Also doing stuff like DefaultOptions.new.default_options is a bit weird...

end

def user_default_options
evaluted_options = default_options
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

evaluted is misspelled - it should be evaluated.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch, thanks :)

@@ -34,6 +34,19 @@ Usage: liftoff [options]
-h, --help Display this help message
```

### Configuration - .liftoffrc

You can use the `.liftoffrc` file to speedup your workflow by defining your favorite settings for liftoff.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lets add a note here about ~/.liftoffrc vs ./.liftoffrc and how the precedence/per-key system works.

@gfontenot
Copy link
Member

@mokagio I've actually gone ahead and made these minor fixes myself, and all of this is merged in 03b34d9. Thank you for your work on this!

@mokagio
Copy link
Contributor Author

mokagio commented Feb 9, 2014

Cool! Awesome stuff!

Thank you guys for coming up with this in the first place! Such a valuable addition to my toolbelt!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants