Code Monkey home page Code Monkey logo

ruson's Introduction

ruson's People

Contributors

hisaki-kanno-litalico avatar klriutsa avatar paulononaka avatar zedtux avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

ruson's Issues

Timestamp to time

I have an expiredAt attribute in the JSON file which is a timestamp (value: 1575608400.0) but ruson doesn't convert it when I defined my model as the following:

class Vehicle < Ruson::Base
  field :name
  field :price
  field :expired_at, name: 'expiredAt', class: Time
end
vehicle = Vehicle.new(name: 'Black Sims', price: 17.43, "expiredAt" => 1575608400.0)
vehicle.expired_at # => 1575608400-01-01 00:00:00.000000000 +0000

While it should be:

vehicle = Vehicle.new(name: 'Black Sims', price: 17.43, "expiredAt" => 1575608400.0)
vehicle.expired_at # => Fri, 06 Dec 2019 05:00:00.000000000 +0000

Add an ActiveRecord like `all` method

As of now, there's noway to get all the records:

class User < Ruson::Base
  field :name
end

User.all

produces:

NoMethodError (undefined method `all' for User:Class)

Find and save methods

Have you plan to add search and persistence methods to ruson?

My use case is fetching JSON from an API, and I'd like to save the created models using ruson, but also to update (find + save or find + create).

I'm looking for a methods find, first_or_create, and save/save!.

I'm expecting to give a folder where to save the JSON files to ruson, and when I'm saving a new model instance, to have a JSON file created in the given folder, using a sub folder with the model's class name, and object id as filename maybe?

name option works only in one way

Given a JSON that has a expiredAt attributes, when I define my model as the following:

class Vehicle < Ruson::Base
  field :expired_at, name: 'expiredAt', class: Time
end

And I try to create a new Vehicle:

data = fetch_vehicle_data
vehicle = Vehicle.new(data) # data is like {"expiredAt" => 1575608400.0}
vehicle.expired_at # => nil

Update the gem description

As of now, on rubygems.org and on this github repo, the description says:

A Ruby serialization/deserialization library to convert Ruby Objects into JSON and back

While the gem allow to do it, it does much more so I strongly think a new description should be made.

I suggestion I could make :

Ruson is an ODM (Object Document Mapper) Framework to JSON files, written in Ruby.

New gem release

Hi @klriutsa,

Can you please release a new version of this gem after having merged the remaining PR?

Thank you

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.