newbie: copy file from github to local directory?

11 views
Skip to first unread message

Jason McMahan

unread,
Jun 5, 2018, 4:14:49 PM6/5/18
to Ruby on Rails: Talk
Good day,
I am new to rails and would like suggestions/help to copy a file from github to a local directory.

I assume use the FileUtils but any help would be appreciated.

Thank you

Joe Guerra

unread,
Jun 5, 2018, 4:17:06 PM6/5/18
to rubyonra...@googlegroups.com
just download it.

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe@googlegroups.com.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/8943f08a-38ea-4f1c-aad1-79bff84278f3%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Ralph Shnelvar

unread,
Jun 5, 2018, 4:30:17 PM6/5/18
to Jason McMahan
Jason,

I am not aware of any Rails/Ruby-native facility to download stuff from github.

As has been stated elseelse - and I will paraphrase - just use github-native commands.

Ralph
--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-ta...@googlegroups.com.
To post to this group, send email to
rubyonra...@googlegroups.com.

To view this discussion on the web visit

Hassan Schroeder

unread,
Jun 5, 2018, 5:15:08 PM6/5/18
to rubyonrails-talk
On Tue, Jun 5, 2018 at 1:14 PM, Jason McMahan <jason.m...@gmail.com> wrote:

> I am new to rails and would like suggestions/help to copy a file from github
> to a local directory.

Not a Rails question at all, but assuming you know the URL of the
file you want to retrieve:

https://ruby-doc.org/stdlib-2.5.1/libdoc/open-uri/rdoc/OpenURI.html

--
Hassan Schroeder ------------------------ hassan.s...@gmail.com
twitter: @hassan
Consulting Availability : Silicon Valley or remote

Jason McMahan

unread,
Jun 6, 2018, 6:56:43 AM6/6/18
to Ruby on Rails: Talk
The url is https://github.com/Azure/WALinuxAgent/blob/master/config/66-azure-storage.rules

I thought something along the lines of 

    if File.exist? '/etc/udev/rules.d/66-azure-storage.rules'
      setcode do
       #*something*
      end
    else
      #Copy file from url to /etc/udev/rules.d/66-azure-storage.rules
      #then do something.
    end

Thank you all the quick replies and help thus far it is appreciated.

Jason McMahan

unread,
Jun 6, 2018, 8:49:59 AM6/6/18
to Ruby on Rails: Talk
Would this code work or am i way off?

    setcode do
      if File.exist? '/etc/udev/rules.d/66-azure-storage.rules'
          #do something
      else
        IO.copy_stream(download, '/etc/udev/rules.d/66-azure-storage.rules')
         #do something
      end
    end

Hassan Schroeder

unread,
Jun 6, 2018, 9:57:42 AM6/6/18
to rubyonrails-talk
On Wed, Jun 6, 2018 at 5:49 AM, Jason McMahan <jason.m...@gmail.com> wrote:
> Would this code work or am i way off?

Why not just try it?
Reply all
Reply to author
Forward
0 new messages