repunit 0.1.2

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: 56737d9d1e0ea39ed464ca9612fbe4579f1c552c26159f9d3c52281a2e663e74
4
+ data.tar.gz: cdffac765c794b8ff53bc390f62d629198be88ac950beccae6764d1baffa8b76
5
+ SHA512:
6
+ metadata.gz: 451eb0cc11344ed25d013d53f6b9c560d63d87fb5e2d01721ac3ee863d1e3025a53a89dd9defddaa73234674f30328be993b1d249c7989bc3da6d78f95c28a42
7
+ data.tar.gz: 95667561aef4e106c5322bf18a2734c35e44b8cc31b2b5d1b440c51b3d0bfdfb1a93d57c7b9fa08e0e07c656a08a65ea67a6db569ddd21833741f1e24dcbbcee
data/.gitignore ADDED
@@ -0,0 +1,9 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /_yardoc/
4
+ /coverage/
5
+ /doc/
6
+ /pkg/
7
+ /spec/reports/
8
+ /tmp/
9
+ Gemfile.lock
data/CHANGELOG.md ADDED
@@ -0,0 +1,10 @@
1
+ # CHANGELOG
2
+
3
+ ## 0.1.2 (January 10, 2021)
4
+ - Simplified the code in repunit.rb.
5
+
6
+ ## 0.1.1 (January 10, 2021)
7
+ - Fixed bug in gemspec.
8
+
9
+ ## 0.1.0 (January 9, 2021)
10
+ Initial release.
data/Gemfile ADDED
@@ -0,0 +1,8 @@
1
+ # frozen_string_literal: true
2
+
3
+ source "https://rubygems.org"
4
+
5
+ # Specify your gem's dependencies in repunit.gemspec
6
+ gemspec
7
+
8
+ gem "rake", "~> 13.0"
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2021 nsk-1010
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,73 @@
1
+ # Repunit
2
+ <table>
3
+ <thead>
4
+ <tr>
5
+ <th style="text-align:center">
6
+ <a href="README_ja.md">日本語</a>
7
+ </th>
8
+ <th style="text-align:center">
9
+ <a href="README.md">English</a>
10
+ </th>
11
+ </tr>
12
+ </thead>
13
+ </table>
14
+
15
+ **日本語版は[こちら](./README_ja.md)にあります**
16
+
17
+ Repunit Generation Library
18
+
19
+ ## Installation
20
+
21
+ Add this line to your application's Gemfile:
22
+
23
+ ```ruby
24
+ gem 'repunit', :git => 'https://github.com/NSK-1010/ruby-repunit.git', :tag => 'Version'
25
+ ```
26
+
27
+ And then execute:
28
+
29
+ $ bundle install
30
+
31
+ Or install it yourself as:
32
+
33
+ $ gem install specific_install
34
+ $ gem specific_install https://github.com/NSK-1010/ruby-repunit.git Version
35
+
36
+ ## Usage
37
+
38
+ ### First step
39
+ ```ruby
40
+ require 'repunit'
41
+ ```
42
+
43
+ ### Convert from number of digits in Repunit to Repunit
44
+ ```ruby
45
+ Repunit.convert(digits)
46
+ ```
47
+ ### Restore from Repunit to number of digits in Repunit
48
+ ```ruby
49
+ Repunit.restore(Repunit)
50
+ ```
51
+ ### example
52
+ ```ruby
53
+ require 'repunit'
54
+ p Repunit.convert(Repunit.restore(111111)) #=> 111111
55
+ ```
56
+ ```ruby
57
+ require 'repunit'
58
+ p 3 * Repunit.convert(4) #=> 3333
59
+ ```
60
+
61
+ ## Development
62
+
63
+ 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.
64
+
65
+ 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.
66
+
67
+ ## Contributing
68
+
69
+ Bug reports and pull requests are welcome on GitHub at [https://github.com/NSK-1010/ruby-repunit](https://github.com/NSK-1010/ruby-repunit).
70
+
71
+ ## License
72
+
73
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
data/README_ja.md ADDED
@@ -0,0 +1,72 @@
1
+ # Repunit
2
+ <table>
3
+ <thead>
4
+ <tr>
5
+ <th style="text-align:center">
6
+ <a href="README_ja.md">日本語</a>
7
+ </th>
8
+ <th style="text-align:center">
9
+ <a href="README.md">English</a>
10
+ </th>
11
+ </tr>
12
+ </thead>
13
+ </table>
14
+
15
+ **English version is [here](./README.md).**
16
+
17
+ レピュニットを生成するライブラリ
18
+
19
+ ## インストール方法
20
+ あなたのアプリケーションのGemfileにこの文字列を追加してください。
21
+
22
+ ```ruby
23
+ gem 'repunit', :git => 'https://github.com/NSK-1010/ruby-repunit.git', :tag => 'バージョン'
24
+ ```
25
+
26
+ そして、このコマンド実行してください。
27
+
28
+ $ bundle install
29
+
30
+ また、手動でインストールすることもできます。
31
+
32
+ $ gem install specific_install
33
+ $ gem specific_install https://github.com/NSK-1010/ruby-repunit.git バージョン
34
+
35
+ ## 使い方
36
+
37
+ ### 最初に
38
+ ```ruby
39
+ require 'repunit'
40
+ ```
41
+
42
+ ### レピュニットの桁数からレピュニットへ変換する
43
+ ```ruby
44
+ Repunit.convert(桁数)
45
+ ```
46
+ ### レピュニットからレピュニットの桁数へ復元する
47
+ ```ruby
48
+ Repunit.restore(レピュニット)
49
+ ```
50
+ ### 例
51
+ ```ruby
52
+ require 'repunit'
53
+ p Repunit.convert(Repunit.restore(111111)) #=> 111111
54
+ ```
55
+ ```ruby
56
+ require 'repunit'
57
+ p 3 * Repunit.convert(4) #=> 3333
58
+ ```
59
+
60
+ ## 開発者向け
61
+
62
+ レポジトリをチェックアウトしたら、`bin/setup` を実行して依存関係をインストールしてください。また、`bin/console`を実行すると対話型のプロンプトが表示され、テストを行うことができます。
63
+
64
+ このgemをローカルマシンにインストールするには、`bundle exec rake install` を実行してください。新しいバージョンをリリースするには、`version.rb` のバージョン番号を更新してから `bundle exec rake release` を実行します。
65
+
66
+ ## 貢献
67
+
68
+ バグ報告やプルリクはGitHubで受け付けています。 [https://github.com/NSK-1010/ruby-repunit](https://github.com/NSK-1010/ruby-repunit)
69
+
70
+ ## ライセンス
71
+
72
+ このgemは、[MIT License](https://opensource.org/licenses/MIT)の条件の下でオープンソースとして利用可能です。
data/Rakefile ADDED
@@ -0,0 +1,4 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "bundler/gem_tasks"
4
+ task default: %i[]
data/bin/console ADDED
@@ -0,0 +1,15 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
4
+ require "bundler/setup"
5
+ require "repunit"
6
+
7
+ # You can add fixtures and/or initialization code here to make experimenting
8
+ # with your gem easier. You can also use a different console, if you like.
9
+
10
+ # (If you use this, don't forget to add pry to your Gemfile!)
11
+ # require "pry"
12
+ # Pry.start
13
+
14
+ require "irb"
15
+ IRB.start(__FILE__)
data/bin/setup ADDED
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
data/lib/repunit.rb ADDED
@@ -0,0 +1,16 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "repunit/version"
4
+
5
+ module Repunit
6
+ class << self
7
+ def convert(repnum)
8
+ rep1 = "1" * repnum.to_i
9
+ repunit = rep1.to_i
10
+ return repunit
11
+ end
12
+ def restore(repunit)
13
+ return repunit.to_s.count('1')
14
+ end
15
+ end
16
+ end
@@ -0,0 +1,5 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Repunit
4
+ VERSION = "0.1.2"
5
+ end
data/repunit.gemspec ADDED
@@ -0,0 +1,35 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "lib/repunit/version"
4
+
5
+ Gem::Specification.new do |spec|
6
+ spec.name = "repunit"
7
+ spec.version = Repunit::VERSION
8
+ spec.authors = ["nsk-1010"]
9
+ spec.email = ["kotone.olin1010@gmail.com"]
10
+
11
+ spec.summary = "Repunit Generation Library"
12
+ spec.description = "You can easily generate Repunit with this library."
13
+ spec.homepage = "https://github.com/NSK-1010/ruby-repunit"
14
+ spec.license = "MIT"
15
+ spec.required_ruby_version = Gem::Requirement.new(">= 2.3.0")
16
+
17
+ spec.metadata["homepage_uri"] = spec.homepage
18
+ spec.metadata["source_code_uri"] = spec.homepage
19
+ spec.metadata["changelog_uri"] = spec.homepage + "/blob/main/CHANGELOG.md"
20
+
21
+ # Specify which files should be added to the gem when it is released.
22
+ # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
23
+ spec.files = Dir.chdir(File.expand_path(__dir__)) do
24
+ `git ls-files -z`.split("\x0").reject { |f| f.match(%r{\A(?:test|spec|features)/}) }
25
+ end
26
+ spec.bindir = "exe"
27
+ spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) }
28
+ spec.require_paths = ["lib"]
29
+
30
+ # Uncomment to register a new dependency of your gem
31
+ # spec.add_dependency "example-gem", "~> 1.0"
32
+
33
+ # For more information and examples about making a new gem, checkout our
34
+ # guide at: https://bundler.io/guides/creating_gem.html
35
+ end
metadata ADDED
@@ -0,0 +1,58 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: repunit
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.2
5
+ platform: ruby
6
+ authors:
7
+ - nsk-1010
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2021-03-31 00:00:00.000000000 Z
12
+ dependencies: []
13
+ description: You can easily generate Repunit with this library.
14
+ email:
15
+ - kotone.olin1010@gmail.com
16
+ executables: []
17
+ extensions: []
18
+ extra_rdoc_files: []
19
+ files:
20
+ - ".gitignore"
21
+ - CHANGELOG.md
22
+ - Gemfile
23
+ - LICENSE.txt
24
+ - README.md
25
+ - README_ja.md
26
+ - Rakefile
27
+ - bin/console
28
+ - bin/setup
29
+ - lib/repunit.rb
30
+ - lib/repunit/version.rb
31
+ - repunit.gemspec
32
+ homepage: https://github.com/NSK-1010/ruby-repunit
33
+ licenses:
34
+ - MIT
35
+ metadata:
36
+ homepage_uri: https://github.com/NSK-1010/ruby-repunit
37
+ source_code_uri: https://github.com/NSK-1010/ruby-repunit
38
+ changelog_uri: https://github.com/NSK-1010/ruby-repunit/blob/main/CHANGELOG.md
39
+ post_install_message:
40
+ rdoc_options: []
41
+ require_paths:
42
+ - lib
43
+ required_ruby_version: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: 2.3.0
48
+ required_rubygems_version: !ruby/object:Gem::Requirement
49
+ requirements:
50
+ - - ">="
51
+ - !ruby/object:Gem::Version
52
+ version: '0'
53
+ requirements: []
54
+ rubygems_version: 3.2.13
55
+ signing_key:
56
+ specification_version: 4
57
+ summary: Repunit Generation Library
58
+ test_files: []