{"action":"created","issue":{"url":"https://api.github.com/repos/Aaronepower/tokei/issues/279","repository_url":"https://api.github.com/repos/Aaronepower/tokei","labels_url":"https://api.github.com/repos/Aaronepower/tokei/issues/279/labels{/name}","comments_url":"https://api.github.com/repos/Aaronepower/tokei/issues/279/comments","events_url":"https://api.github.com/repos/Aaronepower/tokei/issues/279/events","html_url":"https://github.com/Aaronepower/tokei/pull/279","id":379241160,"node_id":"MDExOlB1bGxSZXF1ZXN0MjI5NzU2MTcx","number":279,"title":"Access files to analyze through FileAccess trait","user":{"login":"udoprog","id":111092,"node_id":"MDQ6VXNlcjExMTA5Mg==","avatar_url":"https://avatars0.githubusercontent.com/u/111092?v=4","gravatar_id":"","url":"https://api.github.com/users/udoprog","html_url":"https://github.com/udoprog","followers_url":"https://api.github.com/users/udoprog/followers","following_url":"https://api.github.com/users/udoprog/following{/other_user}","gists_url":"https://api.github.com/users/udoprog/gists{/gist_id}","starred_url":"https://api.github.com/users/udoprog/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/udoprog/subscriptions","organizations_url":"https://api.github.com/users/udoprog/orgs","repos_url":"https://api.github.com/users/udoprog/repos","events_url":"https://api.github.com/users/udoprog/events{/privacy}","received_events_url":"https://api.github.com/users/udoprog/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":2,"created_at":"2018-11-09T16:55:08Z","updated_at":"2018-11-09T21:51:31Z","closed_at":null,"author_association":"NONE","pull_request":{"url":"https://api.github.com/repos/Aaronepower/tokei/pulls/279","html_url":"https://github.com/Aaronepower/tokei/pull/279","diff_url":"https://github.com/Aaronepower/tokei/pull/279.diff","patch_url":"https://github.com/Aaronepower/tokei/pull/279.patch"},"body":"This pushes the abstractions available to provide files for analysis down a bit, and exposes a refactored, lower-level version of `get_statistics` that allows you to provide an iterator of `FileAccess` objects for analysis.\r\n\r\nThis allows you to analyze non-filesystem like things, like tar and zip archives. Or in-memory collections of files by building an implementation of `FileAccess`.\r\n\r\nA simple example would look something like (warning: not tested):\r\n\r\n```rust\r\nuse std::io;\r\n\r\nstruct FakeFile {\r\n    name: String,\r\n    content: String,\r\n}\r\n\r\nimpl<'a> FileAccess<'a> for &'a FakeFile {\r\n    fn read_to_string(self) -> io::Result<String> {\r\n        Ok(self.content.clone())\r\n    }\r\n\r\n    fn read_first_line(self) -> io::Result<String> {\r\n        let line = self.content.split(\"\\n\").next().map(|s| s.to_string()).unwrap_or_else(|| self.content.to_string());\r\n        Ok(line)\r\n    }\r\n\r\n    fn name(self) -> Cow<'a, str> {\r\n        Cow::from(&self.name)\r\n    }\r\n\r\n    fn file_name(self) -> Option<Cow<'a, str>> {\r\n        Some(self.name.rsplit(\"/\").next().map(Cow::from).unwrap_or_else(|| Cow::from(&self.name)))\r\n    }\r\n\r\n    fn extension(self) -> Option<Cow<'a, str>> {\r\n        match self.file_name() {\r\n            Some(Cow::Borrowed(n)) => n.rsplit(\".\").next().map(Cow::from),\r\n            Some(Cow::Owned(n)) => n.rsplit(\".\").next().map(|s| s.to_string()).map(Cow::from),\r\n            None => None,\r\n        }\r\n    }\r\n}\r\n```"},"comment":{"url":"https://api.github.com/repos/Aaronepower/tokei/issues/comments/437506241","html_url":"https://github.com/Aaronepower/tokei/pull/279#issuecomment-437506241","issue_url":"https://api.github.com/repos/Aaronepower/tokei/issues/279","id":437506241,"node_id":"MDEyOklzc3VlQ29tbWVudDQzNzUwNjI0MQ==","user":{"login":"udoprog","id":111092,"node_id":"MDQ6VXNlcjExMTA5Mg==","avatar_url":"https://avatars0.githubusercontent.com/u/111092?v=4","gravatar_id":"","url":"https://api.github.com/users/udoprog","html_url":"https://github.com/udoprog","followers_url":"https://api.github.com/users/udoprog/followers","following_url":"https://api.github.com/users/udoprog/following{/other_user}","gists_url":"https://api.github.com/users/udoprog/gists{/gist_id}","starred_url":"https://api.github.com/users/udoprog/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/udoprog/subscriptions","organizations_url":"https://api.github.com/users/udoprog/orgs","repos_url":"https://api.github.com/users/udoprog/repos","events_url":"https://api.github.com/users/udoprog/events{/privacy}","received_events_url":"https://api.github.com/users/udoprog/received_events","type":"User","site_admin":false},"created_at":"2018-11-09T21:51:31Z","updated_at":"2018-11-09T21:51:31Z","author_association":"NONE","body":"FTR, I'm currently working on building a PoC that uses this trait in combination with the `tar-rs`."}}
{"actor":{"display_login":"udoprog"}}