htk 0.0.1 → 0.1.0

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
- SHA1:
3
- metadata.gz: a7dd939114342957941851759641e01558dcbcd9
4
- data.tar.gz: 54b563d7b32b3b1bc9a3be0b35ee8e719164dd53
2
+ SHA256:
3
+ metadata.gz: da21995ad81e76241e6523499be438eb48fcf53f6b145e1fdea0fe77c31c3b13
4
+ data.tar.gz: bcb41707b5b44145d32c557de4802795c35a32632f32eeeb502135039abe257c
5
5
  SHA512:
6
- metadata.gz: 33df9f1d19af442a79ff2bb83a3b05520cad29d0ca5013f91840a41d695c9af1ffd935a996e6e4cac44b70ca39aec3d6ff944bfa06cd3d086668560380e30478
7
- data.tar.gz: b171bc46628cf7208f31a41587ff7bdd3801737f411bbffe6eb1ded6a6eee5b1fd0d81cb7b28951f47a90b6075e1b95cfd227caf4b9eaf256ee3b95243563818
6
+ metadata.gz: 6012b7a982e1413c79fbf40aabe160719887c7dbb3f30e6753696e233b738b31ad9487f00b0566a146a8e2bb3f4f7addb5d3b4c28cf58fef11fe931b398b0cf2
7
+ data.tar.gz: aaedb6f33778ec0f977b60ad817dda51b7392429c10b4fa17e7a144cde58fa50351e8ff16871d3a1b7b3b16482eb60f8880408ddd5aec026d9cd4a300f4e233e
File without changes
data/lib/Htk/utils.rb ADDED
@@ -0,0 +1,71 @@
1
+ require 'date'
2
+ require 'fileutils'
3
+ require 'json'
4
+ require 'singleton'
5
+
6
+ DEFAULT_FILE_PATH = '/tmp/fdebug.log'
7
+
8
+ module Htk
9
+ class FDebugCounter
10
+ include Singleton
11
+
12
+ def initialize()
13
+ @counter = 0
14
+ end
15
+
16
+ def increment
17
+ @counter += 1
18
+ end
19
+
20
+ def count
21
+ @counter
22
+ end
23
+ end
24
+
25
+ class Base
26
+ def slack_debug(text)
27
+ conn = ::Htk::Apis::SlackDebug.connection
28
+ response = conn.post('') do |req|
29
+ req.headers['Accept'] = 'application/json'
30
+ req.headers['Content-Type'] = 'application/json'
31
+
32
+ req.body = {
33
+ 'text' => text,
34
+ }.to_json
35
+ end
36
+ end
37
+
38
+ ##
39
+ # Dumps the given text to the given file. If file_path omited, uses 'DEFAULT_FILE_PATH'
40
+
41
+ def fdebug(text, file_path=DEFAULT_FILE_PATH)
42
+ counter = ::Htk::FDebugCounter.instance
43
+ counter.increment
44
+
45
+ now = ::DateTime.now
46
+ now_str = now.strftime('%Y-%m-%d %H:%I:%S')
47
+
48
+ dirname = File.dirname(file_path)
49
+ unless File.directory?(dirname)
50
+ FileUtils.mkdir_p(dirname)
51
+ end
52
+
53
+ open(file_path, 'a') { |f|
54
+ f << ">>>>>>>>>> FDEBUG #{counter.count} #{now_str} <<<<<<<<<<\n"
55
+ f << text + "\n"
56
+ f << ">>>>>>>>>> FDEBUG #{counter.count} #{now_str} <<<<<<<<<<\n"
57
+ }
58
+
59
+ end
60
+
61
+ ##
62
+ # Dumps given object to given file as JSON. If file_path omited, default path is 'DEFAULT_FILE_PATH'
63
+
64
+ def fdebug_json(obj, file_path=DEFAULT_FILE_PATH)
65
+ data = obj.to_json
66
+ fdebug(JSON.pretty_generate(data), file_path)
67
+ end
68
+ end
69
+
70
+ Utils = Base.new
71
+ end
metadata CHANGED
@@ -1,56 +1,25 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: htk
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.1.0
5
5
  platform: ruby
6
6
  authors:
7
+ - Hacktoolkit
7
8
  - Jonathan Tsai
9
+ - Gökhan Öztürk
8
10
  autorequire:
9
11
  bindir: bin
10
12
  cert_chain: []
11
- date: 2020-12-16 00:00:00.000000000 Z
12
- dependencies:
13
- - !ruby/object:Gem::Dependency
14
- name: bundler
15
- requirement: !ruby/object:Gem::Requirement
16
- requirements:
17
- - - "~>"
18
- - !ruby/object:Gem::Version
19
- version: '1.6'
20
- type: :development
21
- prerelease: false
22
- version_requirements: !ruby/object:Gem::Requirement
23
- requirements:
24
- - - "~>"
25
- - !ruby/object:Gem::Version
26
- version: '1.6'
27
- - !ruby/object:Gem::Dependency
28
- name: rake
29
- requirement: !ruby/object:Gem::Requirement
30
- requirements:
31
- - - ">="
32
- - !ruby/object:Gem::Version
33
- version: '0'
34
- type: :development
35
- prerelease: false
36
- version_requirements: !ruby/object:Gem::Requirement
37
- requirements:
38
- - - ">="
39
- - !ruby/object:Gem::Version
40
- version: '0'
41
- description: A set of convenience utils for Ruby. A loosely inspired, not-quite-close-to-feature
42
- parity port of [`pyhtk-lite`](https://github.com/hacktoolkit/pyhtk-lite).
43
- email:
44
- - hello@jontsaicom
13
+ date: 2021-10-19 00:00:00.000000000 Z
14
+ dependencies: []
15
+ description: A set of convenience utils and debuggers for Ruby.
16
+ email: hello@hacktoolkit.com
45
17
  executables: []
46
18
  extensions: []
47
19
  extra_rdoc_files: []
48
20
  files:
49
- - ".editorconfig"
50
- - ".gitignore"
51
- - LICENSE.md
52
- - README.md
53
- - lib/apis.rb
21
+ - lib/Htk/apis.rb
22
+ - lib/Htk/utils.rb
54
23
  homepage: https://github.com/hacktoolkit/htk-rb
55
24
  licenses:
56
25
  - MIT
@@ -70,8 +39,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
70
39
  - !ruby/object:Gem::Version
71
40
  version: '0'
72
41
  requirements: []
73
- rubyforge_project:
74
- rubygems_version: 2.2.2
42
+ rubygems_version: 3.0.3
75
43
  signing_key:
76
44
  specification_version: 4
77
45
  summary: A set of convenience utils for Ruby.
data/.editorconfig DELETED
@@ -1,12 +0,0 @@
1
- # See http://EditorConfig.org for details
2
-
3
- # Top-most EditorConfig file
4
- root = true
5
-
6
- # Unix-style newlines with a newline ending every file
7
- # Two space indent by default
8
- [*]
9
- end_of_line = lf
10
- insert_final_newline = true
11
- indent_style = space
12
- indent_size = 2
data/.gitignore DELETED
@@ -1 +0,0 @@
1
- local_settings.rb
data/LICENSE.md DELETED
@@ -1,21 +0,0 @@
1
- MIT License
2
-
3
- Copyright (c) 2019 Hacktoolkit
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining a copy
6
- of this software and associated documentation files (the "Software"), to deal
7
- in the Software without restriction, including without limitation the rights
8
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- copies of the Software, and to permit persons to whom the Software is
10
- furnished to do so, subject to the following conditions:
11
-
12
- The above copyright notice and this permission notice shall be included in all
13
- copies or substantial portions of the Software.
14
-
15
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
- SOFTWARE.
data/README.md DELETED
@@ -1,63 +0,0 @@
1
- # HTK for Ruby
2
-
3
- A set of convenience utils for Ruby. A loosely inspired, not-quite-close-to-feature parity port of [`pyhtk-lite`](https://github.com/hacktoolkit/pyhtk-lite).
4
-
5
- # Features
6
-
7
- 1. Debug via Slack using `::Htk::Utils.slack_debug('some debugging message')`. The best of `println` debugging, without the inconvenience of visually fishing for one message out of thousands of log lines.
8
-
9
- # How to Use This Awesome?
10
-
11
- 1. Clone this repository into a directory named `htk` (preferred) or `htk_lite`
12
- SSH: `git clone git@github.com:hacktoolkit/htk-rb.git htk`
13
- HTTPS: `git clone https://github.com/hacktoolkit/htk-rb.git`
14
- 1. (Optional) Create a symlink to `htk` inside of your app's `lib/` directory.
15
- 1. Create `local_settings.rb` and add your [Slack incoming webhook](https://slack.com/apps/A0F7XDUAZ-incoming-webhooks) URL to `SLACK_WEBHOOK_URL`.
16
- 1. In your code, simply do:
17
- ```
18
- ::Htk::Utils.slack_debug('This is seriously awesome!')
19
- ::Htk::Utils.slack_debug('Yeah, no kidding.')
20
- ```
21
- 1. Check your Slack to verify that the message was posted. If not, perhaps your token was wrong, or the Slack integration was disabled.
22
- ![image](https://user-images.githubusercontent.com/422501/61013274-e65e1e00-a336-11e9-90aa-44a6fd1e217c.png)
23
- (Alternative link to screenshot above: https://cl.ly/436cfb4383a2)
24
- 1. Profit!
25
-
26
- ## Tips on Location of HTK Module
27
-
28
- 1. You can place it outside of your app directory tree, and then symlink it inside.
29
- 1. To not be nagged by the presence of the `htk` directory whenever you do `git status`, add `htk` to your `.git/info/exclude` file (like `.gitignore`, but only in your local repository, not checked in).
30
-
31
- ## Installation
32
-
33
- Add this line to your application's Gemfile:
34
-
35
- gem 'htk'
36
-
37
- And then execute:
38
-
39
- $ bundle
40
-
41
- Or install it yourself as:
42
-
43
- $ gem install htk
44
-
45
- ## Usage
46
-
47
- TODO: Write usage instructions here
48
-
49
- ## Contributing
50
-
51
- 1. Fork it ( https://github.com/hacktoolkit/htk-rb/fork )
52
- 2. Create your feature branch (`git checkout -b my-new-feature`)
53
- 3. Commit your changes (`git commit -am 'Add some feature'`)
54
- 4. Push to the branch (`git push origin my-new-feature`)
55
- 5. Create a new Pull Request
56
-
57
- # Authors and Maintainers
58
-
59
- [Hacktoolkit](https://github.com/hacktoolkit) and [Jonathan Tsai](https://github.com/jontsai)
60
-
61
- # License
62
-
63
- MIT. See `LICENSE.md`