dronr 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (48) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +14 -0
  3. data/.rspec +2 -0
  4. data/CHANGELOG +0 -0
  5. data/COMINGSOON +108 -0
  6. data/Gemfile +3 -0
  7. data/LICENSE.txt +22 -0
  8. data/README.md +82 -0
  9. data/Rakefile +2 -0
  10. data/TODO +4 -0
  11. data/bin/dronr +6 -0
  12. data/dronr.gemspec +29 -0
  13. data/lib/dronr/cli.rb +76 -0
  14. data/lib/dronr/drone.rb +44 -0
  15. data/lib/dronr/drones/cleanup.rb +11 -0
  16. data/lib/dronr/drones/compass.rb +15 -0
  17. data/lib/dronr/drones/dotenv.rb +15 -0
  18. data/lib/dronr/drones/draper.rb +11 -0
  19. data/lib/dronr/drones/dronr.rb +19 -0
  20. data/lib/dronr/drones/factory_girl.rb +11 -0
  21. data/lib/dronr/drones/foundation.rb +15 -0
  22. data/lib/dronr/drones/foundation_icons.rb +15 -0
  23. data/lib/dronr/drones/git.rb +11 -0
  24. data/lib/dronr/drones/heroku.rb +11 -0
  25. data/lib/dronr/drones/migrant.rb +11 -0
  26. data/lib/dronr/drones/postgresql.rb +15 -0
  27. data/lib/dronr/drones/rspec.rb +20 -0
  28. data/lib/dronr/drones/slim.rb +11 -0
  29. data/lib/dronr/drones/underscore.rb +15 -0
  30. data/lib/dronr/drones.rb +23 -0
  31. data/lib/dronr/manager.rb +167 -0
  32. data/lib/dronr/register/canonical.yml +37 -0
  33. data/lib/dronr/register/standard.yml +27 -0
  34. data/lib/dronr/register.rb +91 -0
  35. data/lib/dronr/version.rb +3 -0
  36. data/lib/dronr.rb +17 -0
  37. data/spec/dronr/drone_spec.rb +75 -0
  38. data/spec/dronr/register_spec.rb +152 -0
  39. data/spec/fixtures/register_drone_not_found.yml +8 -0
  40. data/spec/fixtures/register_invalid.yml +8 -0
  41. data/spec/fixtures/register_keys_missing.yml +2 -0
  42. data/spec/fixtures/register_malformed.yml +7 -0
  43. data/spec/fixtures/register_template.yml +9 -0
  44. data/spec/spec_helper.rb +18 -0
  45. data/spec/support/fixture_path.rb +9 -0
  46. data/spec/support/sample_drones.rb +15 -0
  47. data/spec/tmp/dronr.yml +7 -0
  48. metadata +200 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 2d4f3a0a153eb347c2d172a10b0c22861543222b
4
+ data.tar.gz: 0789e70d405b9e51f16ce6f28d70267316ec081e
5
+ SHA512:
6
+ metadata.gz: e33cc38e6284fa1f3137fc298b29558e6ce156eb498005b4842017cfdc9b381896fb0bbbb599d2396266195e13fe9df6de69a5404923c903e6a1b43aa77d09c1
7
+ data.tar.gz: 421fc5cb03e75c5fb3ba36f1ff0cb553845e9c6086d470155f9f4191e894a360d4e70320f475670177dace8f1b78f12e3d4f0285c0ddbd6d50e6462dff12c98c
data/.gitignore ADDED
@@ -0,0 +1,14 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
10
+ *.bundle
11
+ *.so
12
+ *.o
13
+ *.a
14
+ mkmf.log
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --color
2
+ --require spec_helper
data/CHANGELOG ADDED
File without changes
data/COMINGSOON ADDED
@@ -0,0 +1,108 @@
1
+ .env
2
+ quiet_assets
3
+ letter_opener
4
+ js-routes
5
+ momentjs-rails
6
+ compass-rails
7
+ faker
8
+ simple_form
9
+ show_for
10
+ mapbox-rails
11
+
12
+ rabl-rails
13
+ gon
14
+ draper
15
+
16
+ email_validator
17
+ active_attr
18
+
19
+
20
+ incoming:
21
+ # core:
22
+
23
+ # app:
24
+ # - foreman
25
+ # - resque
26
+ # - sidekiq
27
+
28
+ # database:
29
+ - postgresql
30
+ - migrant
31
+
32
+ # templating:
33
+ - slim
34
+
35
+ # assets:
36
+ - foundation
37
+ - foundation_icons
38
+ - underscore
39
+
40
+ # development:
41
+ - dotenv
42
+ - rspec
43
+ # - guard
44
+ # - guard_rspec
45
+ - factory_girl
46
+
47
+ # integration:
48
+ # - shippable
49
+
50
+ # deployment:
51
+ # - heroku
52
+
53
+ # team:
54
+ # - slack
55
+
56
+ - cleanup
57
+
58
+ - git
59
+
60
+ bundled:
61
+
62
+ finished:
63
+
64
+
65
+
66
+ select2-rails
67
+
68
+ gritter
69
+
70
+
71
+ # app/workers
72
+
73
+ 'resque'
74
+ 'resque-web', require: 'resque_web'
75
+ gem 'resque-scheduler'
76
+ gem 'resque-retry'
77
+ gem 'resque-loner'
78
+ gem 'redis'
79
+
80
+ # OAuth for configurable routes
81
+ gem 'simple_admin_auth'
82
+
83
+ foreman
84
+ timecop
85
+
86
+ # spec
87
+
88
+
89
+ group :test do
90
+ gem 'simplecov', require: false
91
+ gem 'shoulda-matchers'
92
+ # gem 'webmock', '~> 1.13.0'
93
+ # gem 'vcr'
94
+ gem 'rspec-xml'
95
+ end
96
+
97
+ group :doc do
98
+ gem 'sdoc', require: false
99
+ end
100
+
101
+ # deploy
102
+ gem 'capistrano', '~> 3.2'
103
+ gem 'capistrano-rails', '~> 1.1'
104
+ gem 'honeybadger'
105
+
106
+ # lib
107
+ gem 'nokogiri'
108
+ gem 'color'
data/Gemfile ADDED
@@ -0,0 +1,3 @@
1
+ source 'https://rubygems.org'
2
+
3
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2014 recombinary
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,82 @@
1
+ This is a long-overdue rewrite of a previous project of mine, [jeriko/app_drone](https://github.com/jeriko/app_drone)
2
+
3
+ # Dronr
4
+
5
+ Dronr is your Rails 4 workhorse. Boring application setup, fully automated!
6
+
7
+ Dronr is opinionated, designed to promote best practices and coding patterns, and doesn't aim to provide installations for the totality of existing things.
8
+
9
+ ## Getting started
10
+
11
+ ### Installation
12
+
13
+ $ gem install dronr
14
+
15
+ ### Create a brand new app
16
+
17
+ $ dronr new MyApp
18
+
19
+ You can also supply a path to a valid register file
20
+
21
+ $ dronr new MyApp --template templates/prototyping.yml
22
+
23
+ Or try a popular configuration (coming soon)
24
+
25
+ $ dronr new MyApp --template https://dronr.recombinary.com/templates/api_server.yml
26
+
27
+
28
+ #### Under the hood
29
+
30
+ The `dronr new` command runs like so:
31
+
32
+ 1. Generate app structure (like `rails new`) with custom config (e.g. `--skip-test-unit` if RSpec was declared)
33
+ 2. Install dronr gem in newly generated app & generate binstub
34
+ 3. Set up register file if a template register was supplied (more on this later)
35
+ 4. Invoke `dronr up` to run any new drones
36
+
37
+ ### Bootstrapping an existing app (coming soon)
38
+
39
+ If your app was not generated with the `dronr new` command, you can bootstrap it by navigating to the app directory and running:
40
+
41
+ $ bundle exec dronr bootstrap
42
+
43
+ with an optional template argument
44
+
45
+ $ bundle exec dronr bootstrap --template templates/prototyping.yml
46
+
47
+ This will install the dronr gem, generate a binstub, and copy the template register.
48
+
49
+ Be aware that existing apps might already have undergone manual installation of some drones you may want to add. I'll add more info here later.
50
+
51
+
52
+ # Drones
53
+
54
+ ## Listing drones
55
+
56
+ Coming soon.
57
+
58
+ ## Adding a drone
59
+
60
+ Register a drone for installation by adding it's name to the 'incoming' list in .dronr.yml
61
+
62
+ incoming:
63
+ - rspec
64
+ - simple_form
65
+ - ...
66
+
67
+ Whenever you're ready to run new changes:
68
+
69
+ $ bin/dronr up
70
+
71
+ Drone work their way from `incoming`, to `bundled` (once a drone's gems have been installed), to `finished` (once a drone's installation commands have been executed).
72
+
73
+ Note that it may take multiple iterations of `dronr up` to complete the entire process. This is because gems & config are changing so code may need to be reloaded.
74
+
75
+
76
+ ## Contributing
77
+
78
+ 1. Fork it ( https://github.com/[my-github-username]/dronr/fork )
79
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
80
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
81
+ 4. Push to the branch (`git push origin my-new-feature`)
82
+ 5. Create a new Pull Request
data/Rakefile ADDED
@@ -0,0 +1,2 @@
1
+ require "bundler/gem_tasks"
2
+
data/TODO ADDED
@@ -0,0 +1,4 @@
1
+ # TODO
2
+
3
+ 1. Improve resilience against failures during dronr commands. For example, currently if bundle fails during `dronr up`, the app requires manual repairing.
4
+ 2. `dronr stage` to see what changes will be applied by `dronr up
data/bin/dronr ADDED
@@ -0,0 +1,6 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'dronr'
4
+
5
+ Dronr::CLI.start(ARGV)
6
+
data/dronr.gemspec ADDED
@@ -0,0 +1,29 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'dronr/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "dronr"
8
+ spec.version = Dronr::VERSION
9
+ spec.authors = ["Dan Davey"]
10
+ spec.email = ["dan@recombinary.com"]
11
+ spec.summary = %q{Dev automation for Rails apps}
12
+ spec.description = %q{}
13
+ spec.homepage = ""
14
+ spec.license = "MIT"
15
+
16
+ spec.files = `git ls-files -z`.split("\x0")
17
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
+ spec.require_paths = ["lib"]
20
+
21
+ spec.add_development_dependency "bundler", "~> 1.7"
22
+ spec.add_development_dependency "rake", "~> 10.0"
23
+ spec.add_development_dependency "rspec", "~> 3.0"
24
+
25
+ spec.add_dependency "rails", "~> 4"
26
+ spec.add_dependency "pry"
27
+ spec.add_dependency "thor"
28
+ spec.add_dependency "thor-rails"
29
+ end
data/lib/dronr/cli.rb ADDED
@@ -0,0 +1,76 @@
1
+ require 'thor'
2
+
3
+ module Dronr
4
+ class CLI < Thor
5
+
6
+ # TODO you need a better way to detect if dronr is being run within a Rails app.
7
+ # Maybe don't detect, just load Thor::Rails for the specific methods that require it?
8
+ # esp. since it's currently impossible to run full path commands e.g. `~/Code/appname/bin/dronr up`
9
+ IS_RAILS_APP = File.exists? File.join(Dir.getwd, 'config/environment.rb')
10
+
11
+ if IS_RAILS_APP
12
+ require 'thor/rails'
13
+ include Thor::Rails
14
+ end
15
+
16
+ desc 'new', 'Generates a new Rails app, with dronr installed'
17
+ option :template
18
+
19
+ def new(app_name)
20
+ app_requirement(false)
21
+
22
+ # TODO allow CLI params thru
23
+ # # args = Rails::Generators::ARGVScrubber.new([]).prepare!
24
+ # args = [app_name]
25
+
26
+ template_register = if template_path = options[:template]
27
+ Register.load(template_path)
28
+ else
29
+ Register.new
30
+ end
31
+
32
+ Dronr::Manager.from_scratch(app_name, template_register)
33
+ end
34
+
35
+
36
+ # desc 'stage', 'Generates a new Rails app, with dronr installed'
37
+ # def stage
38
+ # load_app
39
+ # app_requirement(true)
40
+
41
+ # app_generator = Rails::Generators::AppGenerator.new [Rails.root], {}, destination_root: Rails.root
42
+ # manager = Dronr::Manager.new(app_generator)
43
+ # manager.stage
44
+ # end
45
+
46
+ desc 'up', 'Installs all pending drones based on dronr.yml'
47
+ option :loop
48
+
49
+ def up
50
+ app_requirement(true)
51
+
52
+ Dronr::Manager.existing({ loop: options[:loop] })
53
+
54
+ end
55
+
56
+ # def yank
57
+ # app_requirement(true)
58
+ # # CONFIRM ARE YOU SURE?
59
+
60
+ # # self destruct, yank self completely
61
+ # end
62
+
63
+
64
+
65
+ protected
66
+
67
+ def app_requirement(required)
68
+ if IS_RAILS_APP
69
+ raise "FATAL: Existing app detected: #{::Rails.application}" if !required
70
+ else
71
+ raise "FATAL: App not found" if required
72
+ end
73
+ end
74
+
75
+ end
76
+ end
@@ -0,0 +1,44 @@
1
+ module Dronr
2
+
3
+ class Drone
4
+
5
+ attr_accessor :state
6
+ def initialize(state=nil)
7
+ @state = state
8
+ end
9
+
10
+ class DroneNotFoundError < StandardError
11
+ end
12
+
13
+ def self.find_class_by_human_name(human_name)
14
+ class_name = human_name.camelize
15
+ begin
16
+ "Dronr::Drones::#{class_name}".constantize
17
+ rescue Exception => e
18
+ raise DroneNotFoundError.new(human_name), "`#{human_name}` is not a valid Drone name (looked for #{class_name})"
19
+ end
20
+ end
21
+
22
+ def human_name
23
+ self.class.to_s.demodulize.underscore
24
+ end
25
+
26
+ def args_for_app_create
27
+ {}
28
+ end
29
+
30
+ %w{bundle install finish}.each do |directive|
31
+
32
+ define_singleton_method(directive) do |&block|
33
+ instance_variable_set :"@#{directive}_block", block
34
+ end
35
+
36
+ define_singleton_method("#{directive}_block") do |&block|
37
+ instance_variable_get :"@#{directive}_block"
38
+ end
39
+
40
+ end
41
+
42
+ end
43
+
44
+ end
@@ -0,0 +1,11 @@
1
+ module Dronr
2
+ module Drones
3
+ class Cleanup < Drone
4
+
5
+ install do
6
+ rake 'db:create'
7
+ end
8
+
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,15 @@
1
+ module Dronr
2
+ module Drones
3
+ class Compass < Drone
4
+
5
+ bundle do
6
+ gem 'compass-rails'
7
+ end
8
+
9
+ finish do
10
+ say_status :dronr, "Now add `@import 'compass'` to your stylesheet", :red
11
+ end
12
+
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,15 @@
1
+ module Dronr
2
+ module Drones
3
+ class Dotenv < Drone
4
+
5
+ bundle do
6
+ gem 'dotenv-rails', :groups => [:development, :test]
7
+ end
8
+
9
+ finish do
10
+ say_status :dronr, 'You probably want to generate a .env file'
11
+ end
12
+
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,11 @@
1
+ module Dronr
2
+ module Drones
3
+ class Draper < Drone
4
+
5
+ bundle do
6
+ gem 'draper'
7
+ end
8
+
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,19 @@
1
+ module Dronr
2
+ module Drones
3
+ class Dronr < Drone
4
+
5
+ bundle do
6
+ gem 'dronr', "~> #{::Dronr::VERSION}", group: :development
7
+ end
8
+
9
+ bundle do
10
+ gem 'dronr', path: '../../dronr', group: :development
11
+ end if ENV['DEBUG']
12
+
13
+ install do
14
+ bundle_command 'binstub dronr'
15
+ end
16
+
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,11 @@
1
+ module Dronr
2
+ module Drones
3
+ class FactoryGirl < Drone
4
+
5
+ bundle do
6
+ gem 'factory_girl_rails', group: %w(development test)
7
+ end
8
+
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,15 @@
1
+ module Dronr
2
+ module Drones
3
+ class Foundation < Drone
4
+
5
+ bundle do
6
+ gem 'foundation-rails'
7
+ end
8
+
9
+ install do
10
+ generate('foundation:install')
11
+ end
12
+
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,15 @@
1
+ module Dronr
2
+ module Drones
3
+ class FoundationIcons < Drone
4
+
5
+ bundle do
6
+ gem 'foundation-icons-sass-rails'
7
+ end
8
+
9
+ finish do
10
+ say_status :dronr, "Now add `@import 'foundation-icons'` to your stylesheet", :red
11
+ end
12
+
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,11 @@
1
+ module Dronr
2
+ module Drones
3
+ class Git < Drone
4
+
5
+ install do
6
+ git :init
7
+ end
8
+
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,11 @@
1
+ module Dronr
2
+ module Drones
3
+ class Heroku < Drone
4
+
5
+ bundle do
6
+ gem 'rails_12factor', group: :production
7
+ end
8
+
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,11 @@
1
+ module Dronr
2
+ module Drones
3
+ class Migrant < Drone
4
+
5
+ bundle do
6
+ gem 'migrant'
7
+ end
8
+
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,15 @@
1
+ module Dronr
2
+ module Drones
3
+ class Postgresql < Drone
4
+
5
+ def args_for_app_create
6
+ { database: 'postgresql' }
7
+ end
8
+
9
+ bundle do
10
+ gem 'pg'
11
+ end
12
+
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,20 @@
1
+ module Dronr
2
+ module Drones
3
+ class Rspec < Drone
4
+
5
+ def args_for_app_create
6
+ { skip_test_unit: true }
7
+ end
8
+
9
+ bundle do
10
+ gem 'rspec-rails', group: %w(development test)
11
+ end
12
+
13
+ install do
14
+ generate('rspec:install')
15
+ bundle_command 'binstub rspec-core'
16
+ end
17
+
18
+ end
19
+ end
20
+ end
@@ -0,0 +1,11 @@
1
+ module Dronr
2
+ module Drones
3
+ class Slim < Drone
4
+
5
+ bundle do
6
+ gem 'slim-rails'
7
+ end
8
+
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,15 @@
1
+ module Dronr
2
+ module Drones
3
+ class Underscore < Drone
4
+
5
+ bundle do
6
+ gem 'underscore-rails'
7
+ end
8
+
9
+ finish do
10
+ say_status :dronr, 'Now add `//= require underscore` to your javascript manifest'
11
+ end
12
+
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,23 @@
1
+ module Dronr
2
+ module Drones
3
+
4
+ extend ActiveSupport::Autoload
5
+
6
+ autoload :Cleanup
7
+ autoload :Compass
8
+ autoload :Dotenv
9
+ autoload :Dronr
10
+ autoload :Draper
11
+ autoload :FactoryGirl
12
+ autoload :Foundation
13
+ autoload :FoundationIcons
14
+ autoload :Git
15
+ autoload :Heroku
16
+ autoload :Migrant
17
+ autoload :Postgresql
18
+ autoload :Rspec
19
+ autoload :Slim
20
+ autoload :Underscore
21
+
22
+ end
23
+ end