scribbler 0.0.1
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.
- data/.gitignore +17 -0
- data/.travis.yml +6 -0
- data/Gemfile +4 -0
- data/README.markdown +69 -0
- data/Rakefile +13 -0
- data/bin/scribbler +14 -0
- data/lib/scribbler.rb +7 -0
- data/lib/scribbler/base.rb +105 -0
- data/lib/scribbler/cli.rb +95 -0
- data/lib/scribbler/configurator.rb +15 -0
- data/lib/scribbler/executable.rb +14 -0
- data/lib/scribbler/includeables.rb +88 -0
- data/lib/scribbler/version.rb +3 -0
- data/scribbler.gemspec +24 -0
- data/spec/scribbler/base_spec.rb +50 -0
- data/spec/scribbler/cli_spec.rb +39 -0
- data/spec/scribbler/configurator_spec.rb +25 -0
- data/spec/scribbler/executable_spec.rb +21 -0
- data/spec/scribbler/includeables_spec.rb +9 -0
- data/spec/scribbler/version_spec.rb +9 -0
- data/spec/scribbler_spec.rb +7 -0
- data/spec/spec_helper.rb +29 -0
- data/spec/support/examples/scribbler_example.rb +17 -0
- data/spec/support/lib/spec_utils.rb +9 -0
- data/templates/scribbler.rb +17 -0
- metadata +168 -0
data/.gitignore
ADDED
data/.travis.yml
ADDED
data/Gemfile
ADDED
data/README.markdown
ADDED
@@ -0,0 +1,69 @@
|
|
1
|
+
# Scribbler
|
2
|
+
|
3
|
+
[](http://travis-ci.org/jphenow/scribbler "Travis-CI Scribbler")
|
4
|
+
|
5
|
+
Scribbler is a little utility for simplifying logging across one application or more.
|
6
|
+
Currently it assists in:
|
7
|
+
|
8
|
+
* Dynamically defining methods for accessing the log files
|
9
|
+
* Centralized log method for file, message, and error checks
|
10
|
+
- Currently also able to notify NewRelic, abstraction and extension to come
|
11
|
+
|
12
|
+
## Usage
|
13
|
+
|
14
|
+
In your Rails project add
|
15
|
+
|
16
|
+
gem scribbler
|
17
|
+
|
18
|
+
to your Gemfile and
|
19
|
+
|
20
|
+
bundle install
|
21
|
+
|
22
|
+
Then
|
23
|
+
|
24
|
+
rake scribbler:install # THIS DOESN'T WORK YET
|
25
|
+
|
26
|
+
You'll find your configuration options in `config/initializers/scribbler.rb`.
|
27
|
+
As an example, with this configuration file in a Rails app called `Blogger`:
|
28
|
+
|
29
|
+
Scribbler::Base.configure do
|
30
|
+
config.application_include = true
|
31
|
+
config.logs = %w[production delayed_job]
|
32
|
+
end
|
33
|
+
|
34
|
+
You are given a few methods for free. To get the production logfile location:
|
35
|
+
|
36
|
+
Blogger.production_log_location
|
37
|
+
# => <#Path: Rails.root.join('log', 'production.log')>
|
38
|
+
|
39
|
+
or
|
40
|
+
|
41
|
+
Scribbler::Base.production_log_location
|
42
|
+
# => <#Path: Rails.root.join('log', 'production.log')>
|
43
|
+
|
44
|
+
More importantly you're given access to a sweet `log` method:
|
45
|
+
|
46
|
+
# Notifies NewRelic and drops the message in log found at Blogger.production_log_location
|
47
|
+
Blogger.log :production, :error => e, :message => "#{e} broke stuff"
|
48
|
+
Scribbler::Base.log :production, :error => e, :message => "#{e} broke stuff"
|
49
|
+
|
50
|
+
# Only logs to log/delayed_job.log and doesn't notify NewRelic
|
51
|
+
Blogger.log :delayed_job, :message => "Successfully executed Delayed Job"
|
52
|
+
Scribbler::Base.log :delayed_job, :message => "Successfully executed Delayed Job"
|
53
|
+
|
54
|
+
# Doesn't notify NewRelic but gives the method access to the error and logs the message
|
55
|
+
# to the given logfile
|
56
|
+
Blogger.log 'production', :new_relic => false, :error => e, :message => "#{e} broke stuff"
|
57
|
+
Scribbler::Base.log 'production', :new_relic => false, :error => e, :message => "#{e} broke stuff"
|
58
|
+
|
59
|
+
# Logs to given file without using the fancy log methods
|
60
|
+
Blogger.log File.expand_path(File.join(File.dirname(__FILE__), 'logfile.log')), :message => "#{e} broke stuff"
|
61
|
+
Scribbler::Base.log File.expand_path(File.join(File.dirname(__FILE__), 'logfile.log')), :message => "#{e} broke stuff"
|
62
|
+
|
63
|
+
## Todo
|
64
|
+
|
65
|
+
* More options in configure
|
66
|
+
* More testing
|
67
|
+
- Specifically New executable and cli stuff
|
68
|
+
* Make block available in log method for better extensibility
|
69
|
+
* Currently attempts to notify NewRelic if its there, abstract and allow custom services
|
data/Rakefile
ADDED
@@ -0,0 +1,13 @@
|
|
1
|
+
#!/usr/bin/env rake
|
2
|
+
require "bundler/gem_tasks"
|
3
|
+
require "rspec/core/rake_task"
|
4
|
+
|
5
|
+
RSpec::Core::RakeTask.new(:spec)
|
6
|
+
|
7
|
+
namespace :spec do
|
8
|
+
RSpec::Core::RakeTask.new(:docs) do |t|
|
9
|
+
t.rspec_opts = ["--format doc"]
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
task :default => :spec
|
data/bin/scribbler
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
require 'rubygems' # ruby1.9 doesn't "require" it though
|
3
|
+
require 'thor'
|
4
|
+
require 'scribbler'
|
5
|
+
|
6
|
+
class ScribblerExecutable < Thor
|
7
|
+
desc "install", "Installs the necessary files for Scribbler (default: config/initializers/scribbler.rb)"
|
8
|
+
method_option :path, :aliases => "-p", :desc => "Specify a different path for the scribbler initialization"
|
9
|
+
def install
|
10
|
+
Scribbler::Executable.install(options)
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
ScribblerExecutable.start
|
data/lib/scribbler.rb
ADDED
@@ -0,0 +1,105 @@
|
|
1
|
+
module Scribbler
|
2
|
+
# TODO not sure this'll work
|
3
|
+
delegate :configure, :to => :Base
|
4
|
+
delegate :log, :to => :Base
|
5
|
+
class Base
|
6
|
+
# Gets the path of this Gem
|
7
|
+
#
|
8
|
+
# Examples:
|
9
|
+
#
|
10
|
+
# Base.gem_path
|
11
|
+
# # => '/some/home/.rvm/gems/ruby-1.9.3-p125/gems/scribbler-0.0.1/'
|
12
|
+
#
|
13
|
+
# Returns String of the current gem's directory path
|
14
|
+
def self.gem_path
|
15
|
+
File.expand_path(File.join(File.dirname(__FILE__), '..', '..'))
|
16
|
+
end
|
17
|
+
|
18
|
+
# Gets all the paths to the template files in the gem's template directory
|
19
|
+
#
|
20
|
+
# Examples:
|
21
|
+
#
|
22
|
+
# Base.templates
|
23
|
+
# # => ['/some/home/.rvm/gems/ruby-1.9.3-p125/gems/scribbler-0.0.1/templates/1.rb',
|
24
|
+
# # '/some/home/.rvm/gems/ruby-1.9.3-p125/gems/scribbler-0.0.1/templates/2.rb]
|
25
|
+
#
|
26
|
+
# Returns Array of Strings of the gem's template files
|
27
|
+
def self.templates
|
28
|
+
Dir.glob(File.join(gem_path, 'templates', '*'))
|
29
|
+
end
|
30
|
+
|
31
|
+
# Gets the path to the default install directory. If Rails is present
|
32
|
+
# it will default to the Rails.root/config/initializers/. Otherwise
|
33
|
+
# it assumes its the $PWD/config/initializer. Should look at a cleaner
|
34
|
+
# abstraction of this
|
35
|
+
#
|
36
|
+
# Examples:
|
37
|
+
#
|
38
|
+
# Base.default_install_path
|
39
|
+
# # => '/some/home/projects/rails_app/config/initializers/'
|
40
|
+
#
|
41
|
+
# Returns String for best guess of a good install path
|
42
|
+
def self.default_install_path
|
43
|
+
begin
|
44
|
+
::Rails.root.join 'config', 'initializers', ''
|
45
|
+
rescue NameError
|
46
|
+
File.join Dir.pwd, 'config', 'initializers', ''
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
# Rails style configure block with some cleanup afterwards. This is the
|
51
|
+
# main method that kicks off the module and is necessary for its operation
|
52
|
+
#
|
53
|
+
# &block - Block is class_eval'd to give total access to the config file.
|
54
|
+
# Most importantly giving access to `config` object
|
55
|
+
#
|
56
|
+
# Examples:
|
57
|
+
#
|
58
|
+
# Base.configure do
|
59
|
+
# config.logs = %w[log1 log2]
|
60
|
+
# config.application_include = true
|
61
|
+
# end
|
62
|
+
# # => Nothing
|
63
|
+
#
|
64
|
+
# Returns Nothing
|
65
|
+
# TODO Abstract the callbacks so that we can just add them where they're written
|
66
|
+
def self.configure(&block)
|
67
|
+
class_eval(&block)
|
68
|
+
Base.include_in_application
|
69
|
+
BaseIncluder.include_includeables
|
70
|
+
end
|
71
|
+
|
72
|
+
# Simply returns the configurator class.
|
73
|
+
#
|
74
|
+
# Examples:
|
75
|
+
#
|
76
|
+
# Base.config
|
77
|
+
# # => Scribbler::Configurator
|
78
|
+
#
|
79
|
+
# Returns the singleton configurator
|
80
|
+
def self.config
|
81
|
+
Scribbler::Configurator
|
82
|
+
end
|
83
|
+
|
84
|
+
private
|
85
|
+
# If the config agrees, attempt to include our special methods
|
86
|
+
# in the main application object.
|
87
|
+
#
|
88
|
+
# Example:
|
89
|
+
#
|
90
|
+
# Base.include_in_application
|
91
|
+
# # => Nothing
|
92
|
+
#
|
93
|
+
# Returns Nothing
|
94
|
+
# TODO Allow config to define where we send the include
|
95
|
+
def self.include_in_application
|
96
|
+
if config.application_include
|
97
|
+
begin
|
98
|
+
::Rails.application.class.parent.send :include, Includeables
|
99
|
+
rescue NameError
|
100
|
+
nil
|
101
|
+
end
|
102
|
+
end
|
103
|
+
end
|
104
|
+
end
|
105
|
+
end
|
@@ -0,0 +1,95 @@
|
|
1
|
+
module Scribbler
|
2
|
+
class CLI
|
3
|
+
# Run a shell command and output clean text explaining what happened
|
4
|
+
#
|
5
|
+
# command - Shell command to run
|
6
|
+
# poptions - Set of options to alter default behavior
|
7
|
+
# :output - Disable default out of the command (default: true)
|
8
|
+
#
|
9
|
+
# Examples:
|
10
|
+
#
|
11
|
+
# CLI.run_command('pwd')
|
12
|
+
# # No output, because no pwd association yet
|
13
|
+
# # => '/some/dir'
|
14
|
+
#
|
15
|
+
# CLI.run_command('cp x y')
|
16
|
+
# # Copying files
|
17
|
+
# # => nothing
|
18
|
+
#
|
19
|
+
# CLI.run_command('cp x y', :output => false)
|
20
|
+
# # => nothing
|
21
|
+
#
|
22
|
+
# Returns the backtick return of the command
|
23
|
+
def self.run_command(command, poptions={})
|
24
|
+
options = {:output => true}.merge(poptions)
|
25
|
+
output command if options[:output]
|
26
|
+
`#{command}`
|
27
|
+
end
|
28
|
+
|
29
|
+
# Central method for outputting text. Will serve
|
30
|
+
# as a central location for changing how Scribbler outputs
|
31
|
+
#
|
32
|
+
# text - Text to output
|
33
|
+
#
|
34
|
+
# Examples:
|
35
|
+
#
|
36
|
+
# CLI.say "Output stuff"
|
37
|
+
# # "Output stuff"
|
38
|
+
# # => "Output stuff"
|
39
|
+
#
|
40
|
+
# Returns whatever `puts` command returns
|
41
|
+
def self.say(text)
|
42
|
+
puts text
|
43
|
+
end
|
44
|
+
|
45
|
+
# Copy a list of files to one location with one output
|
46
|
+
# for the whole copy
|
47
|
+
#
|
48
|
+
# files - List of strings representing files to be copied
|
49
|
+
# destination - Directory to send the files
|
50
|
+
#
|
51
|
+
# Examples:
|
52
|
+
#
|
53
|
+
# CLI.mass_copy(['/etc/a.file', 'etc/b.file'], '/tmp')
|
54
|
+
# # "Copying files"
|
55
|
+
# # => Nothing
|
56
|
+
#
|
57
|
+
# Returns Nothing
|
58
|
+
def self.mass_copy(files, destination)
|
59
|
+
output 'cp'
|
60
|
+
files.each do |file|
|
61
|
+
run_command "cp #{file} #{destination}", :output => false
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
65
|
+
private
|
66
|
+
|
67
|
+
# Get the command and try to output a human description
|
68
|
+
# of what's happening
|
69
|
+
#
|
70
|
+
# command - Whole command that we're finding output for
|
71
|
+
#
|
72
|
+
# Examples:
|
73
|
+
#
|
74
|
+
# CLI.output 'cp x y'
|
75
|
+
# # "Copying files"
|
76
|
+
# # => "Copying files"
|
77
|
+
#
|
78
|
+
# CLI.output 'mkdir /a/dir'
|
79
|
+
# # "Checking necessary directories are in place"
|
80
|
+
# # => "Checking necessary directories are in place"
|
81
|
+
#
|
82
|
+
# Returns Nothing
|
83
|
+
def self.output(command)
|
84
|
+
final_out = []
|
85
|
+
pieces = command.split(' ')
|
86
|
+
case pieces.first
|
87
|
+
when 'mkdir'
|
88
|
+
final_out << "Checking necessary directories are in place"
|
89
|
+
when 'cp'
|
90
|
+
final_out << "Coping files"
|
91
|
+
end
|
92
|
+
say final_out.join ' '
|
93
|
+
end
|
94
|
+
end
|
95
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
module Scribbler
|
2
|
+
class Executable
|
3
|
+
# Runs installer, makes dirs and copy's template files
|
4
|
+
#
|
5
|
+
# options - Options from command in shell
|
6
|
+
# :path - changes the path its installing config files too
|
7
|
+
#
|
8
|
+
def self.install(options={})
|
9
|
+
install_path = options[:path] || Base.default_install_path
|
10
|
+
CLI.run_command "mkdir -p #{install_path}"
|
11
|
+
CLI.mass_copy Base.templates, install_path
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
@@ -0,0 +1,88 @@
|
|
1
|
+
module Scribbler
|
2
|
+
class BaseIncluder # I don't love this
|
3
|
+
# Wonky way of allowing Base to include the Includeables.
|
4
|
+
# Receives require errors with this currently.
|
5
|
+
#
|
6
|
+
# Examples:
|
7
|
+
#
|
8
|
+
# BaseIncluder.include_includeables
|
9
|
+
# # => Nothing
|
10
|
+
#
|
11
|
+
# Returns Nothing
|
12
|
+
# TODO Rework; there must be a more sane way of including these
|
13
|
+
def self.include_includeables
|
14
|
+
Scribbler::Base.send :include, Scribbler::Includeables
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
module Includeables
|
19
|
+
extend ActiveSupport::Concern
|
20
|
+
|
21
|
+
included do
|
22
|
+
build_methods
|
23
|
+
end
|
24
|
+
|
25
|
+
module ClassMethods
|
26
|
+
def build_methods
|
27
|
+
# Public: defines methods for log location. The first element
|
28
|
+
# defines the prefix for the method so "subseason" = subseason_log_location.
|
29
|
+
# The second element defines the name of the logfile so "subseason" =
|
30
|
+
# root_of_app/log/subseason.log
|
31
|
+
#
|
32
|
+
# Examples
|
33
|
+
#
|
34
|
+
# subseason_log_location
|
35
|
+
# # => #<Pathname:/path_to_ngin/log/subseason_copy_structure.log>
|
36
|
+
#
|
37
|
+
# Returns Pathname to log
|
38
|
+
Scribbler::Base.config.logs.each do |value|
|
39
|
+
define_singleton_method "#{value}_log_location" do
|
40
|
+
Rails.root.join('log', "#{value}.log")
|
41
|
+
#TODO remove dependence on Rails here
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
# Public: Save ourselves some repetition. Notifies error to NewRelic
|
47
|
+
# and drops given string into a given log.
|
48
|
+
#
|
49
|
+
# location - Either a pathname from the above method or symbol for an above
|
50
|
+
# method
|
51
|
+
# options - Hash of options for logging on Ngin
|
52
|
+
# :error - Error object, mostly for passing to NewRelic
|
53
|
+
# :message - Message to log in the actual file
|
54
|
+
# :new_relic - Notify NewRelic of the error (default: true)
|
55
|
+
#
|
56
|
+
# Examples
|
57
|
+
#
|
58
|
+
# log(Ngin.subseason_log_location, :error => e, :message => "Error message stuff", :new_relic => false)
|
59
|
+
#
|
60
|
+
# log(:subseason, :error => e, :message => "Error message stuff")
|
61
|
+
#
|
62
|
+
# log(:subseason, :message => "Logging like a bauss")
|
63
|
+
#
|
64
|
+
# Returns Nothing.
|
65
|
+
def log(location, options={})
|
66
|
+
begin
|
67
|
+
NewRelic::Agent.notice_error(options[:error]) if options[:error] and options[:new_relic] != false
|
68
|
+
rescue NameError
|
69
|
+
nil
|
70
|
+
end
|
71
|
+
|
72
|
+
real_location = location
|
73
|
+
if real_location.is_a?(Symbol) or real_location.is_a?(String)
|
74
|
+
real_method = location.to_s + "_log_location"
|
75
|
+
real_location = self.send(real_method) if self.respond_to? real_method
|
76
|
+
real_location = real_location.to_s
|
77
|
+
end
|
78
|
+
|
79
|
+
#if File.exists?(real_location) and options[:message].present?
|
80
|
+
if options[:message].present?
|
81
|
+
log = File.open(real_location, 'a')
|
82
|
+
log.puts options[:message]
|
83
|
+
log.close
|
84
|
+
end
|
85
|
+
end
|
86
|
+
end
|
87
|
+
end
|
88
|
+
end
|
data/scribbler.gemspec
ADDED
@@ -0,0 +1,24 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
require File.expand_path('../lib/scribbler/version', __FILE__)
|
3
|
+
|
4
|
+
Gem::Specification.new do |gem|
|
5
|
+
gem.authors = ["Jon Phenow"]
|
6
|
+
gem.email = ["jon.phenow@tstmedia.com"]
|
7
|
+
gem.description = %q{}
|
8
|
+
gem.summary = %q{}
|
9
|
+
gem.homepage = ""
|
10
|
+
|
11
|
+
gem.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
12
|
+
gem.files = `git ls-files`.split("\n")
|
13
|
+
gem.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
14
|
+
gem.name = "scribbler"
|
15
|
+
gem.require_paths = ["lib"]
|
16
|
+
gem.version = Scribbler::VERSION
|
17
|
+
|
18
|
+
gem.add_dependency 'activesupport'
|
19
|
+
gem.add_dependency 'thor'
|
20
|
+
|
21
|
+
gem.add_development_dependency 'rake'
|
22
|
+
gem.add_development_dependency 'rspec'
|
23
|
+
gem.add_development_dependency 'awesome_print'
|
24
|
+
end
|
@@ -0,0 +1,50 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
module Scribbler
|
4
|
+
describe Base do
|
5
|
+
subject { Base }
|
6
|
+
|
7
|
+
before :each do
|
8
|
+
Object.send :remove_const, :Rails if defined?(Rails) == 'constant' && Rails.class == Class
|
9
|
+
end
|
10
|
+
|
11
|
+
it "should give me a configurator" do
|
12
|
+
subject.config.should == Scribbler::Configurator
|
13
|
+
end
|
14
|
+
|
15
|
+
describe "include_in_application" do
|
16
|
+
it "should attempt to include to the Rails app" do
|
17
|
+
module ::Rails; end
|
18
|
+
::Rails.stub(:application => stub(:class => stub(:parent => stub(:send => true))))
|
19
|
+
subject.stub(:config => stub(:application_include => true))
|
20
|
+
subject.include_in_application.should be_true
|
21
|
+
end
|
22
|
+
|
23
|
+
it "should return nil because it caught the NameError of Rails not existing" do
|
24
|
+
subject.stub(:config => stub(:application_include => true))
|
25
|
+
subject.include_in_application.should be_nil
|
26
|
+
end
|
27
|
+
|
28
|
+
it "should not attempt to include in app if config is false" do
|
29
|
+
subject.stub(:config => stub(:application_include => false))
|
30
|
+
subject.include_in_application.should be_nil
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
describe "configure" do
|
35
|
+
it "kicks off the module and sends includes" do
|
36
|
+
subject.should_receive(:include_in_application).once
|
37
|
+
BaseIncluder.should_receive(:include_includeables).once
|
38
|
+
subject.configure do
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
it "sets some config variables" do
|
43
|
+
subject.configure do
|
44
|
+
config.application_include = true
|
45
|
+
end
|
46
|
+
subject.config.application_include.should be_true
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
@@ -0,0 +1,39 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
module Scribbler
|
4
|
+
describe CLI do
|
5
|
+
subject { CLI }
|
6
|
+
let(:cp_command) { 'cp x y' }
|
7
|
+
describe '.run_command' do
|
8
|
+
it 'calls backtick command with output' do
|
9
|
+
subject.should_receive(:`).with(cp_command)
|
10
|
+
subject.should_receive(:output).with(cp_command)
|
11
|
+
subject.run_command cp_command
|
12
|
+
end
|
13
|
+
|
14
|
+
it 'calls backtick command without output' do
|
15
|
+
subject.should_receive(:`).with(cp_command)
|
16
|
+
subject.should_not_receive(:output)
|
17
|
+
subject.run_command cp_command, :output => false
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
describe '.say' do
|
22
|
+
it 'calls puts wth the param' do
|
23
|
+
subject.should_receive(:puts).with("Boom")
|
24
|
+
subject.say "Boom"
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
describe '.mass_copy' do
|
29
|
+
let(:file_list) { ["/tmp/fake_file_1", "/tmp/fake_file 2"] }
|
30
|
+
let(:destination) { "/tmp/destination" }
|
31
|
+
it "copies all the files to the destination" do
|
32
|
+
subject.should_receive(:output).with('cp').once
|
33
|
+
subject.should_receive(:run_command).with("cp #{file_list[0]} #{destination}", :output => false).once
|
34
|
+
subject.should_receive(:run_command).with("cp #{file_list[1]} #{destination}", :output => false).once
|
35
|
+
subject.mass_copy file_list, destination
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
module Scribbler
|
4
|
+
describe Configurator do
|
5
|
+
subject { Configurator }
|
6
|
+
describe "logs" do
|
7
|
+
it "lets me set logs" do
|
8
|
+
new_logs = %w{1 2}
|
9
|
+
subject.logs = new_logs
|
10
|
+
subject.logs.should == new_logs
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
describe "application_include" do
|
15
|
+
it "get default" do
|
16
|
+
subject.application_include.should == false
|
17
|
+
end
|
18
|
+
|
19
|
+
it "should let me set it" do
|
20
|
+
subject.application_include = true
|
21
|
+
subject.application_include.should == true
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
module Scribbler
|
4
|
+
describe Executable do
|
5
|
+
subject { Executable }
|
6
|
+
describe '.install' do
|
7
|
+
it 'runs some CLI commands' do
|
8
|
+
CLI.should_receive(:run_command).with("mkdir -p #{Base.default_install_path}")
|
9
|
+
CLI.should_receive(:mass_copy).with(Base.templates, Base.default_install_path)
|
10
|
+
subject.install
|
11
|
+
end
|
12
|
+
|
13
|
+
let(:custom_path) { '/some/custom/path' }
|
14
|
+
it 'runs changes install path with given option' do
|
15
|
+
CLI.should_receive(:run_command).with("mkdir -p #{custom_path}")
|
16
|
+
CLI.should_receive(:mass_copy).with(Base.templates, custom_path)
|
17
|
+
subject.install :path => custom_path
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
# This file was generated by the `rspec --init` command. Conventionally, all
|
2
|
+
# specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`.
|
3
|
+
# Require this file using `require "spec_helper"` to ensure that it is only
|
4
|
+
# loaded once.
|
5
|
+
#
|
6
|
+
# See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
|
7
|
+
require 'scribbler'
|
8
|
+
require 'ap'
|
9
|
+
require 'active_support/inflector'
|
10
|
+
require 'active_support/concern'
|
11
|
+
Dir.glob(File.expand_path('../support/lib/**/*.rb', __FILE__)).each { |file| require file }
|
12
|
+
include SpecUtils
|
13
|
+
|
14
|
+
singletons = %w[Base CLI Configurator Executable]
|
15
|
+
RSpec.configure do |config|
|
16
|
+
config.treat_symbols_as_metadata_keys_with_true_values = true
|
17
|
+
config.run_all_when_everything_filtered = true
|
18
|
+
config.filter_run :focus
|
19
|
+
config.color = true
|
20
|
+
config.after(:all) do # Force a reset of some Classes
|
21
|
+
project_dir = ENV['BUNDLE_GEMFILE'].split('/')
|
22
|
+
project_dir.delete_at(-1)
|
23
|
+
project_dir = project_dir.join('/')
|
24
|
+
singletons.each do |s|
|
25
|
+
Scribbler.send(:remove_const, s)
|
26
|
+
load "#{project_dir}/lib/scribbler/#{s.downcase}.rb"
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
Scribbler::Base.configure do
|
2
|
+
# This is like the Rails configure. This is actually a #class_eval.
|
3
|
+
# Unless you'd like to experiment with breaking things and battling dragons,
|
4
|
+
# please only use what we document here.
|
5
|
+
#
|
6
|
+
# Alter the path to the configuration yaml. If you alter those variables
|
7
|
+
# from this config, those here will take precedence. Don't confuse yourself
|
8
|
+
# by having thos options here and there.
|
9
|
+
#
|
10
|
+
# config.yaml_config_path = Rails.root.join('config', 'scribbler.yml')
|
11
|
+
#
|
12
|
+
# Include the log methods to the rails application. So, if you have an
|
13
|
+
# application called Blog you can do Blog.log(...), rather than
|
14
|
+
# Scribbler.log(...). Default: false
|
15
|
+
#
|
16
|
+
# config.application_include = true
|
17
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
Scribbler::Base.configure do
|
2
|
+
# This is like the Rails configure. This is actually a #class_eval.
|
3
|
+
# Unless you'd like to experiment with breaking things and battling dragons,
|
4
|
+
# please only use what we document here.
|
5
|
+
#
|
6
|
+
# Alter the path to the configuration yaml. If you alter those variables
|
7
|
+
# from this config, those here will take precedence. Don't confuse yourself
|
8
|
+
# by having thos options here and there.
|
9
|
+
#
|
10
|
+
# config.yaml_config_path = Rails.root.join('config', 'scribbler.yml')
|
11
|
+
#
|
12
|
+
# Include the log methods to the rails application. So, if you have an
|
13
|
+
# application called Blog you can do Blog.log(...), rather than
|
14
|
+
# Scribbler.log(...). Default: false
|
15
|
+
#
|
16
|
+
# config.application_include = true
|
17
|
+
end
|
metadata
ADDED
@@ -0,0 +1,168 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: scribbler
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Jon Phenow
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2012-06-14 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: activesupport
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ! '>='
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: '0'
|
22
|
+
type: :runtime
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ! '>='
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: '0'
|
30
|
+
- !ruby/object:Gem::Dependency
|
31
|
+
name: thor
|
32
|
+
requirement: !ruby/object:Gem::Requirement
|
33
|
+
none: false
|
34
|
+
requirements:
|
35
|
+
- - ! '>='
|
36
|
+
- !ruby/object:Gem::Version
|
37
|
+
version: '0'
|
38
|
+
type: :runtime
|
39
|
+
prerelease: false
|
40
|
+
version_requirements: !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
42
|
+
requirements:
|
43
|
+
- - ! '>='
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
version: '0'
|
46
|
+
- !ruby/object:Gem::Dependency
|
47
|
+
name: rake
|
48
|
+
requirement: !ruby/object:Gem::Requirement
|
49
|
+
none: false
|
50
|
+
requirements:
|
51
|
+
- - ! '>='
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
version: '0'
|
54
|
+
type: :development
|
55
|
+
prerelease: false
|
56
|
+
version_requirements: !ruby/object:Gem::Requirement
|
57
|
+
none: false
|
58
|
+
requirements:
|
59
|
+
- - ! '>='
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
- !ruby/object:Gem::Dependency
|
63
|
+
name: rspec
|
64
|
+
requirement: !ruby/object:Gem::Requirement
|
65
|
+
none: false
|
66
|
+
requirements:
|
67
|
+
- - ! '>='
|
68
|
+
- !ruby/object:Gem::Version
|
69
|
+
version: '0'
|
70
|
+
type: :development
|
71
|
+
prerelease: false
|
72
|
+
version_requirements: !ruby/object:Gem::Requirement
|
73
|
+
none: false
|
74
|
+
requirements:
|
75
|
+
- - ! '>='
|
76
|
+
- !ruby/object:Gem::Version
|
77
|
+
version: '0'
|
78
|
+
- !ruby/object:Gem::Dependency
|
79
|
+
name: awesome_print
|
80
|
+
requirement: !ruby/object:Gem::Requirement
|
81
|
+
none: false
|
82
|
+
requirements:
|
83
|
+
- - ! '>='
|
84
|
+
- !ruby/object:Gem::Version
|
85
|
+
version: '0'
|
86
|
+
type: :development
|
87
|
+
prerelease: false
|
88
|
+
version_requirements: !ruby/object:Gem::Requirement
|
89
|
+
none: false
|
90
|
+
requirements:
|
91
|
+
- - ! '>='
|
92
|
+
- !ruby/object:Gem::Version
|
93
|
+
version: '0'
|
94
|
+
description: ''
|
95
|
+
email:
|
96
|
+
- jon.phenow@tstmedia.com
|
97
|
+
executables:
|
98
|
+
- scribbler
|
99
|
+
extensions: []
|
100
|
+
extra_rdoc_files: []
|
101
|
+
files:
|
102
|
+
- .gitignore
|
103
|
+
- .travis.yml
|
104
|
+
- Gemfile
|
105
|
+
- Gemfile.lock
|
106
|
+
- README.markdown
|
107
|
+
- Rakefile
|
108
|
+
- bin/scribbler
|
109
|
+
- lib/scribbler.rb
|
110
|
+
- lib/scribbler/base.rb
|
111
|
+
- lib/scribbler/cli.rb
|
112
|
+
- lib/scribbler/configurator.rb
|
113
|
+
- lib/scribbler/executable.rb
|
114
|
+
- lib/scribbler/includeables.rb
|
115
|
+
- lib/scribbler/version.rb
|
116
|
+
- scribbler.gemspec
|
117
|
+
- spec/scribbler/base_spec.rb
|
118
|
+
- spec/scribbler/cli_spec.rb
|
119
|
+
- spec/scribbler/configurator_spec.rb
|
120
|
+
- spec/scribbler/executable_spec.rb
|
121
|
+
- spec/scribbler/includeables_spec.rb
|
122
|
+
- spec/scribbler/version_spec.rb
|
123
|
+
- spec/scribbler_spec.rb
|
124
|
+
- spec/spec_helper.rb
|
125
|
+
- spec/support/examples/scribbler_example.rb
|
126
|
+
- spec/support/lib/spec_utils.rb
|
127
|
+
- templates/scribbler.rb
|
128
|
+
homepage: ''
|
129
|
+
licenses: []
|
130
|
+
post_install_message:
|
131
|
+
rdoc_options: []
|
132
|
+
require_paths:
|
133
|
+
- lib
|
134
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
135
|
+
none: false
|
136
|
+
requirements:
|
137
|
+
- - ! '>='
|
138
|
+
- !ruby/object:Gem::Version
|
139
|
+
version: '0'
|
140
|
+
segments:
|
141
|
+
- 0
|
142
|
+
hash: -3576438178393875545
|
143
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
144
|
+
none: false
|
145
|
+
requirements:
|
146
|
+
- - ! '>='
|
147
|
+
- !ruby/object:Gem::Version
|
148
|
+
version: '0'
|
149
|
+
segments:
|
150
|
+
- 0
|
151
|
+
hash: -3576438178393875545
|
152
|
+
requirements: []
|
153
|
+
rubyforge_project:
|
154
|
+
rubygems_version: 1.8.24
|
155
|
+
signing_key:
|
156
|
+
specification_version: 3
|
157
|
+
summary: ''
|
158
|
+
test_files:
|
159
|
+
- spec/scribbler/base_spec.rb
|
160
|
+
- spec/scribbler/cli_spec.rb
|
161
|
+
- spec/scribbler/configurator_spec.rb
|
162
|
+
- spec/scribbler/executable_spec.rb
|
163
|
+
- spec/scribbler/includeables_spec.rb
|
164
|
+
- spec/scribbler/version_spec.rb
|
165
|
+
- spec/scribbler_spec.rb
|
166
|
+
- spec/spec_helper.rb
|
167
|
+
- spec/support/examples/scribbler_example.rb
|
168
|
+
- spec/support/lib/spec_utils.rb
|