config-file 1.0.2 → 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
  SHA1:
3
- metadata.gz: a6df8f4a58d923a9f8c8ecae385595bb6831b953
4
- data.tar.gz: a6449fee4d3e15695880ba22f6bb662416e92db8
3
+ metadata.gz: 287a40e5b7d3db007a64b998ec2f36f3b4168677
4
+ data.tar.gz: 56e740003bb1ae027031bc7797b21cf81ba5857d
5
5
  SHA512:
6
- metadata.gz: ecf42a8bd28d51ec3365b0999ca42463711a70025e55e80f7b8fc1ed22bb3eb8af4dc2da4362b99c0b82b29347ef3a93ce657410e1c4aa9021741a5bf81e18bb
7
- data.tar.gz: dd8db24bcf30e8e458f9d69345be666d0c29b8f7bfdc0b1c7b326471dc268b3f5879bf033168c3cf64011982e8430b5a6ccd11f033fb8e47fa9cacaac5b1e664
6
+ metadata.gz: 56043d0f9cab3edb11fc9be3cd2e1f0e4c92e7c76286d254ff991bec30daba29b3bdcad261cf81bbea694ecff54205232db406c10f3d506d20610a9d80a593b2
7
+ data.tar.gz: 672f5763fc0f8184f2cbd28eccc722fe7d5019879788aa3f49dca08e7e80f7e3673b2e6454bdfce34ca9345dac0960264a01ec2218912b9c9738e0770003aef5
@@ -10,19 +10,6 @@
10
10
  </facet>
11
11
  </component>
12
12
  <component name="ModuleRunConfigurationManager">
13
- <configuration default="false" name="tut.double" type="ErlangApplicationRunConfiguration" factoryName="Erlang Application" temporary="true">
14
- <module name="config-file" />
15
- <option name="erlFlags" value="" />
16
- <option name="moduleAndFunction" value="tut double" />
17
- <option name="name" value="tut.double" />
18
- <option name="params" value="" />
19
- <option name="saveOutputToFile" value="false" />
20
- <option name="showConsoleOnStdErr" value="false" />
21
- <option name="showConsoleOnStdOut" value="false" />
22
- <RunnerSettings RunnerId="ErlangRunner" />
23
- <ConfigurationWrapper RunnerId="ErlangRunner" />
24
- <method />
25
- </configuration>
26
13
  <configuration default="false" name="Run spec 'config_file_spec': config-file" type="RSpecRunConfigurationType" factoryName="RSpec" temporary="true">
27
14
  <predefined_log_file id="RUBY_RSPEC" enabled="true" />
28
15
  <module name="config-file" />
@@ -135,6 +122,80 @@
135
122
  <ConfigurationWrapper RunnerId="RubyRunner" />
136
123
  <method />
137
124
  </configuration>
125
+ <configuration default="false" name="ConfigFile : config-file" type="RSpecRunConfigurationType" factoryName="RSpec" temporary="true">
126
+ <predefined_log_file id="RUBY_RSPEC" enabled="true" />
127
+ <module name="config-file" />
128
+ <RSPEC_RUN_CONFIG_SETTINGS_ID NAME="RUBY_ARGS" VALUE="-e $stdout.sync=true;$stderr.sync=true;load($0=ARGV.shift)" />
129
+ <RSPEC_RUN_CONFIG_SETTINGS_ID NAME="WORK DIR" VALUE="$MODULE_DIR$" />
130
+ <RSPEC_RUN_CONFIG_SETTINGS_ID NAME="SHOULD_USE_SDK" VALUE="false" />
131
+ <RSPEC_RUN_CONFIG_SETTINGS_ID NAME="ALTERN_SDK_NAME" VALUE="" />
132
+ <RSPEC_RUN_CONFIG_SETTINGS_ID NAME="myPassParentEnvs" VALUE="true" />
133
+ <envs>
134
+ <env name="JRUBY_OPTS" value="-X+O" />
135
+ </envs>
136
+ <EXTENSION ID="BundlerRunConfigurationExtension" bundleExecEnabled="true" />
137
+ <EXTENSION ID="JRubyRunConfigurationExtension" NailgunExecEnabled="false" />
138
+ <EXTENSION ID="RubyCoverageRunConfigurationExtension" enabled="false" sample_coverage="true" track_test_folders="true" runner="rcov">
139
+ <COVERAGE_PATTERN ENABLED="true">
140
+ <PATTERN REGEXPS="/.rvm/" INCLUDED="false" />
141
+ </COVERAGE_PATTERN>
142
+ </EXTENSION>
143
+ <EXTENSION ID="org.jetbrains.plugins.ruby.motion.run.MotionSimulatorRunExtension" />
144
+ <RSPEC_RUN_CONFIG_SETTINGS_ID NAME="TESTS_FOLDER_PATH" VALUE="" />
145
+ <RSPEC_RUN_CONFIG_SETTINGS_ID NAME="TEST_SCRIPT_PATH" VALUE="$MODULE_DIR$/spec/config_file_spec.rb" />
146
+ <RSPEC_RUN_CONFIG_SETTINGS_ID NAME="SPEC_RUNNER_PATH" VALUE="" />
147
+ <RSPEC_RUN_CONFIG_SETTINGS_ID NAME="TEST_FILE_MASK" VALUE="**/*_spec.rb" />
148
+ <RSPEC_RUN_CONFIG_SETTINGS_ID NAME="SPEC_EXAMPLE_NAME" VALUE="ConfigFile " />
149
+ <RSPEC_RUN_CONFIG_SETTINGS_ID NAME="TEST_TEST_TYPE" VALUE="TEST_SCRIPT" />
150
+ <RSPEC_RUN_CONFIG_SETTINGS_ID NAME="SPEC_ARGS" VALUE="" />
151
+ <RSPEC_RUN_CONFIG_SETTINGS_ID NAME="RUNNER_VERSION" VALUE="" />
152
+ <RSPEC_RUN_CONFIG_SETTINGS_ID NAME="USE_CUSTOM_SPEC_RUNNER" VALUE="false" />
153
+ <RSPEC_RUN_CONFIG_SETTINGS_ID NAME="DRB" VALUE="false" />
154
+ <RSPEC_RUN_CONFIG_SETTINGS_ID NAME="ZEUS" VALUE="false" />
155
+ <RSPEC_RUN_CONFIG_SETTINGS_ID NAME="SPRING" VALUE="false" />
156
+ <RSPEC_RUN_CONFIG_SETTINGS_ID NAME="FULL_BACKTRACE" VALUE="false" />
157
+ <RunnerSettings RunnerId="RubyDebugRunner" />
158
+ <ConfigurationWrapper RunnerId="RubyDebugRunner" />
159
+ <method />
160
+ </configuration>
161
+ <configuration default="false" name="ConfigFile registers and uses xml format: config-file" type="RSpecRunConfigurationType" factoryName="RSpec" temporary="true">
162
+ <predefined_log_file id="RUBY_RSPEC" enabled="true" />
163
+ <module name="config-file" />
164
+ <RSPEC_RUN_CONFIG_SETTINGS_ID NAME="RUBY_ARGS" VALUE="-e $stdout.sync=true;$stderr.sync=true;load($0=ARGV.shift)" />
165
+ <RSPEC_RUN_CONFIG_SETTINGS_ID NAME="WORK DIR" VALUE="$MODULE_DIR$" />
166
+ <RSPEC_RUN_CONFIG_SETTINGS_ID NAME="SHOULD_USE_SDK" VALUE="false" />
167
+ <RSPEC_RUN_CONFIG_SETTINGS_ID NAME="ALTERN_SDK_NAME" VALUE="" />
168
+ <RSPEC_RUN_CONFIG_SETTINGS_ID NAME="myPassParentEnvs" VALUE="true" />
169
+ <envs>
170
+ <env name="JRUBY_OPTS" value="-X+O" />
171
+ </envs>
172
+ <EXTENSION ID="BundlerRunConfigurationExtension" bundleExecEnabled="true" />
173
+ <EXTENSION ID="JRubyRunConfigurationExtension" NailgunExecEnabled="false" />
174
+ <EXTENSION ID="RubyCoverageRunConfigurationExtension" enabled="false" sample_coverage="true" track_test_folders="true" runner="rcov">
175
+ <COVERAGE_PATTERN ENABLED="true">
176
+ <PATTERN REGEXPS="/.rvm/" INCLUDED="false" />
177
+ </COVERAGE_PATTERN>
178
+ </EXTENSION>
179
+ <EXTENSION ID="org.jetbrains.plugins.ruby.motion.run.MotionSimulatorRunExtension" />
180
+ <RSPEC_RUN_CONFIG_SETTINGS_ID NAME="TESTS_FOLDER_PATH" VALUE="" />
181
+ <RSPEC_RUN_CONFIG_SETTINGS_ID NAME="TEST_SCRIPT_PATH" VALUE="$MODULE_DIR$/spec/config_file_spec.rb" />
182
+ <RSPEC_RUN_CONFIG_SETTINGS_ID NAME="SPEC_RUNNER_PATH" VALUE="" />
183
+ <RSPEC_RUN_CONFIG_SETTINGS_ID NAME="TEST_FILE_MASK" VALUE="**/*_spec.rb" />
184
+ <RSPEC_RUN_CONFIG_SETTINGS_ID NAME="SPEC_EXAMPLE_NAME" VALUE="ConfigFile registers and uses xml format" />
185
+ <RSPEC_RUN_CONFIG_SETTINGS_ID NAME="TEST_TEST_TYPE" VALUE="TEST_SCRIPT" />
186
+ <RSPEC_RUN_CONFIG_SETTINGS_ID NAME="SPEC_ARGS" VALUE="" />
187
+ <RSPEC_RUN_CONFIG_SETTINGS_ID NAME="RUNNER_VERSION" VALUE="" />
188
+ <RSPEC_RUN_CONFIG_SETTINGS_ID NAME="USE_CUSTOM_SPEC_RUNNER" VALUE="false" />
189
+ <RSPEC_RUN_CONFIG_SETTINGS_ID NAME="DRB" VALUE="false" />
190
+ <RSPEC_RUN_CONFIG_SETTINGS_ID NAME="ZEUS" VALUE="false" />
191
+ <RSPEC_RUN_CONFIG_SETTINGS_ID NAME="SPRING" VALUE="false" />
192
+ <RSPEC_RUN_CONFIG_SETTINGS_ID NAME="FULL_BACKTRACE" VALUE="false" />
193
+ <RunnerSettings RunnerId="RubyDebugRunner" />
194
+ <RunnerSettings RunnerId="RubyRunner" />
195
+ <ConfigurationWrapper RunnerId="RubyDebugRunner" />
196
+ <ConfigurationWrapper RunnerId="RubyRunner" />
197
+ <method />
198
+ </configuration>
138
199
  </component>
139
200
  <component name="NewModuleRootManager">
140
201
  <content url="file://$MODULE_DIR$" />
@@ -145,6 +206,7 @@
145
206
  <orderEntry type="library" scope="PROVIDED" name="file_utils (v1.0.7, RVM: ruby-2.1.4 [config_file]) [gem]" level="application" />
146
207
  <orderEntry type="library" scope="PROVIDED" name="gemcutter (v0.7.1, RVM: ruby-2.1.4 [config_file]) [gem]" level="application" />
147
208
  <orderEntry type="library" scope="PROVIDED" name="gemspec_deps_gen (v1.1.2, RVM: ruby-2.1.4 [config_file]) [gem]" level="application" />
209
+ <orderEntry type="library" scope="PROVIDED" name="json (v1.8.1, RVM: ruby-2.1.4 [config_file]) [gem]" level="application" />
148
210
  <orderEntry type="library" scope="PROVIDED" name="meta_methods (v1.3.0, RVM: ruby-2.1.4 [config_file]) [gem]" level="application" />
149
211
  <orderEntry type="library" scope="PROVIDED" name="rspec (v3.1.0, RVM: ruby-2.1.4 [config_file]) [gem]" level="application" />
150
212
  <orderEntry type="library" scope="PROVIDED" name="rspec-core (v3.1.7, RVM: ruby-2.1.4 [config_file]) [gem]" level="application" />
data/CHANGES CHANGED
@@ -11,3 +11,7 @@
11
11
  == Version 1.0.2
12
12
 
13
13
  * Adding text interpolation for json format.
14
+
15
+ == Version 1.1.0
16
+
17
+ * Rename load method to read.
data/Gemfile CHANGED
@@ -4,6 +4,8 @@ group :default do
4
4
  gem "meta_methods"
5
5
  gem "json"
6
6
  gem "text-interpolator"
7
+ # gem "nokogiri"
8
+ # gem "activesupport"
7
9
  end
8
10
 
9
11
  group :development do
data/README.md CHANGED
@@ -24,10 +24,10 @@ require 'config_file'
24
24
 
25
25
  config_file = ConfigFile.new
26
26
 
27
- config1 = config_file.load "spec/config/test_config.yaml"
28
- config2 = config_file.load "spec/config/test_config.json"
29
- config3 = config_file.load "spec/config/test_config.rb"
30
- config4 = config_file.load "spec/config/.test_config", ".rb"
27
+ config1 = config_file.read "spec/config/test_config.yaml"
28
+ config2 = config_file.read "spec/config/test_config.json"
29
+ config3 = config_file.read "spec/config/test_config.rb"
30
+ config4 = config_file.read "spec/config/.test_config", ".rb"
31
31
  ```
32
32
 
33
33
  ## Contributing
@@ -11,7 +11,7 @@ class ConfigFile
11
11
 
12
12
  attr_reader :config
13
13
 
14
- def load file_name, ext=nil
14
+ def read file_name, ext=nil
15
15
  ext = File.extname(file_name) unless ext
16
16
 
17
17
  config_file_type = ConfigFile.type(ext)
@@ -1,3 +1,3 @@
1
1
  class ConfigFile
2
- VERSION = "1.0.2"
2
+ VERSION = "1.1.0"
3
3
  end
@@ -0,0 +1,11 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+
3
+ <properties>
4
+ <property name="property1" value="value1"/>
5
+ <property>
6
+ <name>property2</name>
7
+ <value>value2</value>
8
+ </property>
9
+
10
+ <property name="property3" value="#{properties.property1}123"/>
11
+ </properties>
@@ -5,21 +5,21 @@ require 'config_file'
5
5
  describe ConfigFile do
6
6
 
7
7
  it "reads from yaml" do
8
- config = subject.load "spec/config/test_config.yaml"
8
+ config = subject.read "spec/config/test_config.yaml"
9
9
 
10
10
  expect(config['property1']).to eq "value1"
11
11
  expect(config['property2']['property21']).to eq "value21"
12
12
  end
13
13
 
14
14
  it "reads from json" do
15
- config = subject.load "spec/config/test_config.json"
15
+ config = subject.read "spec/config/test_config.json"
16
16
 
17
17
  expect(config[:property1]).to eq "value1"
18
18
  expect(config[:property2][:property21]).to eq "value21"
19
19
  end
20
20
 
21
21
  it "reads from ruby fragment" do
22
- config = subject.load "spec/config/test_config.rb"
22
+ config = subject.read "spec/config/test_config.rb"
23
23
 
24
24
  expect(config[:property1]).to eq "value1"
25
25
  expect(config[:property2][:property21]).to eq "value21"
@@ -27,7 +27,36 @@ describe ConfigFile do
27
27
 
28
28
  it "raises exception for unsupported type" do
29
29
  expect {
30
- subject.load "spec/config/test_config.pdf"
30
+ subject.read "spec/config/test_config.pdf"
31
31
  }.to raise_exception(ArgumentError)
32
32
  end
33
+
34
+ # it "registers and uses xml format" do
35
+ # require 'nokogiri'
36
+ # require 'active_support/core_ext/hash'
37
+ #
38
+ # require 'config_file/config_file'
39
+ #
40
+ # class ConfigType
41
+ # class Xml
42
+ # ConfigFile.register(self)
43
+ #
44
+ # def self.extensions
45
+ # [".xml"]
46
+ # end
47
+ #
48
+ # def read file_name
49
+ # doc = Nokogiri::XML(File.read(file_name))
50
+ #
51
+ # HashWithIndifferentAccess.new Hash.from_xml(doc.to_s)
52
+ # end
53
+ # end
54
+ # end
55
+ #
56
+ # config_file = ConfigFile.new
57
+ #
58
+ # config = config_file.load("spec/config/test_config.xml")
59
+ #
60
+ # p config
61
+ # end
33
62
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: config-file
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.2
4
+ version: 1.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Alexander Shvets
@@ -113,6 +113,7 @@ files:
113
113
  - lib/config_file/version.rb
114
114
  - spec/config/test_config.json
115
115
  - spec/config/test_config.rb
116
+ - spec/config/test_config.xml
116
117
  - spec/config/test_config.yaml
117
118
  - spec/config_file_spec.rb
118
119
  - spec/spec_helper.rb
@@ -143,6 +144,7 @@ summary: Simple library for reading configuration from different sources.
143
144
  test_files:
144
145
  - spec/config/test_config.json
145
146
  - spec/config/test_config.rb
147
+ - spec/config/test_config.xml
146
148
  - spec/config/test_config.yaml
147
149
  - spec/config_file_spec.rb
148
150
  - spec/spec_helper.rb