-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
129 additions
and
2 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 |
---|---|---|
@@ -0,0 +1,38 @@ | ||
$:.unshift(File.join(File.dirname(__FILE__), '..', 'lib')) | ||
$:.unshift(File.dirname(__FILE__)) | ||
require 'rubygems' | ||
require 'ncmb' | ||
require 'yaml' | ||
yaml = YAML.load_file(File.join(File.dirname(__FILE__), '..', 'setting.yml')) | ||
NCMB.initialize application_key: yaml['application_key'], client_key: yaml['client_key'] | ||
|
||
example = NCMB::DataStore.new 'Example' | ||
|
||
require 'benchmark' | ||
|
||
ary = [] | ||
Benchmark.bm 10 do |r| | ||
r.report "Save DataStore" do | ||
100.times do |i| | ||
item = example.new | ||
item.set('String', "テスト#{i}00") | ||
item.set('Integer', i) | ||
item.set('Boolean', true) | ||
item.set('Array', [i, i * 2, i * 3, "Orange", "Tomato"]) | ||
item.set('Object', {test1: 'a', test2: 'b'}) | ||
item.set('Location', NCMB::GeoPoint.new(30, 50)) | ||
item.set('MultipleLine', "test\ntest\n") | ||
item.set('Increment', NCMB::Increment.new(i + 1)) | ||
item.set('Date', Time.now) | ||
item.save | ||
ary << item.objectId | ||
end | ||
end | ||
r.report "Delete objects" do | ||
ary.each do |objectId| | ||
item = example.new(objectId: objectId) | ||
item.delete | ||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
$:.unshift(File.join(File.dirname(__FILE__), '..', 'lib')) | ||
$:.unshift(File.dirname(__FILE__)) | ||
require 'rubygems' | ||
require 'ncmb' | ||
require 'yaml' | ||
yaml = YAML.load_file(File.join(File.dirname(__FILE__), '..', 'setting.yml')) | ||
NCMB.initialize application_key: yaml['application_key'], client_key: yaml['client_key'] | ||
|
||
Parent = NCMB::DataStore.new 'Parent' | ||
|
||
Child = NCMB::DataStore.new 'Child' | ||
child = Child.new(name: "Taro") | ||
parent = Parent.new(name: "Oya") | ||
parent.child = child | ||
parent.save | ||
|
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 @@ | ||
$:.unshift(File.join(File.dirname(__FILE__), '..', 'lib')) | ||
$:.unshift(File.dirname(__FILE__)) | ||
require 'rubygems' | ||
require 'ncmb' | ||
require 'yaml' | ||
yaml = YAML.load_file(File.join(File.dirname(__FILE__), '..', 'setting.yml')) | ||
NCMB.initialize application_key: yaml['application_key'], client_key: yaml['client_key'] | ||
|
||
Food = NCMB::DataStore.new 'Food' | ||
|
||
Basket = NCMB::DataStore.new('Basket') | ||
basket = Basket.new | ||
basket.foods = [] | ||
basket.foods << Food.new(name: "banana", type: "fruit") | ||
basket.foods << Food.new(name: "pear", type: "fruit") | ||
|
||
# relation = NCMB::Relation.new | ||
# relation << Food.new(name: "banana", type: "fruit", objectId: "test1") | ||
# relation << Food.new(name: "pear", type: "fruit", objectId: "test2") | ||
|
||
# puts basket.fields | ||
basket.save |
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 |
---|---|---|
|
@@ -22,4 +22,5 @@ | |
require "ncmb/increment" | ||
require "ncmb/acl" | ||
require "ncmb/role" | ||
require "ncmb/relation" | ||
require "ncmb/error" |
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,5 +1,5 @@ | ||
module NCMB | ||
class Acl < NCMB::Object | ||
class Acl | ||
include NCMB | ||
|
||
def initialize(params = nil) | ||
|
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,24 @@ | ||
module NCMB | ||
class Relation < Array | ||
include NCMB | ||
|
||
def initialize | ||
|
||
end | ||
|
||
def to_json(a = "") | ||
params = { | ||
"__op": "AddRelation", | ||
} | ||
params["objects"] = [] | ||
self.each do |obj| | ||
params["objects"] << { | ||
"__type": "Pointer", | ||
"className": obj.ClassName, | ||
"objectId": obj.objectId | ||
} | ||
end | ||
params.to_json | ||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
module Ncmb | ||
VERSION = "0.1.1" | ||
VERSION = "0.1.2" | ||
end |