perc 0.1.2

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
+ SHA1:
3
+ metadata.gz: 92161ba1324cad9a8ffba1bc9b7aed84727841bc
4
+ data.tar.gz: '081c3b32f599b061e014379ddf91063c2ea871bf'
5
+ SHA512:
6
+ metadata.gz: bc4619a2b38d7905bb88c3f0eadce14c53cc5ab05e5fae035c90ea71dafad1f9dee3016979027b5a17a313f7a717a4224a1c80e5867997a319081e3a6b26534b
7
+ data.tar.gz: b6b12dc427cf251f456e8e96609fc2d6702fd2193c2ae285b7b9e9a1980f3818929b0e1b65310879686d25a841843a518b436d4dcb07f5ec34b771b06ef828e8
data/.gitignore ADDED
@@ -0,0 +1,12 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
10
+
11
+ # rspec failure tracking
12
+ .rspec_status
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --format documentation
2
+ --color
data/.travis.yml ADDED
@@ -0,0 +1,5 @@
1
+ sudo: false
2
+ language: ruby
3
+ rvm:
4
+ - 2.3.3
5
+ before_install: gem install bundler -v 1.14.6
@@ -0,0 +1,74 @@
1
+ # Contributor Covenant Code of Conduct
2
+
3
+ ## Our Pledge
4
+
5
+ In the interest of fostering an open and welcoming environment, we as
6
+ contributors and maintainers pledge to making participation in our project and
7
+ our community a harassment-free experience for everyone, regardless of age, body
8
+ size, disability, ethnicity, gender identity and expression, level of experience,
9
+ nationality, personal appearance, race, religion, or sexual identity and
10
+ orientation.
11
+
12
+ ## Our Standards
13
+
14
+ Examples of behavior that contributes to creating a positive environment
15
+ include:
16
+
17
+ * Using welcoming and inclusive language
18
+ * Being respectful of differing viewpoints and experiences
19
+ * Gracefully accepting constructive criticism
20
+ * Focusing on what is best for the community
21
+ * Showing empathy towards other community members
22
+
23
+ Examples of unacceptable behavior by participants include:
24
+
25
+ * The use of sexualized language or imagery and unwelcome sexual attention or
26
+ advances
27
+ * Trolling, insulting/derogatory comments, and personal or political attacks
28
+ * Public or private harassment
29
+ * Publishing others' private information, such as a physical or electronic
30
+ address, without explicit permission
31
+ * Other conduct which could reasonably be considered inappropriate in a
32
+ professional setting
33
+
34
+ ## Our Responsibilities
35
+
36
+ Project maintainers are responsible for clarifying the standards of acceptable
37
+ behavior and are expected to take appropriate and fair corrective action in
38
+ response to any instances of unacceptable behavior.
39
+
40
+ Project maintainers have the right and responsibility to remove, edit, or
41
+ reject comments, commits, code, wiki edits, issues, and other contributions
42
+ that are not aligned to this Code of Conduct, or to ban temporarily or
43
+ permanently any contributor for other behaviors that they deem inappropriate,
44
+ threatening, offensive, or harmful.
45
+
46
+ ## Scope
47
+
48
+ This Code of Conduct applies both within project spaces and in public spaces
49
+ when an individual is representing the project or its community. Examples of
50
+ representing a project or community include using an official project e-mail
51
+ address, posting via an official social media account, or acting as an appointed
52
+ representative at an online or offline event. Representation of a project may be
53
+ further defined and clarified by project maintainers.
54
+
55
+ ## Enforcement
56
+
57
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be
58
+ reported by contacting the project team at javajo@gmail.com. All
59
+ complaints will be reviewed and investigated and will result in a response that
60
+ is deemed necessary and appropriate to the circumstances. The project team is
61
+ obligated to maintain confidentiality with regard to the reporter of an incident.
62
+ Further details of specific enforcement policies may be posted separately.
63
+
64
+ Project maintainers who do not follow or enforce the Code of Conduct in good
65
+ faith may face temporary or permanent repercussions as determined by other
66
+ members of the project's leadership.
67
+
68
+ ## Attribution
69
+
70
+ This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
71
+ available at [http://contributor-covenant.org/version/1/4][version]
72
+
73
+ [homepage]: http://contributor-covenant.org
74
+ [version]: http://contributor-covenant.org/version/1/4/
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in perc.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2017 Yardstick
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,38 @@
1
+ # Perc
2
+
3
+ Perc is a "microframework" for bootstrapping small ruby apps that are not really web apps so Sinatra and rails aren't quite what you want.
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ ```ruby
10
+ gem 'perc'
11
+ ```
12
+
13
+ And then execute:
14
+
15
+ $ bundle
16
+
17
+ Or install it yourself as:
18
+
19
+ $ gem install perc
20
+
21
+ ## Usage
22
+
23
+ We don't have initializers yet so setup a new ruby app like in `template_app/`
24
+
25
+ ## Development
26
+
27
+ 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.
28
+
29
+ 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).
30
+
31
+ ## Contributing
32
+
33
+ Bug reports and pull requests are welcome on GitHub at https://github.com/yardstick/perc. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
34
+
35
+
36
+ ## License
37
+
38
+ The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
data/Rakefile ADDED
@@ -0,0 +1,6 @@
1
+ require "bundler/gem_tasks"
2
+ require "rspec/core/rake_task"
3
+
4
+ RSpec::Core::RakeTask.new(:spec)
5
+
6
+ task :default => :spec
data/bin/console ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "perc"
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(__FILE__)
data/exe/perc ADDED
@@ -0,0 +1,12 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'bundler/setup'
4
+
5
+ require 'perc'
6
+ require 'perc/cli'
7
+ require './config/application'
8
+
9
+ Bundler.require(:default, Perc.app.env)
10
+ Perc.app.boot
11
+
12
+ Perc::Cli.start(ARGV)
@@ -0,0 +1,111 @@
1
+ require 'active_support'
2
+ require 'active_support/core_ext'
3
+
4
+ module Perc
5
+
6
+ module Config
7
+ Optional = false
8
+ end
9
+ ##
10
+ # Class for holding stuff you might find in a typical application
11
+ class Application
12
+ LoggerLevels = {
13
+ 'DEBUG' => Logger::DEBUG,
14
+ 'INFO' => Logger::INFO,
15
+ 'WARN' => Logger::WARN,
16
+ 'ERROR' => Logger::ERROR
17
+ }
18
+
19
+ class Config
20
+ class FileMissingError < StandardError; end
21
+ class EnvironmentMissingError < StandardError; end
22
+
23
+ attr_accessor :autoload_paths
24
+
25
+ def initialize
26
+ @autoload_paths = []
27
+ end
28
+ end
29
+
30
+ attr_reader :root, :env, :logger
31
+
32
+ delegate :development?, :production?, :test?, to: :env
33
+
34
+ def initialize(options)
35
+ @root = options.fetch(:root)
36
+ @env = ActiveSupport::StringInquirer.new(options.fetch(:env))
37
+ config do |c|
38
+ Dir[root.join('app', '*')].each do |d|
39
+ c.autoload_paths << d.to_s
40
+ end
41
+ end
42
+ end
43
+
44
+ def env=(string)
45
+ @env = ActiveSupport::StringInquirer.new(string)
46
+ end
47
+
48
+ def load_rake
49
+ rake_files = Dir[File.expand_path('../tasks/*.rake', __FILE__)] +
50
+ Dir[root.join('lib/tasks/*.rake')]
51
+
52
+ rake_files.each do |f|
53
+ load(f)
54
+ end
55
+ end
56
+
57
+ def config_for(thing, required = true)
58
+ file = root.join('config', "#{thing}.yml")
59
+ if file.exist?
60
+ require 'yaml'
61
+ require 'erb'
62
+ thing_parsed = (YAML.load(ERB.new(file.read).result) || {})[env]
63
+ return (thing_parsed and thing_parsed.with_indifferent_access) unless (thing_parsed.nil? && required)
64
+ raise Config::EnvironmentMissingError, "config_for(#{thing}) nil for env: #{env}"
65
+ else
66
+ raise Config::FileMissingError, "Could not load configuration. No such file: #{file}"
67
+ end
68
+ end
69
+
70
+ def boot
71
+ initialize_logging
72
+ setup_autoload_directories
73
+ require_environment
74
+ run_initializers
75
+ end
76
+
77
+ def config
78
+ @config ||= Config.new
79
+ yield(@config) if block_given?
80
+ @config
81
+ end
82
+
83
+ def commands
84
+ require 'perc/cli_wrapper'
85
+ cli = CliWrapper.new
86
+ yield(cli) if block_given?
87
+ cli
88
+ end
89
+
90
+ private
91
+
92
+ def run_initializers
93
+ Dir[root.join('config', 'initializers', '*.rb')].each do |f|
94
+ require f
95
+ end
96
+ end
97
+
98
+ def setup_autoload_directories
99
+ ActiveSupport::Dependencies.autoload_paths = config.autoload_paths
100
+ end
101
+
102
+ def initialize_logging
103
+ @logger = Logger.new(test? ? 'log/test.log' : STDERR)
104
+ @logger.level = LoggerLevels[ENV.fetch('PERC_LOG_LEVEL', 'DEBUG')]
105
+ end
106
+
107
+ def require_environment
108
+ require root.join('config', 'environments', env).to_s
109
+ end
110
+ end
111
+ end
data/lib/perc/cli.rb ADDED
@@ -0,0 +1,13 @@
1
+ require 'perc'
2
+ require 'thor'
3
+
4
+ module Perc
5
+ class Cli < Thor
6
+ desc 'console', 'Get access to a console with your environment loaded'
7
+ def console
8
+ ARGV.shift # so irb doesn't explode
9
+ require 'irb'
10
+ IRB.start(Perc.app.root)
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,11 @@
1
+ require 'perc/cli'
2
+
3
+ module Perc
4
+ class CliWrapper
5
+ delegate :desc, to: 'Perc::Cli'
6
+
7
+ def command(name, &block)
8
+ Cli.send(:define_method, name, &block)
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,3 @@
1
+ module Perc
2
+ VERSION = "0.1.2"
3
+ end
data/lib/perc.rb ADDED
@@ -0,0 +1,7 @@
1
+ require "perc/version"
2
+ require "perc/application"
3
+ require 'pathname'
4
+
5
+ module Perc
6
+ mattr_accessor :app
7
+ end
data/perc.gemspec ADDED
@@ -0,0 +1,54 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'perc/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "perc"
8
+ spec.version = Perc::VERSION
9
+ spec.authors = ["Jason Wall"]
10
+ spec.email = ["jasonw@getyardstick.com"]
11
+
12
+ spec.summary = %q{Lightweight application framework for building things that are not necessarily #railsthings}
13
+ spec.description = %q{}
14
+ spec.homepage = "https://github.com/yardstick/perc"
15
+ spec.license = "MIT"
16
+
17
+ spec.executables << ["perc"]
18
+
19
+ spec.files = [
20
+ ".gitignore",
21
+ ".rspec",
22
+ ".travis.yml",
23
+ "CODE_OF_CONDUCT.md",
24
+ "Gemfile",
25
+ "LICENSE.txt",
26
+ "README.md",
27
+ "Rakefile",
28
+ "bin/console",
29
+ "exe/perc",
30
+ "lib/perc.rb",
31
+ "lib/perc/application.rb",
32
+ "lib/perc/cli.rb",
33
+ "lib/perc/cli_wrapper.rb",
34
+ "lib/perc/version.rb",
35
+ "perc.gemspec",
36
+ "template_app/app/.gitkeep",
37
+ "template_app/config/application.rb",
38
+ "template_app/config/environment.rb",
39
+ "template_app/config/environments/development.rb",
40
+ "template_app/config/environments/production.rb",
41
+ "template_app/config/environments/test.rb",
42
+ "template_app/config/initializers/.gitkeep"
43
+ ]
44
+ spec.bindir = "exe"
45
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
46
+ spec.require_paths = ["lib"]
47
+
48
+ spec.add_runtime_dependency "activesupport", ">= 4.0", "< 5.1"
49
+ spec.add_runtime_dependency "thor", "~> 0.19"
50
+ spec.add_runtime_dependency "rake", "~> 10.0"
51
+
52
+ spec.add_development_dependency "bundler", "~> 1.14"
53
+ spec.add_development_dependency "rspec", "~> 3.0"
54
+ end
File without changes
@@ -0,0 +1,6 @@
1
+ Perc.app = Perc::Application.new(
2
+ root: Pathname.new(File.expand_path('../..', __FILE__)),
3
+ env: ENV.fetch('PERC_ENV', 'development')
4
+ )
5
+
6
+ require_relative 'environment'
File without changes
File without changes
File without changes
File without changes
File without changes
metadata ADDED
@@ -0,0 +1,145 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: perc
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.2
5
+ platform: ruby
6
+ authors:
7
+ - Jason Wall
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2018-12-22 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: activesupport
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '4.0'
20
+ - - "<"
21
+ - !ruby/object:Gem::Version
22
+ version: '5.1'
23
+ type: :runtime
24
+ prerelease: false
25
+ version_requirements: !ruby/object:Gem::Requirement
26
+ requirements:
27
+ - - ">="
28
+ - !ruby/object:Gem::Version
29
+ version: '4.0'
30
+ - - "<"
31
+ - !ruby/object:Gem::Version
32
+ version: '5.1'
33
+ - !ruby/object:Gem::Dependency
34
+ name: thor
35
+ requirement: !ruby/object:Gem::Requirement
36
+ requirements:
37
+ - - "~>"
38
+ - !ruby/object:Gem::Version
39
+ version: '0.19'
40
+ type: :runtime
41
+ prerelease: false
42
+ version_requirements: !ruby/object:Gem::Requirement
43
+ requirements:
44
+ - - "~>"
45
+ - !ruby/object:Gem::Version
46
+ version: '0.19'
47
+ - !ruby/object:Gem::Dependency
48
+ name: rake
49
+ requirement: !ruby/object:Gem::Requirement
50
+ requirements:
51
+ - - "~>"
52
+ - !ruby/object:Gem::Version
53
+ version: '10.0'
54
+ type: :runtime
55
+ prerelease: false
56
+ version_requirements: !ruby/object:Gem::Requirement
57
+ requirements:
58
+ - - "~>"
59
+ - !ruby/object:Gem::Version
60
+ version: '10.0'
61
+ - !ruby/object:Gem::Dependency
62
+ name: bundler
63
+ requirement: !ruby/object:Gem::Requirement
64
+ requirements:
65
+ - - "~>"
66
+ - !ruby/object:Gem::Version
67
+ version: '1.14'
68
+ type: :development
69
+ prerelease: false
70
+ version_requirements: !ruby/object:Gem::Requirement
71
+ requirements:
72
+ - - "~>"
73
+ - !ruby/object:Gem::Version
74
+ version: '1.14'
75
+ - !ruby/object:Gem::Dependency
76
+ name: rspec
77
+ requirement: !ruby/object:Gem::Requirement
78
+ requirements:
79
+ - - "~>"
80
+ - !ruby/object:Gem::Version
81
+ version: '3.0'
82
+ type: :development
83
+ prerelease: false
84
+ version_requirements: !ruby/object:Gem::Requirement
85
+ requirements:
86
+ - - "~>"
87
+ - !ruby/object:Gem::Version
88
+ version: '3.0'
89
+ description: ''
90
+ email:
91
+ - jasonw@getyardstick.com
92
+ executables:
93
+ - perc
94
+ extensions: []
95
+ extra_rdoc_files: []
96
+ files:
97
+ - ".gitignore"
98
+ - ".rspec"
99
+ - ".travis.yml"
100
+ - CODE_OF_CONDUCT.md
101
+ - Gemfile
102
+ - LICENSE.txt
103
+ - README.md
104
+ - Rakefile
105
+ - bin/console
106
+ - exe/perc
107
+ - lib/perc.rb
108
+ - lib/perc/application.rb
109
+ - lib/perc/cli.rb
110
+ - lib/perc/cli_wrapper.rb
111
+ - lib/perc/version.rb
112
+ - perc.gemspec
113
+ - template_app/app/.gitkeep
114
+ - template_app/config/application.rb
115
+ - template_app/config/environment.rb
116
+ - template_app/config/environments/development.rb
117
+ - template_app/config/environments/production.rb
118
+ - template_app/config/environments/test.rb
119
+ - template_app/config/initializers/.gitkeep
120
+ homepage: https://github.com/yardstick/perc
121
+ licenses:
122
+ - MIT
123
+ metadata: {}
124
+ post_install_message:
125
+ rdoc_options: []
126
+ require_paths:
127
+ - lib
128
+ required_ruby_version: !ruby/object:Gem::Requirement
129
+ requirements:
130
+ - - ">="
131
+ - !ruby/object:Gem::Version
132
+ version: '0'
133
+ required_rubygems_version: !ruby/object:Gem::Requirement
134
+ requirements:
135
+ - - ">="
136
+ - !ruby/object:Gem::Version
137
+ version: '0'
138
+ requirements: []
139
+ rubyforge_project:
140
+ rubygems_version: 2.6.13
141
+ signing_key:
142
+ specification_version: 4
143
+ summary: 'Lightweight application framework for building things that are not necessarily
144
+ #railsthings'
145
+ test_files: []