fastball 0.1.0

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 ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 705aaa59d0ae67092c18485e8c5a218d1658db10
4
+ data.tar.gz: 96d7d30bd753638c8ee846b0e7b18e39ae170057
5
+ SHA512:
6
+ metadata.gz: 2c91b291b3d3bf04676192761bf830b6030ac9e80cdd331b3e4156b62937d752889a71706fcfae0b6d6fe7c51ab9da23f96e75dcd12065535af8efcdc4d4f607
7
+ data.tar.gz: b8715b22588e5749d38d89ad153336bd31ffe30b612a1d3a0006d5e3ed890a31328f6919f48440cd70bd770bf9c2f9b5073e1611f3ec2510c31efa75143f1e5e
data/.gitignore ADDED
@@ -0,0 +1,9 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --format documentation
2
+ --color
data/.travis.yml ADDED
@@ -0,0 +1,4 @@
1
+ language: ruby
2
+ rvm:
3
+ - 2.2.2
4
+ before_install: gem install bundler -v 1.10.6
data/Gemfile ADDED
@@ -0,0 +1,3 @@
1
+ source 'https://rubygems.org'
2
+
3
+ gemspec
data/Guardfile ADDED
@@ -0,0 +1,14 @@
1
+ guard :rspec, cmd: "bundle exec rspec" do
2
+ require "guard/rspec/dsl"
3
+ dsl = Guard::RSpec::Dsl.new(self)
4
+
5
+ # RSpec files
6
+ rspec = dsl.rspec
7
+ watch(rspec.spec_helper) { rspec.spec_dir }
8
+ watch(rspec.spec_support) { rspec.spec_dir }
9
+ watch(rspec.spec_files)
10
+
11
+ # Ruby files
12
+ ruby = dsl.ruby
13
+ dsl.watch_spec_files_for(ruby.lib_files)
14
+ end
data/LICENSE ADDED
@@ -0,0 +1,22 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2015 Jordan Bach
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 all
13
+ 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 THE
21
+ SOFTWARE.
22
+
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2015 Jordan Bach
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,63 @@
1
+ # Fastball
2
+
3
+ The safest, fastest way to build and deploy dynamic applications.
4
+
5
+ ## Installation
6
+
7
+ With bundler:
8
+
9
+ ```
10
+ # In your Gemfile
11
+ gem 'fastball', require: false
12
+
13
+ # In your terminal
14
+ bundle install
15
+ ```
16
+
17
+ As a gem:
18
+
19
+ ```
20
+ gem install fastball
21
+ ```
22
+
23
+ In your Rakefile:
24
+
25
+ ```
26
+ require 'fastball/tasks'
27
+ ```
28
+
29
+ Verify installation:
30
+
31
+ ```
32
+ $ rake -T fastball
33
+ rake fastball:config # generate environment specific configuration files
34
+ ```
35
+
36
+ ## Documentation
37
+
38
+ See {Fastball::Config} for documentation and examples of using
39
+ Fastball to generate config files.
40
+
41
+ ## Roadmap
42
+
43
+ Fastball is a young, opionated project with more features under active development.
44
+
45
+ - CLI command to vendor fastball in an application so production servers do not require the fastball gem to function
46
+ - Packaging dynamic applications into a build archive with all dependencies vendored (except for the interpreter)
47
+ - Deploying build archives into a designated deployment environment
48
+
49
+ ## Development
50
+
51
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
52
+
53
+ 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).
54
+
55
+ ## Contributing
56
+
57
+ Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/fastball.
58
+
59
+
60
+ ## License
61
+
62
+ The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
63
+
data/Rakefile ADDED
@@ -0,0 +1,9 @@
1
+ require "bundler/gem_tasks"
2
+ require "rspec/core/rake_task"
3
+
4
+ RSpec::Core::RakeTask.new(:spec)
5
+
6
+ task :default => :spec
7
+
8
+ $LOAD_PATH.unshift './lib'
9
+ require 'fastball/tasks'
data/bin/console ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "pitstop"
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
data/bin/setup ADDED
@@ -0,0 +1,7 @@
1
+ #!/bin/bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+
5
+ bundle install
6
+
7
+ # Do any other automated setup that you need to do here
data/fastball.gemspec ADDED
@@ -0,0 +1,25 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'fastball/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "fastball"
8
+ spec.version = Fastball::VERSION
9
+ spec.authors = ["Jordan Bach"]
10
+ spec.email = ["jordanbach@gmail.com"]
11
+
12
+ spec.summary = %q{The safest, fastest way to build and deploy dynamic applications.}
13
+ spec.homepage = "https://github.com/jbgo/fastball"
14
+ spec.license = "MIT"
15
+
16
+ spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
17
+ spec.bindir = "bin"
18
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
19
+ spec.require_paths = ["lib"]
20
+
21
+ spec.add_development_dependency "bundler", "~> 1.10"
22
+ spec.add_development_dependency "rake", "~> 10.0"
23
+ spec.add_development_dependency "rspec"
24
+ spec.add_development_dependency "guard-rspec"
25
+ end
@@ -0,0 +1,127 @@
1
+ require 'erb'
2
+ require 'forwardable'
3
+ require 'yaml'
4
+
5
+ module Fastball
6
+
7
+ # The Fastball::Config generates environment specific configuration files.
8
+ #
9
+ # == Conventions
10
+ #
11
+ # Fastball looks for ERB configuration templates in the following locations
12
+ # relative to the current working directory:
13
+ #
14
+ # - .env.erb
15
+ # - config/*.erb
16
+ #
17
+ # The generated config files will have the same path as the config templates
18
+ # but with the +.erb+ extension removed.
19
+ #
20
+ # config/database.yml.erb --> rake fastball:config --> config/database.yml
21
+ #
22
+ # You should <b>never edit the generated config file</b> by hand because Fastball will
23
+ # overwrite your changes.
24
+ #
25
+ # == app_config.yml
26
+ #
27
+ # To customize the configuration for a specific environment, Fastball expects
28
+ # to find an +app_config.yml+ file in the current directory containing the
29
+ # environment specific values for the variables refenced in the config templates.
30
+ # Fastball will complain if this file does not exist or is missing a config value
31
+ # required by one of the templates.
32
+ #
33
+ # Fastball does not generate +app_config.yml+ for you. Typically, your configuration
34
+ # management tool (ansible, chef, puppet, etc.) will generate +app_config.yml+ for
35
+ # deployment environments, and developers will create and edit +app_config.yml+
36
+ # locally. It is recommended that you don't commit this file to version control.
37
+ # Instead, you should create an +app_config.yml.example+ with dummy config values
38
+ # to use in development/test environments that other team members can copy to
39
+ # +app_config.yml+ and modify for their specific environment.
40
+ #
41
+ # == Example
42
+ #
43
+ # To generate the following +config/database.yml+ file,
44
+ #
45
+ # !!!yaml
46
+ # ---
47
+ # staging:
48
+ # adapter: mysql2
49
+ # host: localhost
50
+ # username: dbuser
51
+ # password: secret
52
+ #
53
+ # you would create a +config/database.yml.erb+ template like this,
54
+ #
55
+ # !!!yaml
56
+ # ---
57
+ # <%= staging %>:
58
+ # adapter: mysql2
59
+ # host: <%= db.host %>
60
+ # username: <%= db.username %>
61
+ # password: <%= db.password %>
62
+ #
63
+ # and save the following config values to +app_config.yml+.
64
+ #
65
+ # !!!yaml
66
+ # ---
67
+ # db:
68
+ # host: localhost
69
+ # username: dbuser
70
+ # password: secret
71
+ #
72
+ class Config
73
+ attr_reader :config
74
+
75
+ extend Forwardable
76
+ def_delegators Fastball, :headline, :progress
77
+
78
+ class << self
79
+ # See {Config} for information about +.generate+.
80
+ def generate
81
+ self.new.generate
82
+ end
83
+ end
84
+
85
+ # See {Config} for information about +#generate+.
86
+ def generate
87
+ load_config_values
88
+
89
+ headline "Rendering config files from provided templates.\n"
90
+ results = template_paths.map do |path|
91
+ render_template path
92
+ end
93
+
94
+ headline "Saving new config files.\n"
95
+ template_paths.zip(results) do |path, result|
96
+ save_result path, result
97
+ end
98
+ end
99
+
100
+ private
101
+
102
+ def template_paths
103
+ @template_paths ||= Dir['.env.erb', 'config/*.erb'].to_a
104
+ end
105
+
106
+ def load_config_values
107
+ @config ||= HashDot.new YAML.load(File.read('app_config.yml'))
108
+ rescue
109
+ raise MissingAppConfig.new("expecting app_config.yml to exist in the current directory")
110
+ end
111
+
112
+ def render_template(path)
113
+ progress "rendering '#{path}'"
114
+ template = ERB.new File.read(path)
115
+ template_binding = config.instance_eval { binding }
116
+ template.result template_binding
117
+ end
118
+
119
+ def save_result(path, result)
120
+ real_path = path.sub(/\.erb$/, '')
121
+ progress "saving '#{real_path}'"
122
+ File.write real_path, result
123
+ end
124
+
125
+ end
126
+
127
+ end
@@ -0,0 +1,39 @@
1
+ module Fastball
2
+
3
+ # A utility class to allow referencing nested hash values as chained method calls.
4
+ #
5
+ # == Example
6
+ #
7
+ # !!!
8
+ # ruby> h = Fastball::HashDot.new name: { name: 'Jordan', state: 'Texas' }
9
+ # ruby> h.contact.name
10
+ # => "Jordan"
11
+ # ruby> h.contact.state
12
+ # => "Texas"
13
+ #
14
+ class HashDot
15
+
16
+ def initialize(hash={})
17
+ @hash = {}
18
+
19
+ hash.map do |k, v|
20
+ @hash[k.to_s] = if v.kind_of?(Hash)
21
+ self.class.new v
22
+ else
23
+ @hash[k.to_s] = v
24
+ end
25
+ end
26
+ end
27
+
28
+ private
29
+
30
+ def method_missing(method_name, *args, &block)
31
+ @hash[method_name.to_s] || super
32
+ end
33
+
34
+ def respond_to_missing?(method_name, include_private=false)
35
+ @hash.key?(method_name.to_s) || super
36
+ end
37
+
38
+ end
39
+ end
@@ -0,0 +1,10 @@
1
+ require 'fastball'
2
+
3
+ namespace :fastball do
4
+
5
+ desc "generate environment specific configuration files"
6
+ task :config do
7
+ Fastball::Config.generate
8
+ end
9
+
10
+ end
@@ -0,0 +1,3 @@
1
+ module Fastball
2
+ VERSION = "0.1.0"
3
+ end
data/lib/fastball.rb ADDED
@@ -0,0 +1,34 @@
1
+ require 'fastball/version'
2
+ require 'fastball/hash_dot'
3
+ require 'fastball/config'
4
+
5
+ # The safest, fastest way to build and deploy dynamic applications.
6
+ #
7
+ # See the {file:README.md README} to get started.
8
+ #
9
+ module Fastball
10
+
11
+ # raised when app_config.yml is not present in current directory
12
+ class MissingAppConfig < StandardError; end
13
+
14
+ # raised when app_config.yml is missing values required by templates
15
+ class ConfigError < StandardError; end
16
+
17
+ class << self
18
+ # used internally to print informational messages to stdout
19
+ def headline(message)
20
+ puts "\n== #{message}" unless silence_output?
21
+ end
22
+
23
+ # used internally to print informational messages to stdout
24
+ def progress(message)
25
+ puts "..... #{message}" unless silence_output?
26
+ end
27
+
28
+ private
29
+
30
+ def silence_output?
31
+ ENV['SILENCE_OUTPUT'] =~ /^(1|true)/i
32
+ end
33
+ end
34
+ end
metadata ADDED
@@ -0,0 +1,119 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: fastball
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Jordan Bach
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2015-08-29 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.10'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.10'
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: rspec
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
+ - !ruby/object:Gem::Dependency
56
+ name: guard-rspec
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ description:
70
+ email:
71
+ - jordanbach@gmail.com
72
+ executables:
73
+ - console
74
+ - setup
75
+ extensions: []
76
+ extra_rdoc_files: []
77
+ files:
78
+ - ".gitignore"
79
+ - ".rspec"
80
+ - ".travis.yml"
81
+ - Gemfile
82
+ - Guardfile
83
+ - LICENSE
84
+ - LICENSE.txt
85
+ - README.md
86
+ - Rakefile
87
+ - bin/console
88
+ - bin/setup
89
+ - fastball.gemspec
90
+ - lib/fastball.rb
91
+ - lib/fastball/config.rb
92
+ - lib/fastball/hash_dot.rb
93
+ - lib/fastball/tasks.rb
94
+ - lib/fastball/version.rb
95
+ homepage: https://github.com/jbgo/fastball
96
+ licenses:
97
+ - MIT
98
+ metadata: {}
99
+ post_install_message:
100
+ rdoc_options: []
101
+ require_paths:
102
+ - lib
103
+ required_ruby_version: !ruby/object:Gem::Requirement
104
+ requirements:
105
+ - - ">="
106
+ - !ruby/object:Gem::Version
107
+ version: '0'
108
+ required_rubygems_version: !ruby/object:Gem::Requirement
109
+ requirements:
110
+ - - ">="
111
+ - !ruby/object:Gem::Version
112
+ version: '0'
113
+ requirements: []
114
+ rubyforge_project:
115
+ rubygems_version: 2.4.5
116
+ signing_key:
117
+ specification_version: 4
118
+ summary: The safest, fastest way to build and deploy dynamic applications.
119
+ test_files: []