sijka 0.0.0.5 → 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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: f7596f523400778472a4d5ce8168a0c00b5fa92b
4
- data.tar.gz: bdb23b0156203dbaba66a0260b4f011566e3eeef
3
+ metadata.gz: bb36e8e536aa4c14b8708cd74d9472ed89e2813c
4
+ data.tar.gz: 2fcb8cdf8a0154d37098bc869fb72cef07f6b39e
5
5
  SHA512:
6
- metadata.gz: 3020ccdd2ff7b16200ea195a00271f1b30b86548bc41a0f2e8fe8501f70cb6ba8296012c7c14e861c42c2b14b8298c8673cde20a7cb5a216afafdcc84d1f5125
7
- data.tar.gz: feb77565d709a78c4964fe82dec75e8888187cf4b5fd85529d479ce1e1eeef74651c21c83246fb6d3e5eb85070a34eec874087180470fe7d70463fdbc5776996
6
+ metadata.gz: 32f6670038b073602b56909658283e4761bc92b8829625c273f6b288fb4618015c323757ae11e9309190fa84c337f4a2936e367bcf224c59d2652b5c21d4b301
7
+ data.tar.gz: 4748e353febef7071d2a440dae531833cf67b055a73912fce8f7000a06209c9e02b296c6fc9323b5c59d7b939fea844d6bed57843bd99f251d29c47fc2340197
data/Gemfile CHANGED
@@ -5,3 +5,4 @@ gemspec
5
5
 
6
6
  gem 'ruby-terminfo', '~> 0.1.1'
7
7
  gem 'pry', required: false
8
+ gem 'I18n'
data/README.md CHANGED
@@ -1,43 +1,21 @@
1
1
  # Sijka
2
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/sijka`. 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
3
+ Smoke without harm to health
6
4
 
7
5
  ## Installation
8
6
 
9
- Add this line to your application's Gemfile:
10
-
11
- ```ruby
12
- gem 'sijka'
13
- ```
14
-
15
- And then execute:
16
-
17
- $ bundle
18
-
19
- Or install it yourself as:
7
+ Install it yourself as:
20
8
 
21
9
  $ gem install sijka
22
10
 
23
- ## Usage
24
-
25
- TODO: Write usage instructions here
26
-
27
- ## Development
28
-
29
- 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.
11
+ And then execute:
30
12
 
31
- 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).
13
+ $ sijka [name]
32
14
 
33
- ## Contributing
15
+ Or:
34
16
 
35
- Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/sijka. 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.
17
+ $ smoke [name]
36
18
 
37
19
  ## License
38
20
 
39
21
  The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
40
-
41
- ## Code of Conduct
42
-
43
- Everyone interacting in the Sijka project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/[USERNAME]/sijka/blob/master/CODE_OF_CONDUCT.md).
data/bin/sijka CHANGED
@@ -1,30 +1,5 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
3
  require_relative '../lib/sijka'
4
- require 'optparse'
5
4
 
6
- options = {}
7
- OptionParser.new do |opts|
8
- opts.banner = "Usage: sijka [-h] [-f sijkafile] [-l] [message]"
9
- opts.on("-l", "List available sijka files") do |cowfile|
10
- options['list'] = true
11
- end
12
- opts.on("-f SIJKAFILE", "Specify a sijka file") do |cowfile|
13
- options['sijkafile'] = sijkafile
14
- end
15
- end.parse!
16
-
17
- if options['list']
18
- puts "Sijka files:"
19
- puts 'base'
20
- # puts Cowsay.character_classes.join(' ')
21
- else
22
- # if ARGV.any?
23
- # message = ARGV.join(' ')
24
- # else
25
- # #retrieve any piped input, otherwise use the empty string.
26
- # message = STDIN.tty? ? '' : ARGF.read.chomp
27
- # end
28
- Sijka.new.smoke
29
- # puts Cowsay.say(message, options['cowfile'])
30
- end
5
+ Sijka::Sijka.new(ARGV, STDIN).smoke
data/bin/smoke CHANGED
@@ -1,30 +1,5 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
3
  require_relative '../lib/sijka'
4
- require 'optparse'
5
4
 
6
- options = {}
7
- OptionParser.new do |opts|
8
- opts.banner = "Usage: sijka [-h] [-f sijkafile] [-l] [message]"
9
- opts.on("-l", "List available sijka files") do |cowfile|
10
- options['list'] = true
11
- end
12
- opts.on("-f SIJKAFILE", "Specify a sijka file") do |cowfile|
13
- options['sijkafile'] = sijkafile
14
- end
15
- end.parse!
16
-
17
- if options['list']
18
- puts "Sijka files:"
19
- puts 'base'
20
- # puts Cowsay.character_classes.join(' ')
21
- else
22
- # if ARGV.any?
23
- # message = ARGV.join(' ')
24
- # else
25
- # #retrieve any piped input, otherwise use the empty string.
26
- # message = STDIN.tty? ? '' : ARGF.read.chomp
27
- # end
28
- Sijka.new.smoke
29
- # puts Cowsay.say(message, options['cowfile'])
30
- end
5
+ Sijka::Sijka.new(ARGV, STDIN).smoke
data/lib/sijka.rb CHANGED
@@ -1,45 +1,20 @@
1
- require 'terminfo'
1
+ require_relative 'sijka/smoke'
2
+ require_relative 'sijka/parser'
2
3
 
3
- class Sijka
4
- SLEEP_TIME = 0.02
5
-
6
- def initialize(file_name = "#{File.dirname(__FILE__)}/characters/base.txt")
7
- @img = File.open(file_name) { |file| file.read.split("\n") }
8
- @movement_range = TermInfo.screen_size[1] - @img.first.length
9
- end
10
-
11
- def smoke
12
- right_move
13
- reverse_img
14
- left_move
15
- puts 'All was smoking!'
16
- sleep(1.3)
17
- system 'clear'
18
- end
19
-
20
- private
21
-
22
- def right_move
23
- @movement_range.times do
24
- system 'clear'
25
- puts @img
26
- sleep(SLEEP_TIME)
27
- @img.map! { |line| line.insert(0, ' ') }
4
+ module Sijka
5
+ class Sijka
6
+ def initialize(argv, stdin)
7
+ sijka_parser = SijkaParser.new(argv, stdin)
8
+ @options = sijka_parser.parse_flags
9
+ @message = sijka_parser.parse_message
28
10
  end
29
- end
30
-
31
- def reverse_img
32
- @img.map! do |line|
33
- line[0..@movement_range - 1] + line[@movement_range..-1].reverse
34
- end
35
- end
36
11
 
37
- def left_move
38
- @movement_range.times do
39
- system 'clear'
40
- puts @img
41
- sleep(SLEEP_TIME)
42
- @img.map! { |line| line[1..-1] }
12
+ def smoke
13
+ if @options['list']
14
+ puts "Sijka files:", Smoke::FILE_LIST
15
+ else
16
+ Smoke.new(@message, @options['sijkafile']).smoke
17
+ end
43
18
  end
44
19
  end
45
20
  end
@@ -0,0 +1,32 @@
1
+ require 'optparse'
2
+
3
+ module Sijka
4
+ class SijkaParser
5
+ def initialize(argv, stdin)
6
+ @argv = argv
7
+ @stdin = stdin
8
+ end
9
+
10
+ def parse_flags
11
+ options = {}
12
+ OptionParser.new do |opts|
13
+ opts.banner = "Usage: sijka [name] [-h] [-f sijkafile] [-l]"
14
+ opts.on("-l", "List available sijka files") do |sijkafile|
15
+ options['list'] = true
16
+ end
17
+ opts.on("-f SIJKAFILE", "Specify a sijka file") do |sijkafile|
18
+ options['sijkafile'] = sijkafile
19
+ end
20
+ end.parse!
21
+ options
22
+ end
23
+
24
+ def parse_message
25
+ if @argv.any?
26
+ @argv.join(' ')
27
+ else
28
+ @stdin.tty? ? '' : @argv.read.chomp
29
+ end
30
+ end
31
+ end
32
+ end
@@ -0,0 +1,52 @@
1
+ require 'terminfo'
2
+ require 'I18n' #TODO locales
3
+
4
+ module Sijka
5
+ class Smoke
6
+ SLEEP_TIME = 0.02
7
+ FILE_LIST = [ 'base' ] #TODO added method when add other screens
8
+
9
+ def initialize(message, file_name)
10
+ file_name = !file_name.to_s.empty? && FILE_LIST.include?(file_name) ? file_name : 'base'
11
+ @message = message.to_s.empty? ? 'All was smoking!' : "All was smoking, #{message}!"
12
+ file_path = "#{File.dirname(__FILE__)}/../characters/#{file_name.downcase}.txt"
13
+ @img = File.open(file_path) { |file| file.read.split("\n") }
14
+ @movement_range = TermInfo.screen_size[1] - @img.first.length
15
+ end
16
+
17
+ def smoke
18
+ right_move
19
+ reverse_img
20
+ left_move
21
+ puts @message
22
+ sleep(1.3)
23
+ system 'clear'
24
+ end
25
+
26
+ private
27
+
28
+ def right_move
29
+ @movement_range.times do
30
+ system 'clear'
31
+ puts @img
32
+ sleep(SLEEP_TIME)
33
+ @img.map! { |line| line.insert(0, ' ') }
34
+ end
35
+ end
36
+
37
+ def reverse_img
38
+ @img.map! do |line|
39
+ line[0..@movement_range - 1] + line[@movement_range..-1].reverse
40
+ end
41
+ end
42
+
43
+ def left_move
44
+ @movement_range.times do
45
+ system 'clear'
46
+ puts @img
47
+ sleep(SLEEP_TIME)
48
+ @img.map! { |line| line[1..-1] }
49
+ end
50
+ end
51
+ end
52
+ end
data/lib/sijka/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Sijka
2
- VERSION = "0.0.0.5"
2
+ VERSION = "0.0.2"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sijka
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.0.5
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mario_Sparta
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-06-25 00:00:00.000000000 Z
11
+ date: 2017-06-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: ruby-terminfo
@@ -73,6 +73,8 @@ files:
73
73
  - lib/.DS_Store
74
74
  - lib/characters/base.txt
75
75
  - lib/sijka.rb
76
+ - lib/sijka/parser.rb
77
+ - lib/sijka/smoke.rb
76
78
  - lib/sijka/version.rb
77
79
  - sijka.gemspec
78
80
  homepage: https://github.com/megosparta/Sijka