wordwiki 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 9495d04ebb634a952d767ce4bf34c95d635f37a1ae43b83d644c45c571aeb545
4
+ data.tar.gz: 53e99fa5b036274aebdbc45b0960fe432a1005be5829ce9264504f1956afb5eb
5
+ SHA512:
6
+ metadata.gz: 3fab08cebd11119ee4f922be0a629c886c8aa46dac01b32eee8bb424dcd62e361b81cc61fd398433586c792deb670a82d670ed5c5d2916adce7c319cd76a94c5
7
+ data.tar.gz: cec4d61cac4dce2a8e33e8ac88a1137c7c404dfb6fb3124fa432dfe0dac17db9f4f874c94ad4e6afb2dc176ea3a20acf13d6f16d46fdb3a369ce666cd75c62dd
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2021 Lovepreet
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.
data/README.md ADDED
@@ -0,0 +1,40 @@
1
+ # wordwiki
2
+
3
+ [![Gem Version](https://badge.fury.io/rb/wordwiki.svg)](https://rubygems.org/gems/wordwiki)
4
+ [![Code Climate](https://codeclimate.com/github/lovepreetkaul/wordwiki/badges/gpa.svg)](https://codeclimate.com/github/lovepreetkaul/wordwiki)
5
+
6
+ Simple commandline based dictionary and wiki. Definitions and answers at your fingertips.
7
+
8
+ ---
9
+
10
+ - [Quick start](#quick-start)
11
+ - [Support](#support)
12
+ - [License](#license)
13
+ - [Code of conduct](#code-of-conduct)
14
+ - [Contribution guide](#contribution-guide)
15
+
16
+ ## Quick start
17
+
18
+ ```
19
+ $ gem install wordwiki
20
+ ```
21
+
22
+ ```ruby
23
+ require "wordwiki"
24
+ ```
25
+
26
+ ## Support
27
+
28
+ If you want to report a bug, or have ideas, feedback or questions about the gem, [let me know via GitHub issues](https://github.com/lovepreetkaul/wordwiki/issues/new) and I will do my best to provide a helpful answer. Happy hacking!
29
+
30
+ ## License
31
+
32
+ The gem is available as open source under the terms of the [MIT License](LICENSE.txt).
33
+
34
+ ## Code of conduct
35
+
36
+ Everyone interacting in this project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](CODE_OF_CONDUCT.md).
37
+
38
+ ## Contribution guide
39
+
40
+ Pull requests are welcome!
data/exe/wordwiki ADDED
@@ -0,0 +1,5 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require_relative "../lib/wordwiki"
4
+
5
+ Wordwiki::CLI.start(ARGV)
@@ -0,0 +1,15 @@
1
+ require 'thor'
2
+
3
+ module Wordwiki
4
+ class CLI < Thor
5
+ include Wordwiki
6
+ class_option :verbose, :aliases => "-v"
7
+
8
+ desc "define WORD", "Get the definition for WORD"
9
+ def define(word)
10
+ #TODO Word validation
11
+ puts get_definition(word)
12
+ end
13
+
14
+ end
15
+ end
@@ -0,0 +1,3 @@
1
+ module Wordwiki
2
+ FREE_DICTIONARY_URL = "https://api.dictionaryapi.dev/api/v2/entries/en"
3
+ end
@@ -0,0 +1,3 @@
1
+ module Wordwiki
2
+ VERSION = "0.2.0".freeze
3
+ end
data/lib/wordwiki.rb ADDED
@@ -0,0 +1,35 @@
1
+ require 'faraday'
2
+ require 'json'
3
+ require 'colorize'
4
+
5
+ require_relative "wordwiki/cli.rb"
6
+ require_relative "wordwiki/version.rb"
7
+ require_relative 'wordwiki/constants.rb'
8
+
9
+ module Wordwiki
10
+ def get_definition(word)
11
+ response = Faraday.get("#{FREE_DICTIONARY_URL}/#{word}")
12
+ format_definition(response.body)
13
+ end
14
+
15
+ private
16
+
17
+ def format_definition(body)
18
+ #TODO Colorize and format output
19
+ #TODO Implement verbose mode
20
+ bodyhash = JSON.parse(body)
21
+ formatted_output = ""
22
+ bodyhash.each do |word|
23
+ formatted_output << ":: |- Word: #{word["word"]}\n"
24
+ formatted_output << ":: |- Origin: #{word["origin"]}\n"
25
+ formatted_output << ":: |- Definitions::>\n"
26
+ word["meanings"].each do |meaning|
27
+ meaning["definitions"].each do |definition|
28
+ formatted_output << ":: |- #{definition["definition"]}\n"
29
+ formatted_output << ":: Example: #{definition["example"]}\n"
30
+ end
31
+ end
32
+ end
33
+ formatted_output
34
+ end
35
+ end
metadata ADDED
@@ -0,0 +1,97 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: wordwiki
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.2.0
5
+ platform: ruby
6
+ authors:
7
+ - Lovepreet
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2021-11-01 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: thor
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: faraday
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: colorize
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
+ description:
56
+ email:
57
+ - lovepreetkaul23@gmail.com
58
+ executables:
59
+ - wordwiki
60
+ extensions: []
61
+ extra_rdoc_files: []
62
+ files:
63
+ - LICENSE.txt
64
+ - README.md
65
+ - exe/wordwiki
66
+ - lib/wordwiki.rb
67
+ - lib/wordwiki/cli.rb
68
+ - lib/wordwiki/constants.rb
69
+ - lib/wordwiki/version.rb
70
+ homepage: https://github.com/lovepreetkaul/wordwiki
71
+ licenses:
72
+ - MIT
73
+ metadata:
74
+ bug_tracker_uri: https://github.com/lovepreetkaul/wordwiki/issues
75
+ changelog_uri: https://github.com/lovepreetkaul/wordwiki/releases
76
+ source_code_uri: https://github.com/lovepreetkaul/wordwiki
77
+ homepage_uri: https://github.com/lovepreetkaul/wordwiki
78
+ post_install_message:
79
+ rdoc_options: []
80
+ require_paths:
81
+ - lib
82
+ required_ruby_version: !ruby/object:Gem::Requirement
83
+ requirements:
84
+ - - ">="
85
+ - !ruby/object:Gem::Version
86
+ version: 2.6.0
87
+ required_rubygems_version: !ruby/object:Gem::Requirement
88
+ requirements:
89
+ - - ">="
90
+ - !ruby/object:Gem::Version
91
+ version: '0'
92
+ requirements: []
93
+ rubygems_version: 3.2.16
94
+ signing_key:
95
+ specification_version: 4
96
+ summary: Commandline based dictionary and wiki.
97
+ test_files: []