Conversation
airtable.gemspec
Outdated
| spec.name = 'airtable' | ||
| spec.version = Airtable::VERSION | ||
| spec.authors = ['Nathan Esquenazi', 'Alexander Sorokin'] | ||
| spec.email = ['nesquena@gmail.com', 'syrnick@gmail.com'] |
There was a problem hiding this comment.
Feel free to put your name here. Nathan wrote original version, so we'll put his name into Readme/Acknowledgements.
lib/airtable/entity/record.rb
Outdated
| end | ||
|
|
||
| def __create__(base, name) | ||
| res = base.__make_request__(:post, name, { fields: fields }) |
There was a problem hiding this comment.
this name needs escaping equivalent to JS encodeURIComponent (e.g. 3cc21ea). I had hard time finding a better way to do it.
lib/airtable/entity/table.rb
Outdated
| end | ||
|
|
||
| def create(fields) | ||
| ::Airtable::Entity::Record.new(nil, fields: fields).__create__(*@args) |
There was a problem hiding this comment.
it would be clearer to spell out *@args as [@base, @name]
There was a problem hiding this comment.
Ok, i will try to change but possible rubocop will not like it.
There was a problem hiding this comment.
I see. If it does, lets use a more descriptive name, so it can't be confused with the method arguments. Right now someone might look at this and think that *@args is the arguments to def create.
lib/airtable/entity/record.rb
Outdated
| self | ||
| end | ||
|
|
||
| def __update__(base, name) |
There was a problem hiding this comment.
Lets rename name to table_name
lib/airtable/entity/record.rb
Outdated
| end | ||
|
|
||
| def __update__(base, name) | ||
| args = [:patch, [name, @id].join('/'), fields: fields] |
There was a problem hiding this comment.
Important: name (i.e. tableName) must be properly encoded as it may have special characters (e.g. 3cc21ea). Try it with a table that's named Some &.#%?// table
lib/airtable/entity/record.rb
Outdated
| end | ||
|
|
||
| class << self | ||
| def all(base, name, params) |
There was a problem hiding this comment.
It seems that all and __fetch__ should be class methods on Table, not Record.
There was a problem hiding this comment.
No. Table class is already too big. And better to use such methods in Record to follow the Ruby/Ruby on Rails way.
lib/airtable/entity/record.rb
Outdated
| res << new(*args) | ||
| end | ||
| return unless result['offset'] | ||
| __fetch__(base, name, params.merge(offset: result['offset']), res) |
There was a problem hiding this comment.
lets add a comment that ruby can easily handle 10k deep stack and that should be plenty to fetch any table.
There was a problem hiding this comment.
no, just here. recursion is a bit of a red flag unless the language always does tail call optimization (ruby has an option that's off by default). Hence, it helps to add a comment to the implementation justifying why it shouldn't cause trouble. There are esoteric scenarios where this will blow up. E.g. iterating over a large base (50k records) with page_size set to 1 (really bad idea of course).
README.md
Outdated
| Supported Operations: | ||
| Get Record (if only RECORD_ID provided) | ||
| Get Field (if RECORD_ID and FIELD_ID are provided) | ||
| Update Field (if RECORD_ID, FIELD_ID and VALUE are provided) |
There was a problem hiding this comment.
Lets make the operation explicit:
airtable get -b Base -t table
airtable get -b Base -t table -f FIELD_NAME
airtable update -b Base -t table -r RECORD_ID -f FIELD_NAME -v newValue
There was a problem hiding this comment.
Sure. Will start working on it shortly.
| spec.require_paths = ["lib"] | ||
| spec.files = `git ls-files -z`.split("\x0") | ||
| spec.bindir = 'exe' | ||
| spec.executables = `git ls-files -- exe/*`.split("\n").map {|f| File.basename(f)} |
There was a problem hiding this comment.
is exe/ better than bin/ ?
There was a problem hiding this comment.
Yes. More info there - http://bundler.io/blog/2015/03/20/moving-bins-to-exe.html
| # Specify your gem's dependencies in airtable.gemspec | ||
| gemspec | ||
|
|
||
| gem 'pry' |
There was a problem hiding this comment.
Its for development purposes. Really helpful. Gemfile is not pushed to the gem file so used only for development environment of gem file only.
| end | ||
|
|
||
| def select(options = {}) | ||
| params = {} |
There was a problem hiding this comment.
Lets add support for view (should be a string if present) and filterByFormula (should be a string if present) parameters.
There was a problem hiding this comment.
Ah, yes it will be added. I want to finished with current codebase and functionality first.
README.md
Outdated
| ```ruby | ||
| # Pass in api key to client | ||
| @client = Airtable::Client.new("keyPCx5W") | ||
| # Or if you have AIRTABLE_KEY varibale you can use |
There was a problem hiding this comment.
typo: varibale -> variable
is this referring to an environment variable? if so, let's make that clearer
README.md
Outdated
|
|
||
| ### Accessing a Base | ||
|
|
||
| Now we can access any base in our Airsheet account by referencing the [API docs](https://airtable.com/api): |
README.md
Outdated
| ``` | ||
|
|
||
| We can specify a `sort` order, `limit`, and `offset` as part of our query: | ||
| We can specify a `sort` order, `limit`, `max_records` and `offset` as part of our query: |
There was a problem hiding this comment.
Maybe take out max_records from here since it can be confusing to see next to limit and most people don't need to use it. We can add a note about it below where we say "This executes a variable number of network requests (100 records per batch) to retrieve all records in a sheet."
instead could say:
"This executes a variable number of network requests (by default 100 records per batch) to retrieve all records in a sheet. You can use max_records to customize the number of records to fetch per batch."
There was a problem hiding this comment.
Then I think better to use per_page instead of max_records.
README.md
Outdated
|
|
||
| ## Command Line Tool | ||
|
|
||
| This gem is include a very simple command line tool which can show basic functionality of service. |
There was a problem hiding this comment.
"This gem includes a simple command line tool which shows the basic functionality of the service."
lib/airtable/entity/base.rb
Outdated
|
|
||
| def __make_request__(method, path, data) | ||
| url = [::Airtable.server_url, @id, path].join('/') | ||
| url = [::Airtable.server_url, CGI.escape(@id), path].join('/') |
There was a problem hiding this comment.
@id shouldn't need escaping for now. It can only be 17-character alphanumeric starting with "app".
lib/airtable/entity/table.rb
Outdated
|
|
||
| def initialize(base, name) | ||
| @name = name | ||
| @name = CGI.escape(name) |
There was a problem hiding this comment.
I don't think CGI.escape works - we need to use an equivalent of encodeUriComponent in JS .
For example, they differ in handling of spaces - GCI.escape turns them into '+' v.s. %2B.
Separately, storing @name as encoded might be confusing later on. If someone does p table.name, they would n't expect the encoding. It'd be better to either:
a) have an accessor url_encoded_name that does encoding on the fly.
b) wrap name access in url_encode e.g. @table_path = [@base, url_encode(@name)]
c) add in instance variable @url_encoded_name = url_encode(@name)

No description provided.