dgr 0.0.2 → 0.0.3

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 3d9a68e572f69b23712ff0b57cf356a35a4e8b16
4
- data.tar.gz: 9ad51539a39f8ebc617a2e0da0f474b8d52c5d4f
3
+ metadata.gz: a30a7af710a33bfde45fca6466c98c9b7bf43990
4
+ data.tar.gz: 26f0035a84334264c74584c76f10427fb0ec04f7
5
5
  SHA512:
6
- metadata.gz: f025704212ce4a723557bf7d38f086e61d63fc9a4db58d8f645ff8ac1643c3edd26a3bd9815745900e109df402d1fe003d496b8dff19c2b563b869951026d380
7
- data.tar.gz: 14ebbe60c4cfde699aade53eeabd581fdc4349fd1728519469b5be32565c39902d9faa8e891f7ab805e46409d555725d8d335a5859cfc9a39be5e598a86c87f1
6
+ metadata.gz: 791a750d49e38db3afaac95db8d1c61c3e246ed8ad116922464c16546b8cd86f54da31c959ac3be7d5709a9b7dbec5c070d159d782a691198daa3701eab32361
7
+ data.tar.gz: cdac1015b7616719a857e294b512e534ac8c62157cebacf6479c0e3f673b0a54d9f71f7b2990bd4992f87f57b5071a9bc98b08da896e76e34ad59c912060e17b
data/.gitignore CHANGED
@@ -1,17 +1,14 @@
1
- *.gem
2
- *.rbc
3
- .bundle
4
- .config
5
- .yardoc
6
- Gemfile.lock
7
- InstalledFiles
8
- _yardoc
9
- coverage
10
- doc/
11
- lib/bundler/man
12
- pkg
13
- rdoc
14
- spec/reports
15
- test/tmp
16
- test/version_tmp
17
- tmp
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
10
+ *.bundle
11
+ *.so
12
+ *.o
13
+ *.a
14
+ mkmf.log
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --format Fuubar
2
+ --color
data/Gemfile CHANGED
@@ -1,4 +1,22 @@
1
1
  source 'https://rubygems.org'
2
2
 
3
- gem 'rest_client'
3
+ # Specify your gem's dependencies in dgr.gemspec
4
+ gemspec
4
5
 
6
+ gem 'rake'
7
+ gem 'json'
8
+ gem 'coveralls', require: false
9
+
10
+ group :development do
11
+ gem 'guard'
12
+ gem 'guard-rspec'
13
+ gem 'pry'
14
+ gem 'pry-remote'
15
+ gem 'pry-nav'
16
+ gem 'fuubar'
17
+ end
18
+
19
+ group :test do
20
+ gem 'rspec'
21
+ gem 'rspec-nc'
22
+ end
@@ -0,0 +1,5 @@
1
+ guard :rspec, cmd: 'rspec --format Fuubar --color spec' do
2
+ watch(%r{^spec/.+_spec\.rb$})
3
+ watch(%r{^lib/(.+)\.rb$}) { |m| "spec/lib/#{m[1]}_spec.rb" }
4
+ watch('spec/spec_helper.rb') { "spec" }
5
+ end
data/README.md CHANGED
@@ -1,47 +1,31 @@
1
- # DgrTest
1
+ #dgr-rb-tool
2
+ A tool for data garage usage using ruby.
2
3
 
3
- A tool for data garage usage
4
+ ## Install
4
5
 
5
- ## Installation
6
-
7
- Add this line to your application's Gemfile:
8
-
9
- gem 'dgr_test'
10
-
11
- And then execute:
12
-
13
- $ bundle
14
-
15
- Or install it yourself as:
16
-
17
- $ gem install dgr_test
6
+ ###
7
+ ```
8
+ gem install dgr
9
+ ```
18
10
 
19
11
  ## Usage
12
+ ```
13
+ Dgr.fetch(id, options = {})
14
+ ```
15
+
16
+ ## Example
17
+ ```
18
+ Dgr.fetch("54a814079cbc60e12d30c2d2")
19
+ Dgr.fetch("54a814079cbc60e12d30c2d2", :fields => "count()")
20
+ Dgr.fetch("54a814079cbc60e12d30c2d2", :limit => 3, fields => "age>31 AND age<35")
21
+ ```
22
+
23
+ ## Development
24
+ ```
25
+ bundle install
26
+ guard
27
+ ```
28
+
29
+ ##License
30
+ MIT [@jackhou07](http://www.github.com/jackhou07)
20
31
 
21
- ### Fetch all data
22
-
23
- * Argument
24
- * Data id(string)
25
- * Return: json
26
-
27
- fetchAll('52e12d31203b41ab5d14964b')
28
-
29
- ### Fetch custom data
30
-
31
- * Argument
32
- * Data id(string)
33
- * data(Object):
34
- * limit: You can limit the number of dataset which you wanna pull
35
- * fields: Select the fields you want to get, should be a string seperate by comma (for example: `Format, Valuie`, ...)
36
- * You could also skip the record you don't want( for example: `skip: 2`, that means the data will start from the 3)
37
- * selector : You can also select the data using greater, lesser, or equal ( for exmaple: `B Fmt=General`)
38
-
39
- fetchCustom('52e12d31203b41ab5d14964b', {'limit': '3'})
40
-
41
- ## Contributing
42
-
43
- 1. Fork it
44
- 2. Create your feature branch (`git checkout -b my-new-feature`)
45
- 3. Commit your changes (`git commit -am 'Add some feature'`)
46
- 4. Push to the branch (`git push origin my-new-feature`)
47
- 5. Create new Pull Request
@@ -6,19 +6,20 @@ require 'dgr/version'
6
6
  Gem::Specification.new do |spec|
7
7
  spec.name = "dgr"
8
8
  spec.version = Dgr::VERSION
9
- spec.authors = ["JackHou"]
10
- spec.email = ["vjack070707@gmail.com"]
11
- spec.description = %q{A tool for data garage usage}
12
- spec.summary = %q{}
13
- spec.homepage = "https://github.com/DataGarage"
9
+ spec.authors = ["zxlai"]
10
+ spec.email = ["garylai1990@gmail.com"]
11
+ spec.summary = "Data Garage Ruby tool."
12
+ spec.description = "Data Garage Ruby tool."
13
+ spec.homepage = ""
14
14
  spec.license = "MIT"
15
15
 
16
- spec.files = `git ls-files`.split($/)
16
+ spec.files = `git ls-files -z`.split("\x0")
17
17
  spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
18
  spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
19
  spec.require_paths = ["lib"]
20
20
 
21
- spec.add_development_dependency "bundler", "~> 1.3"
22
- spec.add_development_dependency "rake"
23
- spec.add_development_dependency "rest_client"
21
+ spec.add_development_dependency "bundler", "~> 1.7"
22
+ spec.add_development_dependency "rake", "~> 10.0"
23
+
24
+ spec.add_dependency "rest_client"
24
25
  end
data/lib/dgr.rb CHANGED
@@ -1,11 +1,27 @@
1
+ require "dgr/version"
1
2
  require 'rest_client'
3
+ require "json"
2
4
 
3
- def fetchAll(dataId)
4
- response = RestClient.get 'http://localhost:3000/api/' + dataId
5
- return response
6
- end
5
+ module Dgr
6
+
7
+ def self.fetch(data_id, options = {})
8
+ fields = options[:fields]
9
+ selector = options[:selector]
10
+ limit = options[:limit]
11
+ skip = options[:skip]
12
+ group = options[:group]
13
+ segments = options[:segments]
14
+ response = RestClient.get "http://www.datagarage.io/api/#{data_id}",
15
+ {
16
+ :params => {
17
+ :fields => fields,
18
+ :selector => selector,
19
+ :limit => limit,
20
+ :skip => skip,
21
+ :group => group,
22
+ :segments => segments
23
+ }
24
+ }
25
+ end
7
26
 
8
- def fetchCustom(dataId, form)
9
- response = RestClient.get 'http://localhost:3000/api/' + dataId, params = form
10
- return response
11
27
  end
@@ -1,3 +1,3 @@
1
1
  module Dgr
2
- VERSION = "0.0.2"
2
+ VERSION = "0.0.3"
3
3
  end
@@ -1,4 +1,4 @@
1
- Copyright (c) 2014 JackHou
1
+ Copyright (c) 2015 zxlai
2
2
 
3
3
  MIT License
4
4
 
@@ -0,0 +1,43 @@
1
+ require "spec_helper"
2
+
3
+ describe Dgr do
4
+
5
+ it "fetch data from server" do
6
+ response = Dgr.fetch("54a814079cbc60e12d30c2d2")
7
+ expect(response.code).to eq 200
8
+ parsed = JSON.parse(response)
9
+ first_one = parsed.first
10
+ expect(first_one["name"].to_s).to eq "Ms. Eula Yost MD"
11
+ expect(first_one["bmi"]).to eq 16.35
12
+ expect(first_one["age"]).to eq 48
13
+ expect(first_one["birthday"]).to eq "1988-09-06T00:00:00.000Z"
14
+ expect(first_one["country"]).to eq "East Staceyberg"
15
+ expect(first_one["married"]).to eq true
16
+ end
17
+
18
+ it "get the count number of data" do
19
+ response = Dgr.fetch("54a814079cbc60e12d30c2d2", :fields => "count()")
20
+ expect(response).to eq "11"
21
+ end
22
+
23
+ it "shold get specfic spec field of data" do
24
+ response = Dgr.fetch("54a814079cbc60e12d30c2d2", :fields => "name,bmi")
25
+ parsed = JSON.parse(response)
26
+ expect(parsed.all? {|p| p.has_key?("name")}).to eq true
27
+ expect(parsed.all? {|p| p.has_key?("bmi")}).to eq true
28
+ expect(parsed.all? {|p| p.has_key?("age")}).to eq false
29
+ end
30
+
31
+ it "shold get limit number of data" do
32
+ response = Dgr.fetch("54a814079cbc60e12d30c2d2", :limit => 5)
33
+ parsed = JSON.parse(response)
34
+ expect(parsed.length).to eq 5
35
+ end
36
+
37
+ it "shold get specfic selector of data" do
38
+ response = Dgr.fetch("54a814079cbc60e12d30c2d2", :selector => "age>31ANDage<35")
39
+ parsed = JSON.parse(response)
40
+ expect(parsed.all? {|p| p["age"] > 31 && p["age"] <35}).to eq true
41
+ end
42
+
43
+ end
@@ -0,0 +1,5 @@
1
+ require 'coveralls'
2
+ Coveralls.wear!
3
+
4
+ require 'pry'
5
+ require 'dgr'
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dgr
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  platform: ruby
6
6
  authors:
7
- - JackHou
7
+ - zxlai
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-02-06 00:00:00.000000000 Z
11
+ date: 2015-01-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -16,28 +16,28 @@ dependencies:
16
16
  requirements:
17
17
  - - ~>
18
18
  - !ruby/object:Gem::Version
19
- version: '1.3'
19
+ version: '1.7'
20
20
  type: :development
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - ~>
25
25
  - !ruby/object:Gem::Version
26
- version: '1.3'
26
+ version: '1.7'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: rake
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - '>='
31
+ - - ~>
32
32
  - !ruby/object:Gem::Version
33
- version: '0'
33
+ version: '10.0'
34
34
  type: :development
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - '>='
38
+ - - ~>
39
39
  - !ruby/object:Gem::Version
40
- version: '0'
40
+ version: '10.0'
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: rest_client
43
43
  requirement: !ruby/object:Gem::Requirement
@@ -45,29 +45,33 @@ dependencies:
45
45
  - - '>='
46
46
  - !ruby/object:Gem::Version
47
47
  version: '0'
48
- type: :development
48
+ type: :runtime
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
52
  - - '>='
53
53
  - !ruby/object:Gem::Version
54
54
  version: '0'
55
- description: A tool for data garage usage
55
+ description: Data Garage Ruby tool.
56
56
  email:
57
- - vjack070707@gmail.com
57
+ - garylai1990@gmail.com
58
58
  executables: []
59
59
  extensions: []
60
60
  extra_rdoc_files: []
61
61
  files:
62
62
  - .gitignore
63
+ - .rspec
63
64
  - Gemfile
64
- - LICENSE.txt
65
+ - Guardfile
65
66
  - README.md
66
67
  - Rakefile
67
68
  - dgr.gemspec
68
69
  - lib/dgr.rb
69
70
  - lib/dgr/version.rb
70
- homepage: https://github.com/DataGarage
71
+ - licnese.txt
72
+ - spec/dgr_spec.rb
73
+ - spec/spec_helper.rb
74
+ homepage: ''
71
75
  licenses:
72
76
  - MIT
73
77
  metadata: {}
@@ -87,8 +91,10 @@ required_rubygems_version: !ruby/object:Gem::Requirement
87
91
  version: '0'
88
92
  requirements: []
89
93
  rubyforge_project:
90
- rubygems_version: 2.1.11
94
+ rubygems_version: 2.4.3
91
95
  signing_key:
92
96
  specification_version: 4
93
- summary: ''
94
- test_files: []
97
+ summary: Data Garage Ruby tool.
98
+ test_files:
99
+ - spec/dgr_spec.rb
100
+ - spec/spec_helper.rb