Subversion gem to track commit history in Ruby on rails app - ruby-on-rails

Currently I'm doing research for a custom build deployment application on a unix system. I've also looked at Capistrano so don't worry ;). I'm looking for a gem that can give me the (subversion) commit stream of several projects. I'd like to run some tests with it to determine if it's possible/necessary to build a custom made deployment application.
Thanks

Take a look at the following URL :
http://www.oneofthewolves.com/2007/03/06/ruby-subversion-bindings-finally-some-documentation/

Related

workflow for building rails engines as gems

We are looking into building a very large rails application and considering using engines for better separation of "modules" out of the main app.
we have started this process by creating a small engine using the gem motorhead (the idea of its active_if component is wanted).
That engine was then removed from the main app and given a git init, then pushed to github.
the main app then was able to pull the gem in within the Gemfile.
During this proof of concept, it works, but not very efficient, and also updating the new engine/gem is a bit awkward in this way as it is kinda a submodule in a way. What is the proper workflow for building and maintaining engines/gems when building a modular app like this?
Thanks in advance
The most akward part about deploying Gems or Engines as modules is the constant need to update. We had a lot of success with using:
bundle config local.my_gem ~/projects/my_gem/
It'll point to the Gem/Engine version on disk without modifying the Gemfile and Gemfile.lock.
To remove the local override run:
bundle config --delete local.my_gem ~/projects/my_gem/
With this you should be able to restrict the times the Gemfile.lock has to be updated to deployment time.

What is the best workflow for updating / deploying a Rails app through Git?

I just deployed my first Ruby on Rails app on a VPS at Digital Ocean.
To get started quickly, I did this by simply dragging my Rails directory tree (and its containing files) onto the server via (S)FTP.
I know this isn't the best solution in the long run. So how can I link my app on the server to my git repository at GitHub?
Ideally, when I work on my app locally, and then git commit and git push to my git repository, my app on the VPS will also get updated automatically.
How can this be achieved or what is the best strategy to achieve this?
Since I am building this app just by myself, I can probably keep things simple and stick to a single master branch, rather than having multiple branches.
Thanks for any help.
If I were you, I'd do the pulling and updating on the remote manually. Sorry, but this is not only best practice, but will also force you to learn something useful about system administration and don't require you to be dependent on one host, but can switch service provider and setup as easy it is to make a git-clone somewhere else.
So my workflow would be:
Client:
# Do some changes, commit and add a nice message
$ git commit myfiles
# Push to remote once I'm happy.
$ git push
# SSH to server, and continue from there.
$ ssh username#server
Server:
# Enter project directory
$ cd /var/www/myproject
# Pull code
$ git pull
Done. Or perhaps finish by refreshing server container (uWSGI, fcgi, gunicorn, what have you...)
Reading other similar answers, they hint to looking at the following resource using Capistrano:
Capistrano documentation at GitHub
You should spend a little time now setting up deploys with some automation. Since you are using rails, you should try Capistrano Gem
Capistrano will help you deploy and maintain your application with just a few simple commands. The Readme will show you how to get started, but in general, you will add the Gem by adding this to your Gemfile:
gem 'capistrano', '~> 3.2.0'
then run bundle install to install Capistrano into your bundle. If you are not already using bundler, you should start.
then run bundle exec cap install to setup your local repo for Capistrano.
Basically now you have a nice structure for deployment scripts as part of your repo. You will have to write some deploy scripts now, or modify the examples.
Once done, Capistrano will help you deploy new code (once committed and pushed to your remote repo) and restart the services.
It depends on whatever service you are using to publish your app. Depending on the provider, they may or may not provide rails service. For example, a site like Heroku, where you can actually host for free up until certain restrictions is accessible via github and you can do exactly what you're saying and just push up and publish.
If you can put your repo on your server, you can set up post-receive hooks to pull your branch into your web app directory.
To do so you would create a bare repo on your server, add it as a remote on your development machine, and then (on your server) create the file /my/app.git/hooks/post-receive and add these lines:
#!/bin/bash
#CONFIG
LIVE="/home/saintsjd/www"
read oldrev newrev refname
if [ $refname = "refs/heads/master" ]; then
echo "===== DEPLOYING TO LIVE SITE ====="
unset GIT_DIR
cd $LIVE
git pull origin master
echo "===== DONE ====="
fi
Code from Automated Deployment of PHP Applications using git, by Jon Saints.
Note that it would be possible to do something like this without putting the repo on your server if you use Github's webhooks (https://developer.github.com/v3/repos/hooks/).
However, I would highly recommend using Capistrano (https://github.com/capistrano/capistrano), which can deploy your application code and help you with a lot of administrative tasks (like restarting the server, etc.).
If you want to stick relatively close to git, you might also check out the git-deploy gem.

Is there a way to let Rails push an internal repository to Github while its hosted?

Assume that I have a Rails project. I have published it on a server like Heroku. Think of it as a small app that have to update a git repository (a separate repository in its public folder). Is there a way to achieve this?
For example...
Think that i have some markdown files in my public folder. My rails app will give me an interface to edit these files. When the editing is over, I need to push these files to a git repository. Only that folder through a script in the Rails app.
You can either shell out to git:
Dir.chdir('/path/to/git/tree') do
system = "git commit -m'Updated by rails' -- #{name_of_file_to_commit}"
# Check $?, and do some appropriate error handling if it's != 0
end
Or you can use one of the several ruby Gems for interfacing with git. I am not familiar enough with them to recommend one; in any case, any recommendation will soon be out of date. It's best to do your own search, find candidate gems, and try them.

Rails w/ HopToad -- Deploying?

I have a deployed Rails application that I'd like to use with Hoptoad (an online exception notification service). It comes packaged in a gem that I installed on my deployment server, but I need to run the script/generate hoptoad every time I deploy to configure it because the Hoptoad config files/changes exist only on my production application (and not on my development, so when I deploy, they all get erased).
Is there an easy way to run that script/generate on the production server every time I deploy? I feel like you could do this with Capistrano tasks, but I don't know how to do that.
What do people usually do for this? Sorry if this post is a little hard to understand, I'm not quite sure how to explain the issue.
Thanks!
You can add the Hoptoad configuration file to your source code repository so that it gets deployed as part of the Rails application.
Alternatively, if you don't want that information within your repository, then upload the config file to your production server (outside of Capistrano's normal releases directory structure) and have Capistrano create a symbolic link to it as part of the deployment process. I provided an answer to a similar question here which should give you the idea.

What is your version control and deployment workflow with Rails?

Especially when considering a fresh Rails project, what does your version control and deployment workflow look like? What tools do you use?
I'm interested in answers for Mac, *nix and Windows work machines. Assume a *nix server.
I'll edit for clarity if need be.
Create a copy of my personal Rails 2.1.1 template with preinstalled plugins and frozen gems.
Change DB passwords, session secret/name and deploy.rb.
Create a private or public repository on GitHub as needed.
Push the empty rails project to GitHub.
SSH to Server and configure apache (copy Virtual Host file and mongrel config files from old project)
Create empty database on MySQL server
cap deploy:setup && cap deploy:cold
If everything works so far: Start developing and committing to GitHub. cap deploy as needed.
Update: Don't forget to write tests for everything you do!
Using Windows Vista and a fresh Ubuntu install at Slicehost.
Create a new empty project in
NetBeans.
Fire deprec (http://www.deprec.org) to install
the Rails stack, including version
control, on the target slice.
Commit the empty project to Subversion.
Using Capistrano, test deploy.
Begin actual development after I've verified that I can access the
Rails start page and, possibly,
scaffolding. (This is really not
necessary because I've done this several times and the software works like it says it does.)
Deprec is seriously magic -- it takes the time it takes to clean-start a Rails project (including server configuration and all that jazz) from about a working day down to about an hour -- and that is an hour where you can be doing coding while everything installs.
this guy documents every workflow he's ever experienced
http://subtlegradient.com/articles/2007/03/30/web-development-environment-and-workflow

Resources