Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
First real commit with basic functions
- Loading branch information
1 parent
a98c135
commit c1a28a9
Showing
11 changed files
with
97 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,3 +2,4 @@ | |
.bundle | ||
Gemfile.lock | ||
pkg/* | ||
.DS_Store |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
--colour |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
rvm use 1.9.2@rjiffy --create |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,3 @@ | ||
source "http://rubygems.org" | ||
|
||
# Specify your gem's dependencies in rjiffy.gemspec | ||
gemspec |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
### Description | ||
# | ||
# | ||
# Find all boxes | ||
api = Rjiffy::Connection.new(<token>) | ||
boxes = api.boxes | ||
|
||
# Find one box | ||
box = api.find(ID) | ||
box == Object with attributes for the box infos | ||
|
||
# Delete a box | ||
box.delete |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,12 @@ | ||
module Rjiffy | ||
# Your code goes here... | ||
require 'rjiffy/connection' | ||
require 'rjiffy/box' | ||
end | ||
|
||
class ::Hash | ||
def method_missing(name) | ||
return self[name] if key? name | ||
self.each { |k,v| return v if k.to_s.to_sym == name } | ||
super.method_missing name | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
class Box < Rjiffy::Connection | ||
def initialize(hash) | ||
hash.each do |k,v| | ||
self.instance_variable_set("@#{k}", v) ## create and initialize an instance variable for this key/value pair | ||
self.class.send(:define_method, k, proc{self.instance_variable_get("@#{k}")}) ## create the getter that returns the instance variable | ||
self.class.send(:define_method, "#{k}=", proc{|v| self.instance_variable_set("@#{k}", v)}) ## create the setter that sets the instance variable | ||
end | ||
end | ||
|
||
def delete | ||
# TODO | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
module Rjiffy | ||
class Connection | ||
include HTTParty | ||
|
||
API_VERSION = "v1.0" | ||
|
||
def initialize(token) | ||
self.class.base_uri "https://api.jiffybox.de/#{token}/#{API_VERSION}" | ||
end | ||
|
||
def list_boxes | ||
response = self.class.get("/jiffyBoxes") | ||
response["result"] | ||
end | ||
|
||
def find(id) | ||
response = self.class.get("/jiffyBoxes/#{id}") | ||
Box.new(response["result"]) | ||
end | ||
|
||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
require File.expand_path(File.join(File.dirname(__FILE__), 'spec_helper')) | ||
|
||
describe Rjiffy do | ||
|
||
before(:all) do | ||
#TODO: stub request | ||
@connection = Rjiffy::Connection.new("sjdhakjsdhkajsdhak") | ||
end | ||
|
||
it "list all jiffyboxes" do | ||
@connection.list_boxes.class.should == Hash | ||
# test if the data are like the jiffybox api specification | ||
end | ||
|
||
it "find jiffybox by id" do | ||
id = 11243 | ||
box = @connection.find(id) | ||
box.name.should == "DeathStar" | ||
box.class.should == Box | ||
end | ||
|
||
it "should delete specific jiffybox" do | ||
# test delete | ||
end | ||
|
||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
$:.push File.expand_path("../lib", __FILE__) | ||
require "httparty" | ||
|
||
require "rjiffy" |