Register a SA Forums Account here!
JOINING THE SA FORUMS WILL REMOVE THIS BIG AD, THE ANNOYING UNDERLINED ADS, AND STUPID INTERSTITIAL ADS!!!

You can: log in, read the tech support FAQ, or request your lost password. This dumb message (and those ads) will appear on every screen until you register! Get rid of this crap by registering your own SA Forums Account and joining roughly 150,000 Goons, for the one-time price of $9.95! We charge money because it costs us money per month for bills, and since we don't believe in showing ads to our users, we try to make the money back through forum registrations.
 
  • Post
  • Reply
Peristalsis
Apr 5, 2004
Move along.

Smol posted:

Model attributes that are not marked as serializable (stuff that is saved as json or yaml strings in the database, usually arrays) are only saved when they are marked to be dirty, i.e. when you use the setter methods. If you mutate the values directly, Rails doesn't know about that.


necrotic posted:

While I wouldn't recommend it for this use case, you can force an attribute to dirty by calling foo.prop_will_change!. See the API Docs for more on dirty attributes.

Awesome, thanks folks! I don't mind going through the setter, I just wanted to understand what's going on.

Adbot
ADBOT LOVES YOU

kayakyakr
Feb 16, 2004

Kayak is true
Last night and this morning are why I hate tests. I have spent more time trying to figure out why this test isn't working than I did writing the drat feature in the first place.

I have 2 nearly identical tests. In one, it works 100% of the time. In the other it fails 100% of the time. The difference is that the failing test has a second user that has been created in the system.

"That's easy, figure out why the other user is causing the test to fail!"

If only. It's failing because in the 2nd test, the controller isn't getting the params that are being passed in the body of the AJAX call.

How does this make any sense:

Ruby code:
p request.body # {"team"=>{"id"=>"5491ad83616d620e44010000", "name"=>"Hogan's Heros", "public"=>false, "user_id"=>"5491ad83616d620e44000000", "coach_ids"=>[], 
			   # "participant_ids"=>[], "invited_users"=>[], "invited_coaches"=>["test2@example.com"], "membership_request_ids"=>[], "invite_ids"=>[], "can_join"=>true, "is_coach"=>true, 
			   # "address"=>{"_id"=>"5491ad86616d620e44030000", "city"=>nil, "location"=>nil, "phone"=>nil, "state"=>nil, "street"=>nil, "street_line2"=>nil, "zip"=>nil}, "coaches"=>[], 
			   # "user"=>{"id"=>"5491ad83616d620e44000000", "name"=>"Named User 1"}, "participants"=>[], "membership_requests"=>[], "invites"=>[]}} 

p params # {"action"=>"update", "controller"=>"teams", "id"=>"5491ad83616d620e44010000"}
Where did the team go?! Why is it only failing when there's a second user on the system!?

I hate you testing.




e: And it winds up being a bug with qt webkit where PATCH requests aren't always interpreted properly? So very strange. Workaround is to switch to a PUT instead as shown here: https://github.com/thoughtbot/capybara-webkit/issues/553

kayakyakr fucked around with this message at 19:47 on Dec 17, 2014

xenilk
Apr 17, 2004

ERRYDAY I BE SPLIT-TONING! Honestly, its the only skill I got other than shooting the back of women and calling it "Editorial".
I have a question for folks who work professionally in a Ruby environment. What type of testing do you use? Reading a lot it seems like Test::Unit, Minitest and RSpec are the most popular but I can't really decide which way I should go that I would benefit the most in the field.

A MIRACLE
Sep 17, 2007

All right. It's Saturday night; I have no date, a two-liter bottle of Shasta and my all-Rush mix-tape... Let's rock.

xenilk posted:

I have a question for folks who work professionally in a Ruby environment. What type of testing do you use? Reading a lot it seems like Test::Unit, Minitest and RSpec are the most popular but I can't really decide which way I should go that I would benefit the most in the field.

RSpec, and then some chromedriver wrapper I forget the name of for browser integration tests. I just write API stuff now so I never have to do frontend

Gmaz
Apr 3, 2011

New DLC for Aoe2 is out: Dynasties of India

xenilk posted:

I have a question for folks who work professionally in a Ruby environment. What type of testing do you use? Reading a lot it seems like Test::Unit, Minitest and RSpec are the most popular but I can't really decide which way I should go that I would benefit the most in the field.
RSpec + Capybara

necrotic
Aug 2, 2005
I owe my brother big time for this!

xenilk posted:

I have a question for folks who work professionally in a Ruby environment. What type of testing do you use? Reading a lot it seems like Test::Unit, Minitest and RSpec are the most popular but I can't really decide which way I should go that I would benefit the most in the field.

There's no "right" way to go about testing. RSpec is definitely popular, but I think Test::Unit holds its own in a large part of the field. I have heard less about minitest, but I know its also a relatively new player on the block.

kayakyakr
Feb 16, 2004

Kayak is true
I hate testing (as I've attested to many times in this thread), but I've settled on RSpec + capybara as the testing that I hate the least.

Chilled Milk
Jun 22, 2003

No one here is alone,
satellites in every home
Yeah, RSpec + Capybara, with FactoryGirl and Timecop as the situation calls for. Simplecov generates a nice coverage report if you need to care about that.

Coincidentally, I just learned Rails 4 Test Prescriptions came out and have a copy on the way, though it's through work and we have the holiday weeks off so it'll be awhile before I can dig into it myself.
https://pragprog.com/book/nrtest2/rails-4-test-prescriptions

Gmaz
Apr 3, 2011

New DLC for Aoe2 is out: Dynasties of India

kayakyakr posted:

I hate testing (as I've attested to many times in this thread), but I've settled on RSpec + capybara as the testing that I hate the least.
May I ask why? Personally coming from a project that was pretty big and had no tests to a smaller one but with good test coverage is a night and day difference. Yes they can be boring to write, but they certainly save a lot of time in the end.

kayakyakr
Feb 16, 2004

Kayak is true

Gmaz posted:

May I ask why? Personally coming from a project that was pretty big and had no tests to a smaller one but with good test coverage is a night and day difference. Yes they can be boring to write, but they certainly save a lot of time in the end.

It's just a struggle for me. Bad testing habits piled against bad luck getting test suites to work.

My normal testing experience is what I posted about halfway up the page. Spend 6 hours implementing a feature, spend 12 hours figuring out why the hell the tests aren't working for said feature.

It also combines with the way I code: pre-writing tests means I can't stream-of-thought program which essentially kills my 2 hour bursts of extreme productivity and afterwards I move on to the next task rather than going back and filling out the test.

I don't argue with the value of a good test suite, though. We're having to build integration tests into one startup because it's gotten large enough that changes are causing cascading issues.

MrDoDo
Jun 27, 2004

You better remember quick before we haul your sweet ass down to the precinct.

kayakyakr posted:

It also combines with the way I code: pre-writing tests means I can't stream-of-thought program which essentially kills my 2 hour bursts of extreme productivity and afterwards I move on to the next task rather than going back and filling out the test.

This has been one of the hardest things for me with testing is getting in to the "TDD mindset", instead of using coding as both exploratory and implementation, then just kind of moving on once things are done. I am starting to realize thought that I think the whole idea of writing your tests before your code is a bit misleading, since there is a completely valid need to have some of a coding spike first to get things going.

Sil
Jan 4, 2007

kayakyakr posted:

It's just a struggle for me. Bad testing habits piled against bad luck getting test suites to work.

My normal testing experience is what I posted about halfway up the page. Spend 6 hours implementing a feature, spend 12 hours figuring out why the hell the tests aren't working for said feature.

It also combines with the way I code: pre-writing tests means I can't stream-of-thought program which essentially kills my 2 hour bursts of extreme productivity and afterwards I move on to the next task rather than going back and filling out the test.

I don't argue with the value of a good test suite, though. We're having to build integration tests into one startup because it's gotten large enough that changes are causing cascading issues.

I'm a noob but feel the same way, except it's just about tests that require javascript. They. Never. loving. Just. Run. There's always a little corner case where the change event on an input isn't triggering properly or you need to exec a script cos of a known bug or whatever the gently caress. And in the absolute best case scenario they are SLLLLLLOoooooOOoOOOOOWwwwww.

I'm basically solo dev for a company with a few legacy PHP/Python/Rails 3 apps and in the middle of porting them to Rails 4. I REALLY want good integration test coverage. REALLY want it. Especially since I end up doubling as QA as well. But gently caress me if it can't take literally 4-5 hours to (fail to) figure out why my jQuery change() event that's meant to show a div with a few extra form fields when you click a certain radio button NEVER gets triggered by clicking a radio button. But switch from using radio buttons to using a select and it's all fine.

Welp, I got angry all over again remembering that :D

Conversely I love unit testing. Works, always helps me design methods and features, saves my bacon when I'm refactoring dumb 800 line models from 7 years ago. Fortunately our apps are very JS light and I can just click about when it gets to that stage.

plasticbugs
Dec 13, 2006

Special Batman and Robin
I have hit a brick wall and I would love some help.

I'm building out some widgets for Twitch.TV users so they have interactive thingies that make it easier to do things like show donations on their live feed, choose a random user from the chat room to win a prize, etc.

I hit a road block with the prize wheel thingy. In order to get the list of all users in the chat room, I'm connecting to Twitch's chat room with the Cinch gem. Twitch chat is modeled after, but isn't quite IRC. Anyway, to use Cinch which is really an IRC bot tool, you need to configure a bot and then start it up so it can begin monitoring the chat.

Soooo... I'm putting the code to configure and start a bot in one of my Rails controllers - and at this point I'd like to point out that I'm most definitely misusing Cinch, which is a chat bot. The command that starts the bot: bot.start blocks the main thread, so I spin it off as a separate thread.

Here's where I show how I know just enough to be dangerous:
After I start the thread, because bot.start is a long-running command, I'm calling sleep(n) so I can access the bot's properties after it's had some time to get going. And so I'm blocking anyway because sleep and sometimes the bot's properties haven't fully set up even after sleeping so I have to refresh the page and retry. So you can see this is starting to get really ugly.

Then, I'm grabbing what I need from the bot and sending it to the view. So this all works™ and the wheel spins with all the names on it and lands on a winner.



However, I'm unable to kill the bot thread after I get what I need, even if I call thr.kill. The bot remains connected -- I can see it's connected because the chat log is still scrolling in the server logs. And then if I refresh the page, a NEW bot is created/configured and connects. So now I have two identical bots connected to the chat and the server log is doubling everything. And if I refresh again... you get the point.

This is all kinds of terrible. But I don't know what I don't know. Can someone give me a gentle push in the right direction?

I would like to start the bot, get what I need without calling sleep, and kill the bot on every page refresh. OR, I'd like to have the bot run once and only once, and maybe even stay connected/persist across multiple page refreshes and I can ask the canonical bot for its properties.

What hole in my knowledge do I have here? I am a clueless and dangerous idiot.

DONT THREAD ON ME
Oct 1, 2002

by Nyc_Tattoo
Floss Finder

xenilk posted:

I have a question for folks who work professionally in a Ruby environment. What type of testing do you use? Reading a lot it seems like Test::Unit, Minitest and RSpec are the most popular but I can't really decide which way I should go that I would benefit the most in the field.

We use Test::Unit. The only thing that makes unit testing at all tolerable for me is mocking/stubbing. Otherwise I just try to do end to end stuff.

A Big... Dog
Mar 25, 2013

HELLO DAD

Seems like a lot of us don't enjoy testing, huh!

I find it very difficult - I'm still at the stage where integration tests are natural, but unit tests are very difficult somehow - and often wonder why so many developers outwardly dislike testing but put up with it. It's saved my rear end so many times, though. gently caress it.

(Also, Cucumber is pretty amazing once you get used to it)

DONT THREAD ON ME
Oct 1, 2002

by Nyc_Tattoo
Floss Finder
My personal approach, just to keep me sane, is to only kill myself testing if:

a) I'm developing a feature, and writing tests is faster than testing manually
b) A failure in the system I'm working on involves money, or some sort of serious obligation

Otherwise, I just do the best I can with the time available. Some legacy systems are just too broken to test in a meaningful way. I can write tests for those things, and I'll be sure that my 'unit' will work, but I wont actually be ensuring that my unit isn't going to be breaking something.

EVGA Longoria
Dec 25, 2005

Let's go exploring!

We use rspec mostly because my team prefers the syntax and the plugins available.

It's not bad, but we never do test first. We end up writing tests at the end to hit about 80% coverage and go from there.

Thalagyrt
Aug 10, 2006

MALE SHOEGAZE posted:

My personal approach, just to keep me sane, is to only kill myself testing if:

a) I'm developing a feature, and writing tests is faster than testing manually
b) A failure in the system I'm working on involves money, or some sort of serious obligation

Otherwise, I just do the best I can with the time available. Some legacy systems are just too broken to test in a meaningful way. I can write tests for those things, and I'll be sure that my 'unit' will work, but I wont actually be ensuring that my unit isn't going to be breaking something.

RSpec here, and I take pretty much the same approach. Anything in my customer portal that can destroy/mess with servers, or deals with billing in any way has 100% test coverage. The stuff that's less critical like admin notes on an account or simple reports? Nah, not worth testing those. Overall I have about 95% test coverage, which is nice, but I don't have much intention to shoot for 100%.

Chilled Milk
Jun 22, 2003

No one here is alone,
satellites in every home

EVGA Longoria posted:

We use rspec mostly because my team prefers the syntax and the plugins available.

It's not bad, but we never do test first. We end up writing tests at the end to hit about 80% coverage and go from there.

As much as I would like to try the test first mindset I think coding as exploration is far too ingrained in my brain. Lately I have been at least switching over to specs once I have a rough outline of things and bouncing back and forth from there. I think that's probably the way to go in practice, for me at least. At least it feels better than the write everything and fart out some tests after I'm 99% sure it's working method.

xenilk
Apr 17, 2004

ERRYDAY I BE SPLIT-TONING! Honestly, its the only skill I got other than shooting the back of women and calling it "Editorial".

MrDoDo posted:

This has been one of the hardest things for me with testing is getting in to the "TDD mindset", instead of using coding as both exploratory and implementation, then just kind of moving on once things are done. I am starting to realize thought that I think the whole idea of writing your tests before your code is a bit misleading, since there is a completely valid need to have some of a coding spike first to get things going.

I'm reading Eloquent Ruby by Russ Olsen (which is great so far) and he tackles that issues in the Test chapter.

quote:

I have to say that I like the idea of test-first development, and I frequently practice it. But not-and here is the rub-always. There are times when I can be more productive by simply writing the code and then going back and adding the tests. When I hit those times I leave the tests for the end. Test-first development is a great idea, but we in the software industry have a habit of messing up really good ideas by deciding they are not just good but absolutely universal. And required. The take-away here is that you are not finished until you have both the software and the tests or specs to go with it. Write the tests first, or second, or third. But write the darned tests.

Jaded Burnout
Jul 10, 2004


My first two years of Ruby was at a place which insisted on 100% BDD. That was good discipline which has served me well in terms of knowing when I should test first and when I shouldn't.

Personally I write the tests first because I find keeping the success criteria in my head while writing the code too much of a cognitive burden, even if I just sketch the tests out first.

Jaded Burnout
Jul 10, 2004


plasticbugs posted:

However, I'm unable to kill the bot thread after I get what I need, even if I call thr.kill. The bot remains connected -- I can see it's connected because the chat log is still scrolling in the server logs. And then if I refresh the page, a NEW bot is created/configured and connects. So now I have two identical bots connected to the chat and the server log is doubling everything. And if I refresh again... you get the point.

Welcome to threading. What thr.kill? You don't have access to the thread Cinch is starting, as it's done internally in the bot here: https://github.com/cinchrb/cinch/blob/master/lib/cinch/irc.rb#L217-L223

plasticbugs posted:

I would like to start the bot, get what I need without calling sleep, and kill the bot on every page refresh.

You're going to have trouble not sleeping as Cinch doesn't seem to have a synchronous mode. If you want to kill the bot once you have what you want, looks like you need bot.quit.

plasticbugs posted:

OR, I'd like to have the bot run once and only once, and maybe even stay connected/persist across multiple page refreshes and I can ask the canonical bot for its properties.

Yeah, do this instead. The key to unlock this is the difference between storing your bot within the controller (which is transient and torn down each request) and storing it somewhere more permanent, like a class attr accessor on your Rails app's main module or a persistent services repository.

plasticbugs
Dec 13, 2006

Special Batman and Robin

Arachnamus posted:

Welcome to threading. What thr.kill? You don't have access to the thread Cinch is starting, as it's done internally in the bot here: https://github.com/cinchrb/cinch/blob/master/lib/cinch/irc.rb#L217-L223


You're going to have trouble not sleeping as Cinch doesn't seem to have a synchronous mode. If you want to kill the bot once you have what you want, looks like you need bot.quit.


Yeah, do this instead. The key to unlock this is the difference between storing your bot within the controller (which is transient and torn down each request) and storing it somewhere more permanent, like a class attr accessor on your Rails app's main module or a persistent services repository.

Thanks for your advice! I'm working on an implementation that creates a canonical bot that I can access across multiple requests. I've been putting the bot code in the controller for no good reason.

Pollyanna
Mar 5, 2005

Milk's on them.


Not a Rails question, but I'm trying to do something a little weird in Middleman. I have a blog page, blog/index.html.haml, and several article pages, blog/article-1.html.md blog/article-2.html.md etc. What I want to do is to have the contents of each article pages rendered into the blog index page, like basically iterate through an array of article.html.mds and add their HTML to a list on the page. I tried using layouts for that, but all I could figure out how to do was to simply display the link to the page - not get the HTML for the page itself. Is there a way to just stick the contents of a page inside another page?

hmm yes
Dec 2, 2000
College Slice
Er, are you using the middleman-blog gem? From what I can tell, it does everything you're looking for. I hate to send a link to docs, sorry, so please correct me if I misunderstood :shobon:

hmm yes fucked around with this message at 06:34 on Jan 5, 2015

Siguy
Sep 15, 2010

10.0 10.0 10.0 10.0 10.0
I'll second that you want to be using middleman-blog.

They have example code for a blog index:

code:
<% page_articles.each_with_index do |article, i| %>
  <h2><%= link_to article.title, article %> <span><%= article.date.strftime('%b %e') %></span></h2>
  <!-- use article.summary(250) if you have Nokogiri available to show just
       the first 250 characters -->
  <%= article.body %>
<% end %>

The article.body is what you're looking for.

EVGA Longoria
Dec 25, 2005

Let's go exploring!

Anyone have an idiomatic example of reading rc files for configuration? Specifically, I'm looking to read bowerrc files, which can be in the global root, the user's home, or any directory in the tree up from current working directory.

Easy enough to do, but I'd rather not reinvent the wheel if it's already been done in a pretty manner.

xtal
Jan 9, 2011

by Fluffdaddy

EVGA Longoria posted:

Anyone have an idiomatic example of reading rc files for configuration? Specifically, I'm looking to read bowerrc files, which can be in the global root, the user's home, or any directory in the tree up from current working directory.

Easy enough to do, but I'd rather not reinvent the wheel if it's already been done in a pretty manner.

I don't think that you need a library for something like that. I don't know of any. It's pretty easy to whip up in an ad-hoc fashion. This function uses recursion to traverse from the current directory to the root in search of filename.

Ruby code:
require 'pathname'

def find(filename, cwd = Pathname.pwd)
  if (pathname = cwd.join(filename)).file?
    pathname
  elsif !cwd.root?
    find(filename, cwd.dirname)
  end
end

conf = find ".bowerrc" || "/etc/bowerrc"

xtal fucked around with this message at 20:42 on Jan 6, 2015

EVGA Longoria
Dec 25, 2005

Let's go exploring!

xtal posted:

I don't think that you need a library for something like that. I don't know of any. It's pretty easy to whip up in an ad-hoc fashion. This function uses recursion to traverse from the current directory to the root in search of filename.

Ruby code:
require 'pathname'

def find(filename, cwd = Pathname.pwd)
  if (pathname = cwd.join(filename)).file?
    pathname
  elsif !cwd.root?
    find(filename, cwd.dirname)
  end
end

conf = find ".bowerrc" || "/etc/bowerrc"

For rc files, you have to merge and override. I.e. settings in /etc are overridden by settings in ~/, which are overridden by files in the local folder.

It's not too difficult to do (since it's a json file), was just curious if someone had something pre-built to handle that kind of thing.

KoRMaK
Jul 31, 2012



I want to add :touch => true functionality to my has_many associations. How do I upgrade has_many to accept touch (like how belong_to behaves). I've find the relevant files in active_record/associations, but its all cryptic and wanted to see if any of you have done this before or have suggestions.

KoRMaK
Jul 31, 2012



KoRMaK posted:

I want to add :touch => true functionality to my has_many associations. How do I upgrade has_many to accept touch (like how belong_to behaves). I've find the relevant files in active_record/associations, but its all cryptic and wanted to see if any of you have done this before or have suggestions.
I did it :science: :unsmigghh:

(in some file that gets included.)
Ruby code:
module ActiveRecord
  
  #module AutosaveAssociation
  #
  #  ASSOCIATION_TYPES = %w{ HasOne HasMany HasManyWithTouch BelongsTo HasAndBelongsToMany }
  #end
  #  
  module Associations
    module Builder
      class HasMany< CollectionAssociation #:nodoc:
        #self.macro = :has_many_with_touch
        
        self.valid_options += [:touch]
        
        alias :old_build :build #stash the old build method in old_build. We do this because we override it in the next step, but we still want
        #to be able to call it. We can't call super, because we still want to call the HasMany vanilla build. So this allows us
        #to override a fucntion, inject our new bheavior, and still maintain the old behavior!
    
        def build
          #byebug
          reflection = old_build #use to be super
          add_touch_callbacks(reflection)         if options[:touch] #stolen from active_record/associations/builder/belongs_to.rb
          reflection #dont forget to pass back the reflect! otherwise the results don't get passed back, and further functions don't have an object to work with!
        end
    
        private
        #add_touch_callbacks stolen from active_record/associations/builder/belongs_to.rb, upgraded to handle a collection of related things
          def add_touch_callbacks(reflection)
            name        = self.name
            method_name = "has_many_with_touch_after_save_or_destroy_for_#{name}"
            touch       = options[:touch]
    
            mixin.redefine_method(method_name) do
              records = send(name)
              
              records.each do |record|
                unless record.nil?
                  if touch == true
                    record.touch
                  else
                    record.touch(touch)
                  end
                end
              end #records.each do |record|
            end
    
            model.after_save(method_name)
            model.after_touch(method_name)
            model.after_destroy(method_name)
          end
      end
    end #module Builder
    

    #you don't need this. But you would need this if you added a new type, like HasManyWithTouch like I tried at first.
    module ClassMethods
      def has_many(name, options = {}, &extension)
        Builder::HasMany.build(self, name, options, &extension)
      end
    end
    
  end #module Associations
end

#usage
#has_many :things, :touch => true

KoRMaK fucked around with this message at 05:44 on Jan 13, 2015

MasterSlowPoke
Oct 9, 2005

Our courage will pull us through
I've got a best practices question about Ajax stuff:

I have a model Article, and I want to be able to update particular attributes of that article through an AJAX form on the Article's Show page. These attributes could be Title, Status, and Footnote.

Right now, I am placing the forms for updating these attributes in their own partials, and placing those onto the show page inside hidden div tags. The forms target the Update action of the ArticleController. I'm manually handling the Ajax calls by binding the ajax:whatever events in articles.js, and this feels a little smelly.

Would I be better off having dedicated update_title action, with its own update_title.js.erb file to handle the Ajax call? I'm a little afraid of overloading the controller.

Edit:
Maybe in update.js.erb I could do something like

JavaScript code:
<% if params[:title] %>
  // stuff to update title
<% end %>
<% if params[:status] %>
  // stuff to update status
<% end %>
// and so on
That kinda feels like a horror but it seems more organized for some reason/

MasterSlowPoke fucked around with this message at 16:14 on Jan 16, 2015

Pollyanna
Mar 5, 2005

Milk's on them.


Is there a way to modify the default ActionMailer::DeliveryJob class to have a callback before it where it waits five minutes before actually sending the email? I just changed something from using deliver_now to deliver_later and I want to see what happens if I tell the job to wait five minutes before sending the email, cause it's hard for me to tell if the email is actually asynchronous or not.

prom candy
Dec 16, 2005

Only I may dance
What's everyone using for provisioning and deploys these days? We're an agency that has about 150 Rails apps and we use a mix of Capistrano for older stuff, git-based deploys for some stuff, and Chef for a few things. I hate Chef because deploys take almost 90 seconds. Looking for something that makes provisioning a new server fairly easy and also supports lightning fast deploys... we're down to ~2 seconds for git deploys if bundle install doesn't need to run and no assets have changed but git deploys aren't ideal for provisioning or scaling.

MasterSlowPoke
Oct 9, 2005

Our courage will pull us through
Is there a fast .xls reader for Ruby? I don't want to write anything or look at fonts or whatever, I'm just interested in the data. I've tried out Roo, but it's taking 3-4 minutes to load a very small (33x10) spreadsheet.

Chilled Milk
Jun 22, 2003

No one here is alone,
satellites in every home

MasterSlowPoke posted:

Is there a fast .xls reader for Ruby? I don't want to write anything or look at fonts or whatever, I'm just interested in the data. I've tried out Roo, but it's taking 3-4 minutes to load a very small (33x10) spreadsheet.

Roo isn't the speediest but that's a still few orders of magnitude off. How are you parsing it?

MasterSlowPoke
Oct 9, 2005

Our courage will pull us through
I've tried both
code:
sheet = Roo::Spreadsheet.new('public/uploads/test.xls')
sheet = Roo::Excel.new('public/uploads/test.xls')
Both of these lines take approximately forever, and then the result takes about 20 seconds just to puts to the screen.

kayakyakr
Feb 16, 2004

Kayak is true

prom candy posted:

What's everyone using for provisioning and deploys these days? We're an agency that has about 150 Rails apps and we use a mix of Capistrano for older stuff, git-based deploys for some stuff, and Chef for a few things. I hate Chef because deploys take almost 90 seconds. Looking for something that makes provisioning a new server fairly easy and also supports lightning fast deploys... we're down to ~2 seconds for git deploys if bundle install doesn't need to run and no assets have changed but git deploys aren't ideal for provisioning or scaling.

I deploy with capistrano. Provisioning is tougher. A lot of people like Ansible.

Wki
Dec 12, 2012

Emily's sassy lime.
Cigar? Toss it in a can. It is so tragic.
Pull up, Eva, we're here! Wave! Pull up!
Ansible and Docker seem to be the new hotness.

Adbot
ADBOT LOVES YOU

Hughlander
May 11, 2005

MasterSlowPoke posted:

Is there a fast .xls reader for Ruby? I don't want to write anything or look at fonts or whatever, I'm just interested in the data. I've tried out Roo, but it's taking 3-4 minutes to load a very small (33x10) spreadsheet.

There was a problem with a recent version of roo where it was rear end slow. The fix was a pull request maybe even merged but no semantic release yet. I'll check when I get home.

  • 1
  • 2
  • 3
  • 4
  • 5
  • Post
  • Reply