google “chef-solo rails deploy git submodule checkout branch sha”
Working with chef resource deploy, faced several issues with Git provider, for examples
- enable_submodule does not work properly
- it does not get the latest code from submodules
- it does not allow you to choose specific branch and sha of any submodule
- in fact for main repo it does not allow you to switch to any specific branch and sha
- for some reason it says branch=version, who knows why ….
I tried correcting all above, and below is one of my examples, its working for me
dealing with concerns
Taking care of concerns, my views are
They are meant not to have large/GOD classes
They are not specific to ActiveRecord
They are there to help us out find out dependencies easier
They should not be dependent on each other, if module A has concern :b, then there should exist paths “root/a.rb” and “/root/a/b.rb“. Though this we ourself have to make sure about concerns path by writing additional code at initialization
I always willing to write clean and neat code, and have end up maintaining my concerns the following ways
- Reopening Class
- Include Module
- Extend ActiveSupport::Concern
I do have one doubt though, out of 3 approaches, which one is good for faster execution?
mailto:jenkins,subject:test case1, case2 on http://staging.site.com
mailto:jenkins,subject:test case1, case2 on http://staging.site.com
So this is something we thought of
- email Jenkins
- to run one or more jobs
- against one of our deployed staging apps(given base_url)
We wrote a mail_watcher.rb, which periodically reads such emails, and rewrite <JENKINS_CHECKS_DIR>/<test_case_name>.checks files adding parameters to be passed on to the test case. In this case it is BASE_URL=. And all we know that we could make Jenkins
1. watch files getting modified
2. use file contents(key=val), as paramters further to be used or passed on to the job exec
Ohh, wait, I did not know how could Jenkins read parameters from a given key=val file and pass it on further. We actaully wrote another shell script which runs as the first step of every job and reads the testcase_name.checks file and set ENV variables like for example BASE_URL.
So in case of subject:test testcase1 on http://mysite.com
- mail watcher will write testcase1.checks file with BASE_URL=http://mysite.com
- shell script will set ENV variable BASE_URL=http://mysite.com

Following is the mail watcher that we simply run to be able to get Jenkins job triggered.
Now any of us teammates, can anytime send an email and get a test case executed. In addition we are as well generating a detailed report email for each job-run that gets published on a Google group. We do have our own custom, half-baked, reporting mechanism(ruby code), which we want to compile the job-execution-report email for each testcase/job executed.
Example reports
subject: testcase1 failed.
body: <Jenkins console output>
subject: rspec 231 passed, 2 failed.
body: <Jenkins console output>
reading huge xml in ruby
Dealing with huge xml? say of size 400 MB or more than a GB. No worries, Nokogiri::XML::Reader is there for your help. But let me tell you it takes a while before you understand it and start using it. Needs to understand types of elements, and when to read value and and when to read attributes. However I have went over it and tried defining my own module which now simplifies it.
Your large xml doc must be having thousands of records, and you may or may not know the structure of record. This module will help you easily read your records, its elements, something like this below …
hey_my_module take_this_xml and look_for_these_elements let_me_know_if_you_find_any_of_them
…hence
HugeXML.read xml, elements_lookup do |element|
# => element{ :name, :value, :attributes}
end
so simple right? wanna check it out… here it is => github.com/amolpujari/reading-huge-xml
DRYing if @current_user.nil?
While working on one of rails applications, as I usually tend to check whether user is logged in, specially in views as follows
<% if @current_user.nil? %> <a href='url to login page'> <% else %> <a href='some url where logged in user have access'> <% end %>
And over some period I found this pattern repeating everywhere.
I thought of DRYing it, I wanted to have a kind of before_filter for every link that appear on the page, every link should go for login if that page or feature require user entity. and this should be handled by a common thing, similar to before_filter: login_require, on server side. I intend to achieve similar in views. A while back when I read up about html5 custom data attribute, and unobtrusive javascript etc, referring to them, I got one idea as described below, though it is not something that I am making use of custom data attribute exactly, but I found this idea useful and working. May be someone would have good suggestions here for me.
I will put any link which require user login as follows
<a href="/feature/page/" login-require >Feature</a>
And then I will have my after_load.js which will have the following event binding
jQuery('a[login-require]').bind('click', function() {
<% if @current_user.nil? %>
openOverlay('overlay-login');
return false;
<% else %>
return true;
<% end %>
});




