config-file 1.0.1 → 1.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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: afcd10b8ee5e413312dbc0c9b892872d4d95603a
4
- data.tar.gz: d1ecc1d5c986192dcdbea8132390d4deff7b8ab9
3
+ metadata.gz: a6df8f4a58d923a9f8c8ecae385595bb6831b953
4
+ data.tar.gz: a6449fee4d3e15695880ba22f6bb662416e92db8
5
5
  SHA512:
6
- metadata.gz: e902f7c3f783d3ebc9b74d03ccec754bb9baf59e31eb7fe63a803b52541bb7e11cbdc122666efaf955d5dc4b3698e32fb07cb5f3b909fa96c85974298cf1042c
7
- data.tar.gz: 9343dbeef9af122582d6065208d46205130996b4de0a777b5d3aa0ac271501c9a416390d6b75cbf7d208e717669e5b5c4a09c68743a8495b336d59eb757b7f73
6
+ metadata.gz: ecf42a8bd28d51ec3365b0999ca42463711a70025e55e80f7b8fc1ed22bb3eb8af4dc2da4362b99c0b82b29347ef3a93ce657410e1c4aa9021741a5bf81e18bb
7
+ data.tar.gz: dd8db24bcf30e8e458f9d69345be666d0c29b8f7bfdc0b1c7b326471dc268b3f5879bf033168c3cf64011982e8430b5a6ccd11f033fb8e47fa9cacaac5b1e664
@@ -97,6 +97,44 @@
97
97
  <ConfigurationWrapper RunnerId="RubyDebugRunner" />
98
98
  <method />
99
99
  </configuration>
100
+ <configuration default="false" name="ConfigFile reads from json: config-file" type="RSpecRunConfigurationType" factoryName="RSpec" temporary="true">
101
+ <predefined_log_file id="RUBY_RSPEC" enabled="true" />
102
+ <module name="config-file" />
103
+ <RSPEC_RUN_CONFIG_SETTINGS_ID NAME="RUBY_ARGS" VALUE="-e $stdout.sync=true;$stderr.sync=true;load($0=ARGV.shift)" />
104
+ <RSPEC_RUN_CONFIG_SETTINGS_ID NAME="WORK DIR" VALUE="$MODULE_DIR$" />
105
+ <RSPEC_RUN_CONFIG_SETTINGS_ID NAME="SHOULD_USE_SDK" VALUE="false" />
106
+ <RSPEC_RUN_CONFIG_SETTINGS_ID NAME="ALTERN_SDK_NAME" VALUE="" />
107
+ <RSPEC_RUN_CONFIG_SETTINGS_ID NAME="myPassParentEnvs" VALUE="true" />
108
+ <envs>
109
+ <env name="JRUBY_OPTS" value="-X+O" />
110
+ </envs>
111
+ <EXTENSION ID="BundlerRunConfigurationExtension" bundleExecEnabled="true" />
112
+ <EXTENSION ID="JRubyRunConfigurationExtension" NailgunExecEnabled="false" />
113
+ <EXTENSION ID="RubyCoverageRunConfigurationExtension" enabled="false" sample_coverage="true" track_test_folders="true" runner="rcov">
114
+ <COVERAGE_PATTERN ENABLED="true">
115
+ <PATTERN REGEXPS="/.rvm/" INCLUDED="false" />
116
+ </COVERAGE_PATTERN>
117
+ </EXTENSION>
118
+ <EXTENSION ID="org.jetbrains.plugins.ruby.motion.run.MotionSimulatorRunExtension" />
119
+ <RSPEC_RUN_CONFIG_SETTINGS_ID NAME="TESTS_FOLDER_PATH" VALUE="" />
120
+ <RSPEC_RUN_CONFIG_SETTINGS_ID NAME="TEST_SCRIPT_PATH" VALUE="$MODULE_DIR$/spec/config_file_spec.rb" />
121
+ <RSPEC_RUN_CONFIG_SETTINGS_ID NAME="SPEC_RUNNER_PATH" VALUE="" />
122
+ <RSPEC_RUN_CONFIG_SETTINGS_ID NAME="TEST_FILE_MASK" VALUE="**/*_spec.rb" />
123
+ <RSPEC_RUN_CONFIG_SETTINGS_ID NAME="SPEC_EXAMPLE_NAME" VALUE="ConfigFile reads from json" />
124
+ <RSPEC_RUN_CONFIG_SETTINGS_ID NAME="TEST_TEST_TYPE" VALUE="TEST_SCRIPT" />
125
+ <RSPEC_RUN_CONFIG_SETTINGS_ID NAME="SPEC_ARGS" VALUE="" />
126
+ <RSPEC_RUN_CONFIG_SETTINGS_ID NAME="RUNNER_VERSION" VALUE="" />
127
+ <RSPEC_RUN_CONFIG_SETTINGS_ID NAME="USE_CUSTOM_SPEC_RUNNER" VALUE="false" />
128
+ <RSPEC_RUN_CONFIG_SETTINGS_ID NAME="DRB" VALUE="false" />
129
+ <RSPEC_RUN_CONFIG_SETTINGS_ID NAME="ZEUS" VALUE="false" />
130
+ <RSPEC_RUN_CONFIG_SETTINGS_ID NAME="SPRING" VALUE="false" />
131
+ <RSPEC_RUN_CONFIG_SETTINGS_ID NAME="FULL_BACKTRACE" VALUE="false" />
132
+ <RunnerSettings RunnerId="RubyDebugRunner" />
133
+ <RunnerSettings RunnerId="RubyRunner" />
134
+ <ConfigurationWrapper RunnerId="RubyDebugRunner" />
135
+ <ConfigurationWrapper RunnerId="RubyRunner" />
136
+ <method />
137
+ </configuration>
100
138
  </component>
101
139
  <component name="NewModuleRootManager">
102
140
  <content url="file://$MODULE_DIR$" />
@@ -107,12 +145,12 @@
107
145
  <orderEntry type="library" scope="PROVIDED" name="file_utils (v1.0.7, RVM: ruby-2.1.4 [config_file]) [gem]" level="application" />
108
146
  <orderEntry type="library" scope="PROVIDED" name="gemcutter (v0.7.1, RVM: ruby-2.1.4 [config_file]) [gem]" level="application" />
109
147
  <orderEntry type="library" scope="PROVIDED" name="gemspec_deps_gen (v1.1.2, RVM: ruby-2.1.4 [config_file]) [gem]" level="application" />
110
- <orderEntry type="library" scope="PROVIDED" name="json (v1.8.1, RVM: ruby-2.1.4 [config_file]) [gem]" level="application" />
111
148
  <orderEntry type="library" scope="PROVIDED" name="meta_methods (v1.3.0, RVM: ruby-2.1.4 [config_file]) [gem]" level="application" />
112
149
  <orderEntry type="library" scope="PROVIDED" name="rspec (v3.1.0, RVM: ruby-2.1.4 [config_file]) [gem]" level="application" />
113
150
  <orderEntry type="library" scope="PROVIDED" name="rspec-core (v3.1.7, RVM: ruby-2.1.4 [config_file]) [gem]" level="application" />
114
151
  <orderEntry type="library" scope="PROVIDED" name="rspec-expectations (v3.1.2, RVM: ruby-2.1.4 [config_file]) [gem]" level="application" />
115
152
  <orderEntry type="library" scope="PROVIDED" name="rspec-mocks (v3.1.3, RVM: ruby-2.1.4 [config_file]) [gem]" level="application" />
116
153
  <orderEntry type="library" scope="PROVIDED" name="rspec-support (v3.1.2, RVM: ruby-2.1.4 [config_file]) [gem]" level="application" />
154
+ <orderEntry type="library" scope="PROVIDED" name="text-interpolator (v1.1.6, RVM: ruby-2.1.4 [config_file]) [gem]" level="application" />
117
155
  </component>
118
156
  </module>
data/CHANGES CHANGED
@@ -7,3 +7,7 @@
7
7
  == Version 1.0.1
8
8
 
9
9
  * Refactoring code.
10
+
11
+ == Version 1.0.2
12
+
13
+ * Adding text interpolation for json format.
data/Gemfile CHANGED
@@ -3,6 +3,7 @@ source "https://rubygems.org"
3
3
  group :default do
4
4
  gem "meta_methods"
5
5
  gem "json"
6
+ gem "text-interpolator"
6
7
  end
7
8
 
8
9
  group :development do
data/Gemfile.lock CHANGED
@@ -21,6 +21,7 @@ GEM
21
21
  rspec-mocks (3.1.3)
22
22
  rspec-support (~> 3.1.0)
23
23
  rspec-support (3.1.2)
24
+ text-interpolator (1.1.6)
24
25
 
25
26
  PLATFORMS
26
27
  ruby
@@ -31,3 +32,4 @@ DEPENDENCIES
31
32
  json
32
33
  meta_methods
33
34
  rspec
35
+ text-interpolator
data/README.md CHANGED
@@ -22,11 +22,12 @@ Or install it yourself as:
22
22
  ```ruby
23
23
  require 'config_file'
24
24
 
25
- config_file = ConfigFile.bew
25
+ config_file = ConfigFile.new
26
26
 
27
27
  config1 = config_file.load "spec/config/test_config.yaml"
28
28
  config2 = config_file.load "spec/config/test_config.json"
29
29
  config3 = config_file.load "spec/config/test_config.rb"
30
+ config4 = config_file.load "spec/config/.test_config", ".rb"
30
31
  ```
31
32
 
32
33
  ## Contributing
data/config-file.gemspec CHANGED
@@ -19,6 +19,7 @@ Gem::Specification.new do |spec|
19
19
 
20
20
  spec.add_runtime_dependency "meta_methods", [">= 0"]
21
21
  spec.add_runtime_dependency "json", [">= 0"]
22
+ spec.add_runtime_dependency "text-interpolator", [">= 0"]
22
23
  spec.add_development_dependency "gemspec_deps_gen", [">= 0"]
23
24
  spec.add_development_dependency "gemcutter", [">= 0"]
24
25
 
@@ -1,6 +1,7 @@
1
1
  require 'meta_methods/core'
2
2
  require 'yaml'
3
3
  require 'json'
4
+ require 'text_interpolator'
4
5
 
5
6
  require 'config_file/config_file'
6
7
 
@@ -25,7 +26,7 @@ class ConfigType
25
26
  end
26
27
 
27
28
  def read file_name
28
- content = File.open(file_name).read
29
+ content = File.read(file_name)
29
30
 
30
31
  MetaMethods::Core.instance.block_to_hash(content)
31
32
  end
@@ -39,9 +40,13 @@ class ConfigType
39
40
  end
40
41
 
41
42
  def read file_name
42
- content = File.open(file_name).read
43
+ interpolator = TextInterpolator.new
43
44
 
44
- ::JSON.parse(content)
45
+ content = File.read(file_name)
46
+
47
+ hash = ::JSON.parse(content, :symbolize_names => true)
48
+
49
+ interpolator.interpolate hash
45
50
  end
46
51
  end
47
52
  end
@@ -1,3 +1,3 @@
1
1
  class ConfigFile
2
- VERSION = "1.0.1"
2
+ VERSION = "1.0.2"
3
3
  end
@@ -14,8 +14,8 @@ describe ConfigFile do
14
14
  it "reads from json" do
15
15
  config = subject.load "spec/config/test_config.json"
16
16
 
17
- expect(config['property1']).to eq "value1"
18
- expect(config['property2']['property21']).to eq "value21"
17
+ expect(config[:property1]).to eq "value1"
18
+ expect(config[:property2][:property21]).to eq "value21"
19
19
  end
20
20
 
21
21
  it "reads from ruby fragment" do
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: config-file
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.1
4
+ version: 1.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Alexander Shvets
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-11-08 00:00:00.000000000 Z
11
+ date: 2014-11-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: meta_methods
@@ -38,6 +38,20 @@ dependencies:
38
38
  - - ">="
39
39
  - !ruby/object:Gem::Version
40
40
  version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: text-interpolator
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
41
55
  - !ruby/object:Gem::Dependency
42
56
  name: gemspec_deps_gen
43
57
  requirement: !ruby/object:Gem::Requirement