haskii 0.1.0

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
+ SHA1:
3
+ metadata.gz: 0095132799344c995787e697cb823d18e0e86a83
4
+ data.tar.gz: dca8fca7ad2f4b13616181a3f4da45a135205c4f
5
+ SHA512:
6
+ metadata.gz: 542acdc35cbf3a4c3ad4c18348b66d4d916d836d8b378391e11a23612a54d551f532ede8ab4bfc18f7f1696b7591ee7a7479c8c1c3a6b21167c35ea4cd1ed2c4
7
+ data.tar.gz: 5a5c655cd6500920f9b74f32d21b9df25b463905db959468831a045641baa1b865a0019335a4f0df01e9f06b3acb24cfa6f0e298f297655ed32e03dc44cd6320
data/.gitignore ADDED
@@ -0,0 +1,10 @@
1
+ *.swp
2
+ /.bundle/
3
+ /.yardoc
4
+ /Gemfile.lock
5
+ /_yardoc/
6
+ /coverage/
7
+ /doc/
8
+ /pkg/
9
+ /spec/reports/
10
+ /tmp/
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --format documentation
2
+ --color
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in haskii.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2017 Milana
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,63 @@
1
+ # Haskii
2
+
3
+ Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/haskii`. To experiment with that code, run `bin/console` for an interactive prompt.
4
+
5
+ TODO: Delete this and the text above, and describe your gem
6
+
7
+ ## Installation
8
+
9
+ Add this line to your application's Gemfile:
10
+
11
+ ```ruby
12
+ gem 'haskii'
13
+ ```
14
+
15
+ And then execute:
16
+
17
+ $ bundle
18
+
19
+ Or install it yourself as:
20
+
21
+ $ gem install haskii
22
+
23
+ ## Usage
24
+
25
+ ```
26
+ $ haskii bar 2 4 6 8 6 4 2 1 6 5 4 3 2 1
27
+ Your happy bar chart:
28
+
29
+ *
30
+ *
31
+ *** *
32
+ *** **
33
+ ***** ***
34
+ ***** ****
35
+ ******* *****
36
+ **************
37
+
38
+ $haskii bar --emoji 🍀 1 1 2 3 5 2
39
+ Your happy bar chart:
40
+
41
+ 🍀
42
+ 🍀
43
+ 🍀🍀
44
+ 🍀🍀🍀🍀
45
+ 🍀🍀🍀🍀🍀🍀
46
+ ```
47
+
48
+
49
+ ## Development
50
+
51
+ 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.
52
+
53
+ 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).
54
+
55
+ ## Contributing
56
+
57
+ Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/haskii.
58
+
59
+
60
+ ## License
61
+
62
+ The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
63
+
data/Rakefile ADDED
@@ -0,0 +1,6 @@
1
+ require "bundler/gem_tasks"
2
+ require "rspec/core/rake_task"
3
+
4
+ RSpec::Core::RakeTask.new(:spec)
5
+
6
+ task :default => :spec
data/bin/console ADDED
@@ -0,0 +1,16 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "require_all"
5
+
6
+ require_all "lib"
7
+
8
+ # You can add fixtures and/or initialization code here to make experimenting
9
+ # with your gem easier. You can also use a different console, if you like.
10
+
11
+ # (If you use this, don't forget to add pry to your Gemfile!)
12
+ # require "pry"
13
+ # Pry.start
14
+
15
+ require "irb"
16
+ IRB.start
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/exe/haskii ADDED
@@ -0,0 +1,9 @@
1
+ #!/usr/bin/env ruby
2
+ # -*- coding: utf-8 -*-
3
+
4
+ require "thor"
5
+ require "require_all"
6
+
7
+ require_all "lib"
8
+
9
+ Haskii::CLI.start(ARGV)
data/haskii.gemspec ADDED
@@ -0,0 +1,39 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'haskii/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "haskii"
8
+ spec.version = Haskii::VERSION
9
+ spec.authors = ["Milana"]
10
+ spec.email = ["milana.stojadinov@gmail.com"]
11
+
12
+ spec.summary = %q{ Playing with ascii }
13
+ spec.description = %q{ This gem draws bar charts, in some cases out of emojies }
14
+ spec.homepage = "https://rubygems.org/gems/haskii"
15
+ spec.license = "MIT"
16
+
17
+ # Prevent pushing this gem to RubyGems.org. To allow pushes either set the 'allowed_push_host'
18
+ # to allow pushing to a single host or delete this section to allow pushing to any host.
19
+ if spec.respond_to?(:metadata)
20
+ spec.metadata['allowed_push_host'] = "https://rubygems.org/"
21
+ else
22
+ raise "RubyGems 2.0 or newer is required to protect against " \
23
+ "public gem pushes."
24
+ end
25
+
26
+ spec.files = `git ls-files -z`.split("\x0").reject do |f|
27
+ f.match(%r{^(test|spec|features)/})
28
+ end
29
+ spec.bindir = "exe"
30
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
31
+ spec.require_paths = ["lib"]
32
+
33
+ spec.add_development_dependency "bundler", "~> 1.13"
34
+ spec.add_development_dependency "rake", "~> 10.0"
35
+ spec.add_development_dependency "rspec", "~> 3.0"
36
+
37
+ spec.add_dependency "thor"
38
+ spec.add_dependency "require_all"
39
+ end
@@ -0,0 +1,13 @@
1
+ module Haskii
2
+ class BarChart
3
+
4
+ def initialize(frequences, emoji)
5
+ @matrix = Haskii::MimiMatrix.new(frequences, emoji).create
6
+ end
7
+
8
+ def render
9
+ @matrix.map { |line| line.join("") }
10
+ end
11
+
12
+ end
13
+ end
data/lib/haskii/cli.rb ADDED
@@ -0,0 +1,54 @@
1
+ require "thor"
2
+
3
+ module Haskii
4
+
5
+ class CLI < Thor
6
+
7
+ desc "bar", "will print out an ascii bar of your choosing"
8
+ long_desc <<-LONGDESC
9
+ Prints a simple bar chart for given number sequence.
10
+
11
+ With --emoji option, haskii bar will print deluxe bar chart edition
12
+ 🌈 🌈 🌈 🌈 🎉 🎉 🎉 🍀 🍀 🍀 when an emoji is suggested.
13
+ Sorry, I understand how 💀 💀 💀 💀 boring searching for emojis can be
14
+
15
+ > $ haskii bar --emoji 🍒 5 3 1
16
+ \x5> Your happy bar chart:
17
+ \x5>
18
+ \x5>🍒
19
+ \x5>🍒
20
+ \x5>🍒🍒
21
+ \x5>🍒🍒
22
+ \x5>🍒🍒🍒
23
+ LONGDESC
24
+ option :emoji, :default => "*"
25
+ def bar(*frequences)
26
+ @frequences = frequences
27
+
28
+ if it_can_be_charted?
29
+ result = Haskii::BarChart.new(@frequences, options[:emoji]).render
30
+ puts "Your happy bar chart:\n\n"
31
+ puts result
32
+ else
33
+ puts "Nothing to see here, please spare some numbers without letters. Tnx"
34
+ end
35
+ end
36
+
37
+ desc "version", "Prints the haskii version info"
38
+ def version
39
+ puts "Haskii version #{Haskii::VERSION}"
40
+ end
41
+ map %w(-v --version) => :version
42
+
43
+ private
44
+
45
+ def convert_to_integer
46
+ @frequences.map! { |i| i.to_i }
47
+ end
48
+
49
+ def it_can_be_charted?
50
+ ( not @frequences.empty? ) && (convert_to_integer.min > 0)
51
+ end
52
+ end
53
+
54
+ end
@@ -0,0 +1,26 @@
1
+ module Haskii
2
+ class MimiMatrix
3
+
4
+ def initialize(numbers, emoji)
5
+ @emoji = emoji
6
+ @numbers = numbers
7
+
8
+ @max = numbers.max
9
+ end
10
+
11
+ def create
12
+ rows.map { |number| generate_row(number) }
13
+ end
14
+
15
+ private
16
+
17
+ def generate_row(number)
18
+ @numbers.map { |x| x >= number ? @emoji : " " }
19
+ end
20
+
21
+ def rows
22
+ Array(1..@max).reverse
23
+ end
24
+
25
+ end
26
+ end
@@ -0,0 +1,3 @@
1
+ module Haskii
2
+ VERSION = "0.1.0"
3
+ end
data/lib/haskii.rb ADDED
@@ -0,0 +1,2 @@
1
+ module Haskii
2
+ end
metadata ADDED
@@ -0,0 +1,131 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: haskii
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Milana
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2017-03-04 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.13'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.13'
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: rspec
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '3.0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '3.0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: thor
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: require_all
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
+ description: " This gem draws bar charts, in some cases out of emojies "
84
+ email:
85
+ - milana.stojadinov@gmail.com
86
+ executables:
87
+ - haskii
88
+ extensions: []
89
+ extra_rdoc_files: []
90
+ files:
91
+ - ".gitignore"
92
+ - ".rspec"
93
+ - Gemfile
94
+ - LICENSE.txt
95
+ - README.md
96
+ - Rakefile
97
+ - bin/console
98
+ - bin/setup
99
+ - exe/haskii
100
+ - haskii.gemspec
101
+ - lib/haskii.rb
102
+ - lib/haskii/bar_chart.rb
103
+ - lib/haskii/cli.rb
104
+ - lib/haskii/mimi_matrix.rb
105
+ - lib/haskii/version.rb
106
+ homepage: https://rubygems.org/gems/haskii
107
+ licenses:
108
+ - MIT
109
+ metadata:
110
+ allowed_push_host: https://rubygems.org/
111
+ post_install_message:
112
+ rdoc_options: []
113
+ require_paths:
114
+ - lib
115
+ required_ruby_version: !ruby/object:Gem::Requirement
116
+ requirements:
117
+ - - ">="
118
+ - !ruby/object:Gem::Version
119
+ version: '0'
120
+ required_rubygems_version: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - ">="
123
+ - !ruby/object:Gem::Version
124
+ version: '0'
125
+ requirements: []
126
+ rubyforge_project:
127
+ rubygems_version: 2.5.1
128
+ signing_key:
129
+ specification_version: 4
130
+ summary: Playing with ascii
131
+ test_files: []