README.md in ncmb-ruby-client-0.1.7 vs README.md in ncmb-ruby-client-0.2.0
- old
+ new
@@ -45,10 +45,111 @@
else
puts "Push save faild."
end
```
+## Unit test
+
+### Settings
+* Install libraries
+```
+bundle install
+```
+* Rename file `setting_default.yml` to `setting.yml` and then fill you `application_key`, `client_key`
+
+### Run unit test
+Run `spec` task:
+```
+rake spec
+```
+
+## Run all examples
+
+Run `examples` task:
+
+```
+rake examples
+```
+
+Or you can run every single example
+
+```
+ruby examples/example_file_name.rb
+```
+
+## Test script
+
+Before run `examples/script.rb`, you should upload the below script files to Script function on the Console screen.
+
+### helloworld.js
+
+* File Name: helloworld.js
+* Method: GET
+* File Status: Executable
+```javascript
+module.exports = function(req, res) {
+ res.send('{"msg":"Hello World!"}');
+}
+```
+
+### helloworld2.js
+
+* File Name: helloworld2.js
+* Method: GET
+* File Status: Executable
+```javascript
+module.exports = function(req, res) {
+ if (req.query.name) {
+ res.send('{"msg":"Hello ' + req.query.name +'!"}');
+ } else {
+ res.send('{"msg":"Hello World!"}');
+ }
+}
+```
+
+### email.js
+
+* File Name: email.js
+* Method: POST
+* File Status: Executable
+
+(Don't forget to change `YOUR-APPLICATION-KEY` and `YOUR-CLIENT-KEY` to your value before upload.)
+
+```javascript
+function saveData(req, res) {
+ // POSTのデータを取得
+ var email = req.body.email;
+ var message = req.body.body;
+
+ var NCMB = require('ncmb');
+ var ncmb = new NCMB('YOUR-APPLICATION-KEY', 'YOUR-CLIENT-KEY');
+
+ // データを保存する
+ var Item = ncmb.DataStore('Item');
+ var item = new Item();
+ item.set("email", email)
+ .set("message", message)
+ .save()
+ .then(function(item){
+ // 成功
+ res.send('{"msg":"POST data successfully!"}');
+
+ })
+ .catch(function(err){
+ // 失敗
+ res.send('{"msg":"' + err + '"}');
+ });
+}
+
+module.exports = saveData;
+```
+
+## Environment to confirm
+
+* Ruby v2.7.3 - Bundler version 2.1.4
+* Ruby v3.0.1 - Bundler version 2.2.15
+
## License
MIT.
-[ニフクラ mobile backend](http://mb.cloud.nifty.com/)
+[ニフクラ mobile backend](https://mbaas.nifcloud.com/)