tiny_settings 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 86c5746483717931cf968369ffce017e993bd006c03b66395a593f739757a202
4
+ data.tar.gz: 9adb3e639fed3e8c7dacc6fb439811696cb6a74c40ad0386ebf595916e231788
5
+ SHA512:
6
+ metadata.gz: 3e12bf115695a644d848f29e7d6fdbe16f5b29d5fe584220505ded944626abe1095372c8f998c53cba4eea9b08bb7cd5af6e5fa7fdf4d804e0d8536e2b56aee9
7
+ data.tar.gz: 5c660f780673d062acea72ee48965154373c08525f9f75923bd86c97aa40e8b18dae22fa2baf6a68ae5b284adaf3b5ece8519c8d0aac4ef1fb822a0bd4bd2f12
@@ -0,0 +1,9 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
@@ -0,0 +1,13 @@
1
+ language: ruby
2
+ services:
3
+ - docker
4
+ rvm:
5
+ - 2.2.2
6
+ - 2.3
7
+ - 2.4
8
+ - jruby
9
+
10
+ install:
11
+ - bundle install
12
+ script:
13
+ - bundle exec rake test
data/Gemfile ADDED
@@ -0,0 +1,10 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in tiny_settings.gemspec
4
+ gemspec
5
+
6
+ group :development, :test do
7
+ gem 'test-unit'
8
+ gem 'test-unit-activesupport'
9
+ gem 'guard'
10
+ end
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2017 inpwjp
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
@@ -0,0 +1,42 @@
1
+ # TinySettings
2
+ [![Build Status](https://travis-ci.org/inpwjp/tiny-settings.svg?branch=master)](https://travis-ci.org/inpwjp/tiny-settings)
3
+
4
+ Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/tiny_settings`. To experiment with that code, run `bin/console` for an interactive prompt.
5
+
6
+ TODO: Delete this and the text above, and describe your gem
7
+
8
+ ## Installation
9
+
10
+ Add this line to your application's Gemfile:
11
+
12
+ ```ruby
13
+ gem 'tiny_settings'
14
+ ```
15
+
16
+ And then execute:
17
+
18
+ $ bundle
19
+
20
+ Or install it yourself as:
21
+
22
+ $ gem install tiny_settings
23
+
24
+ ## Usage
25
+
26
+ TODO: Write usage instructions here
27
+
28
+ ## Development
29
+
30
+ After checking out the repo, run `bin/setup` to install dependencies. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
31
+
32
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
33
+
34
+ ## Contributing
35
+
36
+ Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/tiny_settings.
37
+
38
+
39
+ ## License
40
+
41
+ The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
42
+
@@ -0,0 +1,15 @@
1
+ require "bundler/gem_tasks"
2
+
3
+ require 'rake/testtask'
4
+ require 'active_support'
5
+
6
+ task :default => :test
7
+
8
+ desc 'Run test_unit based test'
9
+ Rake::TestTask.new do |t|
10
+ # To run test for only one file (or file path pattern)
11
+ # $ bundle exec rake test TEST=test/test_specified_path.rb
12
+ t.test_files = Dir["test/test_*.rb"]
13
+ t.verbose = true
14
+ t.warning = false
15
+ end
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "tiny_settings"
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ # (If you use this, don't forget to add pry to your Gemfile!)
10
+ # require "pry"
11
+ # Pry.start
12
+
13
+ require "irb"
14
+ IRB.start
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,43 @@
1
+ require "tiny_settings/version"
2
+ require "methodize/hash"
3
+ require "yaml"
4
+
5
+ module TinySettings
6
+ class Settings
7
+ attr_accessor :file_path,:settings
8
+ FILE_PATH = Dir.pwd
9
+
10
+ def initialize()
11
+ @file_path ||= [FILE_PATH ,"/", "settings.yml"].join
12
+ @settings = {}
13
+ self
14
+ end
15
+
16
+ def load
17
+ begin
18
+ @settings = YAML.load_file(@file_path)
19
+ rescue
20
+ {}
21
+ end
22
+ end
23
+
24
+ def save
25
+ File.open(@file_path, 'w') do |f|
26
+ f.write @settings.to_yaml
27
+ end
28
+ end
29
+
30
+ def symbolize_keys
31
+ self.settings.map{|k,v| [k.to_sym, v] }.to_h
32
+ end
33
+
34
+ def methodize!
35
+ self.settings.methodize!
36
+ end
37
+
38
+ def symbolize_keys!
39
+ tmp_hash = symbolize_keys
40
+ self.settings = tmp_hash
41
+ end
42
+ end
43
+ end
@@ -0,0 +1,3 @@
1
+ module TinySettings
2
+ VERSION = "0.0.1"
3
+ end
@@ -0,0 +1,33 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'tiny_settings/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "tiny_settings"
8
+ spec.version = TinySettings::VERSION
9
+ spec.authors = ["inpwjp"]
10
+ spec.email = ["inpw@mua.biglobe.ne.jp"]
11
+
12
+ spec.summary = %q{get settings from yaml and ENV.}
13
+ spec.description = %q{many settings from yaml file and ENVIROMENT.get ENV (ex docker) and set the yaml file.}
14
+ spec.homepage = "https://www.github.com/inpwjp/tiny_settings"
15
+ spec.license = "MIT"
16
+
17
+ # Prevent pushing this gem to RubyGems.org. To allow pushes either set the 'allowed_push_host'
18
+ # to allow pushing to a single host or delete this section to allow pushing to any host.
19
+ # if spec.respond_to?(:metadata)
20
+ # spec.metadata['allowed_push_host'] = "rubygems.com'"
21
+ # else
22
+ # raise "RubyGems 2.0 or newer is required to protect against public gem pushes."
23
+ # end
24
+
25
+ spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
26
+ spec.bindir = "exe"
27
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
28
+ spec.require_paths = ["lib"]
29
+
30
+ spec.add_development_dependency "bundler", "~> 1.12"
31
+ spec.add_development_dependency "rake", "~> 10.0"
32
+ spec.add_development_dependency "methodize"
33
+ end
metadata ADDED
@@ -0,0 +1,97 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: tiny_settings
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - inpwjp
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2020-09-27 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.12'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.12'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '10.0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '10.0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: methodize
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
+ description: many settings from yaml file and ENVIROMENT.get ENV (ex docker) and set
56
+ the yaml file.
57
+ email:
58
+ - inpw@mua.biglobe.ne.jp
59
+ executables: []
60
+ extensions: []
61
+ extra_rdoc_files: []
62
+ files:
63
+ - ".gitignore"
64
+ - ".travis.yml"
65
+ - Gemfile
66
+ - LICENSE.txt
67
+ - README.md
68
+ - Rakefile
69
+ - bin/console
70
+ - bin/setup
71
+ - lib/tiny_settings.rb
72
+ - lib/tiny_settings/version.rb
73
+ - tiny_settings.gemspec
74
+ homepage: https://www.github.com/inpwjp/tiny_settings
75
+ licenses:
76
+ - MIT
77
+ metadata: {}
78
+ post_install_message:
79
+ rdoc_options: []
80
+ require_paths:
81
+ - lib
82
+ required_ruby_version: !ruby/object:Gem::Requirement
83
+ requirements:
84
+ - - ">="
85
+ - !ruby/object:Gem::Version
86
+ version: '0'
87
+ required_rubygems_version: !ruby/object:Gem::Requirement
88
+ requirements:
89
+ - - ">="
90
+ - !ruby/object:Gem::Version
91
+ version: '0'
92
+ requirements: []
93
+ rubygems_version: 3.0.3
94
+ signing_key:
95
+ specification_version: 4
96
+ summary: get settings from yaml and ENV.
97
+ test_files: []