rubyspark 0.0.1 → 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,15 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: ff04195c852abc0a56a942eb025ec5e57647d4a3
4
- data.tar.gz: 16a89d705724d8e0a5fcbfc9f585ee573e8efac6
2
+ !binary "U0hBMQ==":
3
+ metadata.gz: !binary |-
4
+ M2Q1MzIwZTFjOTc2ZTAzZDI5N2I3M2Y2MjdjNTkyYzhjMDNiZTgzMw==
5
+ data.tar.gz: !binary |-
6
+ NWQyMzYxN2IwMWUyNDJlNzM1OGE3Y2JkNDY4ZWQ1YjIzZTVkNWI0OQ==
5
7
  SHA512:
6
- metadata.gz: 54306e02aad1da929005c7f26520fa5d23e087bbe1bb10fe20e37b8fcae173e85f85eca310fa81694c1ea07eb1dd902c3dfa50ca95eea98723403f504408999a
7
- data.tar.gz: 36e9322191e79c837eeaeabbe66a8cf7b8d62196b05eb862addb57c44c68a9a0a8a69b0ef3a4f7d22867737bfe34e653c4f2b9643a823c014401768364986c07
8
+ metadata.gz: !binary |-
9
+ ZTk5ZTY3MDNlMTM2MGNjZGJhMGQyNDBmMjZjZTljMmZmZGVhMjE5ZmQzMGE2
10
+ Y2E2YTMwZGNmYmNlMDFkYmNhYTFlNzc5YTFiNTk0MDY0MGNjZWJkZjExNmQ1
11
+ Y2QzYWEyMTFmYTk1ZDVmYzViYzg4YzUxZmM5MGNhZDI4ODJlM2Q=
12
+ data.tar.gz: !binary |-
13
+ NTk1MDhlYmRjY2IzM2Y0NTRkYjRmMWMzNDIyMTJkMjA4NzBmNTZhNTRjYjky
14
+ ZWZiOWMwNjQ4NjFiODdkYjNjOGJmZThkNjYzZTIxYjI3YTg0YmViYTY1MDJk
15
+ NGRlYjQ0NTgyZGJhMWE3NzE2ZjU1MzkxZmM0MThhNWU1MzljYzU=
data/.rubocop.yml ADDED
@@ -0,0 +1,30 @@
1
+ Encoding:
2
+ Enabled: false
3
+
4
+ Style/HashSyntax:
5
+ Enabled: false
6
+
7
+ LineLength:
8
+ Enabled: false
9
+
10
+ MethodDefParentheses:
11
+ EnforcedStyle: require_no_parentheses
12
+
13
+ SpaceInsideHashLiteralBraces:
14
+ EnforcedStyle: no_space
15
+
16
+ SignalException:
17
+ EnforcedStyle: only_raise
18
+
19
+ Documentation:
20
+ Enabled: false
21
+
22
+ ClassAndModuleChildren:
23
+ Enabled: false
24
+
25
+ # This rule doesn't work so well with multi argument exception ctors
26
+ RaiseArgs:
27
+ Enabled: false
28
+
29
+ EachWithObject:
30
+ Enabled: false
data/.travis.yml ADDED
@@ -0,0 +1,22 @@
1
+ language: ruby
2
+ rvm:
3
+ - 2.1.0
4
+ - ruby-head
5
+ script: bundle exec rake test
6
+ notifications:
7
+ email:
8
+ recipients:
9
+ - anurag@mohanty.io
10
+ on_success:
11
+ - always|never|change
12
+ on_failure:
13
+ - always|never|change
14
+ deploy:
15
+ provider: rubygems
16
+ api_key:
17
+ secure: efDPrvfQCmfqPkQ+frt9g0uhbC542EzSZYLJLieBADmsZLEKCipWS3rY1WsP9NRKtKIN9LPg/UnDksVrjAFfqr0ZHMfzBsarSjpY/aHQjuABm+Yf2EpBxyRAZzREAWjem3FYSuNWcSGKfFH4+wOlrxmYbtuTfE44Q/VmjL761CI=
18
+ gem: rubyspark
19
+ on:
20
+ tags: true
21
+ all_branches: true
22
+ repo: tevren/rubyspark
data/README.md CHANGED
@@ -1,4 +1,5 @@
1
1
  # Rubyspark
2
+ [![Build Status](https://travis-ci.org/tevren/rubyspark.svg?branch=master)](https://travis-ci.org/tevren/rubyspark)
2
3
 
3
4
  A ruby port of [Spark](http://zachholman.com/spark/)
4
5
 
data/Rakefile CHANGED
@@ -1,2 +1,15 @@
1
- require "bundler/gem_tasks"
1
+ require 'bundler/gem_tasks'
2
+ require 'rspec/core/rake_task'
2
3
 
4
+ desc 'Run specs'
5
+ RSpec::Core::RakeTask.new(:spec) do |task|
6
+ task.rspec_opts = ['--color', '--format', 'progress']
7
+ end
8
+
9
+ desc 'Run rubocop tests'
10
+ task :rubocop do
11
+ sh "bundle exec rubocop -c #{File.dirname(__FILE__)}/.rubocop.yml #{File.dirname(__FILE__)}"
12
+ end
13
+
14
+ task :test => [:spec, :rubocop]
15
+ task :default => [:test, :release]
data/bin/rubyspark CHANGED
@@ -4,9 +4,9 @@ require 'optparse'
4
4
  require File.dirname(__FILE__) + '/../lib/rubyspark'
5
5
 
6
6
  options_parser = OptionParser.new do |opts|
7
- opts.banner = "Usage: #{File.basename($0)} 1 5 22 13 53 \n => ▁▁▃▂▇"
7
+ opts.banner = "Usage: #{File.basename($PROGRAM_NAME)} 1 5 22 13 53 \n => ▁▁▃▂▇"
8
8
 
9
- opts.on_tail("-h", "--help", "Show this message") do
9
+ opts.on_tail('-h', '--help', 'Show this message') do
10
10
  puts opts
11
11
  exit
12
12
  end
@@ -18,4 +18,4 @@ if ARGV.length == 0
18
18
  exit 1
19
19
  end
20
20
 
21
- Rubyspark::Spark.new(ARGV)
21
+ Rubyspark::Spark.new(ARGV)
@@ -1,3 +1,3 @@
1
1
  module Rubyspark
2
- VERSION = "0.0.1"
2
+ VERSION = '0.0.3'
3
3
  end
data/lib/rubyspark.rb CHANGED
@@ -1,29 +1,20 @@
1
- require "rubyspark/version"
1
+ require 'rubyspark/version'
2
2
  module Rubyspark
3
3
  class Spark
4
-
5
- def initialize(data=[])
4
+ def initialize data = []
6
5
  @data = []
7
- data.cycle(1) {|x| @data.push(x.to_i)}
6
+ data.cycle(1) { |x| @data.push(x.to_f) }
8
7
  graphit
9
8
  end
10
9
 
11
- def graphit
12
- ticks=%w[▁ ▅ ▆ ▇]
13
-
14
- distance = @data.compact.max.to_f / ticks.size
15
-
16
- graph = ''
17
- @data.each do |x|
18
- tick = (x/distance).round - 1
19
- if tick <= 0
20
- graph << ticks[0]
21
- else
22
- graph << ticks[tick]
23
- end
24
- end
25
- puts graph
10
+ def compute x, distance
11
+ (x / distance).round - 1
26
12
  end
27
13
 
14
+ def graphit
15
+ ticks = %w(▁ ▂ ▃ ▄ ▅ ▆ ▇)
16
+ distance = @data.max.to_f / ticks.size
17
+ puts @data.map { |x| compute(x, distance) <= 0 ? ticks[0] : ticks[compute(x, distance)] }.join('')
18
+ end
28
19
  end
29
20
  end
data/rubyspark.gemspec CHANGED
@@ -4,21 +4,22 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
4
  require 'rubyspark/version'
5
5
 
6
6
  Gem::Specification.new do |spec|
7
- spec.name = "rubyspark"
7
+ spec.name = 'rubyspark'
8
8
  spec.version = Rubyspark::VERSION
9
- spec.authors = ["Anurag Mohanty"]
10
- spec.email = ["tevren@gmail.com"]
11
- spec.summary = %q{A ruby port of spark}
12
- spec.description = %q{A ruby port of (spark)[https://github.com/holman/spark]}
13
- spec.homepage = ""
14
- spec.license = "MIT"
9
+ spec.authors = ['Anurag Mohanty']
10
+ spec.email = ['tevren@gmail.com']
11
+ spec.summary = 'A ruby port of spark'
12
+ spec.description = 'A ruby port of (spark)[https://github.com/holman/spark])'
13
+ spec.homepage = 'https://github.com/tevren/rubyspark'
14
+ spec.license = 'MIT'
15
15
 
16
- spec.files = `git ls-files -z`.split("\x0")
17
- spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
- spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
- spec.require_paths = ["lib"]
16
+ spec.files = `git ls-files`.split($INPUT_RECORD_SEPARATOR)
17
+ spec.executables = spec.files.grep(/^bin\//) { |f| File.basename(f) }
18
+ spec.test_files = spec.files.grep(/^(test|spec|features)\//)
19
+ spec.require_paths = ['lib']
20
20
 
21
- spec.add_development_dependency "bundler", "~> 1.6"
22
- spec.add_development_dependency "rake"
23
- spec.add_development_dependency "rspec"
21
+ spec.add_development_dependency 'bundler', '~> 1.6'
22
+ spec.add_development_dependency 'rake'
23
+ spec.add_development_dependency 'rubocop'
24
+ spec.add_development_dependency 'rspec'
24
25
  end
@@ -1,7 +1,7 @@
1
1
  require 'spec_helper'
2
2
 
3
- describe "#new" do
4
- it "takes any number of agruements and return a spark graph" do
5
- expect { Rubyspark::Spark.new([1,5,22,13,53]) }.to output("▁▁▃▂▇\n").to_stdout
6
- end
7
- end
3
+ describe '#new' do
4
+ it 'takes any number of agruements and return a spark graph' do
5
+ expect { Rubyspark::Spark.new([1, 5, 22, 13, 53]) }.to output("▁▁▃▂▇\n").to_stdout
6
+ end
7
+ end
metadata CHANGED
@@ -1,58 +1,72 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rubyspark
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Anurag Mohanty
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-08-04 00:00:00.000000000 Z
11
+ date: 2014-12-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - "~>"
17
+ - - ~>
18
18
  - !ruby/object:Gem::Version
19
19
  version: '1.6'
20
20
  type: :development
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - "~>"
24
+ - - ~>
25
25
  - !ruby/object:Gem::Version
26
26
  version: '1.6'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: rake
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - ">="
31
+ - - ! '>='
32
32
  - !ruby/object:Gem::Version
33
33
  version: '0'
34
34
  type: :development
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - ">="
38
+ - - ! '>='
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rubocop
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ! '>='
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ! '>='
39
53
  - !ruby/object:Gem::Version
40
54
  version: '0'
41
55
  - !ruby/object:Gem::Dependency
42
56
  name: rspec
43
57
  requirement: !ruby/object:Gem::Requirement
44
58
  requirements:
45
- - - ">="
59
+ - - ! '>='
46
60
  - !ruby/object:Gem::Version
47
61
  version: '0'
48
62
  type: :development
49
63
  prerelease: false
50
64
  version_requirements: !ruby/object:Gem::Requirement
51
65
  requirements:
52
- - - ">="
66
+ - - ! '>='
53
67
  - !ruby/object:Gem::Version
54
68
  version: '0'
55
- description: A ruby port of (spark)[https://github.com/holman/spark]
69
+ description: A ruby port of (spark)[https://github.com/holman/spark])
56
70
  email:
57
71
  - tevren@gmail.com
58
72
  executables:
@@ -60,7 +74,9 @@ executables:
60
74
  extensions: []
61
75
  extra_rdoc_files: []
62
76
  files:
63
- - ".gitignore"
77
+ - .gitignore
78
+ - .rubocop.yml
79
+ - .travis.yml
64
80
  - Gemfile
65
81
  - LICENSE.txt
66
82
  - README.md
@@ -71,7 +87,7 @@ files:
71
87
  - rubyspark.gemspec
72
88
  - spec/rubyspark_spec.rb
73
89
  - spec/spec_helper.rb
74
- homepage: ''
90
+ homepage: https://github.com/tevren/rubyspark
75
91
  licenses:
76
92
  - MIT
77
93
  metadata: {}
@@ -81,17 +97,17 @@ require_paths:
81
97
  - lib
82
98
  required_ruby_version: !ruby/object:Gem::Requirement
83
99
  requirements:
84
- - - ">="
100
+ - - ! '>='
85
101
  - !ruby/object:Gem::Version
86
102
  version: '0'
87
103
  required_rubygems_version: !ruby/object:Gem::Requirement
88
104
  requirements:
89
- - - ">="
105
+ - - ! '>='
90
106
  - !ruby/object:Gem::Version
91
107
  version: '0'
92
108
  requirements: []
93
109
  rubyforge_project:
94
- rubygems_version: 2.2.2
110
+ rubygems_version: 2.4.5
95
111
  signing_key:
96
112
  specification_version: 4
97
113
  summary: A ruby port of spark