tree_branch 1.0.0 → 1.1.0

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
  SHA256:
3
- metadata.gz: 15671327d19ea465e079da408e3e4a35ff0a26d03b8ec33251e7c96a49d9b87d
4
- data.tar.gz: b40855cf7a130ed233b9e4da84224d81dd75d54de234cabd628d806bda81c9b2
3
+ metadata.gz: 8473f9c14965c2a57e95f136405bb04e54bf0b3d724d583ed9016db22f51a3c7
4
+ data.tar.gz: 0706b615ecf17999274cedb975ba943eaf9b07021645f762ba899f8ee79bbed7
5
5
  SHA512:
6
- metadata.gz: 30b2df3207d1cea66da5197b9582744b8746b4e5fed1f188975f281e8895657bcdf6a96b07bbff9e86b60ff53d4eec492b3d6d4411af77e3258821e2b4d03b72
7
- data.tar.gz: d6bf7412d4db03c36f2ce842f63705b70af25051d337e70672c23fc95ad442762285a57c956ad839781ddd364d043ea64ace974836381be454785218d138106c
6
+ metadata.gz: 9a71be4ef99284701a9ab2c776beac29062bb874b197f000b8f9d8c24c74ba8464e840783e4300e1b8528f064e9ba3cea232e8554e0849147378c45d9028737d
7
+ data.tar.gz: 5560bc79fee28eed4570badba20ece7d269fd4b363f139f4fe6117292236739a711f9cf1d8666d5f634bd70e2ee8079895c0f21c44c208216936d7ad4fae62a6
data/.gitignore CHANGED
@@ -1,3 +1,4 @@
1
1
  .DS_Store
2
2
  *.gem
3
3
  /tmp
4
+ /coverage
data/.travis.yml CHANGED
@@ -1,11 +1,20 @@
1
+ env:
2
+ global:
3
+ - CC_TEST_REPORTER_ID=3f49ba7a3ab8a835b5bba9f0932adaba5996dbffde7c098b20d52a3eaa833757
1
4
  language: ruby
2
5
  rvm:
3
- # Build on the latest stable of all supported Rubies (https://www.ruby-lang.org/en/downloads/):
4
- - 2.3.8
5
- - 2.4.5
6
- - 2.5.3
7
- - 2.6.0
6
+ # Build on the latest stable of all supported Rubies (https://www.ruby-lang.org/en/downloads/):
7
+ - 2.3.8
8
+ - 2.4.5
9
+ - 2.5.3
10
+ - 2.6.0
8
11
  cache: bundler
12
+ before_script:
13
+ - curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 > ./cc-test-reporter
14
+ - chmod +x ./cc-test-reporter
15
+ - ./cc-test-reporter before-build
9
16
  script:
10
- - bundle exec rubocop
11
- - bundle exec rspec
17
+ - bundle exec rubocop
18
+ - bundle exec rspec
19
+ after_script:
20
+ - ./cc-test-reporter after-build --exit-code $TRAVIS_TEST_RESULT
data/CHANGELOG.md CHANGED
@@ -0,0 +1,11 @@
1
+ # 1.1.0 (February 5th, 2019)
2
+
3
+ Maintance Release
4
+
5
+ * Updated Dependencies
6
+ * Installed SimpleCov
7
+ * Updated Rubocop
8
+
9
+ # 1.0.0 (January 28th, 2019)
10
+
11
+ Initial Release
data/Gemfile.lock CHANGED
@@ -1,16 +1,18 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- tree_branch (1.0.0)
4
+ tree_branch (1.1.0)
5
5
  acts_as_hashable (~> 1.0)
6
6
 
7
7
  GEM
8
8
  remote: https://rubygems.org/
9
9
  specs:
10
- acts_as_hashable (1.0.3)
10
+ acts_as_hashable (1.0.5)
11
+ ansi (1.5.0)
11
12
  ast (2.4.0)
12
13
  coderay (1.1.2)
13
14
  diff-lcs (1.3)
15
+ docile (1.3.1)
14
16
  ffi (1.9.25)
15
17
  formatador (0.2.5)
16
18
  guard (2.15.0)
@@ -27,7 +29,9 @@ GEM
27
29
  guard (~> 2.1)
28
30
  guard-compat (~> 1.1)
29
31
  rspec (>= 2.99.0, < 4.0)
30
- jaro_winkler (1.5.1)
32
+ hirb (0.7.3)
33
+ jaro_winkler (1.5.2)
34
+ json (2.1.0)
31
35
  listen (3.1.5)
32
36
  rb-fsevent (~> 0.9, >= 0.9.4)
33
37
  rb-inotify (~> 0.9, >= 0.9.7)
@@ -38,8 +42,8 @@ GEM
38
42
  notiffany (0.1.1)
39
43
  nenv (~> 0.1)
40
44
  shellany (~> 0.0)
41
- parallel (1.12.1)
42
- parser (2.5.3.0)
45
+ parallel (1.13.0)
46
+ parser (2.6.0.0)
43
47
  ast (~> 2.4.0)
44
48
  powerpack (0.1.2)
45
49
  pry (0.12.2)
@@ -62,19 +66,28 @@ GEM
62
66
  diff-lcs (>= 1.2.0, < 2.0)
63
67
  rspec-support (~> 3.8.0)
64
68
  rspec-support (3.8.0)
65
- rubocop (0.59.2)
69
+ rubocop (0.63.1)
66
70
  jaro_winkler (~> 1.5.1)
67
71
  parallel (~> 1.10)
68
72
  parser (>= 2.5, != 2.5.1.1)
69
73
  powerpack (~> 0.1)
70
74
  rainbow (>= 2.2.2, < 4.0)
71
75
  ruby-progressbar (~> 1.7)
72
- unicode-display_width (~> 1.0, >= 1.0.1)
76
+ unicode-display_width (~> 1.4.0)
73
77
  ruby-progressbar (1.10.0)
74
78
  ruby_dep (1.5.0)
75
79
  shellany (0.0.1)
80
+ simplecov (0.16.1)
81
+ docile (~> 1.1)
82
+ json (>= 1.8, < 3)
83
+ simplecov-html (~> 0.10.0)
84
+ simplecov-console (0.4.2)
85
+ ansi
86
+ hirb
87
+ simplecov
88
+ simplecov-html (0.10.2)
76
89
  thor (0.20.3)
77
- unicode-display_width (1.4.0)
90
+ unicode-display_width (1.4.1)
78
91
 
79
92
  PLATFORMS
80
93
  ruby
@@ -82,7 +95,9 @@ PLATFORMS
82
95
  DEPENDENCIES
83
96
  guard-rspec (~> 4.7)
84
97
  rspec (~> 3.8)
85
- rubocop (~> 0.59)
98
+ rubocop (~> 0.63.1)
99
+ simplecov (~> 0.16.1)
100
+ simplecov-console (~> 0.4.2)
86
101
  tree_branch!
87
102
 
88
103
  BUNDLED WITH
data/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # TreeBranch
2
2
 
3
- [![Build Status](https://travis-ci.org/bluemarblepayroll/tree_branch.svg?branch=master)](https://travis-ci.org/bluemarblepayroll/tree_branch)
3
+ [![Gem Version](https://badge.fury.io/rb/tree_branch.svg)](https://badge.fury.io/rb/tree_branch) [![Build Status](https://travis-ci.org/bluemarblepayroll/tree_branch.svg?branch=master)](https://travis-ci.org/bluemarblepayroll/tree_branch) [![Maintainability](https://api.codeclimate.com/v1/badges/9875bbc4672509465601/maintainability)](https://codeclimate.com/github/bluemarblepayroll/tree_branch/maintainability) [![Test Coverage](https://api.codeclimate.com/v1/badges/9875bbc4672509465601/test_coverage)](https://codeclimate.com/github/bluemarblepayroll/tree_branch/test_coverage) [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
4
4
 
5
5
  This library allows you to traverse an entire tree structure, compare all nodes, and choose a tree structure to return. The basic input is defined as:
6
6
 
@@ -417,12 +417,12 @@ Note: ensure you have proper authorization before trying to publish new versions
417
417
  After code changes have successfully gone through the Pull Request review process then the following steps should be followed for publishing new versions:
418
418
 
419
419
  1. Merge Pull Request into master
420
- 2. Update [lib/tree_branch/version.rb](https://github.com/bluemarblepayroll/tree_branch/blob/master/lib/tree_branch/version.rb) [version number](https://semver.org/)
421
- 3. Bundle
422
- 4. Update CHANGELOG.md
423
- 5. Commit & Push master to remote and ensure CI builds master successfully
420
+ 2. Update ```lib/tree_branch/version.rb``` using [semantic versioning](https://semver.org/)
421
+ 3. Install dependencies: ```bundle```
422
+ 4. Update ```CHANGELOG.md``` with release notes
423
+ 5. Commit & push master to remote and ensure CI builds master successfully
424
424
  6. Build the project locally: `gem build tree_branch`
425
- 7. Publish package to NPM: `gem push tree_branch-X.gem` where X is the version to push
425
+ 7. Publish package to RubyGems: `gem push tree_branch-X.gem` where X is the version to push
426
426
  8. Tag master with new version: `git tag <version>`
427
427
  9. Push tags remotely: `git push origin --tags`
428
428
 
@@ -8,5 +8,5 @@
8
8
  #
9
9
 
10
10
  module TreeBranch
11
- VERSION = '1.0.0'
11
+ VERSION = '1.1.0'
12
12
  end
data/spec/spec_helper.rb CHANGED
@@ -10,6 +10,12 @@
10
10
  require 'date'
11
11
  require 'yaml'
12
12
 
13
+ require 'simplecov'
14
+ require 'simplecov-console'
15
+
16
+ SimpleCov.formatter = SimpleCov::Formatter::Console
17
+ SimpleCov.start
18
+
13
19
  require './lib/tree_branch'
14
20
 
15
21
  def fixture_path(filename)
@@ -9,6 +9,57 @@
9
9
 
10
10
  require './spec/spec_helper'
11
11
 
12
+ require 'pry'
13
+
14
+ class MenuItem
15
+ acts_as_hashable
16
+
17
+ attr_reader :menu_items, :name
18
+
19
+ def initialize(name: '', menu_items: [])
20
+ @name = name
21
+ @menu_items = self.class.array(menu_items)
22
+ end
23
+
24
+ def eql?(other)
25
+ name == other.name && menu_items == other.menu_items
26
+ end
27
+
28
+ def ==(other)
29
+ eql?(other)
30
+ end
31
+ end
32
+
33
+ class BornAfter1915 < ::TreeBranch::Comparator
34
+ def valid?
35
+ Date.parse(data.dob).year > 1915
36
+ end
37
+ end
38
+
39
+ class NameStartsWith < ::TreeBranch::Comparator
40
+ def valid?
41
+ context[:letters].include?(data.name.to_s[0])
42
+ end
43
+ end
44
+
45
+ class StateComparator < ::TreeBranch::Comparator
46
+ STATE_OPS = {
47
+ none: %i[open],
48
+ passive: %i[open save close print],
49
+ active: %i[open save close print cut copy paste]
50
+ }.freeze
51
+
52
+ def valid?
53
+ data.command.nil? || Array(STATE_OPS[context[:state]]).include?(data.command)
54
+ end
55
+ end
56
+
57
+ class AuthorizationComparator < ::TreeBranch::Comparator
58
+ def valid?
59
+ data.right.nil? || Array(context[:rights]).include?(data.right)
60
+ end
61
+ end
62
+
12
63
  describe ::TreeBranch do
13
64
  # We will use this spec to also test ::TreeBranch::Node#process since ::TreeBranch#process
14
65
  # fully delegates to that method.
@@ -33,18 +84,6 @@ describe ::TreeBranch do
33
84
  ::TreeBranch::SimpleNode.make(born_after1915_starts_with_m_or_s_hash)
34
85
  end
35
86
 
36
- class BornAfter1915 < ::TreeBranch::Comparator
37
- def valid?
38
- Date.parse(data.dob).year > 1915
39
- end
40
- end
41
-
42
- class NameStartsWith < ::TreeBranch::Comparator
43
- def valid?
44
- context[:letters].include?(data.name.to_s[0])
45
- end
46
- end
47
-
48
87
  let(:name_starts_with_lambda) do
49
88
  lambda do |data, context|
50
89
  context.letters.include?(data.name.to_s[0])
@@ -68,9 +107,9 @@ describe ::TreeBranch do
68
107
 
69
108
  it 'should return valid nodes with two class comparators' do
70
109
  input = {
71
- node: node_hash,
72
- context: { letters: %w[M S] },
73
- comparators: [BornAfter1915, NameStartsWith]
110
+ node: node_hash,
111
+ context: { letters: %w[M S] },
112
+ comparators: [BornAfter1915, NameStartsWith]
74
113
  }
75
114
 
76
115
  expect(::TreeBranch.process(input)).to eq(born_after1915_starts_with_m_or_s)
@@ -78,9 +117,9 @@ describe ::TreeBranch do
78
117
 
79
118
  it 'should return valid nodes with one class comparator and one lambda comparator' do
80
119
  input = {
81
- node: node_hash,
82
- context: { letters: %w[M S] },
83
- comparators: [BornAfter1915, name_starts_with_lambda]
120
+ node: node_hash,
121
+ context: { letters: %w[M S] },
122
+ comparators: [BornAfter1915, name_starts_with_lambda]
84
123
  }
85
124
 
86
125
  expect(::TreeBranch.process(input)).to eq(born_after1915_starts_with_m_or_s)
@@ -90,8 +129,8 @@ describe ::TreeBranch do
90
129
  outside_variable = '!!'
91
130
 
92
131
  input = {
93
- node: node,
94
- context: OpenStruct.new(suffix: 'cakes')
132
+ node: node,
133
+ context: OpenStruct.new(suffix: 'cakes')
95
134
  }
96
135
 
97
136
  processed = ::TreeBranch.process(input) do |data, children, context|
@@ -107,18 +146,6 @@ describe ::TreeBranch do
107
146
  end
108
147
 
109
148
  describe 'README Examples' do
110
- class StateComparator < ::TreeBranch::Comparator
111
- STATE_OPS = {
112
- none: %i[open],
113
- passive: %i[open save close print],
114
- active: %i[open save close print cut copy paste]
115
- }.freeze
116
-
117
- def valid?
118
- data.command.nil? || Array(STATE_OPS[context[:state]]).include?(data.command)
119
- end
120
- end
121
-
122
149
  let(:menu) do
123
150
  {
124
151
  data: { name: 'Menu' },
@@ -254,12 +281,6 @@ describe ::TreeBranch do
254
281
  expect(no_file_menu).to eq(expected)
255
282
  end
256
283
 
257
- class AuthorizationComparator < ::TreeBranch::Comparator
258
- def valid?
259
- data.right.nil? || Array(context[:rights]).include?(data.right)
260
- end
261
- end
262
-
263
284
  it 'should compute state: passive for read-only authorization' do
264
285
  no_file_menu = ::TreeBranch.process(
265
286
  node: menu,
@@ -337,25 +358,6 @@ describe ::TreeBranch do
337
358
  end
338
359
  end
339
360
 
340
- class MenuItem
341
- acts_as_hashable
342
-
343
- attr_reader :menu_items, :name
344
-
345
- def initialize(name: '', menu_items: [])
346
- @name = name
347
- @menu_items = self.class.array(menu_items)
348
- end
349
-
350
- def eql?(other)
351
- name == other.name && menu_items == other.menu_items
352
- end
353
-
354
- def ==(other)
355
- eql?(other)
356
- end
357
- end
358
-
359
361
  it 'should compute state: passive for read/write authorization and return MenuItem(s)' do
360
362
  passive_read_write_menu =
361
363
  ::TreeBranch.process(
data/tree_branch.gemspec CHANGED
@@ -25,5 +25,7 @@ Gem::Specification.new do |s|
25
25
 
26
26
  s.add_development_dependency('guard-rspec', '~>4.7')
27
27
  s.add_development_dependency('rspec', '~> 3.8')
28
- s.add_development_dependency('rubocop', '~> 0.59')
28
+ s.add_development_dependency('rubocop', '~>0.63.1')
29
+ s.add_development_dependency('simplecov', '~>0.16.1')
30
+ s.add_development_dependency('simplecov-console', '~>0.4.2')
29
31
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: tree_branch
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Matthew Ruggio
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-01-29 00:00:00.000000000 Z
11
+ date: 2019-02-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: acts_as_hashable
@@ -58,14 +58,42 @@ dependencies:
58
58
  requirements:
59
59
  - - "~>"
60
60
  - !ruby/object:Gem::Version
61
- version: '0.59'
61
+ version: 0.63.1
62
62
  type: :development
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
66
  - - "~>"
67
67
  - !ruby/object:Gem::Version
68
- version: '0.59'
68
+ version: 0.63.1
69
+ - !ruby/object:Gem::Dependency
70
+ name: simplecov
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: 0.16.1
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: 0.16.1
83
+ - !ruby/object:Gem::Dependency
84
+ name: simplecov-console
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - "~>"
88
+ - !ruby/object:Gem::Version
89
+ version: 0.4.2
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - "~>"
95
+ - !ruby/object:Gem::Version
96
+ version: 0.4.2
69
97
  description: " This library allows you to input a tree structure (node with children),
70
98
  a context, and comparators then outputs you the matching tree structure.\n"
71
99
  email: