ruby_hocon 0.0.1 → 0.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (38) hide show
  1. data/README.md +3 -5
  2. metadata +6 -42
  3. data/lib/hocon.rb +0 -2
  4. data/lib/hocon/config_error.rb +0 -12
  5. data/lib/hocon/config_factory.rb +0 -9
  6. data/lib/hocon/config_object.rb +0 -4
  7. data/lib/hocon/config_parse_options.rb +0 -53
  8. data/lib/hocon/config_render_options.rb +0 -46
  9. data/lib/hocon/config_syntax.rb +0 -7
  10. data/lib/hocon/config_value_type.rb +0 -26
  11. data/lib/hocon/impl.rb +0 -5
  12. data/lib/hocon/impl/abstract_config_object.rb +0 -64
  13. data/lib/hocon/impl/abstract_config_value.rb +0 -130
  14. data/lib/hocon/impl/config_concatenation.rb +0 -136
  15. data/lib/hocon/impl/config_float.rb +0 -9
  16. data/lib/hocon/impl/config_impl.rb +0 -10
  17. data/lib/hocon/impl/config_impl_util.rb +0 -78
  18. data/lib/hocon/impl/config_int.rb +0 -31
  19. data/lib/hocon/impl/config_number.rb +0 -27
  20. data/lib/hocon/impl/config_string.rb +0 -37
  21. data/lib/hocon/impl/full_includer.rb +0 -4
  22. data/lib/hocon/impl/origin_type.rb +0 -9
  23. data/lib/hocon/impl/parseable.rb +0 -151
  24. data/lib/hocon/impl/parser.rb +0 -882
  25. data/lib/hocon/impl/path.rb +0 -59
  26. data/lib/hocon/impl/path_builder.rb +0 -36
  27. data/lib/hocon/impl/resolve_status.rb +0 -18
  28. data/lib/hocon/impl/simple_config.rb +0 -11
  29. data/lib/hocon/impl/simple_config_list.rb +0 -70
  30. data/lib/hocon/impl/simple_config_object.rb +0 -178
  31. data/lib/hocon/impl/simple_config_origin.rb +0 -174
  32. data/lib/hocon/impl/simple_include_context.rb +0 -7
  33. data/lib/hocon/impl/simple_includer.rb +0 -19
  34. data/lib/hocon/impl/token.rb +0 -32
  35. data/lib/hocon/impl/token_type.rb +0 -42
  36. data/lib/hocon/impl/tokenizer.rb +0 -370
  37. data/lib/hocon/impl/tokens.rb +0 -157
  38. data/lib/hocon/impl/unmergeable.rb +0 -4
data/README.md CHANGED
@@ -1,10 +1,8 @@
1
- ruby-hocon
1
+ ruby-typesafe-config
2
2
  ==========
3
3
 
4
4
  This is a port of the [Typesafe Config](https://github.com/typesafehub/config) library to Ruby.
5
5
 
6
- The library provides Ruby support for the [HOCON](https://github.com/typesafehub/config/blob/master/HOCON.md) configuration file format.
7
-
8
6
  At present, the only features it supports are explicit parsing of config files (.conf/HOCON, .json, .properties) via `ConfigFactory.parse_file`, and rendering a parsed config object back to a String. Testing is minimal and not all data types are supported yet. It also does not yet support `include` or interpolated settings.
9
7
 
10
8
  The implementation is intended to be as close to a line-for-line port as the two languages allow, in hopes of making it fairly easy to port over new changesets from the Java code base over time.
@@ -13,7 +11,7 @@ Basic Usage
13
11
  ===========
14
12
 
15
13
  ```rb
16
- require 'hocon/config_factory'
14
+ require 'typesafe/config/config_factory'
17
15
 
18
- conf = Hocon::ConfigFactory.parse_file("myapp.conf")
16
+ conf = Typesafe::Config::ConfigFactory.parse_file("myapp.conf")
19
17
  conf_map = conf.root.unwrapped
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ruby_hocon
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,54 +9,18 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2014-03-16 00:00:00.000000000 Z
12
+ date: 2014-03-14 00:00:00.000000000 Z
13
13
  dependencies: []
14
- description: == A port of the Java {Typesafe Config}[https://github.com/typesafehub/config]
15
- library to Ruby
14
+ description: == This gem has been replaced by the {HOCON}[https://rubygems.org/gems/hocon]
15
+ gem
16
16
  email: chris@puppetlabs.com
17
17
  executables: []
18
18
  extensions: []
19
19
  extra_rdoc_files: []
20
20
  files:
21
- - lib/hocon.rb
22
- - lib/hocon/config_object.rb
23
- - lib/hocon/config_error.rb
24
- - lib/hocon/impl/simple_includer.rb
25
- - lib/hocon/impl/config_number.rb
26
- - lib/hocon/impl/simple_config.rb
27
- - lib/hocon/impl/config_int.rb
28
- - lib/hocon/impl/resolve_status.rb
29
- - lib/hocon/impl/simple_config_origin.rb
30
- - lib/hocon/impl/token.rb
31
- - lib/hocon/impl/config_string.rb
32
- - lib/hocon/impl/config_float.rb
33
- - lib/hocon/impl/full_includer.rb
34
- - lib/hocon/impl/parser.rb
35
- - lib/hocon/impl/tokens.rb
36
- - lib/hocon/impl/tokenizer.rb
37
- - lib/hocon/impl/abstract_config_object.rb
38
- - lib/hocon/impl/simple_include_context.rb
39
- - lib/hocon/impl/token_type.rb
40
- - lib/hocon/impl/path_builder.rb
41
- - lib/hocon/impl/parseable.rb
42
- - lib/hocon/impl/path.rb
43
- - lib/hocon/impl/unmergeable.rb
44
- - lib/hocon/impl/config_impl_util.rb
45
- - lib/hocon/impl/simple_config_object.rb
46
- - lib/hocon/impl/simple_config_list.rb
47
- - lib/hocon/impl/config_impl.rb
48
- - lib/hocon/impl/config_concatenation.rb
49
- - lib/hocon/impl/abstract_config_value.rb
50
- - lib/hocon/impl/origin_type.rb
51
- - lib/hocon/config_factory.rb
52
- - lib/hocon/impl.rb
53
- - lib/hocon/config_parse_options.rb
54
- - lib/hocon/config_render_options.rb
55
- - lib/hocon/config_value_type.rb
56
- - lib/hocon/config_syntax.rb
57
21
  - LICENSE
58
22
  - README.md
59
- homepage: https://github.com/cprice404/ruby-hocon
23
+ homepage: https://github.com/cprice404/ruby-typesafe-config
60
24
  licenses:
61
25
  - Apache License, v2
62
26
  post_install_message:
@@ -80,5 +44,5 @@ rubyforge_project:
80
44
  rubygems_version: 1.8.25
81
45
  signing_key:
82
46
  specification_version: 3
83
- summary: HOCON Config Library
47
+ summary: Typesafe Config
84
48
  test_files: []
@@ -1,2 +0,0 @@
1
- module Hocon
2
- end
@@ -1,12 +0,0 @@
1
- require 'hocon'
2
-
3
- class Hocon::ConfigError < StandardError
4
- def initialize(origin, message, cause)
5
- super(message)
6
- @origin = origin
7
- @cause = cause
8
- end
9
-
10
- class ConfigParseError < Hocon::ConfigError
11
- end
12
- end
@@ -1,9 +0,0 @@
1
- require 'hocon'
2
- require 'hocon/config_parse_options'
3
- require 'hocon/impl/parseable'
4
-
5
- class Hocon::ConfigFactory
6
- def self.parse_file(file_path, options = Hocon::ConfigParseOptions.defaults)
7
- Hocon::Impl::Parseable.new_file(file_path, options).parse.to_config
8
- end
9
- end
@@ -1,4 +0,0 @@
1
- require 'hocon'
2
-
3
- module Hocon::ConfigObject
4
- end
@@ -1,53 +0,0 @@
1
- require 'hocon'
2
-
3
- class Hocon::ConfigParseOptions
4
- attr_accessor :syntax, :origin_description, :allow_missing, :includer
5
-
6
- def self.defaults
7
- self.new(nil, nil, true, nil)
8
- end
9
-
10
- def initialize(syntax, origin_description, allow_missing, includer)
11
- @syntax = syntax
12
- @origin_description = origin_description
13
- @allow_missing = allow_missing
14
- @includer = includer
15
- end
16
-
17
- def allow_missing?
18
- @allow_missing
19
- end
20
-
21
- def with_syntax(syntax)
22
- if @syntax == syntax
23
- self
24
- else
25
- Hocon::ConfigParseOptions.new(syntax,
26
- @origin_description,
27
- @allow_missing,
28
- @includer)
29
- end
30
- end
31
-
32
- def with_includer(includer)
33
- if @includer == includer
34
- self
35
- else
36
- Hocon::ConfigParseOptions.new(@syntax,
37
- @origin_description,
38
- @allow_missing,
39
- includer)
40
- end
41
- end
42
-
43
- def append_includer(includer)
44
- if @includer == includer
45
- self
46
- elsif @includer
47
- with_includer(@includer.with_fallback(includer))
48
- else
49
- with_includer(includer)
50
- end
51
- end
52
-
53
- end
@@ -1,46 +0,0 @@
1
- require 'hocon'
2
-
3
- class Hocon::ConfigRenderOptions
4
- def initialize(origin_comments, comments, formatted, json)
5
- @origin_comments = origin_comments
6
- @comments = comments
7
- @formatted = formatted
8
- @json = json
9
- end
10
-
11
- attr_writer :origin_comments, :comments, :formatted, :json
12
-
13
- def origin_comments?
14
- @origin_comments
15
- end
16
- def comments?
17
- @comments
18
- end
19
- def formatted?
20
- @formatted
21
- end
22
- def json?
23
- @json
24
- end
25
-
26
- #
27
- # Returns the default render options which are verbose (commented and
28
- # formatted). See {@link ConfigRenderOptions#concise} for stripped-down
29
- # options. This rendering will not be valid JSON since it has comments.
30
- #
31
- # @return the default render options
32
- #
33
- def self.defaults
34
- Hocon::ConfigRenderOptions.new(true, true, true, true)
35
- end
36
-
37
- #
38
- # Returns concise render options (no whitespace or comments). For a
39
- # resolved {@link Config}, the concise rendering will be valid JSON.
40
- #
41
- # @return the concise render options
42
- #
43
- def self.concise
44
- Hocon::ConfigRenderOptions.new(false, false, false, true)
45
- end
46
- end
@@ -1,7 +0,0 @@
1
- require 'hocon'
2
-
3
- module Hocon::ConfigSyntax
4
- JSON = 0
5
- CONF = 1
6
- PROPERTIES = 2
7
- end
@@ -1,26 +0,0 @@
1
- require 'hocon'
2
-
3
- #
4
- # The type of a configuration value (following the <a
5
- # href="http://json.org">JSON</a> type schema).
6
- #
7
- module Hocon::ConfigValueType
8
- OBJECT = 0
9
- LIST = 1
10
- NUMBER = 2
11
- BOOLEAN = 3
12
- NULL = 4
13
- STRING = 5
14
-
15
- def self.name(config_value_type)
16
- case config_value_type
17
- when OBJECT then "OBJECT"
18
- when LIST then "LIST"
19
- when NUMBER then "NUMBER"
20
- when BOOLEAN then "BOOLEAN"
21
- when NULL then "NULL"
22
- when STRING then "STRING"
23
- else raise ConfigBugError, "Unrecognized value type '#{config_value_type}'"
24
- end
25
- end
26
- end
@@ -1,5 +0,0 @@
1
- require 'hocon'
2
-
3
- module Hocon::Impl
4
-
5
- end
@@ -1,64 +0,0 @@
1
- require 'hocon/impl'
2
- require 'hocon/impl/abstract_config_value'
3
- require 'hocon/impl/simple_config'
4
- require 'hocon/config_object'
5
- require 'hocon/config_value_type'
6
- require 'hocon/impl/resolve_status'
7
- require 'hocon/impl/simple_config_origin'
8
-
9
- class Hocon::Impl::AbstractConfigObject < Hocon::Impl::AbstractConfigValue
10
- include Hocon::ConfigObject
11
-
12
- def initialize(origin)
13
- super(origin)
14
- @config = Hocon::Impl::SimpleConfig.new(self)
15
- end
16
-
17
- def to_config
18
- @config
19
- end
20
-
21
- def to_fallback_value
22
- self
23
- end
24
-
25
- def value_type
26
- Hocon::ConfigValueType::OBJECT
27
- end
28
-
29
- def new_copy(origin)
30
- new_copy_with_status(resolve_status, origin)
31
- end
32
-
33
- def merge_origins(stack)
34
- if stack.empty?
35
- raise ConfigBugError, "can't merge origins on empty list"
36
- end
37
- origins = []
38
- first_origin = nil
39
- num_merged = 0
40
- stack.each do |v|
41
- if first_origin.nil?
42
- first_origin = v.origin
43
- end
44
-
45
- if (v.is_a?(Hocon::Impl::AbstractConfigObject)) &&
46
- (v.resolve_status == Hocon::Impl::ResolveStatus::RESOLVED) &&
47
- v.empty?
48
- # don't include empty files or the .empty()
49
- # config in the description, since they are
50
- # likely to be "implementation details"
51
- else
52
- origins.push(v.origin)
53
- num_merged += 1
54
- end
55
- end
56
-
57
- if num_merged == 0
58
- # the configs were all empty, so just use the first one
59
- origins.push(first_origin)
60
- end
61
-
62
- Hocon::Impl::SimpleConfigOrigin.merge_origins(origins)
63
- end
64
- end
@@ -1,130 +0,0 @@
1
- require 'hocon/impl'
2
- require 'stringio'
3
- require 'hocon/config_render_options'
4
- require 'hocon/config_object'
5
- require 'hocon/impl/resolve_status'
6
- require 'hocon/impl/unmergeable'
7
- require 'hocon/impl/abstract_config_object'
8
- require 'hocon/impl/config_impl_util'
9
-
10
- ##
11
- ## Trying very hard to avoid a parent reference in config values; when you have
12
- ## a tree like this, the availability of parent() tends to result in a lot of
13
- ## improperly-factored and non-modular code. Please don't add parent().
14
- ##
15
- class Hocon::Impl::AbstractConfigValue
16
- ConfigImplUtil = Hocon::Impl::ConfigImplUtil
17
-
18
- def initialize(origin)
19
- @origin = origin
20
- end
21
-
22
- attr_reader :origin
23
-
24
- def resolve_status
25
- Hocon::Impl::ResolveStatus::RESOLVED
26
- end
27
-
28
- # this is virtualized rather than a field because only some subclasses
29
- # really need to store the boolean, and they may be able to pack it
30
- # with another boolean to save space.
31
- def ignores_fallbacks?
32
- # if we are not resolved, then somewhere in this value there's
33
- # a substitution that may need to look at the fallbacks.
34
- resolve_status == Hocon::Impl::ResolveStatus::RESOLVED
35
- end
36
-
37
- # the withFallback() implementation is supposed to avoid calling
38
- # mergedWith* if we're ignoring fallbacks.
39
- def require_not_ignoring_fallbacks
40
- if ignores_fallbacks?
41
- raise ConfigBugError, "method should not have been called with ignoresFallbacks=true #{self.class.name}"
42
- end
43
- end
44
-
45
- def with_origin(origin)
46
- if @origin == origin
47
- self
48
- else
49
- new_copy(origin)
50
- end
51
- end
52
-
53
- def with_fallback(mergeable)
54
- if ignores_fallbacks?
55
- self
56
- else
57
- other = mergeable.to_fallback_value
58
- if other.is_a?(Hocon::Impl::Unmergeable)
59
- merged_with_the_unmergeable(other)
60
- elsif other.is_a?(Hocon::Impl::AbstractConfigObject)
61
- merged_with_object(other)
62
- else
63
- merged_with_non_object(other)
64
- end
65
- end
66
- end
67
-
68
- def to_s
69
- sb = StringIO.new
70
- render_to_sb(sb, 0, true, nil, Hocon::ConfigRenderOptions.concise)
71
- "#{self.class.name}(#{sb.string})"
72
- end
73
-
74
- def indent(sb, indent_size, options)
75
- if options.formatted?
76
- remaining = indent_size
77
- while remaining > 0
78
- sb << " "
79
- remaining -= 1
80
- end
81
- end
82
- end
83
-
84
- def render_to_sb(sb, indent, at_root, at_key, options)
85
- if !at_key.nil?
86
- rendered_key =
87
- if options.json?
88
- ConfigImplUtil.render_json_string(at_key)
89
- else
90
- ConfigImplUtil.render_string_unquoted_if_possible(at_key)
91
- end
92
-
93
- sb << rendered_key
94
-
95
- if options.json?
96
- if options.formatted?
97
- sb << " : "
98
- else
99
- sb << ":"
100
- end
101
- else
102
- # in non-JSON we can omit the colon or equals before an object
103
- if self.is_a?(Hocon::ConfigObject)
104
- if options.formatted?
105
- sb << ' '
106
- end
107
- else
108
- sb << "="
109
- end
110
- end
111
- end
112
- render_value_to_sb(sb, indent, at_root, options)
113
- end
114
-
115
- # to be overridden by subclasses
116
- def render_value_to_sb(sb, indent, at_root, options)
117
- u = unwrapped
118
- sb << u.to_s
119
- end
120
-
121
- def render(options = Hocon::ConfigRenderOptions.defaults)
122
- sb = StringIO.new
123
- render_to_sb(sb, 0, true, nil, options)
124
- # We take a substring that ends at sb.pos, because we've been decrementing
125
- # sb.pos at various points in the code as a means to remove characters from
126
- # the end of the StringIO
127
- sb.string[0, sb.pos]
128
- end
129
-
130
- end