yiban 0.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 38920b9e9c010b61919e26d23c0a8de53d2cb4cdccbc94ae316fcb69398528f6
4
+ data.tar.gz: 110d17beb8eabd6654624a7858b98ad4f94e61fc10a6c9a43e13cef60d719b4e
5
+ SHA512:
6
+ metadata.gz: 1d20f25e758f6e827f464f53fe92b02cdb4a449f5478a792910617d75f0e78e5b16999ba92ef6c2aeb850648100330151af6062d0bc9b2a47d191b9628d34e7b
7
+ data.tar.gz: 820e72ba2516d51d55299aaed8ad0a06e76cf909bdf785fcee064ad2ba8d7479da607841248f4c2234c49e268baf6becb175ce68c007e4bff20bbbe15408fb77
@@ -0,0 +1,10 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /_yardoc/
4
+ /coverage/
5
+ /doc/
6
+ /pkg/
7
+ /spec/reports/
8
+ /tmp/
9
+ *.sbv
10
+ *.srt
@@ -0,0 +1,74 @@
1
+ # Contributor Covenant Code of Conduct
2
+
3
+ ## Our Pledge
4
+
5
+ In the interest of fostering an open and welcoming environment, we as
6
+ contributors and maintainers pledge to making participation in our project and
7
+ our community a harassment-free experience for everyone, regardless of age, body
8
+ size, disability, ethnicity, gender identity and expression, level of experience,
9
+ nationality, personal appearance, race, religion, or sexual identity and
10
+ orientation.
11
+
12
+ ## Our Standards
13
+
14
+ Examples of behavior that contributes to creating a positive environment
15
+ include:
16
+
17
+ * Using welcoming and inclusive language
18
+ * Being respectful of differing viewpoints and experiences
19
+ * Gracefully accepting constructive criticism
20
+ * Focusing on what is best for the community
21
+ * Showing empathy towards other community members
22
+
23
+ Examples of unacceptable behavior by participants include:
24
+
25
+ * The use of sexualized language or imagery and unwelcome sexual attention or
26
+ advances
27
+ * Trolling, insulting/derogatory comments, and personal or political attacks
28
+ * Public or private harassment
29
+ * Publishing others' private information, such as a physical or electronic
30
+ address, without explicit permission
31
+ * Other conduct which could reasonably be considered inappropriate in a
32
+ professional setting
33
+
34
+ ## Our Responsibilities
35
+
36
+ Project maintainers are responsible for clarifying the standards of acceptable
37
+ behavior and are expected to take appropriate and fair corrective action in
38
+ response to any instances of unacceptable behavior.
39
+
40
+ Project maintainers have the right and responsibility to remove, edit, or
41
+ reject comments, commits, code, wiki edits, issues, and other contributions
42
+ that are not aligned to this Code of Conduct, or to ban temporarily or
43
+ permanently any contributor for other behaviors that they deem inappropriate,
44
+ threatening, offensive, or harmful.
45
+
46
+ ## Scope
47
+
48
+ This Code of Conduct applies both within project spaces and in public spaces
49
+ when an individual is representing the project or its community. Examples of
50
+ representing a project or community include using an official project e-mail
51
+ address, posting via an official social media account, or acting as an appointed
52
+ representative at an online or offline event. Representation of a project may be
53
+ further defined and clarified by project maintainers.
54
+
55
+ ## Enforcement
56
+
57
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be
58
+ reported by contacting the project team at xdite@otcbtc.com. All
59
+ complaints will be reviewed and investigated and will result in a response that
60
+ is deemed necessary and appropriate to the circumstances. The project team is
61
+ obligated to maintain confidentiality with regard to the reporter of an incident.
62
+ Further details of specific enforcement policies may be posted separately.
63
+
64
+ Project maintainers who do not follow or enforce the Code of Conduct in good
65
+ faith may face temporary or permanent repercussions as determined by other
66
+ members of the project's leadership.
67
+
68
+ ## Attribution
69
+
70
+ This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
71
+ available at [http://contributor-covenant.org/version/1/4][version]
72
+
73
+ [homepage]: http://contributor-covenant.org
74
+ [version]: http://contributor-covenant.org/version/1/4/
data/Gemfile ADDED
@@ -0,0 +1,6 @@
1
+ source 'http://rubygems.org'
2
+
3
+ git_source(:github) { |repo_name| "https://github.com/#{repo_name}" }
4
+
5
+ # Specify your gem's dependencies in yiban.gemspec
6
+ gemspec
@@ -0,0 +1,47 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ yiban (0.0.2)
5
+ activesupport
6
+ httparty
7
+ json
8
+ thor
9
+
10
+ GEM
11
+ remote: http://rubygems.org/
12
+ specs:
13
+ activesupport (6.0.1)
14
+ concurrent-ruby (~> 1.0, >= 1.0.2)
15
+ i18n (>= 0.7, < 2)
16
+ minitest (~> 5.1)
17
+ tzinfo (~> 1.1)
18
+ zeitwerk (~> 2.2)
19
+ concurrent-ruby (1.1.5)
20
+ httparty (0.17.1)
21
+ mime-types (~> 3.0)
22
+ multi_xml (>= 0.5.2)
23
+ i18n (1.7.0)
24
+ concurrent-ruby (~> 1.0)
25
+ json (2.2.0)
26
+ mime-types (3.3)
27
+ mime-types-data (~> 3.2015)
28
+ mime-types-data (3.2019.1009)
29
+ minitest (5.13.0)
30
+ multi_xml (0.6.0)
31
+ rake (10.5.0)
32
+ thor (0.20.3)
33
+ thread_safe (0.3.6)
34
+ tzinfo (1.2.5)
35
+ thread_safe (~> 0.1)
36
+ zeitwerk (2.2.1)
37
+
38
+ PLATFORMS
39
+ ruby
40
+
41
+ DEPENDENCIES
42
+ bundler (~> 1.16)
43
+ rake (~> 10.0)
44
+ yiban!
45
+
46
+ BUNDLED WITH
47
+ 1.17.2
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2018 xdite
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
13
+ all 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
21
+ THE SOFTWARE.
@@ -0,0 +1,63 @@
1
+ # Yiban 壹伴标题助手
2
+
3
+ 这是一个可以直接呼叫壹伴标题助手,快速生成 AI 推荐标题的 command line wrapper
4
+
5
+ https://yiban.io/
6
+
7
+ ## Installation
8
+
9
+ Add this line to your application's Gemfile:
10
+
11
+ ```ruby
12
+ gem 'yiban'
13
+ ```
14
+
15
+ ## Setting 产生设定
16
+
17
+ `yiban config`
18
+
19
+ 会在 ~/.yiban/settings.yml 生成
20
+
21
+
22
+ ```
23
+ ---
24
+ :extension_token: ""
25
+ ```
26
+
27
+ ## 拿到壹伴 Token
28
+
29
+ https://shimo.im/docs/yvgjDxjCyTwHJGJt
30
+
31
+ 务必注册并且付费,拿到 chrome_token 才能启用
32
+
33
+ ## Usage 使用方式
34
+
35
+ * yiban word 詞 # 返回推荐标题
36
+
37
+ 返回 json 可以自己排序加工
38
+
39
+
40
+
41
+ ## Other 其他说明
42
+
43
+ 这个软件目前为自用,所以写得很简陋。有问题请自行修复,并拉 pull request。
44
+
45
+
46
+
47
+ ## Development
48
+
49
+ After checking out the repo, run `bin/setup` to install dependencies. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
50
+
51
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
52
+
53
+ ## Contributing
54
+
55
+ Bug reports and pull requests are welcome on GitHub at https://github.com/xdite/yiban. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
56
+
57
+ ## License
58
+
59
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
60
+
61
+ ## Code of Conduct
62
+
63
+ Everyone interacting in the Yiban project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/[USERNAME]/yiban/blob/master/CODE_OF_CONDUCT.md).
@@ -0,0 +1,2 @@
1
+ require 'bundler/gem_tasks'
2
+ task default: :spec
@@ -0,0 +1,6 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'bundler/setup'
4
+ require 'yiban/cli'
5
+
6
+ Yiban::CLI.start
@@ -0,0 +1,9 @@
1
+ require 'yiban/helper/config_helper'
2
+ require 'yiban/version'
3
+ require 'yiban/cli'
4
+ require 'yiban/base'
5
+ require 'yiban/text'
6
+
7
+ module Yiban
8
+ # Your code goes here...
9
+ end
@@ -0,0 +1,39 @@
1
+ # frozen_string_literal: true
2
+ require 'net/http'
3
+ require 'uri'
4
+ require 'json'
5
+
6
+ module Yiban
7
+ class Base
8
+
9
+
10
+ def response
11
+ uri = URI.parse("https://api.yiban.io/title/search")
12
+ request = Net::HTTP::Post.new(uri)
13
+ request.content_type = "application/json"
14
+
15
+ request["X-Extension-Token"] = Yiban.config[:extension_token]
16
+
17
+ request.body = JSON.dump({
18
+ "keyword": @text,
19
+ "size": @size,
20
+ "page": 1
21
+ })
22
+
23
+
24
+ req_options = {
25
+ use_ssl: uri.scheme == "https",
26
+ }
27
+
28
+ response = Net::HTTP.start(uri.hostname, uri.port, req_options) do |http|
29
+ http.request(request)
30
+ end
31
+ end
32
+
33
+ def json
34
+ JSON.parse(response.body)
35
+ end
36
+
37
+
38
+ end
39
+ end
@@ -0,0 +1,36 @@
1
+ require 'thor'
2
+ require 'active_support/core_ext/string'
3
+ require 'yiban'
4
+
5
+ module Yiban
6
+ class CLI < Thor
7
+ include Thor::Actions
8
+
9
+ def self.source_root
10
+ File.expand_path('../..', __dir__)
11
+ end
12
+
13
+ desc 'config', 'change settings'
14
+ def config
15
+
16
+ config_path = Dir.home + '/.yiban'
17
+ if Dir.exist?(config_path)
18
+ puts "Your current name is [#{Yiban.config[:name]}]."
19
+ else
20
+ template 'templates/settings.yml.tt', "http://#{config_path}/settings.yml"
21
+ end
22
+ end
23
+
24
+
25
+ desc 'yiban 单词/句子 ', '建議标题'
26
+ def word(word)
27
+ puts Yiban::Text.new(word).json
28
+ end
29
+
30
+ private
31
+
32
+ def display_name(name)
33
+ puts name
34
+ end
35
+ end
36
+ end
@@ -0,0 +1,53 @@
1
+ require 'fileutils'
2
+ require 'yaml'
3
+ require 'psych'
4
+
5
+ module Yiban
6
+ # Configuration defaults
7
+ @config = {
8
+ name: 'default'
9
+ }
10
+ @valid_config_keys = @config.keys
11
+
12
+ # Configure through hash
13
+ def self.configure(opts = {})
14
+ config
15
+ opts.each do |k, v|
16
+ @config[k.to_sym] = v if @valid_config_keys.include? k.to_sym
17
+ end
18
+ save_config
19
+ end
20
+
21
+ def self.get_config_path
22
+ config_path = Dir.home + '/.yiban'
23
+ if Dir.exist?(config_path)
24
+ # use user settings
25
+ config_path
26
+ else
27
+ system "mkdir #{config_path}"
28
+ config_path
29
+ #raise "Can't find config directory. please init by command: 'mygem config'.'"
30
+ end
31
+ end
32
+
33
+ # configをyamlから@cofigに取得
34
+ def self.config
35
+ yml_path = get_config_path + '/settings.yml'
36
+ yml_file = YAML.load_file(yml_path)
37
+ if yml_file
38
+ @config = yml_file
39
+ else
40
+ File.open(yml_path, 'w') { |f| YAML.dump(@config, f) }
41
+ end
42
+ end
43
+
44
+ # 現在の@configをyamlに保存
45
+ def self.save_config
46
+ yml_path = get_config_path + '/settings.yml'
47
+ if File.exist?(yml_path)
48
+ File.open(yml_path, 'w') { |f| YAML.dump(@config, f) }
49
+ else
50
+ raise "Can't find #{yml_path}. please set configure."
51
+ end
52
+ end
53
+ end
@@ -0,0 +1,11 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Yiban
4
+ class Text < Base
5
+ def initialize(text)
6
+ @text = text
7
+ @size = 50
8
+ end
9
+
10
+ end
11
+ end
@@ -0,0 +1,3 @@
1
+ module Yiban
2
+ VERSION = '0.0.2'.freeze
3
+ end
@@ -0,0 +1,2 @@
1
+ ---
2
+ :extension_token: ""
Binary file
@@ -0,0 +1,33 @@
1
+ lib = File.expand_path('lib', __dir__)
2
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
3
+ require 'yiban/version'
4
+
5
+ Gem::Specification.new do |spec|
6
+ spec.name = 'yiban'
7
+ spec.version = Yiban::VERSION
8
+ spec.authors = ['xdite']
9
+ spec.email = ['xuite.joke@gmail.com']
10
+
11
+ spec.summary = '壹伴 AI 标题生成助手'
12
+ spec.description = '壹伴 AI 标题生成助手'
13
+ spec.homepage = 'https://github.com/xdite/yiban'
14
+ spec.license = 'MIT'
15
+ spec.executables << 'yiban'
16
+
17
+ # Specify which files should be added to the gem when it is released.
18
+ # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
19
+ spec.files = Dir.chdir(File.expand_path(__dir__)) do
20
+ `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
21
+ end
22
+ spec.bindir = 'exe'
23
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
24
+ spec.require_paths = ['lib']
25
+
26
+ spec.add_development_dependency 'bundler', '~> 1.16'
27
+ spec.add_development_dependency 'rake', '~> 10.0'
28
+ spec.add_dependency 'activesupport'
29
+ spec.add_dependency 'httparty'
30
+ spec.add_dependency 'json'
31
+ spec.add_dependency 'thor'
32
+
33
+ end
metadata ADDED
@@ -0,0 +1,145 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: yiban
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.2
5
+ platform: ruby
6
+ authors:
7
+ - xdite
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2019-11-13 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.16'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.16'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '10.0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '10.0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: activesupport
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: httparty
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :runtime
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: json
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :runtime
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ - !ruby/object:Gem::Dependency
84
+ name: thor
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - ">="
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
90
+ type: :runtime
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - ">="
95
+ - !ruby/object:Gem::Version
96
+ version: '0'
97
+ description: 壹伴 AI 标题生成助手
98
+ email:
99
+ - xuite.joke@gmail.com
100
+ executables:
101
+ - yiban
102
+ extensions: []
103
+ extra_rdoc_files: []
104
+ files:
105
+ - ".gitignore"
106
+ - CODE_OF_CONDUCT.md
107
+ - Gemfile
108
+ - Gemfile.lock
109
+ - LICENSE.txt
110
+ - README.md
111
+ - Rakefile
112
+ - exe/yiban
113
+ - lib/yiban.rb
114
+ - lib/yiban/base.rb
115
+ - lib/yiban/cli.rb
116
+ - lib/yiban/helper/config_helper.rb
117
+ - lib/yiban/text.rb
118
+ - lib/yiban/version.rb
119
+ - templates/settings.yml.tt
120
+ - yiban-0.0.1.gem
121
+ - yiban.gemspec
122
+ homepage: https://github.com/xdite/yiban
123
+ licenses:
124
+ - MIT
125
+ metadata: {}
126
+ post_install_message:
127
+ rdoc_options: []
128
+ require_paths:
129
+ - lib
130
+ required_ruby_version: !ruby/object:Gem::Requirement
131
+ requirements:
132
+ - - ">="
133
+ - !ruby/object:Gem::Version
134
+ version: '0'
135
+ required_rubygems_version: !ruby/object:Gem::Requirement
136
+ requirements:
137
+ - - ">="
138
+ - !ruby/object:Gem::Version
139
+ version: '0'
140
+ requirements: []
141
+ rubygems_version: 3.0.3
142
+ signing_key:
143
+ specification_version: 4
144
+ summary: 壹伴 AI 标题生成助手
145
+ test_files: []