cbaoth 0.0.2

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: 68704455909ea7e108851f70a6d947745647232d
4
+ data.tar.gz: 708213cbc735d928d8a9c9e284426d3a07c5b9c7
5
+ SHA512:
6
+ metadata.gz: 50817c6b64c3c59809717155cf624be76ecc6d6239417f5704fec417b45846de0ddc5b91cb53c179bf36eb58107c430ed4e1d5978b7d1656aa25097770920e9d
7
+ data.tar.gz: 5303ad67e22741b26cc8b99918b9570e4090cbfecf182ddb65a9179b96295b7e4d49b82537a3c764a59b2f79421cbf8ca0e4ae4b52e5bfeba81cd0144529ee76
data/.gitignore ADDED
@@ -0,0 +1,17 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --color
2
+ --format progress
data/Gemfile ADDED
@@ -0,0 +1,9 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in ruby_app_generator.gemspec
4
+ gemspec
5
+
6
+ group :development do
7
+ gem 'rspec'
8
+ gem 'guard-rspec'
9
+ end
data/Guardfile ADDED
@@ -0,0 +1,24 @@
1
+ # A sample Guardfile
2
+ # More info at https://github.com/guard/guard#readme
3
+
4
+ guard :rspec do
5
+ watch(%r{^spec/.+_spec\.rb$})
6
+ watch(%r{^lib/(.+)\.rb$}) { |m| "spec/lib/#{m[1]}_spec.rb" }
7
+ watch('spec/spec_helper.rb') { "spec" }
8
+
9
+ # Rails example
10
+ watch(%r{^app/(.+)\.rb$}) { |m| "spec/#{m[1]}_spec.rb" }
11
+ watch(%r{^app/(.*)(\.erb|\.haml)$}) { |m| "spec/#{m[1]}#{m[2]}_spec.rb" }
12
+ watch(%r{^app/controllers/(.+)_(controller)\.rb$}) { |m| ["spec/routing/#{m[1]}_routing_spec.rb", "spec/#{m[2]}s/#{m[1]}_#{m[2]}_spec.rb", "spec/acceptance/#{m[1]}_spec.rb"] }
13
+ watch(%r{^spec/support/(.+)\.rb$}) { "spec" }
14
+ watch('config/routes.rb') { "spec/routing" }
15
+ watch('app/controllers/application_controller.rb') { "spec/controllers" }
16
+
17
+ # Capybara features specs
18
+ watch(%r{^app/views/(.+)/.*\.(erb|haml)$}) { |m| "spec/features/#{m[1]}_spec.rb" }
19
+
20
+ # Turnip features and steps
21
+ watch(%r{^spec/acceptance/(.+)\.feature$})
22
+ watch(%r{^spec/acceptance/steps/(.+)_steps\.rb$}) { |m| Dir[File.join("**/#{m[1]}.feature")][0] || 'spec/acceptance' }
23
+ end
24
+
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2013 covard
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,35 @@
1
+ # Cbaoth
2
+
3
+ Ruby Gem to create a base ruby automation/whatever you want app from the command line. By simply typing cbaoth app_name.
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ gem 'cbaoth'
10
+
11
+ And then execute:
12
+
13
+ $ bundle
14
+
15
+ Or install it yourself as:
16
+
17
+ $ gem install cbaoth
18
+
19
+ ***
20
+ ## Usage
21
+
22
+ From the directory that you want to create your ruby app. Simply type:
23
+
24
+ $ cbaoth my_app
25
+
26
+ Replace *my_app* with the name of your app.
27
+
28
+ ***
29
+ ## Contributing
30
+
31
+ 1. Fork it
32
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
33
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
34
+ 4. Push to the branch (`git push origin my-new-feature`)
35
+ 5. Create new Pull Request
data/Rakefile ADDED
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
data/bin/cbaoth ADDED
@@ -0,0 +1,25 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'cbaoth'
4
+ require 'cbaoth/version'
5
+
6
+ app_name = ARGV.first
7
+
8
+ if app_name == '--help'
9
+ puts
10
+ puts "cbaoth v#{Cbaoth::VERSION}"
11
+ puts 'Author: Curtis Ovard'
12
+ puts "=" * 50
13
+ puts
14
+ puts 'The cbaoth creates a base ruby app, this layout is my base automation layout.'
15
+ puts 'To create your app simply type the following from the command line. (replace my_app_name with your ruby app name)'
16
+ puts 'It will generate a base ruby app within your current directory.'
17
+ puts
18
+ puts "\t $ cbaoth my_app_name"
19
+ puts
20
+ puts "Then follow the instructions output to the consel after that and you are set. The instructions just tell you to cd into"
21
+ puts "new app dir and run the respec and guard init commands."
22
+ else
23
+ gen = Cbaoth::Generator.new
24
+ gen.generate app_name
25
+ end
data/cbaoth.gemspec ADDED
@@ -0,0 +1,23 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'cbaoth/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "cbaoth"
8
+ spec.version = Cbaoth::VERSION
9
+ spec.authors = ["Curtis Ovard"]
10
+ spec.email = ["ovardcj@gmail.com"]
11
+ spec.description = %q{Gem to create base ruby automation apps from cli.}
12
+ spec.summary = %q{Gem to create a base ruby automation app from the command line. Simply typing cbaoth my_app_name}
13
+ spec.homepage = "https://github.com/covard/cbaoth"
14
+ spec.license = "MIT"
15
+
16
+ spec.files = `git ls-files`.split($/)
17
+ spec.executables = ['cbaoth']
18
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
+ spec.require_paths = ["lib"]
20
+
21
+ spec.add_development_dependency "bundler", "~> 1.3"
22
+ spec.add_development_dependency "rake"
23
+ end
@@ -0,0 +1,13 @@
1
+ production:
2
+ adapter: postgresql
3
+ database:
4
+ username:
5
+ password:
6
+ host: localhost
7
+
8
+ test:
9
+ adapter: postgresql
10
+ database:
11
+ username:
12
+ password:
13
+ host: localhost
@@ -0,0 +1,9 @@
1
+ source 'https://rubygems.org'
2
+
3
+ gem 'activerecord'
4
+ gem 'pg'
5
+ gem 'rspec'
6
+ gem 'guard-rspec'
7
+ gem 'protected_attributes'
8
+ gem "shoulda-matchers"
9
+ gem 'database_cleaner'
@@ -0,0 +1,72 @@
1
+ require 'active_record'
2
+ require 'yaml'
3
+ require 'logger'
4
+ require 'database_cleaner'
5
+
6
+ CONFIG = YAML::load(File.open('config/database.yml'))
7
+
8
+ task :default => :migrate
9
+ namespace :db do
10
+ desc "Migrate the database through scripts in db/migrate. Target specific version with VERSION=x"
11
+ task :migrate => :environment do
12
+ ActiveRecord::Migrator.migrate('db/migrate', ENV["VERSION"] ? ENV["VERSION"].to_i : nil )
13
+ end
14
+
15
+ task :drop => :environment do
16
+ puts "----- Drop DB -----"
17
+ ActiveRecord::Base.connection.drop_database CONFIG["production"]["database"]
18
+ end
19
+
20
+ task :create do
21
+ puts "----- Create DB -----"
22
+ config = YAML::load(File.open('config/database.yml'))
23
+ config['production']['database'] = 'postgres'
24
+ ActiveRecord::Base.establish_connection config['production']
25
+ ActiveRecord::Base.connection.create_database CONFIG["production"]["database"]
26
+
27
+ ActiveRecord::Base.establish_connection CONFIG["production"]["database"]
28
+ end
29
+
30
+ task :reset => :environment do
31
+ puts "----- Reset DB -----"
32
+ Rake::Task["db:drop"].invoke
33
+ Rake::Task["db:create"].invoke
34
+ Rake::Task["db:migrate"].invoke
35
+ Rake::Task["db:seed"].invoke
36
+ end
37
+
38
+ desc "Truncate all existing data"
39
+ task :truncate, [:arg1] => :environment do |t, args|
40
+ if args[:arg1] =~ /all/i
41
+ DatabaseCleaner.clean_with :truncation
42
+ else
43
+ DatabaseCleaner.clean_with :truncation, { only: [args[:arg1]] }
44
+ end
45
+ end
46
+
47
+ namespace :test do
48
+ desc "Migrate test DB"
49
+ task :migrate do
50
+ ActiveRecord::Base.establish_connection CONFIG["test"]
51
+ ActiveRecord::Migrator.migrate('db/migrate', ENV["VERSION"] ? ENV["VERSION"].to_i : nil )
52
+
53
+ end
54
+
55
+ desc "Create test DB"
56
+ task :create do
57
+ puts "----- Create DB -----"
58
+ config = YAML::load(File.open('config/database.yml'))
59
+ config['test']['database'] = 'postgres'
60
+ ActiveRecord::Base.establish_connection config['test']
61
+ ActiveRecord::Base.connection.create_database CONFIG["test"]["database"]
62
+
63
+ ActiveRecord::Base.establish_connection CONFIG["test"]["database"]
64
+ end
65
+ end
66
+
67
+ end
68
+
69
+ task :environment do
70
+ ActiveRecord::Base.establish_connection CONFIG["production"]
71
+ ActiveRecord::Base.logger = Logger.new(File.open('log/database.log', 'a'))
72
+ end
@@ -0,0 +1,3 @@
1
+ # todo: Fill in app name
2
+
3
+ todo: Put content here
data/lib/cbaoth.rb ADDED
@@ -0,0 +1,59 @@
1
+ require "cbaoth/version"
2
+
3
+ module Cbaoth
4
+
5
+ class Generator
6
+
7
+ def generate app_name
8
+ vars = init_variables app_name
9
+ create_app_name_dir app_name
10
+ create_dir_structure vars[:working_directory]
11
+ generate_base_files vars[:working_directory], vars[:gem_directory]
12
+ alert_user app_name
13
+ end
14
+
15
+ def init_variables app_name
16
+ wd = Dir.pwd + "/#{app_name}"
17
+ gem_dir = File.dirname(__FILE__)
18
+
19
+ { working_directory: wd, gem_directory: gem_dir }
20
+ end
21
+
22
+ def create_app_name_dir app_name
23
+ puts "creating app '#{app_name}' folder"
24
+ puts
25
+ system "mkdir #{app_name}"
26
+ end
27
+
28
+ def create_dir_structure wd
29
+ puts "creating base app dir structure"
30
+ puts
31
+ system "mkdir -p #{wd}/lib #{wd}/bin #{wd}/config #{wd}/db/migrate"
32
+ end
33
+
34
+ def generate_base_files wd, gem_dir
35
+ puts "generating base files"
36
+ puts
37
+ base_files = gem_dir + "/base_files"
38
+ system "cp #{base_files}/base_gemfile #{wd}/Gemfile"
39
+ system "cp #{base_files}/base_rakefile #{wd}/Rakefile"
40
+ system "cp #{base_files}/base_readme #{wd}/README.md"
41
+ system "cp #{base_files}/base_database.yml #{wd}/config/database.yml"
42
+ end
43
+
44
+ def alert_user app_name
45
+ puts
46
+ puts "*" * 90
47
+ puts "App created if you want to set up rspec and guard follow the instructions below:"
48
+ puts "-" * 90
49
+ puts "\t$ cd #{app_name}"
50
+ puts "\t$ rspec --init"
51
+ puts "\t$ guard init rspec"
52
+ puts
53
+ puts "That's it. Thanks for using cbaoth."
54
+ puts "Happy rubying =) - #{ENV["LOGNAME"]}"
55
+ end
56
+
57
+ end
58
+
59
+ end
@@ -0,0 +1,3 @@
1
+ module Cbaoth
2
+ VERSION = "0.0.2"
3
+ end
@@ -0,0 +1,84 @@
1
+ require 'spec_helper'
2
+
3
+ describe Cbaoth::Generator do
4
+ before :all do
5
+ FileUtils.mkdir_p("spec/testing_dir/test")
6
+ Dir.chdir("spec/testing_dir/test")
7
+ end
8
+ before :each do
9
+ @generator = Cbaoth::Generator.new
10
+ end
11
+
12
+ describe '#generate' do
13
+ it { should respond_to :generate }
14
+ end
15
+
16
+ describe '#init_variables' do
17
+ it { should respond_to :init_variables }
18
+ it 'initializes and returns 2 instance variables' do
19
+ vars = {}
20
+ vars = @generator.init_variables 'test'
21
+ expect(vars.length).to eq 2
22
+ end
23
+ end
24
+
25
+ describe '#create_dir_structure' do
26
+ it { should respond_to :create_dir_structure }
27
+ previous_dir = Dir.pwd
28
+ before do
29
+ # Dir.chdir("spec/testing_dir/test")
30
+ dirs = @generator.init_variables 'test'
31
+ @generator.create_dir_structure dirs[:working_directory]
32
+ end
33
+
34
+ it 'creates the bin dir' do
35
+ expect(Dir.exist?("bin")).to be_true
36
+ end
37
+
38
+ it 'creates the lib dir' do
39
+ expect(Dir.exist?('lib')).to be_true
40
+ end
41
+
42
+ it 'creates the config dir' do
43
+ expect(Dir.exist?('config')).to be_true
44
+ end
45
+
46
+ it 'creates the db dir' do
47
+ expect(Dir.exist?('db')).to be_true
48
+ end
49
+
50
+ it 'creates the db/migrate dir' do
51
+ expect(Dir.exist?('db/migrate')).to be_true
52
+ end
53
+
54
+ # after { Dir.chdir(previous_dir) }
55
+ end
56
+
57
+ describe '#generate_base_files' do
58
+ it { should respond_to :generate_base_files }
59
+ before {
60
+ wd = Dir.pwd
61
+ @generator.generate_base_files wd, "../../../"
62
+ }
63
+ it 'creates a rakefile' do
64
+ expect(File.exist?("Rakefile")).to be_true
65
+ end
66
+
67
+ it 'creates a gemfile' do
68
+ expect(File.exist?("Gemfile")).to be_true
69
+ end
70
+
71
+ it 'creates a readmefile' do
72
+ expect(File.exist?("README.md")).to be_true
73
+ end
74
+
75
+ it 'creates a database.yml file' do
76
+ expect(File.exist?("config/database.yml")).to be_true
77
+ end
78
+ end
79
+
80
+ describe '#alert_user' do
81
+ it { should respond_to :alert_user }
82
+ end
83
+
84
+ end
@@ -0,0 +1,25 @@
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
+
8
+ require_relative '../lib/ruby_app_generator'
9
+
10
+ RSpec.configure do |config|
11
+ config.treat_symbols_as_metadata_keys_with_true_values = true
12
+ config.run_all_when_everything_filtered = true
13
+ config.filter_run :focus
14
+
15
+ # todo: change this to after so we don't have unwanted test dir's/files
16
+ config.after :suite do
17
+ FileUtils.rm_rf "spec/testing_dir"
18
+ end
19
+
20
+ # Run specs in random order to surface order dependencies. If you find an
21
+ # order dependency and want to debug it, you can fix the order by providing
22
+ # the seed, which is printed after each run.
23
+ # --seed 1234
24
+ config.order = 'random'
25
+ end
metadata ADDED
@@ -0,0 +1,93 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: cbaoth
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.2
5
+ platform: ruby
6
+ authors:
7
+ - Curtis Ovard
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2013-07-25 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.3'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ~>
25
+ - !ruby/object:Gem::Version
26
+ version: '1.3'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - '>='
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - '>='
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ description: Gem to create base ruby automation apps from cli.
42
+ email:
43
+ - ovardcj@gmail.com
44
+ executables:
45
+ - cbaoth
46
+ extensions: []
47
+ extra_rdoc_files: []
48
+ files:
49
+ - .gitignore
50
+ - .rspec
51
+ - Gemfile
52
+ - Guardfile
53
+ - LICENSE.txt
54
+ - README.md
55
+ - Rakefile
56
+ - bin/cbaoth
57
+ - cbaoth.gemspec
58
+ - lib/base_files/base_database.yml
59
+ - lib/base_files/base_gemfile
60
+ - lib/base_files/base_rakefile
61
+ - lib/base_files/base_readme
62
+ - lib/cbaoth.rb
63
+ - lib/cbaoth/version.rb
64
+ - spec/lib/cbaoth_spec.rb
65
+ - spec/spec_helper.rb
66
+ homepage: https://github.com/covard/cbaoth
67
+ licenses:
68
+ - MIT
69
+ metadata: {}
70
+ post_install_message:
71
+ rdoc_options: []
72
+ require_paths:
73
+ - lib
74
+ required_ruby_version: !ruby/object:Gem::Requirement
75
+ requirements:
76
+ - - '>='
77
+ - !ruby/object:Gem::Version
78
+ version: '0'
79
+ required_rubygems_version: !ruby/object:Gem::Requirement
80
+ requirements:
81
+ - - '>='
82
+ - !ruby/object:Gem::Version
83
+ version: '0'
84
+ requirements: []
85
+ rubyforge_project:
86
+ rubygems_version: 2.0.3
87
+ signing_key:
88
+ specification_version: 4
89
+ summary: Gem to create a base ruby automation app from the command line. Simply typing
90
+ cbaoth my_app_name
91
+ test_files:
92
+ - spec/lib/cbaoth_spec.rb
93
+ - spec/spec_helper.rb