GithubHelp home page GithubHelp logo

yolk / mite-rb Goto Github PK

View Code? Open in Web Editor NEW
21.0 21.0 10.0 58 KB

The official ruby library for interacting with the RESTful mite.api.

Home Page: http://mite.yo.lk/en/api

License: MIT License

Ruby 100.00%

mite-rb's People

Stargazers

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

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

mite-rb's Issues

uninitialized constant Mite::VERSION

When adding the gem mite-rb to the Gemfile of a clean Rails app (3.2.1) the following error is thrown on the start of the server or console:

~/.rvm/gems/ruby-1.9.3-p125/gems/mite-rb-0.4.1/lib/mite-rb.rb:73:in `<module:Mite>': uninitialized constant Mite::VERSION (NameError)
from ~/.rvm/gems/ruby-1.9.3-p125/gems/mite-rb-0.4.1/lib/mite-rb.rb:7:in `<top (required)>'

Adding require 'mite/version.rb' to the top of the file mite-rb-0.4.1/lib/mite-rb.rb solves the issue.

Is the API ruby wrapper broken?

I get the following error while creating a project or customer. My Mite API credentials are correct.

project = Mite::Project.create(:name => 'Playing with the mite.api')

DEPRECATION WARNING: Returning errors as a hash without a root "errors" key is deprecated. (called from create at (irb):35)
NoMethodError: undefined method `each' for "Bitte gib dem Projekt einen Namen.":String

Mite::Tracker.start not working as expected

I get the following:

time_entry = Mite::TimeEntry.first(:params => {:at => 'today'})
# => #<Mite::TimeEntry:0x00000101ecfa98 @attributes={"billable"=>true, "created_at"=>"2012-11-29T22:05:48+01:00", "date_at"=>"2012-11-29", "id"=>14693669, "locked"=>false, "minutes"=>8, "project_id"=>625108, "revenue"=>0.0, "service_id"=>98557, "updated_at"=>"2012-11-29T22:23:52+01:00", "user_id"=>23934, "note"=>"", "user_name"=>"Jakob Skjerning", "customer_id"=>83878, "customer_name"=>"Open Source", "project_name"=>"mite-rb", "service_name"=>"Application development", "tracker"=>#<Mite::Tracker:0x00000101ecd8d8 @attributes={"since"=>"2012-11-29T22:23:12+01:00", "minutes"=>33}, @prefix_options={}, @persisted=false>}, @prefix_options={}, @persisted=true>
Mite::Tracker.start(time_entry)
# => ActiveResource::ResourceNotFound: Failed.  Response code = 404.  Response message = Not Found.

... which isn't quite what I expected.

Digging further it seems it is sending a PUT request to "/tracker/.json", ie without the id of the TimeEntry for whatever reason, which naturally results in a 404.

Running Ruby 1.9.3p194 with a gem list of

  • activemodel (3.2.9)
  • activeresource (3.2.9)
  • activesupport (3.2.9)
  • builder (3.0.4)
  • bundler (1.1.4, 1.1.3)
  • i18n (0.6.1)
  • mite-rb (0.4.5)
  • multi_json (1.3.7)
  • powder (0.1.8)
  • rake (0.9.2.2)
  • rubygems-bundler (1.0.2)
  • rvm (1.11.3.3)
  • thor (0.16.0)

README only contains project API

Judging from the source code there are much more APIs (e.g. getting all time entries of a user) however only the project API is documented

TimeEntry does not behave as expected

I wrote a small rspec example to try out the mite-rb library:

# mite_spec.rb
require 'mite-rb'
require 'date'

describe Mite do
  it "retrieves what is saved" do
    Mite.account = ENV['my_mite_account']
    Mite.key = ENV['my_valid_mite_key']
    Mite.validate!

    today = DateTime.now.strftime("%F")
    time_entry = Mite::TimeEntry.new
    time_entry.date_at = today
    time_entry.minutes = 45
    time_entry.note = "this is a test"

    puts "saving: #{time_entry.inspect}"
    time_entry.save
    id = time_entry.id
    puts "saved as id #{id}"
    retrieved_entry = Mite::TimeEntry.find(id)
    puts "retrieved: #{retrieved_entry.inspect}"

    retrieved_entry.date_at.should == today
    retrieved_entry.minutes.should == 45
    retrieved_entry.note.should == "this is a test"

    retrieved_entry.destroy

    invalid_entry = Mite::TimeEntry.find(id)
    invalid_entry.should == nil
  end
end

rspec mite_spec.rb fails (XXX replaces private information):

$ rspec mite_spec.rb
saving: #<Mite::TimeEntry:0x007fb8726e2eb8 @attributes={"date_at"=>"2013-11-27", "minutes"=>45, "note"=>"this is a test"}, @prefix_options={}, @persisted=false>
saved as id 21177544
retrieved: #<Mite::TimeEntry:0x007fb8727e0fb8 @attributes={"billable"=>true, "created_at"=>"2013-11-27T16:54:02+01:00", "date_at"=>"2013-11-27", "id"=>21177544, "locked"=>false, "minutes"=>0, "project_id"=>nil, "revenue"=>nil, "service_id"=>nil, "updated_at"=>"2013-11-27T16:54:02+01:00", "user_id"=>XXXXX, "note"=>"", "user_name"=>"XXXXXXXX"}, @prefix_options={}, @persisted=true>
F

Failures:

  1) Mite retrieves what is saved
     Failure/Error: retrieved_entry.minutes.should == 45
       expected: 45
            got: 0 (using ==)
     # ./mite_spec.rb:24:in `block (2 levels) in <top (required)>'

Finished in 1.86 seconds
1 example, 1 failure

Failed examples:

rspec ./mite_spec.rb:5 # Mite retrieves what is saved

Am I doing something wrong or is there a bug somewhere?

Rails 5 compatibility

Hi,

mite won't work with rails 5 due to the activeresource dependency which hasn't been released for rails 5.

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.