htk 0.0.1 → 0.2.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: 37e3dab788054a77fa2e660d8c332cb192d1056123c6484a4e1a3e29473b5521
4
+ data.tar.gz: b7c1ddac5b97e5fb3fa10f4042b482dc4fa419472c4218f6ead167cd4b957ffa
5
5
  SHA512:
6
- metadata.gz: 33df9f1d19af442a79ff2bb83a3b05520cad29d0ca5013f91840a41d695c9af1ffd935a996e6e4cac44b70ca39aec3d6ff944bfa06cd3d086668560380e30478
7
- data.tar.gz: b171bc46628cf7208f31a41587ff7bdd3801737f411bbffe6eb1ded6a6eee5b1fd0d81cb7b28951f47a90b6075e1b95cfd227caf4b9eaf256ee3b95243563818
6
+ metadata.gz: 485c80370a48b5a98ec7aff509828f75ac99f68748a68575f86fe46e388ee02e116e9ad9fff82639c0897610c548c124b20fd80138b6d443d8b4a4ef8d02c528
7
+ data.tar.gz: 1d441d13c9b22d2fee8f5f65bd0633f79b13900b202c0fa08c9d6b87f7590e5cb2fb3587b36200d02df12e23d6f5bb426232c87088b73611cbfeb6c8b9b86751
@@ -12,14 +12,9 @@ module Htk
12
12
 
13
13
  def connection(&block)
14
14
  Faraday.new(url) do |faraday|
15
- faraday.use ::Middleware::Mode
16
- faraday.use ::Middleware::AuthParams
17
- faraday.use ::Middleware::UseCanary
18
- faraday.use ::Middleware::Timeout
19
- faraday.use ::Middleware::RequestUuid
20
15
  faraday.use ::Faraday::Request::Multipart
21
16
  faraday.use ::Faraday::Request::UrlEncoded
22
- faraday.use ::Faraday::Adapter::NetHttp
17
+ faraday.adapter ::Faraday::Adapter::NetHttp
23
18
 
24
19
  block.call(faraday) if block_given?
25
20
  end
data/lib/Htk/utils.rb ADDED
@@ -0,0 +1,76 @@
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
+ response.status
37
+ end
38
+
39
+ ##
40
+ # Dumps the given text to the given file. If file_path omited, uses 'DEFAULT_FILE_PATH'
41
+
42
+ def fdebug(text, file_path=DEFAULT_FILE_PATH)
43
+ counter = ::Htk::FDebugCounter.instance
44
+ counter.increment
45
+
46
+ now = ::DateTime.now
47
+ now_str = now.strftime('%Y-%m-%d %H:%I:%S')
48
+
49
+ dirname = File.dirname(file_path)
50
+ unless File.directory?(dirname)
51
+ FileUtils.mkdir_p(dirname)
52
+ end
53
+
54
+ open(file_path, 'a') { |f|
55
+ f << ">>>>>>>>>> FDEBUG #{counter.count} #{now_str} <<<<<<<<<<\n"
56
+ f << text + "\n"
57
+ f << ">>>>>>>>>> FDEBUG #{counter.count} #{now_str} <<<<<<<<<<\n"
58
+ }
59
+
60
+ end
61
+
62
+ ##
63
+ # Dumps given object to given file as JSON. If file_path omited, default path is 'DEFAULT_FILE_PATH'
64
+
65
+ def fdebug_json(obj, file_path=DEFAULT_FILE_PATH)
66
+ data = obj.to_json
67
+ fdebug(JSON.pretty_generate(data), file_path)
68
+ end
69
+
70
+ alias_method :sdb, :slack_debug
71
+ alias_method :fdb, :fdebug
72
+ alias_method :fdb_json, :fdebug_json
73
+ end
74
+
75
+ Utils = Base.new
76
+ 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.2.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: 2024-03-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.3.7
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`