Code Monkey home page Code Monkey logo

synced_resources's Introduction

SyncedResources

Gem Version Build Status Code Climate Test Coverage

Welcome to your new gem! In this directory, you’ll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file lib/synced_resources. To experiment with that code, run bin/console for an interactive prompt.

TODO: Delete this and the text above, and describe your gem

Installation

Add this line to your application’s Gemfile:

gem 'synced_resources'

And then execute:

$ bundle

Or install it yourself as:

$ gem install synced_resources

Usage

TODO: Write usage instructions here

Development

After checking out the repo, run bin/setup to install dependencies. Then, run rake spec to run the tests. You can also run bin/console for an interactive prompt that will allow you to experiment.

To install this gem onto your local machine, run bundle exec rake install. To release a new version, update the version number in version.rb, and then run bundle exec rake release, which will create a git tag for the version, push git commits and tags, and push the .gem file to rubygems.org.

Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/riboseinc/synced_resources. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the Contributor Covenant code of conduct.

License

The gem is available as open source under the terms of the MIT License.

Code of Conduct

Everyone interacting in the SyncedResources project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the code of conduct.

synced_resources's People

Contributors

skalee avatar ribose-jeffreylau avatar petertky avatar kevinwongso avatar kwkwan avatar

Stargazers

Ronald Tse avatar

Watchers

Ronald Tse avatar  avatar James Cloos avatar  avatar  avatar  avatar

synced_resources's Issues

SELECT DISTINCT does not allow ORDER with non-id columns (in MySQL 5.7+)

In _compose_indices, if the objects variable contains an ORDER statement this would raise an error in MySQL 5.7+, e.g. when a controller wants to serve an index request with sorting options.

This is because in MySQL 5.7+, SELECT DISTINCT is not allowed to ORDER based on columns not included by the SELECT statement. Since we use .pluck so that Rails does not build the Ruby model object for efficiency reasons, as we only need the ids here, only the id column is part of the SELECT statement and keeping DISTINCT means we can not ask for a sort based on other columns. By removing DISTINCT, and filtering duplicates on the Ruby side using .uniq instead, we can still sort by non-id columns and still use .pluck so that Rails won't waste time trying to build the Ruby model objects.

Update README

format

README needs to be in asciidoc format.

content

The installation step is similar to inherited_resources.
Need usage instructions.
E.g.
Set up serializers (optional) config/initializers/synced_resources.rb

SyncedResources.base_time = MyApp.git_commit_time

# This may be more useful in RSpec...
SyncedResources.sync_string_encoder = lambda { |id_to_synced_at_map|
  MyApp.encode_sync_str(id_to_synced_at_map)
}

SyncedResources.sync_string_decoder = lambda { |encoded_map, base_time|
  MyApp.decode_sync_str(
    encoded_map,
    base_time,
  )
}

Then in e.g. app/controllers/foo_controller.rb,

class FooController < ApplicationController
  synced_resources
  # ...
end

or

class FooController < SyncedResources::Base
  # ...
end

Since SyncedResources inherit from inherited_resources, its options are also available for tweaking.

Use Combustion to provide the dummy application for tests

Right now we have a full-blown Rails application in spec/dummy, which adds some maintenance burden, like many configuration options which tend to change as Rails evolves. Also we want to test this gem against multiple Rails version, which makes things even more complicated.

Let's build this dummy application with Combustion, which requires us to write only necessary parts, and even disable unused Rails parts as needed.

Use Database Cleaner

Right now we clear database with explicit TRUNCATE statement which won't work with some database engines, e.g. with SQLite. Let's switch to a Database Cleaner gem.

Some tests are failing

There are four examples which do not pass. The result is consistent among Rails versions (at least ones which I was able to run so far, that is 4.1, 4.2, and 5.0). Failures happen every time I run these tests. See this build, for instance.

According to #15 (comment), they aren't normal. They reason they fail for isn't investigated yet.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.