README.md in quandl_client-0.0.4 vs README.md in quandl_client-0.0.5
- old
+ new
@@ -66,11 +66,11 @@
#### Create
```ruby
attributes = {
- code: "TEST_12345",
+ code: "TEST_#{Time.now.to_i}",
source_code: 'OFDP',
name: "Test Upload #{Time.now.to_i}",
frequency: 'daily',
locations:
[
@@ -84,64 +84,120 @@
}
d = Dataset.create( attributes )
```
-##### Errors
-```ruby
-
-d = Dataset.create(code: 'TEST', source_code: 'OFDP', locations_attributes: [{ type: 'http', url: 'test.com' }] )
-d.errors
-=> {"locations.post_data"=>["can't be blank"], "locations.cookie_url"=>["can't be blank"], "name"=>["can't be blank"], "frequency"=>["is not included in the list"]}
-
-```
-
-
#### Update
```ruby
-d = Dataset.find("OFDP/TEST_12345")
+d = Dataset.find( d.full_code )
d.name = 'New Name'
d.data = Quandl::Data::Random.table.to_csv
d.save
-d = Dataset.collapse(:weekly).find("OFDP/TEST_12345")
+d = Dataset.collapse(:weekly).find( d.full_code )
d.data
=> [[...],...]
```
+#### Delete
+```ruby
+Dataset.destroy_existing('SOME_SOURCE/SOME_CODE')
+Dataset.destroy_existing(52352)
+
+Dataset.find('SOME_SOURCE/SOME_CODE')
+=> nil
+
+```
+
+
+#### Error Handling
+
+```ruby
+
+d = Dataset.create(code: 'TEST', source_code: 'OFDP', locations: [{ type: 'http', url: 'test.com' }] )
+d.error_messages
+=> {:name=>["can't be blank"]}
+
+d = Dataset.create(name: 'asdfs', code: 'TEST', source_code: 'OFDP', locations: [{ type: 'http', url: 'test.com' }] )
+d.error_messages
+=> {"code"=>["has already been taken"], "frequency"=>["is not included in the list"]}
+
+```
+
+
+
+
## Quandl::Client::Source
#### Search
```ruby
-sources = Quandl::Client::Source.query('canada').page(2).all
+sources = Quandl::Client::Source.query('can').all
-=> [#<Quandl::Client::Source(sources) code="STATCAN1" title="Stat Can">,...]
+=> [#<Quandl::Client::Source(sources/413) code="STATSCAN5" datasets_count=1>...]
```
#### Show
```ruby
-sheet = Quandl::Client::Source.find('STATCAN1')
+s = Quandl::Client::Source.find('STATSCAN5')
```
+#### Create
+```ruby
+s = Source.create( code: 'test' )
+s.valid?
+s.error_messages
+=> {:code=>["is invalid"], :host=>["can't be blank"], :name=>["can't be blank"]}
+
+s = Source.create(code: %Q{TEST_#{Time.now.to_i}}, name: 'asdf', host: "http://asdf#{Time.now}.com" )
+s.saved?
+=> true
+
+```
+
+
+#### Update
+
+```ruby
+
+s = Source.find(s.code)
+s.name = "Updated Name #{Time.now.to_i}"
+s.code = "DATA_#{Time.now.to_i}"
+s.save
+
+```
+
+
+#### Delete
+
+```ruby
+
+Source.destroy_existing('SOMESOURCE')
+Source.destroy_existing(52352)
+
+```
+
+
+
+
## Quandl::Client::Sheet
#### Search
@@ -164,15 +220,16 @@
#### Create
```ruby
-include Quandl::Client
+s = Quandl::Client::Sheet.create( title: 'ocean' )
+s = Quandl::Client::Sheet.create( full_url_title: 'ocean/river', title: 'River' )
+s = Quandl::Client::Sheet.create( full_url_title: 'ocean/river/lake', title: 'Lake!' )
-s = Sheet.create( title: 'ocean' )
-s = Sheet.create( full_url_title: 'ocean/river', title: 'River' )
-s = Sheet.create( full_url_title: 'ocean/river/lake', title: 'Lake!' )
+Sheet.find('ocean/river/lake').title
+=> 'Lake!'
Sheet.find('ocean').children.first.title
=> River
```
@@ -180,14 +237,23 @@
#### Update
```ruby
-Quandl::Client.token = 'xyz'
-
-s = Quandl::Client::Sheet.find_by_url_title('hi_there')
-s.title = 'another title'
+s = Quandl::Client::Sheet.find('ocean/river')
+s.title = "River #{Time.now.to_i}"
s.save
+
+```
+
+
+#### Delete
+
+```ruby
+
+Quandl::Client::Sheet.destroy_existing('ocean/river/lake')
+
+Quandl::Client::Sheet.destroy_existing(15252)
```