iodruby 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 59f5c08725693815e3dea872861326aa283defd2
4
- data.tar.gz: 87f72a722a9ff5b182a0cae77d52c6ce433d51bf
3
+ metadata.gz: 706940c880b86e48f147a9b92e72213cbfd59869
4
+ data.tar.gz: 50561f394c4935b9b641af5909583ea01f21cf5f
5
5
  SHA512:
6
- metadata.gz: 9e9b480e267116ae47bba410d8f5bfac5e835d1f9f51f6d3f1b345714a95833ac8f510492dd6dc69a7a30110524f8bdac5cf5e40ae7bc678a32a51cf7ffd569b
7
- data.tar.gz: 80db91a0040c189eb9e87bdc786b8cc4bc4950a2b1434444e7647904bb0fa76804bacc4e648b267024f91c0e69e1d8bdd98c89e272c9aef7fe8ee3a72d55355a
6
+ metadata.gz: 27a1eba1d619cc3b6a24437e2837cc6e483ecf295f9688545915939b8a69055a81d07e11445b4ed33d555a5ef7ce2d04b42df3c4ca7c29563a3350ec68eb1ca5
7
+ data.tar.gz: e6ac74f31e0f4c0582d423c066f392129c865d5d97f242ab8286ada2ceb086c4a4d38516c726958b276dad45c8e52f47778835f7e7c1df83210dcb85de285467
data/.DS_Store CHANGED
Binary file
@@ -0,0 +1 @@
1
+ *.gem
data/README.md CHANGED
@@ -1,4 +1,4 @@
1
- # Iodruby
1
+ # iodruby
2
2
 
3
3
  Ruby Gem to help call IDOL OnDemand API.
4
4
  [http://idolondemand.com](http://idolondemand.com)
@@ -6,11 +6,17 @@ Ruby Gem to help call IDOL OnDemand API.
6
6
 
7
7
  ## Installation
8
8
 
9
- To install from this git repo use the specific_install gem.
9
+ To install from rubygems.org.
10
+
11
+ ```
12
+ gem install iodruby
13
+ ```
14
+
15
+ To install the latest version from this github repo, use the specific_install gem.
10
16
 
11
17
  ```
12
18
  gem install specific_install
13
- gem specific_install http://github.com/lemoogle/iodruby
19
+ gem specific_install https://github.com/HP-IDOL-OnDemand/iodruby
14
20
  ```
15
21
 
16
22
 
@@ -18,15 +24,19 @@ gem specific_install http://github.com/lemoogle/iodruby
18
24
 
19
25
 
20
26
  ### Importing
21
-
27
+ When using rails and other frameworks with a gem file, include it in it.
28
+ ```ruby
29
+ gem "iodruby"
22
30
  ```
31
+ Or, require it directly in your app.
32
+ ```ruby
23
33
  require "iodruby"
24
34
  ```
25
35
 
26
36
  ###Initializing the client
27
37
 
28
- ```
29
- client= IODClient.new("http://api.idolondemand.com",$apikey)
38
+ ```ruby
39
+ client = IODClient.new("http://api.idolondemand.com", $apikey)
30
40
  ```
31
41
 
32
42
  All that is needed to initialize the client is an apikey and the url of the API.
@@ -35,33 +45,32 @@ All that is needed to initialize the client is an apikey and the url of the API.
35
45
  ###Sending requests
36
46
 
37
47
  ```ruby
38
- r=client.post('analyzesentiment',{:text=>'I like cats'})
48
+ r = client.post('analyzesentiment', {:text=>'I like cats'})
39
49
  ```
40
50
  The client's *post* method takes the apipath that you're sending your request to as well as an object containing the parameters you want to send to the api. You do not need to send your apikey each time as the client will handle that automatically
41
51
 
42
52
  ###Posting files
43
-
44
53
  ```ruby
45
- r=client.post('ocrdocument',{:file=>File.new("/path/to/file", 'rb')})
54
+ r = client.post('ocrdocument', {:file=>File.new("/path/to/file", 'rb')})
46
55
  ```
47
56
  Sending files is just as easy.
48
57
 
49
58
  ```ruby
50
- r=client.post('ocrdocument',{:mode=>'photo',:file=>File.new("/path/to/file", 'rb')})
51
- r=client.post('ocrdocument',{:mode=>'photo',:file=>File.new("/path/to/file", 'rb')})
59
+ r = client.post('ocrdocument', {:mode=>'photo',:file=>File.new("/path/to/file", 'rb')})
60
+ r = client.post('ocrdocument', {:mode=>'photo',:file=>File.new("/path/to/file", 'rb')})
52
61
  ```
53
62
  Any extra parameters should be added in the same way as regular calls, or in the data parameter.
54
63
 
55
64
  ###Parsing the output
56
65
 
57
66
  ```ruby
58
- myjson=r.json()
67
+ myjson = r.json()
59
68
  ```
60
69
 
61
70
  The object returned is a response object from the python [requests library](http://docs.python-requests.org/en/latest/) and can easily be turned to json.
62
71
 
63
72
  ```ruby
64
- docs=myjson["documents"]
73
+ docs = myjson["documents"]
65
74
  array.each {|doc| puts doc["title"] }
66
75
  ```
67
76
 
@@ -70,7 +79,7 @@ array.each {|doc| puts doc["title"] }
70
79
  **Creating an index**
71
80
 
72
81
  ```ruby
73
- index=client.createIndex("mytestindex",flavor="explorer")
82
+ index = client.createIndex("mytestindex", flavor="explorer")
74
83
  ```
75
84
 
76
85
  An Index object can easily be created
@@ -84,7 +93,7 @@ The getIndex call will return an iodindex Index object but will not check for ex
84
93
 
85
94
  ```ruby
86
95
  indexes = client.listIndexes()
87
- indexes.fetch('myindex',client.createIndex('myindex'))
96
+ indexes.fetch('myindex', client.createIndex('myindex'))
88
97
  ```
89
98
 
90
99
  Here we first check the list of our indexes and return a newly created index if the index does not already exist
@@ -100,8 +109,8 @@ An index can be deleted in two equivalent ways
100
109
  **Indexing documents**
101
110
 
102
111
  ```ruby
103
- doc1=IODDoc.new({title:"title1",reference:"doc1",content:"my content 1"})
104
- doc2=IODDoc.new({title:"title2",reference:"doc2",content:"my content 2"})
112
+ doc1 = IODDoc.new({title: "title1", reference: "doc1", content: "my content 1"})
113
+ doc2 = IODDoc.new({title: "title2", reference: "doc2", content: "my content 2"})
105
114
  ```
106
115
  Documents can be created as regular python objects
107
116
 
@@ -130,9 +139,9 @@ It makes it easy to batch together groups of documents.
130
139
  ####Indexing - Connectors
131
140
 
132
141
  ```ruby
133
- client= IODClient.new("http://api.idolondemand.com",$apikey)
134
- conn=IODConnector.new("mytestconnector",client)
135
- conn.create(type="web",config={ "url" => "http://www.idolondemand.com" })
142
+ client = IODClient.new("http://api.idolondemand.com", $apikey)
143
+ conn = IODConnector.new("mytestconnector", client)
144
+ conn.create(type="web", config = { "url" => "http://www.idolondemand.com" })
136
145
  conn.delete()
137
146
  ```
138
147
 
@@ -142,7 +151,7 @@ conn.delete()
142
151
  For each call the Async parameter can be set to true to send an asynchronous request.
143
152
 
144
153
  ```ruby
145
- r=client.post('analyzesentiment',{:text=>'I like cats'},async=True)
154
+ r = client.post('analyzesentiment', {:text => 'I like cats'}, async = true)
146
155
  print r.json()
147
156
 
148
157
  # will return status of call, queued or finished
@@ -154,14 +163,14 @@ puts r.result().json()
154
163
  Same thing for indexing.
155
164
 
156
165
  ```ruby
157
- r=index.commit(async=True)
166
+ r = index.commit(async = true)
158
167
  ```
159
168
 
160
169
 
161
170
 
162
171
  ## Contributing
163
172
 
164
- 1. Fork it ( https://github.com/lemoogle/iodruby/fork )
173
+ 1. Fork it ( https://github.com/HP-IDOL-OnDemand/iodruby/fork )
165
174
  2. Create your feature branch (`git checkout -b my-new-feature`)
166
175
  3. Commit your changes (`git commit -am 'Add some feature'`)
167
176
  4. Push to the branch (`git push origin my-new-feature`)
@@ -138,8 +138,8 @@ class IODClient
138
138
  end
139
139
  Unirest.timeout(30)
140
140
  response=Unirest.post "#{@url}/#{@@version}/api/#{syncpath}/#{handler}/v#{@@apidefault}",
141
- headers:{ "Accept" => "application/json" },
142
- parameters:data
141
+ headers:{ "Accept" => "application/json", "Content-Type" => "application/json"},
142
+ parameters:data.to_json
143
143
  if response.code == 200
144
144
 
145
145
  if async
@@ -1,3 +1,3 @@
1
1
  module Iodruby
2
- VERSION = "0.0.1"
2
+ VERSION = "0.0.2"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: iodruby
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tyler Nappy
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2015-09-22 00:00:00.000000000 Z
12
+ date: 2015-10-01 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: unirest
@@ -62,6 +62,7 @@ extensions: []
62
62
  extra_rdoc_files: []
63
63
  files:
64
64
  - ".DS_Store"
65
+ - ".gitignore"
65
66
  - Gemfile
66
67
  - LICENSE.txt
67
68
  - README.md