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

Ability to add component meta #27

Merged
merged 15 commits into from
Nov 6, 2015

Conversation

GustavoCaso
Copy link
Contributor

This pull request is related with the #24 issue.

This will let user to add meta information about the component, in their #{component}.yml file.
I didn't know the best way of configuring this so I changed a liitle the structure of the yml file, now you need to have stubs that would be an array of components.

There could be some problems for supporting previous components, so I added a extra check on the display of the component, to check it follow the correct format stubs_correct_format? so that way if in the future we change the format the user will know. Also if the user have previous stubs it will show the correct format to him thanks to this method stub_example, it will show an example component yml file.

I will wait for your feedback


assert_instance_of Array, component.styleguide_stubs
assert_equal expected_stub, component.styleguide_stubs.first
end

def test_component_stubs
component = MountainView::Component.new('header')
Copy link
Collaborator

Choose a reason for hiding this comment

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

Prefer double-quoted strings unless you need single quotes to avoid extra backslashes for escaping.

component_without_stub_file =
MountainView::Component.new("social_media_icons")
compoenet_with_stubs_but_incorrect_format =
MountainView::Component.new('card')
Copy link
Collaborator

Choose a reason for hiding this comment

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

Prefer double-quoted strings unless you need single quotes to avoid extra backslashes for escaping.

@@ -7,6 +7,7 @@ class ComponentGeneratorTest < Rails::Generators::TestCase
setup :prepare_destination

test "Assert all files are properly created" do
skip
Copy link
Owner

Choose a reason for hiding this comment

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

@GustavoCaso Why do we skip both tests in this file?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@jgnatch They are failing randomly, if you check the travis builds you'll see, also in development they fail randomly, or maybe I'm missing something

Copy link
Collaborator

Choose a reason for hiding this comment

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

We can always re-run them. I think it's preferable to have the tests as false negatives and re-run them than to skip them.

I tried figuring out why it randomly failed but wasn't successful. Any feedback is welcome on that!

This was referenced Oct 22, 2015
end

def stubs_correct_format?
(styleguide_stubs.is_a?(Hash) && styleguide_stubs.key?(:stubs)) || styleguide_stubs.is_a?(Array)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Line is too long. [102/80]

@GustavoCaso
Copy link
Contributor Author

@jgnatch @kitop I have update my code to support Array and Hashes and remove the extra lines for the new hint. But I'm not able to fix the random failing test could give a hand or skip them to merge this pull request and open a new issue to fix this problem ??

Really appreciated, thanks.

@kitop
Copy link
Collaborator

kitop commented Oct 26, 2015

@GustavoCaso Thanks!!
Re-run the test and now passed—yeah, that should be handled in a different issue/PR.

Will give it a look tomorrow evening :) Thanks again!!!

@GustavoCaso
Copy link
Contributor Author

@kitop how we doing with this one ?

@kitop
Copy link
Collaborator

kitop commented Oct 28, 2015

@GustavoCaso having some really busy days, sorry for the delay!!
Should be reviewed and merged soon :)

@kitop
Copy link
Collaborator

kitop commented Oct 30, 2015

@GustavoCaso Sorry for the late response! Everything looks great.
There's only one small thing that I guess it was a bit confusing in the talk.
Regarding the

def self.stub_example
  File.read(File.expand_path("../example.yml", __FILE__))
end

and related code that was changed in: a77f908.

When I mentioned erb, I was thinking of making the yml file and erb, so example.yml.erb so you could interpolate things in there, like the name of the component.
The change introduces some more complexity, and I guess it was because of miscommunication. Sorry about that!

Ideally, going back to the original way it was done, but just changing stub_example to be an instance variable reading from a example.yml file (not even adding the erb stuff now) would simplify the code a bit.
Sorry if I wasn't clear the first time. I can merge and make that change myself if you prefer. Just let me know.

@GustavoCaso
Copy link
Contributor Author

@kitop Don't worry I can do it myself, I really like to help.

So basically what you want is an yml.erb that can interpolate variables ?

@kitop
Copy link
Collaborator

kitop commented Oct 30, 2015

I'd was thinking of that, going back to how the example was rendered (by just reading a file), but make that file a bit more flexible so we could add component name and make the help a bit more friendly :)

More than happy to hear what you think about it! Sorry again about the miscommunication.

@GustavoCaso
Copy link
Contributor Author

@kitop I tried doing that, loading a file example with extension yml.erb and did not feel natural to me.
Already with current working functionality, there is an example.html.erbthat can by as flexible as you want it to be, passing the component name and all the future functionality added to the component, if the example file needed.

But what I did was added the name of the component to that file and display and example stubs so that the users knows how to proceed if they don't have stubs or the have invalid format.

Still giving support for previous stubs as Array

@kitop I'm open to suggestions, if you don't like this way.

@GustavoCaso
Copy link
Contributor Author

@kitop I have no idea such helper exists, the problem is using srtip_heredoc will place the example_stubs just below the :stubs: array and we don't want that.

image

A part from this is there anything else you would do differently.

I will wait for your feedback @kitop

@kitop
Copy link
Collaborator

kitop commented Nov 2, 2015

@GustavoCaso Ah, I see. Thanks for the screenshot :) I guess the :stubs: should be in the string too to be formatted properly, but not a big deal.

Everything looks great! Thanks again for your collaboration. Will probably merge today.

@GustavoCaso
Copy link
Contributor Author

@kitop I moved stubs into the example_stubs now we are using strip_heredoc

When you merge it I will start with the PR #24 for adding extra pages to the style guide

@GustavoCaso
Copy link
Contributor Author

Hey @kitop what is the status with this one ?

kitop added a commit that referenced this pull request Nov 6, 2015
@kitop kitop merged commit 8ef8c67 into devnacho:master Nov 6, 2015
@kitop
Copy link
Collaborator

kitop commented Nov 6, 2015

@GustavoCaso merged. Thanks for your patience!

@GustavoCaso
Copy link
Contributor Author

@kitop Thanks to you. This was my first contribution to open source. I really excited about it.
As mention before I will continue working with the other issue #24

@kitop
Copy link
Collaborator

kitop commented Nov 9, 2015

Congrats @GustavoCaso!!
All contributions are welcome :)

@devnacho
Copy link
Owner

👏 👏 😀

@OddEssay
Copy link
Contributor

Hi guys, do you realise this isn't yet in a tagged release so bundler isn't pulling in the changes?

I got around it by pulling in the master branch directly from github:

gem 'mountain_view', git: 'https://github.com/jgnatch/mountain_view', branch: 'master'

I'm not sure if that's intentional, or just an oversight.

@kitop
Copy link
Collaborator

kitop commented Jan 22, 2016

@OddEssay totally an oversight! Just released v0.8.0 😄
Thanks for letting us know!

Readme still has to be updated to reflect latest changes, but the code is in there!

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.

5 participants