kvn 0.2.2 → 0.2.3

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
- SHA1:
3
- metadata.gz: f2ae8d951dc4662ce1e7bdc1e01b91b69f8fdcab
4
- data.tar.gz: 59df5c150e2e33eb8ee50cb43f6eab619629ebd1
2
+ SHA256:
3
+ metadata.gz: ba4b62e0cded253b4bb92d230fe4a093f2d2c00f5b6c4bab7ce1cba22acc1d13
4
+ data.tar.gz: 4a4aae64eedfb4b019d3b4b5847b2956b812b47c5350fa693bc57fd877ae8359
5
5
  SHA512:
6
- metadata.gz: b06f2a6820026a8f6e5572c0b00427fe0a60ff4647a93abb631e72384fa94caf08c8a70220b28d75493d8afda931d6764d2445fd10b67f15800e373d1e8c6957
7
- data.tar.gz: 677387de4b6d8e0b99dbc82ab2e6247bed046a960887d077423a3a9f1b0735c0c2f91d2eb77462deab58ab8bf01aba29eed24801199d3d267d7d25b920990586
6
+ metadata.gz: 7d3068ceef40a18c9825799564caa8d880ffeac4d75b5bdc150bece98fd22c1e2475a63a0f36969c8f893bd5d2465a82f8019c5fe3f845e821c68368ba7a7db1
7
+ data.tar.gz: 2d76714936e688d89b3b50f6dae0a127f7f1859205bd79fb471cb3a9e27da63a715cb66f79eba0a9e63a8a61a3219385d47b78e6994c5c5b3f2d351a0cc8f540
data/Gemfile CHANGED
@@ -1,4 +1,6 @@
1
- source 'https://rubygems.org'
1
+ # frozen_string_literal: true
2
+
3
+ source "https://rubygems.org"
2
4
 
3
5
  # Specify your gem's dependencies in kvn.gemspec
4
6
  gemspec
@@ -1,83 +1,97 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- kvn (0.2.1)
4
+ kvn (0.2.3)
5
5
  lex (= 0.1.0)
6
6
 
7
7
  GEM
8
8
  remote: https://rubygems.org/
9
9
  specs:
10
- binding_of_caller (0.7.2)
10
+ ast (2.4.1)
11
+ binding_of_caller (0.8.0)
11
12
  debug_inspector (>= 0.0.1)
12
- byebug (8.2.2)
13
- coderay (1.1.1)
14
- coveralls (0.8.10)
15
- json (~> 1.8)
16
- rest-client (>= 1.6.8, < 2)
17
- simplecov (~> 0.11.0)
13
+ byebug (11.1.3)
14
+ coderay (1.1.3)
15
+ coveralls (0.8.23)
16
+ json (>= 1.8, < 3)
17
+ simplecov (~> 0.16.1)
18
18
  term-ansicolor (~> 1.3)
19
- thor (~> 0.19.1)
20
- tins (~> 1.6.0)
21
- debug_inspector (0.0.2)
22
- docile (1.1.5)
23
- domain_name (0.5.20160128)
24
- unf (>= 0.0.5, < 1.0.0)
25
- http-cookie (1.0.2)
26
- domain_name (~> 0.5)
19
+ thor (>= 0.19.4, < 2.0)
20
+ tins (~> 1.6)
21
+ debug_inspector (0.0.3)
22
+ docile (1.3.2)
27
23
  interception (0.5)
28
- json (1.8.3)
24
+ json (2.3.1)
29
25
  lex (0.1.0)
30
- method_source (0.8.2)
31
- mime-types (2.99.1)
32
- netrc (0.11.0)
33
- os (0.9.6)
34
- pry (0.10.3)
35
- coderay (~> 1.1.0)
36
- method_source (~> 0.8.1)
37
- slop (~> 3.4)
38
- pry-byebug (3.3.0)
39
- byebug (~> 8.0)
40
- pry (~> 0.10)
41
- pry-rescue (1.4.2)
26
+ magic_frozen_string_literal (1.1.0)
27
+ method_source (1.0.0)
28
+ os (1.1.1)
29
+ parallel (1.19.2)
30
+ parser (2.7.1.4)
31
+ ast (~> 2.4.1)
32
+ pry (0.13.1)
33
+ coderay (~> 1.1)
34
+ method_source (~> 1.0)
35
+ pry-byebug (3.9.0)
36
+ byebug (~> 11.0)
37
+ pry (~> 0.13.0)
38
+ pry-rescue (1.5.2)
42
39
  interception (>= 0.5)
43
- pry
44
- pry-stack_explorer (0.4.9.2)
45
- binding_of_caller (>= 0.7)
46
- pry (>= 0.9.11)
47
- pry-test (0.6.4)
40
+ pry (>= 0.12.0)
41
+ pry-stack_explorer (0.5.1)
42
+ binding_of_caller (~> 0.7)
43
+ pry (~> 0.13)
44
+ pry-test (0.6.6)
48
45
  os
49
46
  pry
50
47
  pry-byebug
51
48
  pry-rescue
52
49
  pry-stack_explorer
53
- rake (10.5.0)
54
- rest-client (1.8.0)
55
- http-cookie (>= 1.0.2, < 2.0)
56
- mime-types (>= 1.16, < 3.0)
57
- netrc (~> 0.7)
58
- simplecov (0.11.2)
59
- docile (~> 1.1.0)
60
- json (~> 1.8)
50
+ rainbow (3.0.0)
51
+ rake (13.0.1)
52
+ regexp_parser (1.7.1)
53
+ rexml (3.2.4)
54
+ rubocop (0.85.1)
55
+ parallel (~> 1.10)
56
+ parser (>= 2.7.0.1)
57
+ rainbow (>= 2.2.2, < 4.0)
58
+ regexp_parser (>= 1.7)
59
+ rexml
60
+ rubocop-ast (>= 0.0.3)
61
+ ruby-progressbar (~> 1.7)
62
+ unicode-display_width (>= 1.4.0, < 2.0)
63
+ rubocop-ast (0.3.0)
64
+ parser (>= 2.7.1.4)
65
+ rubocop-performance (1.6.1)
66
+ rubocop (>= 0.71.0)
67
+ ruby-progressbar (1.10.1)
68
+ simplecov (0.16.1)
69
+ docile (~> 1.1)
70
+ json (>= 1.8, < 3)
61
71
  simplecov-html (~> 0.10.0)
62
- simplecov-html (0.10.0)
63
- slop (3.6.0)
64
- term-ansicolor (1.3.2)
72
+ simplecov-html (0.10.2)
73
+ standard (0.4.7)
74
+ rubocop (~> 0.85.0)
75
+ rubocop-performance (~> 1.6.0)
76
+ sync (0.5.0)
77
+ term-ansicolor (1.7.1)
65
78
  tins (~> 1.0)
66
- thor (0.19.1)
67
- tins (1.6.0)
68
- unf (0.1.4)
69
- unf_ext
70
- unf_ext (0.0.7.2)
79
+ thor (1.0.1)
80
+ tins (1.25.0)
81
+ sync
82
+ unicode-display_width (1.7.0)
71
83
 
72
84
  PLATFORMS
73
85
  ruby
74
86
 
75
87
  DEPENDENCIES
76
- bundler (~> 1.11)
88
+ bundler
77
89
  coveralls
78
90
  kvn!
91
+ magic_frozen_string_literal
79
92
  pry-test
80
- rake (~> 10.0)
93
+ rake
94
+ standard
81
95
 
82
96
  BUNDLED WITH
83
- 1.11.2
97
+ 2.1.4
data/README.md CHANGED
@@ -1,6 +1,5 @@
1
- [![Lines of Code](http://img.shields.io/badge/lines_of_code-147-brightgreen.svg?style=flat)](http://blog.codinghorror.com/the-best-code-is-no-code-at-all/)
2
- [![Code Status](http://img.shields.io/codeclimate/github/hopsoft/kvn.svg?style=flat)](https://codeclimate.com/github/hopsoft/kvn)
3
- [![Dependency Status](http://img.shields.io/gemnasium/hopsoft/kvn.svg?style=flat)](https://gemnasium.com/hopsoft/kvn)
1
+ [![Lines of Code](http://img.shields.io/badge/lines_of_code-144-brightgreen.svg?style=flat)](http://blog.codinghorror.com/the-best-code-is-no-code-at-all/)
2
+ [![Maintainability](https://api.codeclimate.com/v1/badges/8c94848444b6afc448b8/maintainability)](https://codeclimate.com/github/hopsoft/kvn/maintainability)
4
3
  [![Build Status](http://img.shields.io/travis/hopsoft/kvn.svg?style=flat)](https://travis-ci.org/hopsoft/kvn)
5
4
  [![Coverage Status](https://img.shields.io/coveralls/hopsoft/kvn.svg?style=flat)](https://coveralls.io/r/hopsoft/kvn?branch=master)
6
5
  [![Downloads](http://img.shields.io/gem/dt/kvn.svg?style=flat)](http://rubygems.org/gems/kvn)
data/Rakefile CHANGED
@@ -1,7 +1,9 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require "bundler/gem_tasks"
2
4
 
3
5
  task :test do
4
6
  exec "bundle exec pry-test"
5
7
  end
6
8
 
7
- task :default => :test
9
+ task default: :test
@@ -0,0 +1,26 @@
1
+ lib = File.expand_path("../lib", __FILE__)
2
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
3
+ require "kvn/version"
4
+
5
+ Gem::Specification.new do |spec|
6
+ spec.name = "kvn"
7
+ spec.version = Kvn::VERSION
8
+ spec.authors = ["Nathan Hopkins"]
9
+ spec.email = ["natehop@gmail.com"]
10
+
11
+ spec.summary = "KVN key/value notation converter & parser"
12
+ spec.homepage = "https://github.com/hopsoft/kvn"
13
+ spec.license = "MIT"
14
+
15
+ spec.files = Dir["lib/**/*.rb", "[A-Z]*"]
16
+ spec.require_paths = ["lib"]
17
+
18
+ spec.add_dependency "lex", "0.1.0"
19
+
20
+ spec.add_development_dependency "bundler"
21
+ spec.add_development_dependency "coveralls"
22
+ spec.add_development_dependency "magic_frozen_string_literal"
23
+ spec.add_development_dependency "pry-test"
24
+ spec.add_development_dependency "rake"
25
+ spec.add_development_dependency "standard"
26
+ end
data/lib/kvn.rb CHANGED
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require "lex"
2
4
  require "kvn/version"
3
5
  require "kvn/unsupported_hash_error"
@@ -14,8 +16,6 @@ module Kvn
14
16
  Symbol,
15
17
  String,
16
18
  Integer,
17
- Fixnum,
18
- Bignum,
19
19
  Float,
20
20
  Rational
21
21
  ]
@@ -1,9 +1,15 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Kvn
2
4
  class Converter
3
5
  attr_reader :value
4
6
 
5
7
  def initialize(value)
6
- @value = (value ||= {}).to_h rescue {}
8
+ @value = begin
9
+ (value || {}).to_h
10
+ rescue
11
+ {}
12
+ end
7
13
 
8
14
  if invalid_values_present?
9
15
  message = "All values must be a supported type! #{Kvn::SUPPORTED_VALUE_TYPES.join ", "}"
@@ -12,20 +18,16 @@ module Kvn
12
18
  end
13
19
 
14
20
  def convert
15
- value.keys.sort.each_with_object([]) do |key, memo|
21
+ value.keys.sort.each_with_object([]) { |key, memo|
16
22
  v = value[key]
17
23
  v = "null" if v.nil?
18
24
  next if v.to_s.strip.empty?
19
25
  memo << "#{key}:#{v};"
20
- end.join(" ")
26
+ }.join(" ")
21
27
  end
22
28
 
23
29
  private
24
30
 
25
- def standardize_value(value)
26
- value.to_s.strip
27
- end
28
-
29
31
  def value_types
30
32
  value.values.map(&:class).uniq
31
33
  end
@@ -33,6 +35,5 @@ module Kvn
33
35
  def invalid_values_present?
34
36
  !(value_types - Kvn::SUPPORTED_VALUE_TYPES).empty?
35
37
  end
36
-
37
38
  end
38
39
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Kvn
2
4
  class Lexer < Lex::Lexer
3
5
  tokens(
@@ -8,7 +10,7 @@ module Kvn
8
10
  )
9
11
 
10
12
  rule :KEY, /\w+(?=:)/
11
- rule :VALUE, /[\w\s\.\-]+(?=;)/
13
+ rule :VALUE, /[\w\s.\-]+(?=;)/
12
14
  rule :PAIRDELIM, /;\s*/
13
15
  rule :PARTDELIM, /:/
14
16
 
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Kvn
2
4
  class Parser
3
5
  attr_reader :value
@@ -11,38 +13,35 @@ module Kvn
11
13
  def parse
12
14
  output = lexer.lex(value)
13
15
  {}.tap do |parsed|
14
- begin
15
- key = nil
16
- key_found = false
17
- value_found = false
18
- while output.peek
19
- token = output.next
20
- if token.name == :KEY
21
- key = token.value
22
- key_found = true
23
- value_found = false
24
- end
16
+ key = nil
17
+ key_found = false
18
+ value_found = false
19
+ while output.peek
20
+ token = output.next
21
+ if token.name == :KEY
22
+ key = token.value
23
+ key_found = true
24
+ value_found = false
25
+ end
25
26
 
26
- if token.name == :VALUE
27
- raise SyntaxError.new("Empty key detected for value! <#{token.value}>") unless key_found
28
- value_output = value_lexer.lex(token.value)
29
- parsed[key] = value_output.next.value
30
- value_found = true
31
- key_found = false
32
- end
27
+ if token.name == :VALUE
28
+ raise SyntaxError.new("Empty key detected for value! <#{token.value}>") unless key_found
29
+ value_output = value_lexer.lex(token.value)
30
+ parsed[key] = value_output.next.value
31
+ value_found = true
32
+ key_found = false
33
+ end
33
34
 
34
- if token.name == :PAIRDELIM && !value_found
35
- raise SyntaxError.new("Empty value detected for key! <#{key}>")
36
- end
35
+ if token.name == :PAIRDELIM && !value_found
36
+ raise SyntaxError.new("Empty value detected for key! <#{key}>")
37
37
  end
38
- rescue StopIteration
39
38
  end
39
+ rescue StopIteration
40
40
  end
41
41
  end
42
42
 
43
43
  private
44
44
 
45
45
  attr_reader :lexer, :value_lexer
46
-
47
46
  end
48
47
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Kvn
2
4
  class UnsupportedHashError < StandardError
3
5
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Kvn
2
4
  class ValueLexer < Lex::Lexer
3
5
  tokens(
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Kvn
2
- VERSION = "0.2.2"
4
+ VERSION = "0.2.3"
3
5
  end
data/tags ADDED
@@ -0,0 +1,35 @@
1
+ !_TAG_FILE_FORMAT 2 /extended format; --format=1 will not append ;" to lines/
2
+ !_TAG_FILE_SORTED 1 /0=unsorted, 1=sorted, 2=foldcase/
3
+ !_TAG_PROGRAM_AUTHOR Darren Hiebert /dhiebert@users.sourceforge.net/
4
+ !_TAG_PROGRAM_NAME Exuberant Ctags //
5
+ !_TAG_PROGRAM_URL http://ctags.sourceforge.net /official site/
6
+ !_TAG_PROGRAM_VERSION 5.8 //
7
+ Converter lib/kvn/converter.rb /^ class Converter$/;" c class:Kvn
8
+ ConverterTest test/converter_test.rb /^ class ConverterTest < PryTest::Test$/;" c class:Kvn
9
+ IllegalCharacterError lib/kvn/illegal_character_error.rb /^ class IllegalCharacterError < StandardError$/;" c class:Kvn
10
+ Kvn lib/kvn.rb /^module Kvn$/;" m
11
+ Kvn lib/kvn/converter.rb /^module Kvn$/;" m
12
+ Kvn lib/kvn/illegal_character_error.rb /^module Kvn$/;" m
13
+ Kvn lib/kvn/lexer.rb /^module Kvn$/;" m
14
+ Kvn lib/kvn/parser.rb /^module Kvn$/;" m
15
+ Kvn lib/kvn/unsupported_hash_error.rb /^module Kvn$/;" m
16
+ Kvn lib/kvn/value_lexer.rb /^module Kvn$/;" m
17
+ Kvn lib/kvn/version.rb /^module Kvn$/;" m
18
+ Kvn test/converter_test.rb /^module Kvn$/;" m
19
+ Kvn test/lexer_test.rb /^module Kvn$/;" m
20
+ Kvn test/parser_test.rb /^module Kvn$/;" m
21
+ Lexer lib/kvn/lexer.rb /^ class Lexer < Lex::Lexer$/;" c class:Kvn
22
+ LexerTest test/lexer_test.rb /^ class LexerTest < PryTest::Test$/;" c class:Kvn
23
+ Parser lib/kvn/parser.rb /^ class Parser$/;" c class:Kvn
24
+ ParserTest test/parser_test.rb /^ class ParserTest < PryTest::Test$/;" c class:Kvn
25
+ UnsupportedHashError lib/kvn/unsupported_hash_error.rb /^ class UnsupportedHashError < StandardError$/;" c class:Kvn
26
+ ValueLexer lib/kvn/value_lexer.rb /^ class ValueLexer < Lex::Lexer$/;" c class:Kvn
27
+ convert lib/kvn/converter.rb /^ def convert$/;" f class:Kvn.Converter
28
+ false? lib/kvn/parser.rb /^ def false?(value)$/;" f class:Kvn.Parser
29
+ initialize lib/kvn/converter.rb /^ def initialize(value)$/;" f class:Kvn.Converter
30
+ initialize lib/kvn/parser.rb /^ def initialize(value)$/;" f class:Kvn.Parser
31
+ invalid_values_present? lib/kvn/converter.rb /^ def invalid_values_present?$/;" f class:Kvn.Converter.convert
32
+ parse lib/kvn/parser.rb /^ def parse$/;" f class:Kvn.Parser
33
+ standardize_value lib/kvn/converter.rb /^ def standardize_value(value)$/;" f class:Kvn.Converter.convert
34
+ true? lib/kvn/parser.rb /^ def true?(value)$/;" f class:Kvn.Parser
35
+ value_types lib/kvn/converter.rb /^ def value_types$/;" f class:Kvn.Converter.convert
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: kvn
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.2
4
+ version: 0.2.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nathan Hopkins
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-04-07 00:00:00.000000000 Z
11
+ date: 2020-08-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: lex
@@ -28,30 +28,44 @@ dependencies:
28
28
  name: bundler
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - "~>"
31
+ - - ">="
32
32
  - !ruby/object:Gem::Version
33
- version: '1.11'
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
39
  - !ruby/object:Gem::Version
40
- version: '1.11'
40
+ version: '0'
41
41
  - !ruby/object:Gem::Dependency
42
- name: rake
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
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: magic_frozen_string_literal
43
57
  requirement: !ruby/object:Gem::Requirement
44
58
  requirements:
45
- - - "~>"
59
+ - - ">="
46
60
  - !ruby/object:Gem::Version
47
- version: '10.0'
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
- version: '10.0'
68
+ version: '0'
55
69
  - !ruby/object:Gem::Dependency
56
70
  name: pry-test
57
71
  requirement: !ruby/object:Gem::Requirement
@@ -67,7 +81,21 @@ dependencies:
67
81
  - !ruby/object:Gem::Version
68
82
  version: '0'
69
83
  - !ruby/object:Gem::Dependency
70
- name: coveralls
84
+ name: rake
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - ">="
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - ">="
95
+ - !ruby/object:Gem::Version
96
+ version: '0'
97
+ - !ruby/object:Gem::Dependency
98
+ name: standard
71
99
  requirement: !ruby/object:Gem::Requirement
72
100
  requirements:
73
101
  - - ">="
@@ -80,7 +108,7 @@ dependencies:
80
108
  - - ">="
81
109
  - !ruby/object:Gem::Version
82
110
  version: '0'
83
- description:
111
+ description:
84
112
  email:
85
113
  - natehop@gmail.com
86
114
  executables: []
@@ -92,6 +120,7 @@ files:
92
120
  - LICENSE.txt
93
121
  - README.md
94
122
  - Rakefile
123
+ - kvn.gemspec
95
124
  - lib/kvn.rb
96
125
  - lib/kvn/converter.rb
97
126
  - lib/kvn/lexer.rb
@@ -99,11 +128,12 @@ files:
99
128
  - lib/kvn/unsupported_hash_error.rb
100
129
  - lib/kvn/value_lexer.rb
101
130
  - lib/kvn/version.rb
131
+ - tags
102
132
  homepage: https://github.com/hopsoft/kvn
103
133
  licenses:
104
134
  - MIT
105
135
  metadata: {}
106
- post_install_message:
136
+ post_install_message:
107
137
  rdoc_options: []
108
138
  require_paths:
109
139
  - lib
@@ -118,9 +148,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
118
148
  - !ruby/object:Gem::Version
119
149
  version: '0'
120
150
  requirements: []
121
- rubyforge_project:
122
- rubygems_version: 2.5.1
123
- signing_key:
151
+ rubygems_version: 3.0.3
152
+ signing_key:
124
153
  specification_version: 4
125
154
  summary: KVN key/value notation converter & parser
126
155
  test_files: []