envify 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: d706532a5b69f3eaed05ef843c96682a022c51b6794d6ff43546ae94a05895ae
4
+ data.tar.gz: 9f6d96d7c4de0c9b9785d113cf232db6def771debfa6d35fda739babfaca327c
5
+ SHA512:
6
+ metadata.gz: a88d5f80efcf12d5db5c873f1b9b4bc0c90048fddc387b37d6cf8118bfd07e9345a7520994dffad0bb4554c0d5e36e9ee1d8612e9e0b6f87ab51f903017e1b9a
7
+ data.tar.gz: 4ca19c2c8852fdba2be935629afe671f539252dd7c5f669d749f453714140ab7a4423a1401204d10e139bb09e85fb1d819a5ba8cf104711559994b174dba18e2
data/.env.example.erb ADDED
@@ -0,0 +1 @@
1
+ HELLO=<%= `echo world` %>
data/.envrc ADDED
@@ -0,0 +1 @@
1
+ use flake
data/Gemfile ADDED
@@ -0,0 +1,10 @@
1
+ # frozen_string_literal: true
2
+
3
+ source "https://rubygems.org"
4
+
5
+ # Specify your gem's dependencies in envify.gemspec
6
+ gemspec
7
+
8
+ gem "rake", "~> 13.0"
9
+
10
+ gem "minitest", "~> 5.0"
data/Gemfile.lock ADDED
@@ -0,0 +1,28 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ envify (0.1.0)
5
+ erb (~> 4.0)
6
+ thor (~> 1.2)
7
+
8
+ GEM
9
+ remote: https://rubygems.org/
10
+ specs:
11
+ cgi (0.3.6)
12
+ erb (4.0.3)
13
+ cgi (>= 0.3.3)
14
+ minitest (5.20.0)
15
+ rake (13.0.6)
16
+ thor (1.2.2)
17
+
18
+ PLATFORMS
19
+ arm64-darwin-22
20
+ x86_64-linux
21
+
22
+ DEPENDENCIES
23
+ envify!
24
+ minitest (~> 5.0)
25
+ rake (~> 13.0)
26
+
27
+ BUNDLED WITH
28
+ 2.4.6
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2023 Richard Hao
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.
data/README.md ADDED
@@ -0,0 +1,35 @@
1
+ # Envify
2
+
3
+ Create `.env` by evaluating `.env.erb` (or `.env.staging.erb -> .env.staging` when using `-d staging`)
4
+
5
+ ## Installation
6
+
7
+ TODO
8
+
9
+ ## Usage
10
+
11
+ TODO: Write usage instructions here
12
+
13
+ ```bash
14
+ envify generate -d example
15
+ ```
16
+
17
+ or
18
+
19
+ ```bash
20
+ envify g -d example
21
+ ```
22
+
23
+ ## Development
24
+
25
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake test` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
26
+
27
+ 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 the created tag, and push the `.gem` file to [rubygems.org](https://rubygems.org).
28
+
29
+ ## Contributing
30
+
31
+ Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/envify.
32
+
33
+ ## License
34
+
35
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
data/Rakefile ADDED
@@ -0,0 +1,12 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "bundler/gem_tasks"
4
+ require "rake/testtask"
5
+
6
+ Rake::TestTask.new(:test) do |t|
7
+ t.libs << "test"
8
+ t.libs << "lib"
9
+ t.test_files = FileList["test/**/test_*.rb"]
10
+ end
11
+
12
+ task default: :test
data/envify.gemspec ADDED
@@ -0,0 +1,37 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative 'lib/envify/version'
4
+
5
+ Gem::Specification.new do |spec|
6
+ spec.name = 'envify'
7
+ spec.version = Envify::VERSION
8
+ spec.authors = ['Richard Hao']
9
+ spec.email = ['richard@0xdev.dev']
10
+
11
+ spec.summary = 'Create .env by evaluating .env.erb'
12
+ spec.description = 'Create .env by evaluating .env.erb (or .env.staging.erb -> .env.staging when using -d staging)'
13
+ spec.homepage = 'https://0xdev.dev'
14
+ spec.license = 'MIT'
15
+ spec.required_ruby_version = '>= 3.2'
16
+
17
+ spec.metadata['homepage_uri'] = spec.homepage
18
+
19
+ # Specify which files should be added to the gem when it is released.
20
+ # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
21
+ spec.files = Dir.chdir(__dir__) do
22
+ `git ls-files -z`.split("\x0").reject do |f|
23
+ (File.expand_path(f) == __FILE__) || f.start_with?(*%w[bin/ test/ spec/ features/ .git .circleci appveyor])
24
+ end
25
+ end
26
+ spec.executables << 'envify'
27
+ spec.require_paths = ['lib']
28
+ spec.bindir = 'libexe'
29
+
30
+ # Uncomment to register a new dependency of your gem
31
+ # spec.add_dependency "example-gem", "~> 1.0"
32
+ spec.add_dependency 'erb', '~> 4.0'
33
+ spec.add_dependency 'thor', '~> 1.2'
34
+
35
+ # For more information and examples about making a new gem, check out our
36
+ # guide at: https://bundler.io/guides/creating_gem.html
37
+ end
data/flake.lock ADDED
@@ -0,0 +1,27 @@
1
+ {
2
+ "nodes": {
3
+ "nixpkgs": {
4
+ "locked": {
5
+ "lastModified": 1689261696,
6
+ "narHash": "sha256-LzfUtFs9MQRvIoQ3MfgSuipBVMXslMPH/vZ+nM40LkA=",
7
+ "owner": "NixOS",
8
+ "repo": "nixpkgs",
9
+ "rev": "df1eee2aa65052a18121ed4971081576b25d6b5c",
10
+ "type": "github"
11
+ },
12
+ "original": {
13
+ "owner": "NixOS",
14
+ "ref": "nixpkgs-unstable",
15
+ "repo": "nixpkgs",
16
+ "type": "github"
17
+ }
18
+ },
19
+ "root": {
20
+ "inputs": {
21
+ "nixpkgs": "nixpkgs"
22
+ }
23
+ }
24
+ },
25
+ "root": "root",
26
+ "version": 7
27
+ }
data/flake.nix ADDED
@@ -0,0 +1,20 @@
1
+ {
2
+ description = "A Nix-flake-based Ruby development environment";
3
+
4
+ inputs.nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
5
+
6
+ outputs = { self, nixpkgs }:
7
+ let
8
+ supportedSystems = [ "x86_64-linux" "aarch64-linux" "x86_64-darwin" "aarch64-darwin" ];
9
+ forEachSupportedSystem = f: nixpkgs.lib.genAttrs supportedSystems (system: f {
10
+ pkgs = import nixpkgs { inherit system; };
11
+ });
12
+ in
13
+ {
14
+ devShells = forEachSupportedSystem ({ pkgs }: {
15
+ default = pkgs.mkShell {
16
+ packages = with pkgs; [ ruby_3_2 ];
17
+ };
18
+ });
19
+ };
20
+ }
data/lib/envify/cli.rb ADDED
@@ -0,0 +1,26 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Envify
4
+ class Cli < Thor
5
+ def self.exit_on_failure?
6
+ true
7
+ end
8
+
9
+ class_option :destination, aliases: '-d',
10
+ desc: 'Specify destination to be used for generating .env file (staging -> env.staging)'
11
+
12
+ method_options alias: 'g'
13
+ desc 'generate', 'Create .env by evaluating .env.erb (or .env.staging.erb -> .env.staging when using -d staging)'
14
+ def generate
15
+ if destination = options[:destination]
16
+ env_template_path = ".env.#{destination}.erb"
17
+ env_path = ".env.#{destination}"
18
+ else
19
+ env_template_path = '.env.erb'
20
+ env_path = '.env'
21
+ end
22
+
23
+ File.write(env_path, ERB.new(File.read(env_template_path), trim_mode: '>').result, perm: 0o600)
24
+ end
25
+ end
26
+ end
@@ -0,0 +1,5 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Envify
4
+ VERSION = "0.1.0"
5
+ end
data/lib/envify.rb ADDED
@@ -0,0 +1,6 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'thor'
4
+ require 'erb'
5
+ require_relative 'envify/version'
6
+ require_relative 'envify/cli'
data/libexe/envify ADDED
@@ -0,0 +1,13 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
4
+ require 'bundler/setup'
5
+ require 'envify'
6
+
7
+ begin
8
+ Envify::Cli.start(ARGV)
9
+ rescue StandardError => e
10
+ puts " \e[31mERROR (#{e.class}): #{e.message}\e[0m"
11
+ puts e.backtrace if ENV['VERBOSE']
12
+ exit 1
13
+ end
Binary file
data/sig/envify.rbs ADDED
@@ -0,0 +1,4 @@
1
+ module Envify
2
+ VERSION: String
3
+ # See the writing guide of rbs: https://github.com/ruby/rbs#guides
4
+ end
metadata ADDED
@@ -0,0 +1,90 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: envify
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Richard Hao
8
+ autorequire:
9
+ bindir: libexe
10
+ cert_chain: []
11
+ date: 2023-10-06 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: erb
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '4.0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '4.0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: thor
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '1.2'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '1.2'
41
+ description: Create .env by evaluating .env.erb (or .env.staging.erb -> .env.staging
42
+ when using -d staging)
43
+ email:
44
+ - richard@0xdev.dev
45
+ executables:
46
+ - envify
47
+ extensions: []
48
+ extra_rdoc_files: []
49
+ files:
50
+ - ".env.example.erb"
51
+ - ".envrc"
52
+ - Gemfile
53
+ - Gemfile.lock
54
+ - LICENSE.txt
55
+ - README.md
56
+ - Rakefile
57
+ - envify.gemspec
58
+ - flake.lock
59
+ - flake.nix
60
+ - lib/envify.rb
61
+ - lib/envify/cli.rb
62
+ - lib/envify/version.rb
63
+ - libexe/envify
64
+ - pkg/envify-0.1.0.gem
65
+ - sig/envify.rbs
66
+ homepage: https://0xdev.dev
67
+ licenses:
68
+ - MIT
69
+ metadata:
70
+ homepage_uri: https://0xdev.dev
71
+ post_install_message:
72
+ rdoc_options: []
73
+ require_paths:
74
+ - lib
75
+ required_ruby_version: !ruby/object:Gem::Requirement
76
+ requirements:
77
+ - - ">="
78
+ - !ruby/object:Gem::Version
79
+ version: '3.2'
80
+ required_rubygems_version: !ruby/object:Gem::Requirement
81
+ requirements:
82
+ - - ">="
83
+ - !ruby/object:Gem::Version
84
+ version: '0'
85
+ requirements: []
86
+ rubygems_version: 3.4.1
87
+ signing_key:
88
+ specification_version: 4
89
+ summary: Create .env by evaluating .env.erb
90
+ test_files: []