yolk / mite-rb Goto Github PK
View Code? Open in Web Editor NEWThe official ruby library for interacting with the RESTful mite.api.
Home Page: http://mite.yo.lk/en/api
License: MIT License
The official ruby library for interacting with the RESTful mite.api.
Home Page: http://mite.yo.lk/en/api
License: MIT License
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.
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
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
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
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?
Hi,
mite won't work with rails 5 due to the activeresource dependency which hasn't been released for rails 5.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.