typecheck 0.1.1 → 0.1.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: f76e0be630cb566def0e4b2b83b427afc0e856d5
4
- data.tar.gz: 26f08e776636a425f7834e2338ad68a3f169cdae
3
+ metadata.gz: d78752097c75269ad3ef9a8ecf8843517d3eed28
4
+ data.tar.gz: 3431ab7b9bd8c981223fa5b16b52cbfb8eaffc10
5
5
  SHA512:
6
- metadata.gz: 4d29e6f557d66947c70949de7a006200484767f0614d58bc216174c335f88e6a0b847293efdebf2a46a23d75b08d1d3220680a7bf6797af341aadcf44542bf59
7
- data.tar.gz: 435e26ef5a06df032b63dfa4bd1a1a3531b5f0e914b1711f51d1e31892ba622665dbf16351127374627f2861e38bd3ca12d1db23c0168a1952dc0b69585dd058
6
+ metadata.gz: c46f14b64c4f9bc3055bac652c7176cb4a64cdf847da075e4dbef1255e44f1cbdf3b8072b0d476d94d81c8382ea999bdf010a397a5f9f56793bda0ee84eaee6c
7
+ data.tar.gz: 20df8348e031d06bb9b93e3038cd04f5e52e495c913b3ff7ed5e97e3b68538773f77dc6b431e4ce0463eb7e3531a8a1b0cad672411264c1062be8412a4a9771f
data/.gitignore CHANGED
@@ -1 +1,2 @@
1
1
  pkg
2
+ Gemfile.lock
@@ -0,0 +1,15 @@
1
+ language: ruby
2
+ rvm:
3
+ - 2.0
4
+ - 2.1
5
+ - rbx
6
+ - ruby-head
7
+ - jruby
8
+ - jruby-head
9
+ matrix:
10
+ allow_failures:
11
+ - rvm: ruby-head
12
+ - rvm: rbx
13
+ - rvm: jruby
14
+ - rvm: jruby-head
15
+ script: bundle exec rake mutant
data/Gemfile CHANGED
@@ -1,5 +1,2 @@
1
- # A sample Gemfile
2
- source "https://rubygems.org"
3
-
4
- # gem "rails"
5
1
  gemspec
2
+ source 'https://rubygems.org'
data/Rakefile CHANGED
@@ -10,7 +10,8 @@ task :default => :mutant
10
10
 
11
11
  task :mutant do
12
12
  pattern = ENV.fetch('PATTERN', 'Typecheck*')
13
- result = Mutant::CLI.run(%w[-Ilib -rtypecheck --use rspec --score 99] + [pattern])
13
+ opts = ENV.fetch('MUTANT_OPTS', '').split(' ')
14
+ result = Mutant::CLI.run(%w[-Ilib -rtypecheck --use rspec --score 100] + opts + [pattern])
14
15
  fail unless result == Mutant::CLI::EXIT_SUCCESS
15
16
  end
16
17
 
@@ -0,0 +1,32 @@
1
+ # Contributor Code of Conduct
2
+
3
+ As contributors and maintainers of this project, we pledge to respect
4
+ all people who contribute through reporting issues, posting feature
5
+ requests, updating documentation, submitting pull requests or patches,
6
+ and other activities.
7
+
8
+ We are committed to making participation in this project a
9
+ harassment-free experience for everyone, regardless of level of
10
+ experience, gender, gender identity and expression, sexual
11
+ orientation, disability, personal appearance, body size, race, age, or
12
+ religion.
13
+
14
+ Examples of unacceptable behavior by participants include the use of
15
+ sexual language or imagery, derogatory comments or personal attacks,
16
+ trolling, public or private harassment, insults, or other
17
+ unprofessional conduct.
18
+
19
+ Project maintainers have the right and responsibility to remove, edit,
20
+ or reject comments, commits, code, wiki edits, issues, and other
21
+ contributions that are not aligned to this Code of Conduct. Project
22
+ maintainers who do not follow the Code of Conduct may be removed from
23
+ the project team.
24
+
25
+ Instances of abusive, harassing, or otherwise unacceptable behavior
26
+ may be reported by opening an issue or contacting one or more of the
27
+ project maintainers.
28
+
29
+ This Code of Conduct is adapted from the
30
+ [Contributor Covenant](http:contributor-covenant.org), version 1.0.0,
31
+ available at
32
+ [http://contributor-covenant.org/version/1/0/0/](http://contributor-covenant.org/version/1/0/0/)
@@ -1,5 +1,5 @@
1
1
  module Typecheck
2
- VERSION = '0.1.1'
2
+ VERSION = '0.1.2'
3
3
 
4
4
  def typecheck(signature, method)
5
5
  alias_method "#{method}_unchecked", method
@@ -12,7 +12,7 @@ module Typecheck
12
12
  check_args, check_out = parse_sig(signature)
13
13
  ->(*args) do
14
14
  check_args.(*args)
15
- send(unchecked_method, *args).tap do |result|
15
+ __send__(unchecked_method, *args).tap do |result|
16
16
  check_out.(result)
17
17
  end
18
18
  end
@@ -20,7 +20,7 @@ module Typecheck
20
20
 
21
21
  def parse_sig(sig)
22
22
  in_t, out_t = sig.split('->').map(&:strip)
23
- in_ts = in_t.split(',').map(&:strip)
23
+ in_ts = in_t.split(',')
24
24
 
25
25
  in_checks = in_ts.map(&method(:parse_type_list))
26
26
  out_check = parse_type_list(out_t)
@@ -42,7 +42,7 @@ module Typecheck
42
42
  end
43
43
 
44
44
  def parse_type_list(choices)
45
- types = choices.split('|').map(&:strip)
45
+ types = choices.split('|')
46
46
  pred_or [
47
47
  pred_or(types.map {|choice|
48
48
  parse_type(choice, :check)
@@ -66,6 +66,17 @@ describe Typecheck do
66
66
  num
67
67
  end
68
68
  typecheck 'Fixnum, String, Symbol -> Numeric', :optional
69
+
70
+ def public_interface(x)
71
+ private_helper(x)
72
+ end
73
+
74
+ private
75
+
76
+ def private_helper(x)
77
+ x + x
78
+ end
79
+ typecheck 'Numeric -> Numeric', :private_helper
69
80
  end
70
81
  end
71
82
 
@@ -106,9 +117,12 @@ describe Typecheck do
106
117
  include_examples 'valid', :optional, [1, 'x', :foo], 1
107
118
  include_examples 'valid', :optional, [1, 'x'], 1
108
119
  include_examples 'valid', :optional, [1], 1
109
- include_examples 'invalid', :optional, [1, 'x', 'y'], 1, 'Bad type: "y", expected Symbol'
120
+ include_examples 'invalid', :optional, [1, 'x', 'y'], 'Bad type: "y", expected Symbol'
110
121
  include_examples 'invalid', :optional, [], /wrong number of arguments/, ArgumentError
111
122
 
123
+ include_examples 'valid', :public_interface, [1], 2
124
+ include_examples 'invalid', :public_interface, ['x'], 'Bad type: "x", expected Numeric'
125
+
112
126
  it 'should make the original method available' do
113
127
  expect(subject.double_me_unchecked('foo')).to eq 'foofoo'
114
128
  end
@@ -17,7 +17,7 @@ Gem::Specification.new do |gem|
17
17
  gem.test_files = `git ls-files -- spec`.split($/)
18
18
  gem.extra_rdoc_files = %w[README.md LICENSE]
19
19
 
20
- gem.add_development_dependency 'rake' , '~> 10.2'
21
- gem.add_development_dependency 'rspec' , '~> 2.14'
22
- gem.add_development_dependency 'mutant-rspec' , '~> 0.5.10'
20
+ gem.add_development_dependency 'rake' , '~> 10.4'
21
+ gem.add_development_dependency 'rspec' , '~> 3'
22
+ gem.add_development_dependency 'mutant-rspec' , '~> 0'
23
23
  end
metadata CHANGED
@@ -1,57 +1,57 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: typecheck
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Arne Brasseur
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-04-26 00:00:00.000000000 Z
11
+ date: 2014-12-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - ~>
17
+ - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: '10.2'
19
+ version: '10.4'
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
- version: '10.2'
26
+ version: '10.4'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: rspec
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - ~>
31
+ - - "~>"
32
32
  - !ruby/object:Gem::Version
33
- version: '2.14'
33
+ version: '3'
34
34
  type: :development
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - ~>
38
+ - - "~>"
39
39
  - !ruby/object:Gem::Version
40
- version: '2.14'
40
+ version: '3'
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: mutant-rspec
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
- - - ~>
45
+ - - "~>"
46
46
  - !ruby/object:Gem::Version
47
- version: 0.5.10
47
+ version: '0'
48
48
  type: :development
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
- - - ~>
52
+ - - "~>"
53
53
  - !ruby/object:Gem::Version
54
- version: 0.5.10
54
+ version: '0'
55
55
  description: Type checking for Ruby methods.
56
56
  email:
57
57
  - arne@arnebrasseur.net
@@ -61,12 +61,13 @@ extra_rdoc_files:
61
61
  - README.md
62
62
  - LICENSE
63
63
  files:
64
- - .gitignore
64
+ - ".gitignore"
65
+ - ".travis.yml"
65
66
  - Gemfile
66
- - Gemfile.lock
67
67
  - LICENSE
68
68
  - README.md
69
69
  - Rakefile
70
+ - code_of_conduct.md
70
71
  - lib/typecheck.rb
71
72
  - spec/integration/typecheck_spec.rb
72
73
  - spec/spec_helper.rb
@@ -81,17 +82,17 @@ require_paths:
81
82
  - lib
82
83
  required_ruby_version: !ruby/object:Gem::Requirement
83
84
  requirements:
84
- - - '>='
85
+ - - ">="
85
86
  - !ruby/object:Gem::Version
86
87
  version: '0'
87
88
  required_rubygems_version: !ruby/object:Gem::Requirement
88
89
  requirements:
89
- - - '>='
90
+ - - ">="
90
91
  - !ruby/object:Gem::Version
91
92
  version: '0'
92
93
  requirements: []
93
94
  rubyforge_project:
94
- rubygems_version: 2.0.14
95
+ rubygems_version: 2.2.2
95
96
  signing_key:
96
97
  specification_version: 4
97
98
  summary: Type checking for Ruby methods.
@@ -1,83 +0,0 @@
1
- PATH
2
- remote: .
3
- specs:
4
- typecheck (0.1.1)
5
-
6
- GEM
7
- remote: https://rubygems.org/
8
- specs:
9
- abstract_type (0.0.7)
10
- adamantium (0.2.0)
11
- ice_nine (~> 0.11.0)
12
- memoizable (~> 0.4.0)
13
- anima (0.2.0)
14
- abstract_type (~> 0.0.7)
15
- adamantium (~> 0.1)
16
- equalizer (~> 0.0.8)
17
- ast (1.1.0)
18
- concord (0.1.5)
19
- adamantium (~> 0.2.0)
20
- equalizer (~> 0.0.9)
21
- diff-lcs (1.2.5)
22
- equalizer (0.0.9)
23
- ice_nine (0.11.0)
24
- inflecto (0.0.2)
25
- memoizable (0.4.2)
26
- thread_safe (~> 0.3, >= 0.3.1)
27
- morpher (0.2.2)
28
- abstract_type (~> 0.0.7)
29
- adamantium (~> 0.2.0)
30
- anima (~> 0.2.0)
31
- ast (~> 1.1.0)
32
- concord (~> 0.1.4)
33
- equalizer (~> 0.0.9)
34
- ice_nine (~> 0.11.0)
35
- procto (~> 0.0.2)
36
- mutant (0.5.10)
37
- abstract_type (~> 0.0.7)
38
- adamantium (~> 0.2.0)
39
- anima (~> 0.2.0)
40
- concord (~> 0.1.4)
41
- diff-lcs (~> 1.2)
42
- equalizer (~> 0.0.9)
43
- ice_nine (~> 0.11.0)
44
- inflecto (~> 0.0.2)
45
- memoizable (~> 0.4.2)
46
- morpher (~> 0.2.1)
47
- parser (~> 2.1)
48
- procto (~> 0.0.2)
49
- unparser (~> 0.1.10)
50
- mutant-rspec (0.5.10)
51
- mutant (~> 0.5.10)
52
- rspec-core (>= 2.14.1, <= 3.0.0.beta2)
53
- parser (2.1.8)
54
- ast (~> 1.1)
55
- slop (~> 3.4, >= 3.4.5)
56
- procto (0.0.2)
57
- rake (10.3.1)
58
- rspec (2.14.1)
59
- rspec-core (~> 2.14.0)
60
- rspec-expectations (~> 2.14.0)
61
- rspec-mocks (~> 2.14.0)
62
- rspec-core (2.14.8)
63
- rspec-expectations (2.14.5)
64
- diff-lcs (>= 1.1.3, < 2.0)
65
- rspec-mocks (2.14.6)
66
- slop (3.5.0)
67
- thread_safe (0.3.3)
68
- unparser (0.1.12)
69
- abstract_type (~> 0.0.7)
70
- adamantium (~> 0.2.0)
71
- concord (~> 0.1.4)
72
- equalizer (~> 0.0.9)
73
- parser (~> 2.1)
74
- procto (~> 0.0.2)
75
-
76
- PLATFORMS
77
- ruby
78
-
79
- DEPENDENCIES
80
- mutant-rspec (~> 0.5.10)
81
- rake (~> 10.2)
82
- rspec (~> 2.14)
83
- typecheck!