Comments (5)
Could you provide a short example script with some fake data of what the data looks like, what command (roughly) you'd like to run and what output you hope to see? I think that will just help clarify that we are on the same page before I dig too deep down a blind alley.
from formatador.
Sure!
Example response from the third party.
→ http https://api.example.com/ssh_users.json
HTTP/1.1 200 OK
Connection: keep-alive
Content-Length: 112
Content-Type: application/json;charset=utf-8
Date: Mon, 06 Jan 2014 19:28:29 GMT
Server: nginx
Status: 200 OK
X-Content-Type-Options: nosniff
X-Rate-Limit-Limit: 360
X-Rate-Limit-Remaining: 359
X-Rate-Limit-Reset: 1389038400
[
{
"id": "11744",
"nickname": "[email protected]"
},
{
"id": "23228",
"nickname": "[email protected]"
},
{
"id": "23229",
"nickname": "[email protected]"
}
]
In terms of the command, I am not 100% sure where it would best fit - maybe an extra hash of actual fields => rewritten output field? E.g. Formatador.display_table(table_data, [:id, :nickname => "username"])
.
from formatador.
Hmm. Trying to think how to make this easier. Perhaps you can just do something like:
response = JSON.parse(Excon.get('https://api.example.com/ssh_users.json').body)
data = Hash.new do |hash, key|
case key
when 'username'
hash['nickname']
else
nil
end
end
data.merge!(response)
Formatador.display_table(data)
Just wanted to offer some kind of fix that involved less iterating for you, since I too am unsure where one might best fit in those extra fields.
from formatador.
The more I think about this, the more I am convinced that this requirement should be outside of the scope of Formatador as it isn't anything to do with the outputting of the table, it is altering the data that is returned which is the issue here.
If you don't have anything further to add I am happy to close this off and leave it as is.
Thanks for the replies though!
from formatador.
@jacobbednarz - alright. I certainly see how something like this could be helpful, but there are also points for keeping the table stuff simple. So, yeah, lets just leave it for now. Thanks for the feedback and discussion!
from formatador.
Related Issues (15)
- Empty lines in a simple table HOT 1
- Decouple From Terminal + Add HTML / Spreadsheets Output? HOT 4
- Add License information to gemfile HOT 1
- Semantic Versioning HOT 4
- Allow renaming of headers in display_table HOT 6
- Allow display of a row index HOT 4
- Better visualization on README HOT 5
- Allow to send color codes even if no tty HOT 3
- make a new release? HOT 1
- Is there a way to right-justify a numeric HOT 3
- Building on travis-ci.org is ceased HOT 1
- 1.1 missing in changelog HOT 1
- uninitialized constant StringIO while running tests HOT 4
- Tests fail when redirected to a file HOT 5
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from formatador.