switchs 1.0.1

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.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: c5d8d959b3093154257989db10a2cc3660583b4e2c0a5143923f24212dd9cb0f
4
+ data.tar.gz: 54d98c81d3390065abf072a07353feff60df3e4f67826c3783facb7d62acba87
5
+ SHA512:
6
+ metadata.gz: c628adff017f75b916cf58a5efcebc1db0db242b6e8b222ecaaf4622f53d51d3bcf4d4f12059fc3ef284e6d4e2ee2afedd59fcc57535bef4e90df749d8bc56c7
7
+ data.tar.gz: 24a027daebb9eb53bcf2c3f57fe97879d536f6297ba5f8f19a15f9a78ede1fb394fae5770f0787657655e07d2fa9cdb65e1b462934a62acb8b48be792741b395
data/.editorconfig ADDED
@@ -0,0 +1,14 @@
1
+ # EditorConfig is awesome: https://EditorConfig.org
2
+
3
+ # top-most EditorConfig file
4
+ root = true
5
+
6
+ # Unix-style newlines with a newline ending every file
7
+ [*]
8
+ end_of_line = lf
9
+ insert_final_newline = true
10
+ indent_style = space
11
+ indent_size = 2
12
+ charset = utf-8
13
+ trim_trailing_whitespace = true
14
+ quote_type = single
data/.rspec ADDED
@@ -0,0 +1,3 @@
1
+ --format progress
2
+ --color
3
+ --require spec_helper
data/.rubocop.yml ADDED
@@ -0,0 +1,22 @@
1
+ require:
2
+ - rubocop-rspec
3
+ - rubocop-performance
4
+
5
+ AllCops:
6
+ TargetRubyVersion: 2.6
7
+ NewCops: disable
8
+
9
+ Style/Documentation:
10
+ Enabled: false
11
+
12
+ Style/ClassAndModuleChildren:
13
+ EnforcedStyle: compact
14
+
15
+ RSpec/DescribedClass:
16
+ Enabled: false
17
+
18
+ RSpec/ExampleLength:
19
+ Enabled: false
20
+
21
+ Bundler/OrderedGems:
22
+ Enabled: false
data/CHANGELOG.md ADDED
@@ -0,0 +1,5 @@
1
+ ## [Unreleased]
2
+
3
+ ## [1.0.0] - 2022-06-06
4
+
5
+ - Initial release
data/Gemfile ADDED
@@ -0,0 +1,18 @@
1
+ # frozen_string_literal: true
2
+
3
+ source 'https://rubygems.org'
4
+
5
+ # Specify your gem's dependencies in switchs.gemspec
6
+ gemspec
7
+
8
+ gem 'rake', '~> 13.0'
9
+
10
+ gem 'rspec', '~> 3.0'
11
+ gem 'rspec-retry'
12
+
13
+ gem 'aruba'
14
+ gem 'cucumber'
15
+
16
+ gem 'rubocop', '~> 1.21'
17
+ gem 'rubocop-performance'
18
+ gem 'rubocop-rspec'
data/Gemfile.lock ADDED
@@ -0,0 +1,109 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ switchs (1.0.1)
5
+
6
+ GEM
7
+ remote: https://rubygems.org/
8
+ specs:
9
+ aruba (2.1.0)
10
+ bundler (>= 1.17, < 3.0)
11
+ childprocess (>= 2.0, < 5.0)
12
+ contracts (>= 0.16.0, < 0.18.0)
13
+ cucumber (>= 4.0, < 9.0)
14
+ rspec-expectations (~> 3.4)
15
+ thor (~> 1.0)
16
+ ast (2.4.2)
17
+ builder (3.2.4)
18
+ childprocess (4.1.0)
19
+ contracts (0.17)
20
+ cucumber (8.0.0)
21
+ builder (~> 3.2, >= 3.2.4)
22
+ cucumber-ci-environment (~> 9.0, >= 9.0.4)
23
+ cucumber-core (~> 11.0, >= 11.0.0)
24
+ cucumber-cucumber-expressions (~> 15.1, >= 15.1.1)
25
+ cucumber-gherkin (~> 23.0, >= 23.0.1)
26
+ cucumber-html-formatter (~> 19.1, >= 19.1.0)
27
+ cucumber-messages (~> 18.0, >= 18.0.0)
28
+ diff-lcs (~> 1.5, >= 1.5.0)
29
+ mime-types (~> 3.4, >= 3.4.1)
30
+ multi_test (~> 1.1, >= 1.1.0)
31
+ sys-uname (~> 1.2, >= 1.2.2)
32
+ cucumber-ci-environment (9.0.4)
33
+ cucumber-core (11.0.0)
34
+ cucumber-gherkin (~> 23.0, >= 23.0.1)
35
+ cucumber-messages (~> 18.0, >= 18.0.0)
36
+ cucumber-tag-expressions (~> 4.1, >= 4.1.0)
37
+ cucumber-cucumber-expressions (15.2.0)
38
+ cucumber-gherkin (23.0.1)
39
+ cucumber-messages (~> 18.0, >= 18.0.0)
40
+ cucumber-html-formatter (19.2.0)
41
+ cucumber-messages (~> 18.0, >= 18.0.0)
42
+ cucumber-messages (18.0.0)
43
+ cucumber-tag-expressions (4.1.0)
44
+ diff-lcs (1.5.0)
45
+ ffi (1.15.5)
46
+ mime-types (3.4.1)
47
+ mime-types-data (~> 3.2015)
48
+ mime-types-data (3.2022.0105)
49
+ multi_test (1.1.0)
50
+ parallel (1.22.1)
51
+ parser (3.1.2.0)
52
+ ast (~> 2.4.1)
53
+ rainbow (3.1.1)
54
+ rake (13.0.6)
55
+ regexp_parser (2.5.0)
56
+ rexml (3.2.5)
57
+ rspec (3.11.0)
58
+ rspec-core (~> 3.11.0)
59
+ rspec-expectations (~> 3.11.0)
60
+ rspec-mocks (~> 3.11.0)
61
+ rspec-core (3.11.0)
62
+ rspec-support (~> 3.11.0)
63
+ rspec-expectations (3.11.0)
64
+ diff-lcs (>= 1.2.0, < 2.0)
65
+ rspec-support (~> 3.11.0)
66
+ rspec-mocks (3.11.1)
67
+ diff-lcs (>= 1.2.0, < 2.0)
68
+ rspec-support (~> 3.11.0)
69
+ rspec-retry (0.6.2)
70
+ rspec-core (> 3.3)
71
+ rspec-support (3.11.0)
72
+ rubocop (1.30.0)
73
+ parallel (~> 1.10)
74
+ parser (>= 3.1.0.0)
75
+ rainbow (>= 2.2.2, < 4.0)
76
+ regexp_parser (>= 1.8, < 3.0)
77
+ rexml (>= 3.2.5, < 4.0)
78
+ rubocop-ast (>= 1.18.0, < 2.0)
79
+ ruby-progressbar (~> 1.7)
80
+ unicode-display_width (>= 1.4.0, < 3.0)
81
+ rubocop-ast (1.18.0)
82
+ parser (>= 3.1.1.0)
83
+ rubocop-performance (1.14.1)
84
+ rubocop (>= 1.7.0, < 2.0)
85
+ rubocop-ast (>= 0.4.0)
86
+ rubocop-rspec (2.11.1)
87
+ rubocop (~> 1.19)
88
+ ruby-progressbar (1.11.0)
89
+ sys-uname (1.2.2)
90
+ ffi (~> 1.1)
91
+ thor (1.2.1)
92
+ unicode-display_width (2.1.0)
93
+
94
+ PLATFORMS
95
+ x86_64-darwin-21
96
+
97
+ DEPENDENCIES
98
+ aruba
99
+ cucumber
100
+ rake (~> 13.0)
101
+ rspec (~> 3.0)
102
+ rspec-retry
103
+ rubocop (~> 1.21)
104
+ rubocop-performance
105
+ rubocop-rspec
106
+ switchs!
107
+
108
+ BUNDLED WITH
109
+ 2.3.15
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2022 ton-tonton
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,53 @@
1
+ # Switchs
2
+
3
+ Just switching your given string.
4
+
5
+ ## Installation
6
+
7
+ Install the gem and add to the application's Gemfile by executing:
8
+
9
+ $ bundle add switchs
10
+
11
+ If bundler is not being used to manage dependencies, install the gem by executing:
12
+
13
+ $ gem install switchs
14
+
15
+ ## Usage
16
+
17
+ In .rb file
18
+
19
+ ```ruby
20
+ require 'switchs'
21
+
22
+ Switchs.exec('your_awesome_string')
23
+ ```
24
+
25
+ Output:
26
+
27
+ ```
28
+ => "yruemn__rsooagiwste"
29
+ ```
30
+
31
+ In command line
32
+
33
+ $ switchs your_awesome_string
34
+
35
+ Output:
36
+
37
+ ```
38
+ usor_rsmet_weynaoig
39
+ ```
40
+
41
+ ## Development
42
+
43
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
44
+
45
+ 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 the created tag, and push the `.gem` file to [rubygems.org](https://rubygems.org).
46
+
47
+ ## Contributing
48
+
49
+ Bug reports and pull requests are welcome on GitHub at https://github.com/ton-tonton/switchs.
50
+
51
+ ## License
52
+
53
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
data/Rakefile ADDED
@@ -0,0 +1,12 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'bundler/gem_tasks'
4
+ require 'rspec/core/rake_task'
5
+
6
+ RSpec::Core::RakeTask.new(:spec)
7
+
8
+ require 'rubocop/rake_task'
9
+
10
+ RuboCop::RakeTask.new
11
+
12
+ task default: %i[spec rubocop]
data/exe/switchs ADDED
@@ -0,0 +1,6 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
4
+ require 'switchs/cli'
5
+
6
+ Switchs::CLI.start
@@ -0,0 +1,14 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'switchs'
4
+ require 'switchs/cli_parser'
5
+
6
+ module Switchs::CLI
7
+ def self.start
8
+ Switchs::CLIParser.parse(ARGV)
9
+
10
+ puts Switchs.exec(ARGV[0])
11
+ rescue Switchs::Error
12
+ Switchs::CLIParser.parse(%w[--help])
13
+ end
14
+ end
@@ -0,0 +1,16 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'optparse'
4
+
5
+ module Switchs::CLIParser
6
+ def self.parse(args)
7
+ OptionParser.new do |opts|
8
+ opts.banner = 'Usage: switchs [STR]'
9
+
10
+ opts.on('-h', '--help', 'Prints this help') do
11
+ puts opts
12
+ exit
13
+ end
14
+ end.parse!(args)
15
+ end
16
+ end
@@ -0,0 +1,5 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Switchs
4
+ VERSION = '1.0.1'
5
+ end
data/lib/switchs.rb ADDED
@@ -0,0 +1,21 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative 'switchs/version'
4
+
5
+ module Switchs
6
+ class Error < StandardError; end
7
+
8
+ def self.exec(str)
9
+ raise Error, 'Given string cannot be null' if str.nil? || str.empty?
10
+
11
+ length = str.size
12
+ dup_str = str.dup
13
+ new_str = []
14
+
15
+ length.times do
16
+ new_str << dup_str.slice!(rand(dup_str.size))
17
+ end
18
+
19
+ new_str.join('')
20
+ end
21
+ end
data/sig/switchs.rbs ADDED
@@ -0,0 +1,4 @@
1
+ module Switchs
2
+ VERSION: String
3
+ # See the writing guide of rbs: https://github.com/ruby/rbs#guides
4
+ end
data/switchs.gemspec ADDED
@@ -0,0 +1,30 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative 'lib/switchs/version'
4
+
5
+ Gem::Specification.new do |spec|
6
+ spec.name = 'switchs'
7
+ spec.version = Switchs::VERSION
8
+ spec.authors = ['ton-tonton']
9
+ spec.email = ['phantom.ness@windowslive.com']
10
+
11
+ spec.summary = 'Switching given string'
12
+ spec.homepage = 'https://github.com/ton-tonton/switchs'
13
+ spec.license = 'MIT'
14
+ spec.required_ruby_version = '>= 2.6.0'
15
+
16
+ spec.metadata['allowed_push_host'] = 'https://rubygems.org'
17
+
18
+ spec.metadata['homepage_uri'] = spec.homepage
19
+ spec.metadata['source_code_uri'] = 'https://github.com/ton-tonton/switchs'
20
+ spec.metadata['changelog_uri'] = 'https://github.com/ton-tonton/switchs/blob/main/CHANGELOG.md'
21
+
22
+ spec.files = Dir.chdir(__dir__) do
23
+ `git ls-files -z`.split("\x0").reject do |f|
24
+ (f == __FILE__) || f.match(%r{\A(?:(?:bin|test|spec|features)/|\.(?:git|travis|circleci)|appveyor)})
25
+ end
26
+ end
27
+ spec.bindir = 'exe'
28
+ spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) }
29
+ spec.require_paths = ['lib']
30
+ end
metadata ADDED
@@ -0,0 +1,64 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: switchs
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.1
5
+ platform: ruby
6
+ authors:
7
+ - ton-tonton
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2022-06-07 00:00:00.000000000 Z
12
+ dependencies: []
13
+ description:
14
+ email:
15
+ - phantom.ness@windowslive.com
16
+ executables:
17
+ - switchs
18
+ extensions: []
19
+ extra_rdoc_files: []
20
+ files:
21
+ - ".editorconfig"
22
+ - ".rspec"
23
+ - ".rubocop.yml"
24
+ - CHANGELOG.md
25
+ - Gemfile
26
+ - Gemfile.lock
27
+ - LICENSE.txt
28
+ - README.md
29
+ - Rakefile
30
+ - exe/switchs
31
+ - lib/switchs.rb
32
+ - lib/switchs/cli.rb
33
+ - lib/switchs/cli_parser.rb
34
+ - lib/switchs/version.rb
35
+ - sig/switchs.rbs
36
+ - switchs.gemspec
37
+ homepage: https://github.com/ton-tonton/switchs
38
+ licenses:
39
+ - MIT
40
+ metadata:
41
+ allowed_push_host: https://rubygems.org
42
+ homepage_uri: https://github.com/ton-tonton/switchs
43
+ source_code_uri: https://github.com/ton-tonton/switchs
44
+ changelog_uri: https://github.com/ton-tonton/switchs/blob/main/CHANGELOG.md
45
+ post_install_message:
46
+ rdoc_options: []
47
+ require_paths:
48
+ - lib
49
+ required_ruby_version: !ruby/object:Gem::Requirement
50
+ requirements:
51
+ - - ">="
52
+ - !ruby/object:Gem::Version
53
+ version: 2.6.0
54
+ required_rubygems_version: !ruby/object:Gem::Requirement
55
+ requirements:
56
+ - - ">="
57
+ - !ruby/object:Gem::Version
58
+ version: '0'
59
+ requirements: []
60
+ rubygems_version: 3.3.7
61
+ signing_key:
62
+ specification_version: 4
63
+ summary: Switching given string
64
+ test_files: []