rumonade 0.4.2 → 0.4.3

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
+ SHA1:
3
+ metadata.gz: 231aae55cd63267988369976fc4c303e63e40547
4
+ data.tar.gz: 5b4bdc7d0a536c164577684786f1ecb4857189da
5
+ SHA512:
6
+ metadata.gz: 44a05e9b1e41ac9b4454de558853885b307a2f57f9c3bdc5d575729ddfa2925d9477fdd0f5b64c50e48f7da25e4cee7116d5c262b560d062cb2c354eaf07cfbd
7
+ data.tar.gz: 031ed1dc50bc70392dcb957089c4871c9213a744198e350d5611b0b84144a3672c56071eb4dc6026452a5ec9c705136f1c3d401562dbab20db15a9703ee63c17
data/.coveralls.yml ADDED
@@ -0,0 +1,2 @@
1
+ service_name: travis-ci
2
+
data/.gitignore CHANGED
@@ -7,4 +7,4 @@ html
7
7
  rdoc
8
8
  .yardoc
9
9
  doc
10
-
10
+ coverage
data/.ruby-gemset ADDED
@@ -0,0 +1 @@
1
+ rumonade
data/.ruby-version ADDED
@@ -0,0 +1 @@
1
+ ruby-2.0.0-p247
data/.travis.yml CHANGED
@@ -1,6 +1,7 @@
1
1
  language: ruby
2
2
  rvm:
3
+ - 2.0.0
3
4
  - 1.9.2
4
5
  - 1.9.3
5
6
  - jruby-19mode
6
- - rbx-19mode
7
+ - rbx-19mode
data/HISTORY.md CHANGED
@@ -1,5 +1,10 @@
1
1
  # HISTORY
2
2
 
3
+ ## v0.4.3 (Aug 27, 2013)
4
+
5
+ - Fix: prevent Array#flatten from attempting to flatten Hash (thanks @moser!)
6
+ - See full list @ https://github.com/ms-ati/rumonade/compare/v0.4.2...v0.4.3
7
+
3
8
  ## v0.4.2 (May 9, 2013)
4
9
 
5
10
  - revert change which confused Array#map with Array#flat_map
data/README.md CHANGED
@@ -1,7 +1,10 @@
1
1
  # [Rumonade](https://rubygems.org/gems/rumonade)
2
2
 
3
+ [![Gem Version](https://badge.fury.io/rb/rumonade.png)](http://badge.fury.io/rb/rumonade)
3
4
  [![Build Status](https://travis-ci.org/ms-ati/rumonade.png)](https://travis-ci.org/ms-ati/rumonade)
4
5
  [![Dependency Status](https://gemnasium.com/ms-ati/rumonade.png)](https://gemnasium.com/ms-ati/rumonade)
6
+ [![Code Climate](https://codeclimate.com/github/ms-ati/rumonade.png)](https://codeclimate.com/github/ms-ati/rumonade)
7
+ [![Coverage Status](https://coveralls.io/repos/ms-ati/rumonade/badge.png)](https://coveralls.io/r/ms-ati/rumonade)
5
8
 
6
9
  *_Project_*: [github](http://github.com/ms-ati/rumonade)
7
10
 
data/lib/rumonade/hash.rb CHANGED
@@ -27,9 +27,16 @@ module Rumonade
27
27
  Option(self[key])
28
28
  end
29
29
  end
30
+
31
+ module InstanceOverrides
32
+ def can_flatten_in_monad?
33
+ false
34
+ end
35
+ end
30
36
  end
31
37
  end
32
38
 
33
39
  Hash.send(:extend, Rumonade::HashExtensions::ClassMethods)
34
40
  Hash.send(:include, Rumonade::HashExtensions::InstanceMethods)
35
41
  Hash.send(:include, Rumonade::Monad)
42
+ Hash.send(:include, Rumonade::HashExtensions::InstanceOverrides)
@@ -57,9 +57,15 @@ module Rumonade
57
57
  #
58
58
  def flatten_with_monad(depth=nil)
59
59
  if depth.is_a? Integer
60
- depth.times.inject(self) {|e, _| e.shallow_flatten }
60
+ depth.times.inject(self) { |e, _| e.shallow_flatten }
61
61
  else
62
- bind { |x| x.is_a?(Monad) ? x.flatten_with_monad : self.class.unit(x) }
62
+ bind do |x|
63
+ if x.is_a?(Monad) && x.can_flatten_in_monad?
64
+ x.flatten_with_monad
65
+ else
66
+ self.class.unit(x)
67
+ end
68
+ end
63
69
  end
64
70
  end
65
71
 
@@ -85,5 +91,13 @@ module Rumonade
85
91
  def shallow_flatten
86
92
  bind { |x| x.is_a?(Monad) ? x : self.class.unit(x) }
87
93
  end
94
+
95
+ # Returns +true+ if #flatten_with_monad can call recursively on contained
96
+ # values members (eg. elements of an array).
97
+ #
98
+ # NOTE: Is overridden in Hash.
99
+ def can_flatten_in_monad?
100
+ true
101
+ end
88
102
  end
89
103
  end
@@ -1,3 +1,3 @@
1
1
  module Rumonade
2
- VERSION = "0.4.2"
2
+ VERSION = "0.4.3"
3
3
  end
data/rumonade.gemspec CHANGED
@@ -21,4 +21,5 @@ Gem::Specification.new do |s|
21
21
  # specify any dependencies here; for example:
22
22
  s.add_development_dependency "test-unit"
23
23
  s.add_development_dependency "rake"
24
+ s.add_development_dependency "coveralls"
24
25
  end
data/test/array_test.rb CHANGED
@@ -56,4 +56,9 @@ class ArrayTest < Test::Unit::TestCase
56
56
  assert_equal [1, None], [Some(Some(1)), Some(Some(None)), [None]].flatten(2)
57
57
  assert_equal [1], [Some(Some(1)), Some(Some(None)), [None]].flatten(3)
58
58
  end
59
- end
59
+
60
+ def test_flatten_does_not_break_default_ruby_behaviour_with_nested_hash
61
+ arr = [ { 'thou' => 'shalt', 'not touch' => 'hashes' }, ', seriously!' ]
62
+ assert_equal arr, arr.flatten
63
+ end
64
+ end
data/test/test_helper.rb CHANGED
@@ -1,6 +1,18 @@
1
1
  $:.unshift(File.dirname(File.dirname(File.expand_path(__FILE__))) + '/lib')
2
2
  require "rubygems"
3
3
  require "test/unit"
4
+
5
+ # Setup code coverage via SimpleCov and post to Coveralls.io
6
+ require "simplecov"
7
+ require "coveralls"
8
+ SimpleCov.formatter = SimpleCov::Formatter::MultiFormatter[
9
+ SimpleCov::Formatter::HTMLFormatter,
10
+ Coveralls::SimpleCov::Formatter
11
+ ]
12
+ SimpleCov.start do
13
+ add_filter "/test/"
14
+ end
15
+
4
16
  require "rumonade"
5
17
 
6
18
  # see http://stackoverflow.com/questions/2709361/monad-equivalent-in-ruby
metadata CHANGED
@@ -1,46 +1,55 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rumonade
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.2
5
- prerelease:
4
+ version: 0.4.3
6
5
  platform: ruby
7
6
  authors:
8
7
  - Marc Siegel
9
8
  autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
- date: 2013-05-09 00:00:00.000000000 Z
11
+ date: 2013-08-27 00:00:00.000000000 Z
13
12
  dependencies:
14
13
  - !ruby/object:Gem::Dependency
15
14
  name: test-unit
16
15
  requirement: !ruby/object:Gem::Requirement
17
- none: false
18
16
  requirements:
19
- - - ! '>='
17
+ - - '>='
20
18
  - !ruby/object:Gem::Version
21
19
  version: '0'
22
20
  type: :development
23
21
  prerelease: false
24
22
  version_requirements: !ruby/object:Gem::Requirement
25
- none: false
26
23
  requirements:
27
- - - ! '>='
24
+ - - '>='
28
25
  - !ruby/object:Gem::Version
29
26
  version: '0'
30
27
  - !ruby/object:Gem::Dependency
31
28
  name: rake
32
29
  requirement: !ruby/object:Gem::Requirement
33
- none: false
34
30
  requirements:
35
- - - ! '>='
31
+ - - '>='
36
32
  - !ruby/object:Gem::Version
37
33
  version: '0'
38
34
  type: :development
39
35
  prerelease: false
40
36
  version_requirements: !ruby/object:Gem::Requirement
41
- none: false
42
37
  requirements:
43
- - - ! '>='
38
+ - - '>='
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: coveralls
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
+ - - '>='
44
53
  - !ruby/object:Gem::Version
45
54
  version: '0'
46
55
  description: A Scala-inspired Monad library for Ruby, aiming to share the most common
@@ -51,8 +60,10 @@ executables: []
51
60
  extensions: []
52
61
  extra_rdoc_files: []
53
62
  files:
63
+ - .coveralls.yml
54
64
  - .gitignore
55
- - .rvmrc
65
+ - .ruby-gemset
66
+ - .ruby-version
56
67
  - .travis.yml
57
68
  - Gemfile
58
69
  - HISTORY.md
@@ -79,27 +90,26 @@ files:
79
90
  - test/test_helper.rb
80
91
  homepage: http://github.com/ms-ati/rumonade
81
92
  licenses: []
93
+ metadata: {}
82
94
  post_install_message:
83
95
  rdoc_options: []
84
96
  require_paths:
85
97
  - lib
86
98
  required_ruby_version: !ruby/object:Gem::Requirement
87
- none: false
88
99
  requirements:
89
- - - ! '>='
100
+ - - '>='
90
101
  - !ruby/object:Gem::Version
91
102
  version: '0'
92
103
  required_rubygems_version: !ruby/object:Gem::Requirement
93
- none: false
94
104
  requirements:
95
- - - ! '>='
105
+ - - '>='
96
106
  - !ruby/object:Gem::Version
97
107
  version: '0'
98
108
  requirements: []
99
109
  rubyforge_project: rumonade
100
- rubygems_version: 1.8.25
110
+ rubygems_version: 2.0.5
101
111
  signing_key:
102
- specification_version: 3
112
+ specification_version: 4
103
113
  summary: A Scala-inspired Monad library for Ruby
104
114
  test_files:
105
115
  - test/array_test.rb
data/.rvmrc DELETED
@@ -1,48 +0,0 @@
1
- #!/usr/bin/env bash
2
-
3
- # This is an RVM Project .rvmrc file, used to automatically load the ruby
4
- # development environment upon cd'ing into the directory
5
-
6
- # First we specify our desired <ruby>[@<gemset>], the @gemset name is optional,
7
- # Only full ruby name is supported here, for short names use:
8
- # echo "rvm use 1.9.3" > .rvmrc
9
- environment_id="ruby-1.9.3-p385@rumonade"
10
-
11
- # Uncomment the following lines if you want to verify rvm version per project
12
- # rvmrc_rvm_version="1.18.8 (stable)" # 1.10.1 seams as a safe start
13
- # eval "$(echo ${rvm_version}.${rvmrc_rvm_version} | awk -F. '{print "[[ "$1*65536+$2*256+$3" -ge "$4*65536+$5*256+$6" ]]"}' )" || {
14
- # echo "This .rvmrc file requires at least RVM ${rvmrc_rvm_version}, aborting loading."
15
- # return 1
16
- # }
17
-
18
- # First we attempt to load the desired environment directly from the environment
19
- # file. This is very fast and efficient compared to running through the entire
20
- # CLI and selector. If you want feedback on which environment was used then
21
- # insert the word 'use' after --create as this triggers verbose mode.
22
- if [[ -d "${rvm_path:-$HOME/.rvm}/environments"
23
- && -s "${rvm_path:-$HOME/.rvm}/environments/$environment_id" ]]
24
- then
25
- \. "${rvm_path:-$HOME/.rvm}/environments/$environment_id"
26
- [[ -s "${rvm_path:-$HOME/.rvm}/hooks/after_use" ]] &&
27
- \. "${rvm_path:-$HOME/.rvm}/hooks/after_use" || true
28
- else
29
- # If the environment file has not yet been created, use the RVM CLI to select.
30
- rvm --create "$environment_id" || {
31
- echo "Failed to create RVM environment '${environment_id}'."
32
- return 1
33
- }
34
- fi
35
-
36
- # If you use bundler, this might be useful to you:
37
- # if [[ -s Gemfile ]] && {
38
- # ! builtin command -v bundle >/dev/null ||
39
- # builtin command -v bundle | GREP_OPTIONS= \grep $rvm_path/bin/bundle >/dev/null
40
- # }
41
- # then
42
- # printf "%b" "The rubygem 'bundler' is not installed. Installing it now.\n"
43
- # gem install bundler
44
- # fi
45
- # if [[ -s Gemfile ]] && builtin command -v bundle >/dev/null
46
- # then
47
- # bundle install | GREP_OPTIONS= \grep -vE '^Using|Your bundle is complete'
48
- # fi