ki 0.4.9 → 0.4.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/lib/ki/orm.rb +4 -2
- data/lib/ki/version.rb +1 -1
- data/spec/examples/json.northpole.ro/config/deploy.rb +1 -1
- data/spec/examples/json.northpole.ro/public/images/js.png +0 -0
- data/spec/examples/json.northpole.ro/public/javascripts/app.coffee +24 -90
- data/spec/examples/json.northpole.ro/public/javascripts/jnorthpole.coffee +49 -32
- data/spec/examples/json.northpole.ro/public/javascripts/music/angular-youtube-embed.js +251 -0
- data/spec/examples/json.northpole.ro/public/stylesheets/app.sass +24 -0
- data/spec/examples/json.northpole.ro/views/awsum.haml +108 -0
- data/spec/examples/json.northpole.ro/views/examples.haml +24 -6
- data/spec/examples/json.northpole.ro/views/faq.haml +25 -19
- data/spec/examples/json.northpole.ro/views/java.haml +1 -0
- data/spec/examples/json.northpole.ro/views/javascript.haml +7 -0
- data/spec/examples/json.northpole.ro/views/layout.haml +2 -0
- data/spec/examples/json.northpole.ro/views/playground.haml +9 -8
- data/spec/examples/json.northpole.ro/views/{foo.haml → seed.haml} +0 -1
- data/spec/lib/ki/orm_spec.rb +1 -1
- data/spec/spec_helper.rb +0 -4
- metadata +12 -12
- data/spec/examples/json.northpole.ro/public/javascripts/util.coffee +0 -31
- data/spec/examples/json.northpole.ro/public/stylesheets/application.sass +0 -222
- data/spec/examples/json.northpole.ro/public/stylesheets/cover.css +0 -154
- data/spec/examples/json.northpole.ro/views/signup.haml +0 -2
@@ -2,6 +2,8 @@ body
|
|
2
2
|
padding-top: 20px
|
3
3
|
padding-bottom: 20px
|
4
4
|
|
5
|
+
$text-color: #333
|
6
|
+
|
5
7
|
.navbar
|
6
8
|
margin-bottom: 20px
|
7
9
|
|
@@ -21,3 +23,25 @@ body
|
|
21
23
|
|
22
24
|
.code
|
23
25
|
text-align: justify
|
26
|
+
|
27
|
+
#parsedJson
|
28
|
+
text-align: left
|
29
|
+
|
30
|
+
.value
|
31
|
+
// color: darken($cool, 20%)
|
32
|
+
font-weight: bold
|
33
|
+
|
34
|
+
#playground
|
35
|
+
width: 100%
|
36
|
+
height: 300px
|
37
|
+
color: $text-color
|
38
|
+
padding: 15px
|
39
|
+
font-family: Menlo,Monaco,Consolas,'Courier New',monospace
|
40
|
+
background-color: #f5f5f5
|
41
|
+
|
42
|
+
input[type="text"], textarea
|
43
|
+
outline: none
|
44
|
+
box-shadow: none !important
|
45
|
+
|
46
|
+
.form-control:focus
|
47
|
+
border-color: #ccc
|
@@ -0,0 +1,108 @@
|
|
1
|
+
.row{ 'ng-app' => 'app', 'ng-controller' => 'MainCtrl' }
|
2
|
+
.col-xs-6
|
3
|
+
.embed-responsive.embed-responsive-16by9
|
4
|
+
%youtube-video.embed-responsive-item{ 'video-url' => 'ytVideoUrl', 'player' => 'bestPlayer', 'player-vars' => 'playerVars' }
|
5
|
+
.col-xs-6
|
6
|
+
%div{ 'ng-show' => 'results.length == 0' }
|
7
|
+
%input{ 'ng-model' => 'json.api_key', 'type' => 'text', 'placeholder' => 'api key' }
|
8
|
+
%input{ 'ng-model' => 'json.secret', 'type' => 'password', 'placeholder' => 'secret' }
|
9
|
+
%i.fa.fa-refresh{ 'ng-click' => 'refresh()' }
|
10
|
+
%div{ 'ng-show' => 'results.length > 0' }
|
11
|
+
%ul
|
12
|
+
%li.text-center{ 'ng-click' => 'playRandom()' }
|
13
|
+
%i.fa.fa-random{ 'alt' => 'yes, I know' }
|
14
|
+
%li{ 'ng-repeat' => 'result in results', 'ng-click' => 'play(result)', 'ng-class' => '{ selected: isSelected(result) }'}
|
15
|
+
%span.pull-right
|
16
|
+
%i.fa.fa-edit
|
17
|
+
%p
|
18
|
+
{{ result.name || result }}
|
19
|
+
%li.text-center
|
20
|
+
%i.fa.fa-plus
|
21
|
+
|
22
|
+
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/font-awesome/4.4.0/css/font-awesome.min.css">
|
23
|
+
|
24
|
+
<script src="https://www.youtube.com/iframe_api"></script>
|
25
|
+
= js "https://ajax.googleapis.com/ajax/libs/angularjs/1.3.14/angular.min.js"
|
26
|
+
= js "/javascripts/music/angular-youtube-embed.js"
|
27
|
+
|
28
|
+
:css
|
29
|
+
.embed-responsive {
|
30
|
+
position: relative;
|
31
|
+
display: block;
|
32
|
+
height: 0;
|
33
|
+
padding: 0;
|
34
|
+
overflow: hidden;
|
35
|
+
}
|
36
|
+
|
37
|
+
.embed-responsive.embed-responsive-16by9 {
|
38
|
+
padding-bottom: 56.25%;
|
39
|
+
}
|
40
|
+
|
41
|
+
.embed-responsive-item {
|
42
|
+
position: absolute;
|
43
|
+
top: 0;
|
44
|
+
bottom: 0;
|
45
|
+
left: 0;
|
46
|
+
width: 100%;
|
47
|
+
height: 100%;
|
48
|
+
border: 0;
|
49
|
+
}
|
50
|
+
|
51
|
+
.selected {
|
52
|
+
background-color: yellow;
|
53
|
+
}
|
54
|
+
|
55
|
+
li {
|
56
|
+
list-style-type: none;
|
57
|
+
}
|
58
|
+
|
59
|
+
:javascript
|
60
|
+
var app = angular.module('app', ['youtube-embed']);
|
61
|
+
|
62
|
+
app.controller('MainCtrl', function ($scope, youtubeEmbedUtils) {
|
63
|
+
$scope.results = []
|
64
|
+
$scope.refresh = function () {
|
65
|
+
jNorthPole.getStorage($scope.json, function (data) {
|
66
|
+
if ($scope.json.apiKey != 'guest' && data.error === undefined) {
|
67
|
+
localStorage.json = angular.toJson($scope.json)
|
68
|
+
}
|
69
|
+
|
70
|
+
if (data.error === undefined) {
|
71
|
+
$scope.results = data;
|
72
|
+
$scope.$apply();
|
73
|
+
}
|
74
|
+
});
|
75
|
+
};
|
76
|
+
$scope.playerVars = {
|
77
|
+
controls: 1,
|
78
|
+
autoplay: 1
|
79
|
+
};
|
80
|
+
|
81
|
+
if (localStorage.json === undefined) {
|
82
|
+
$scope.json = { 'api_key': 'guest', 'secret': 'quest', 'category': 'music' };
|
83
|
+
} else {
|
84
|
+
$scope.json = angular.fromJson(localStorage.json);
|
85
|
+
$scope.refresh();
|
86
|
+
}
|
87
|
+
|
88
|
+
$scope.play = function (video) {
|
89
|
+
$scope.ytVideoUrl = video.url;
|
90
|
+
console.log(youtubeEmbedUtils.getIdFromURL($scope.ytVideoUrl));
|
91
|
+
}
|
92
|
+
|
93
|
+
$scope.isSelected = function (video) {
|
94
|
+
return $scope.ytVideoUrl == video.url;
|
95
|
+
}
|
96
|
+
|
97
|
+
$scope.playRandom = function() {
|
98
|
+
var item = $scope.results[Math.floor(Math.random()*$scope.results.length)];
|
99
|
+
$scope.play(item);
|
100
|
+
if (player !== undefined) {
|
101
|
+
player.seekTo(0);
|
102
|
+
}
|
103
|
+
}
|
104
|
+
|
105
|
+
$scope.$on('youtube.player.ended', function ($event, player) {
|
106
|
+
$scope.playRandom(player)
|
107
|
+
})
|
108
|
+
});
|
@@ -2,20 +2,38 @@
|
|
2
2
|
|
3
3
|
%ul#myTab.nav.nav-tabs
|
4
4
|
%li.active
|
5
|
-
%a{"data-toggle" => "tab", href: "#curl"}
|
5
|
+
%a{"data-toggle" => "tab", href: "#curl"}
|
6
|
+
%img{"src" => "/images/shell.png"}
|
7
|
+
curl
|
6
8
|
%li
|
7
|
-
%a{"data-toggle" => "tab", href: "#
|
9
|
+
%a{"data-toggle" => "tab", href: "#javascript"}
|
10
|
+
%img{"src" => "/images/js.png"}
|
11
|
+
javascript
|
8
12
|
%li
|
9
|
-
%a{"data-toggle" => "tab", href: "#
|
13
|
+
%a{"data-toggle" => "tab", href: "#ruby"}
|
14
|
+
%img{"src" => "/images/ruby.png"}
|
15
|
+
ruby
|
10
16
|
%li
|
11
|
-
%a{"data-toggle" => "tab", href: "#
|
17
|
+
%a{"data-toggle" => "tab", href: "#python"}
|
18
|
+
%img{"src" => "/images/python.png"}
|
19
|
+
python
|
12
20
|
%li
|
13
|
-
%a{"data-toggle" => "tab", href: "#
|
21
|
+
%a{"data-toggle" => "tab", href: "#php"}
|
22
|
+
%img{"src" => "/images/php.png"}
|
23
|
+
php
|
14
24
|
%li
|
15
|
-
%a{"data-toggle" => "tab", href: "#
|
25
|
+
%a{"data-toggle" => "tab", href: "#java"}
|
26
|
+
%img{"src" => "/images/java.png"}
|
27
|
+
java
|
28
|
+
%li
|
29
|
+
%a{"data-toggle" => "tab", href: "#dotnet"}
|
30
|
+
%img{"src" => "/images/dotnet.png"}
|
31
|
+
\.net
|
16
32
|
.tab-content
|
17
33
|
#curl.tab-pane.fade.in.active
|
18
34
|
= partial 'curl'
|
35
|
+
#javascript.tab-pane.fade
|
36
|
+
= partial 'javascript'
|
19
37
|
#ruby.tab-pane.fade
|
20
38
|
= partial 'ruby'
|
21
39
|
#python.tab-pane.fade
|
@@ -1,32 +1,38 @@
|
|
1
|
-
%a{
|
1
|
+
%a{href: '#what'} What is json.northpole.ro?
|
2
2
|
%br
|
3
|
-
%a{
|
3
|
+
%a{href: '#how'} How do I use the API?
|
4
4
|
%br
|
5
|
-
%a{
|
5
|
+
%a{href: '#storage'} What can I store?
|
6
6
|
%br
|
7
|
-
%a{
|
7
|
+
%a{href: '#why'} Why should I register?
|
8
8
|
%br
|
9
|
-
%a{
|
9
|
+
%a{href: '#register'} How do I register?
|
10
10
|
%br
|
11
|
-
%h3#what What is json.northpole.ro
|
11
|
+
%h3#what What is json.northpole.ro?
|
12
12
|
%p
|
13
|
-
json.northpole.ro is a JSON cloud storage service.
|
13
|
+
json.northpole.ro is a JSON cloud storage service.
|
14
|
+
%p
|
15
|
+
It is designed to be simple, fast and easy to use. Use a RESTful HTTP api to manage
|
16
|
+
your json objects and access them from anywhere.
|
14
17
|
%h3#how How do I use the API?
|
15
18
|
%p
|
16
|
-
|
19
|
+
HTTP requests. Read
|
20
|
+
%a{href: '/examples'} the docs
|
21
|
+
for more info.
|
17
22
|
%p
|
18
|
-
To get an idea of how the API works,
|
19
|
-
%a{:
|
20
|
-
|
23
|
+
To get an idea of how the API works, head to the
|
24
|
+
%a{href: '/playground'} playground
|
25
|
+
\.
|
21
26
|
%h3#storage What can I store?
|
22
27
|
%p
|
23
|
-
Any valid json object. The object can contain keys, arrays and hashes.
|
24
|
-
%h3#where Where do I signup for my free account?
|
28
|
+
Any valid json object. The object can contain keys, arrays and hashes.
|
25
29
|
%p
|
26
|
-
|
27
|
-
|
28
|
-
%
|
30
|
+
Once the object gets created it will receive a unique id.
|
31
|
+
%h3#why Why should I register?
|
32
|
+
%p You get your own private storage space under your api_key and secret.
|
33
|
+
%h3#register How do I register?
|
29
34
|
%p
|
30
|
-
|
31
|
-
%a{
|
32
|
-
|
35
|
+
Create a user in the
|
36
|
+
%a{href: '/playground'} playground
|
37
|
+
\. If you can't do that, there is a good chance you don't understand
|
38
|
+
how the API works. Think of it as a tutorial.
|
@@ -0,0 +1 @@
|
|
1
|
+
TODO
|
@@ -1,12 +1,13 @@
|
|
1
1
|
.row
|
2
2
|
.col-md-6
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
3
|
+
.form-group
|
4
|
+
%textarea#playground.form-control
|
5
|
+
= preserve do
|
6
|
+
{
|
7
|
+
\ "api_key":"guest",
|
8
|
+
\ "secret":"guest"
|
9
|
+
}
|
10
|
+
.text-center{style: 'margin-bottom: 14px;'}
|
10
11
|
.btn-group
|
11
12
|
%button.btn.btn-default.dropdown-toggle{"data-toggle" => "dropdown", type: "button"}
|
12
13
|
%span#resource Storage
|
@@ -32,7 +33,7 @@
|
|
32
33
|
.btn-group
|
33
34
|
%button#npAction.btn.btn-default Execute Request
|
34
35
|
.col-md-6{:style => 'height: 100%'}
|
35
|
-
%pre#parsedJson
|
36
|
+
%pre#parsedJson
|
36
37
|
{}
|
37
38
|
.row
|
38
39
|
.col-md-12
|
data/spec/lib/ki/orm_spec.rb
CHANGED
@@ -81,7 +81,7 @@ describe Ki::Orm do
|
|
81
81
|
it 'should delete by id' do
|
82
82
|
obj_id = @db.insert 'foo', { 'hello' => 'world' }
|
83
83
|
expect {
|
84
|
-
@db.delete('foo', obj_id).should == {}
|
84
|
+
@db.delete('foo', obj_id).should == { deleted_item_count: 1 }
|
85
85
|
}.to change { @db.count 'foo' }.by(-1)
|
86
86
|
end
|
87
87
|
end
|
data/spec/spec_helper.rb
CHANGED
@@ -14,10 +14,6 @@ module Ki
|
|
14
14
|
def config_file_path
|
15
15
|
config_yml_path = 'spec/config.yml'
|
16
16
|
config_yml_path += '.example' unless File.exist?('spec/config.yml')
|
17
|
-
|
18
|
-
if config_yml_path.end_with?('example')
|
19
|
-
puts 'WARNING: spec/config.yml.example used'
|
20
|
-
end
|
21
17
|
config_yml_path
|
22
18
|
end
|
23
19
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ki
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.4.
|
4
|
+
version: 0.4.10
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Cristian Mircea Messel
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-06
|
11
|
+
date: 2015-09-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -363,6 +363,7 @@ files:
|
|
363
363
|
- spec/examples/json.northpole.ro/public/images/ice.png
|
364
364
|
- spec/examples/json.northpole.ro/public/images/java.png
|
365
365
|
- spec/examples/json.northpole.ro/public/images/java_small.png
|
366
|
+
- spec/examples/json.northpole.ro/public/images/js.png
|
366
367
|
- spec/examples/json.northpole.ro/public/images/json.png
|
367
368
|
- spec/examples/json.northpole.ro/public/images/json_small.png
|
368
369
|
- spec/examples/json.northpole.ro/public/images/logo.png
|
@@ -379,25 +380,24 @@ files:
|
|
379
380
|
- spec/examples/json.northpole.ro/public/javascripts/app.coffee
|
380
381
|
- spec/examples/json.northpole.ro/public/javascripts/docs.min.js
|
381
382
|
- spec/examples/json.northpole.ro/public/javascripts/jnorthpole.coffee
|
382
|
-
- spec/examples/json.northpole.ro/public/javascripts/
|
383
|
+
- spec/examples/json.northpole.ro/public/javascripts/music/angular-youtube-embed.js
|
383
384
|
- spec/examples/json.northpole.ro/public/stylesheets/app.sass
|
384
|
-
- spec/examples/json.northpole.ro/
|
385
|
-
- spec/examples/json.northpole.ro/public/stylesheets/cover.css
|
385
|
+
- spec/examples/json.northpole.ro/views/awsum.haml
|
386
386
|
- spec/examples/json.northpole.ro/views/curl.haml
|
387
387
|
- spec/examples/json.northpole.ro/views/doc.haml
|
388
388
|
- spec/examples/json.northpole.ro/views/doc_table.haml
|
389
389
|
- spec/examples/json.northpole.ro/views/dotnet.haml
|
390
390
|
- spec/examples/json.northpole.ro/views/examples.haml
|
391
391
|
- spec/examples/json.northpole.ro/views/faq.haml
|
392
|
-
- spec/examples/json.northpole.ro/views/foo.haml
|
393
392
|
- spec/examples/json.northpole.ro/views/index.haml
|
394
393
|
- spec/examples/json.northpole.ro/views/java.haml
|
394
|
+
- spec/examples/json.northpole.ro/views/javascript.haml
|
395
395
|
- spec/examples/json.northpole.ro/views/layout.haml
|
396
396
|
- spec/examples/json.northpole.ro/views/php.haml
|
397
397
|
- spec/examples/json.northpole.ro/views/playground.haml
|
398
398
|
- spec/examples/json.northpole.ro/views/python.haml
|
399
399
|
- spec/examples/json.northpole.ro/views/ruby.haml
|
400
|
-
- spec/examples/json.northpole.ro/views/
|
400
|
+
- spec/examples/json.northpole.ro/views/seed.haml
|
401
401
|
- spec/examples/json.northpole.ro/views/thanks.haml
|
402
402
|
- spec/examples/tasks-example/.ruby-gemset
|
403
403
|
- spec/examples/tasks-example/.ruby-version
|
@@ -536,6 +536,7 @@ test_files:
|
|
536
536
|
- spec/examples/json.northpole.ro/public/images/ice.png
|
537
537
|
- spec/examples/json.northpole.ro/public/images/java.png
|
538
538
|
- spec/examples/json.northpole.ro/public/images/java_small.png
|
539
|
+
- spec/examples/json.northpole.ro/public/images/js.png
|
539
540
|
- spec/examples/json.northpole.ro/public/images/json.png
|
540
541
|
- spec/examples/json.northpole.ro/public/images/json_small.png
|
541
542
|
- spec/examples/json.northpole.ro/public/images/logo.png
|
@@ -552,25 +553,24 @@ test_files:
|
|
552
553
|
- spec/examples/json.northpole.ro/public/javascripts/app.coffee
|
553
554
|
- spec/examples/json.northpole.ro/public/javascripts/docs.min.js
|
554
555
|
- spec/examples/json.northpole.ro/public/javascripts/jnorthpole.coffee
|
555
|
-
- spec/examples/json.northpole.ro/public/javascripts/
|
556
|
+
- spec/examples/json.northpole.ro/public/javascripts/music/angular-youtube-embed.js
|
556
557
|
- spec/examples/json.northpole.ro/public/stylesheets/app.sass
|
557
|
-
- spec/examples/json.northpole.ro/
|
558
|
-
- spec/examples/json.northpole.ro/public/stylesheets/cover.css
|
558
|
+
- spec/examples/json.northpole.ro/views/awsum.haml
|
559
559
|
- spec/examples/json.northpole.ro/views/curl.haml
|
560
560
|
- spec/examples/json.northpole.ro/views/doc.haml
|
561
561
|
- spec/examples/json.northpole.ro/views/doc_table.haml
|
562
562
|
- spec/examples/json.northpole.ro/views/dotnet.haml
|
563
563
|
- spec/examples/json.northpole.ro/views/examples.haml
|
564
564
|
- spec/examples/json.northpole.ro/views/faq.haml
|
565
|
-
- spec/examples/json.northpole.ro/views/foo.haml
|
566
565
|
- spec/examples/json.northpole.ro/views/index.haml
|
567
566
|
- spec/examples/json.northpole.ro/views/java.haml
|
567
|
+
- spec/examples/json.northpole.ro/views/javascript.haml
|
568
568
|
- spec/examples/json.northpole.ro/views/layout.haml
|
569
569
|
- spec/examples/json.northpole.ro/views/php.haml
|
570
570
|
- spec/examples/json.northpole.ro/views/playground.haml
|
571
571
|
- spec/examples/json.northpole.ro/views/python.haml
|
572
572
|
- spec/examples/json.northpole.ro/views/ruby.haml
|
573
|
-
- spec/examples/json.northpole.ro/views/
|
573
|
+
- spec/examples/json.northpole.ro/views/seed.haml
|
574
574
|
- spec/examples/json.northpole.ro/views/thanks.haml
|
575
575
|
- spec/examples/tasks-example/.ruby-gemset
|
576
576
|
- spec/examples/tasks-example/.ruby-version
|
@@ -1,31 +0,0 @@
|
|
1
|
-
window.notify = (text, label) ->
|
2
|
-
$("#signup-info")
|
3
|
-
.text(text)
|
4
|
-
.removeClass()
|
5
|
-
.addClass(label)
|
6
|
-
|
7
|
-
window.syntaxHighlight = (json) ->
|
8
|
-
json = json.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">")
|
9
|
-
json.replace /("(\\u[a-zA-Z0-9]{4}|\\[^u]|[^\\"])*"(\s*:)?|\b(true|false|null)\b|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?)/g, (match) ->
|
10
|
-
cls = "number"
|
11
|
-
if /^"/.test(match)
|
12
|
-
if /:$/.test(match)
|
13
|
-
cls = "key"
|
14
|
-
else
|
15
|
-
cls = "string"
|
16
|
-
else if /true|false/.test(match)
|
17
|
-
cls = "boolean"
|
18
|
-
else cls = "null" if /null/.test(match)
|
19
|
-
"<span class=\"" + cls + "\">" + match + "</span>"
|
20
|
-
|
21
|
-
window.getDataFromTable = () ->
|
22
|
-
obj = {}
|
23
|
-
# :gt(0) skips the header
|
24
|
-
$('#tryNowTable tr:gt(0)').each (index) ->
|
25
|
-
elements = $(this).find('input');
|
26
|
-
key = $(elements[0]).val()
|
27
|
-
val = $(elements[1]).val()
|
28
|
-
if (key != '' && val != '')
|
29
|
-
obj[key]=val
|
30
|
-
obj
|
31
|
-
|