maguro 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +4 -0
- data/.rspec +2 -0
- data/.ruby-gemset +1 -0
- data/.ruby-version +1 -0
- data/Gemfile +4 -0
- data/Gemfile.lock +102 -0
- data/LICENSE.txt +22 -0
- data/README.md +77 -0
- data/Rakefile +2 -0
- data/bin/maguro +18 -0
- data/lib/maguro.rb +9 -0
- data/lib/maguro/app_generator.rb +113 -0
- data/lib/maguro/bitbucket.rb +185 -0
- data/lib/maguro/cli.rb +10 -0
- data/lib/maguro/features.rb +389 -0
- data/lib/maguro/gemfile.rb +14 -0
- data/lib/maguro/github.rb +23 -0
- data/lib/maguro/heroku.rb +45 -0
- data/lib/maguro/keychain.rb +53 -0
- data/lib/maguro/version.rb +7 -0
- data/maguro.gemspec +27 -0
- data/spec/maguro/app_generator_spec.rb +46 -0
- data/spec/maguro/bitbucket_spec.rb +46 -0
- data/spec/spec_helper.rb +89 -0
- data/templates/home_controller.rb +4 -0
- data/templates/home_index.html.erb +2 -0
- metadata +145 -0
@@ -0,0 +1,53 @@
|
|
1
|
+
require 'shellwords'
|
2
|
+
|
3
|
+
module Maguro
|
4
|
+
class Keychain
|
5
|
+
class << self
|
6
|
+
|
7
|
+
def add_account(server, username, password)
|
8
|
+
puts "Keychain: adding credentials with username #{username} for server #{server}"
|
9
|
+
server = custom_server(server)
|
10
|
+
|
11
|
+
# Try to delete existing password, in case it already exists
|
12
|
+
delete_account(server)
|
13
|
+
|
14
|
+
# Add the new password
|
15
|
+
r = %x[security add-internet-password -a #{Shellwords::escape(username)} -s #{Shellwords::escape(server)} -w #{Shellwords::escape(password)} > /dev/null 2>&1]
|
16
|
+
end
|
17
|
+
|
18
|
+
def delete_account(server)
|
19
|
+
puts "Keychain: attempting to remove credentials for #{server}"
|
20
|
+
server = custom_server(server)
|
21
|
+
|
22
|
+
# Suppress output, since command will expectedly fail if credentials have not yet been saved for the server
|
23
|
+
r = %x[security delete-internet-password -s #{Shellwords::escape(server)} > /dev/null 2>&1]
|
24
|
+
end
|
25
|
+
|
26
|
+
def retrieve_account(server)
|
27
|
+
puts "Keychain: attempting to retrieve credentials for #{server}"
|
28
|
+
server = custom_server(server)
|
29
|
+
|
30
|
+
# Retrieve the password from the keychain, but do not print it to STDOUT
|
31
|
+
output = %x[security 2>&1 >/dev/null find-internet-password -gs #{Shellwords::escape(server)}]
|
32
|
+
password = output[/^password: "(.*)"$/, 1]
|
33
|
+
return nil if password.nil?
|
34
|
+
|
35
|
+
output = %x[security find-internet-password -s #{Shellwords::escape(server)}]
|
36
|
+
username = output[/"acct"<blob>="(.*)"$/, 1]
|
37
|
+
return nil if username.nil?
|
38
|
+
|
39
|
+
{ username: username, password: password }
|
40
|
+
end
|
41
|
+
|
42
|
+
private
|
43
|
+
PREFIX = "maguro-"
|
44
|
+
|
45
|
+
# Use a custom prefix, so that Maguro's keychain entries will be separate
|
46
|
+
# from any others in the Keychain (for the same domain)
|
47
|
+
# Prepend the prefix, unless it has already been added
|
48
|
+
def custom_server(server)
|
49
|
+
"#{PREFIX}#{server}" if !server.start_with? PREFIX
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
data/maguro.gemspec
ADDED
@@ -0,0 +1,27 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'maguro/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "maguro"
|
8
|
+
spec.version = Maguro::VERSION
|
9
|
+
spec.authors = ["Bottega8", "newyorkpizza"]
|
10
|
+
spec.email = ["haji@bottega8.com"]
|
11
|
+
spec.summary = %q{Bottega8's rails application template.}
|
12
|
+
spec.description = %q{Get stuff done faster.}
|
13
|
+
spec.homepage = "https://github.com/Bottega8/maguro"
|
14
|
+
spec.license = "MIT"
|
15
|
+
|
16
|
+
spec.files = `git ls-files -z`.split("\x0")
|
17
|
+
spec.executables << 'maguro'
|
18
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
|
+
spec.require_paths = ["lib"]
|
20
|
+
|
21
|
+
spec.add_runtime_dependency 'thor', '~> 0.19'
|
22
|
+
spec.add_runtime_dependency 'rails', Maguro::RAILS_VERSION
|
23
|
+
|
24
|
+
spec.add_development_dependency "bundler", "~> 1.6"
|
25
|
+
spec.add_development_dependency "rake", '~> 0'
|
26
|
+
spec.add_development_dependency "rspec", '~> 0'
|
27
|
+
end
|
@@ -0,0 +1,46 @@
|
|
1
|
+
require_relative '../../lib/maguro'
|
2
|
+
require 'rails/generators/rails/app/app_generator'
|
3
|
+
require 'tmpdir'
|
4
|
+
require 'fileutils'
|
5
|
+
|
6
|
+
describe Maguro::AppGenerator do
|
7
|
+
|
8
|
+
describe 'app generator command line options' do
|
9
|
+
|
10
|
+
before(:example) do
|
11
|
+
# Perform the exact same set up as in 'bin/maguro',
|
12
|
+
# so that it is almost as if we've run 'maguro new' on the command line
|
13
|
+
templates_root = File.expand_path(File.join("..", "templates"), File.dirname(__FILE__))
|
14
|
+
Maguro::AppGenerator.source_root templates_root
|
15
|
+
Maguro::AppGenerator.source_paths << Rails::Generators::AppGenerator.source_root
|
16
|
+
|
17
|
+
# Generates a unique directory
|
18
|
+
@temp_directory = Dir.mktmpdir
|
19
|
+
@pwd = Dir.pwd
|
20
|
+
Dir.chdir @temp_directory
|
21
|
+
puts "Generated and switched to temp directory #{@temp_directory}"
|
22
|
+
end
|
23
|
+
|
24
|
+
after(:example) do
|
25
|
+
# Cleans up any files generated by the generator
|
26
|
+
FileUtils.rm_rf(@temp_directory)
|
27
|
+
Dir.chdir @pwd
|
28
|
+
puts "Cleaned #{@temp_directory}"
|
29
|
+
end
|
30
|
+
|
31
|
+
|
32
|
+
it "should throw exception when no organization is passed in" do
|
33
|
+
arguments = ["new", "test2", nil]
|
34
|
+
|
35
|
+
result = Maguro::Cli.start(arguments)
|
36
|
+
# TODO: the exception does not propagate up to here.
|
37
|
+
# How to get a return value, or the start output, or is there a better API to
|
38
|
+
# perform this test?
|
39
|
+
end
|
40
|
+
|
41
|
+
it "should throw exception when there is a saved organization, and no organization is passed in" do
|
42
|
+
# TODO fill in to test exception at line 42 in app_generator.rb
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
end
|
@@ -0,0 +1,46 @@
|
|
1
|
+
require_relative '../../lib/maguro/bitbucket'
|
2
|
+
require_relative '../../lib/maguro/keychain'
|
3
|
+
require 'rails/generators/rails/app/app_generator'
|
4
|
+
|
5
|
+
describe Maguro::Bitbucket do
|
6
|
+
|
7
|
+
describe '#get_repo' do
|
8
|
+
it "returns the repo if found" do
|
9
|
+
# Create generator, since it may be needed to prompt the user
|
10
|
+
# for their BitBucket credentials
|
11
|
+
project = Rails::Generators::AppGenerator.new(["."])
|
12
|
+
|
13
|
+
app_name = "quiz-app"
|
14
|
+
organization = "bottega8"
|
15
|
+
bitbucket = Maguro::Bitbucket.new(project, app_name, organization)
|
16
|
+
|
17
|
+
expect(bitbucket.git_url).to match /https:\/\/(.*)@bitbucket.org\/#{organization}\/quiz-app.git/
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
describe '#create_repo' do
|
22
|
+
it 'creates a new repo on bitbucket' do
|
23
|
+
# TODO: Doug: How can we pass the organization to the generator and the tests (and other code)?
|
24
|
+
organization = "bottega8"
|
25
|
+
|
26
|
+
# Generate repository name that looks like:
|
27
|
+
# test-41T5IGEW5YJ
|
28
|
+
rando = (0..10).map {(('1'..'9').to_a + ('A'..'Z').to_a)[rand(36)]}.join.downcase
|
29
|
+
app_name = "test-#{rando}"
|
30
|
+
|
31
|
+
bitbucket = Maguro::Bitbucket.new(nil, app_name, organization)
|
32
|
+
bitbucket.create_repo
|
33
|
+
|
34
|
+
expect(bitbucket.git_url).to match /https:\/\/(.*)@bitbucket.org\/#{organization}\/#{app_name}.git/
|
35
|
+
|
36
|
+
# Remove the repository from BitBucket
|
37
|
+
bitbucket.delete_repo
|
38
|
+
|
39
|
+
# Ensure that the repository has actually been deleted
|
40
|
+
info = bitbucket.get_repo
|
41
|
+
expect(info).to be_nil
|
42
|
+
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,89 @@
|
|
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
|
+
# The generated `.rspec` file contains `--require spec_helper` which will cause this
|
4
|
+
# file to always be loaded, without a need to explicitly require it in any files.
|
5
|
+
#
|
6
|
+
# Given that it is always loaded, you are encouraged to keep this file as
|
7
|
+
# light-weight as possible. Requiring heavyweight dependencies from this file
|
8
|
+
# will add to the boot time of your test suite on EVERY test run, even for an
|
9
|
+
# individual file that may not need all of that loaded. Instead, consider making
|
10
|
+
# a separate helper file that requires the additional dependencies and performs
|
11
|
+
# the additional setup, and require it from the spec files that actually need it.
|
12
|
+
#
|
13
|
+
# The `.rspec` file also contains a few flags that are not defaults but that
|
14
|
+
# users commonly want.
|
15
|
+
#
|
16
|
+
# See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
|
17
|
+
RSpec.configure do |config|
|
18
|
+
# rspec-expectations config goes here. You can use an alternate
|
19
|
+
# assertion/expectation library such as wrong or the stdlib/minitest
|
20
|
+
# assertions if you prefer.
|
21
|
+
config.expect_with :rspec do |expectations|
|
22
|
+
# This option will default to `true` in RSpec 4. It makes the `description`
|
23
|
+
# and `failure_message` of custom matchers include text for helper methods
|
24
|
+
# defined using `chain`, e.g.:
|
25
|
+
# be_bigger_than(2).and_smaller_than(4).description
|
26
|
+
# # => "be bigger than 2 and smaller than 4"
|
27
|
+
# ...rather than:
|
28
|
+
# # => "be bigger than 2"
|
29
|
+
expectations.include_chain_clauses_in_custom_matcher_descriptions = true
|
30
|
+
end
|
31
|
+
|
32
|
+
# rspec-mocks config goes here. You can use an alternate test double
|
33
|
+
# library (such as bogus or mocha) by changing the `mock_with` option here.
|
34
|
+
config.mock_with :rspec do |mocks|
|
35
|
+
# Prevents you from mocking or stubbing a method that does not exist on
|
36
|
+
# a real object. This is generally recommended, and will default to
|
37
|
+
# `true` in RSpec 4.
|
38
|
+
mocks.verify_partial_doubles = true
|
39
|
+
end
|
40
|
+
|
41
|
+
# The settings below are suggested to provide a good initial experience
|
42
|
+
# with RSpec, but feel free to customize to your heart's content.
|
43
|
+
=begin
|
44
|
+
# These two settings work together to allow you to limit a spec run
|
45
|
+
# to individual examples or groups you care about by tagging them with
|
46
|
+
# `:focus` metadata. When nothing is tagged with `:focus`, all examples
|
47
|
+
# get run.
|
48
|
+
config.filter_run :focus
|
49
|
+
config.run_all_when_everything_filtered = true
|
50
|
+
|
51
|
+
# Limits the available syntax to the non-monkey patched syntax that is recommended.
|
52
|
+
# For more details, see:
|
53
|
+
# - http://myronmars.to/n/dev-blog/2012/06/rspecs-new-expectation-syntax
|
54
|
+
# - http://teaisaweso.me/blog/2013/05/27/rspecs-new-message-expectation-syntax/
|
55
|
+
# - http://myronmars.to/n/dev-blog/2014/05/notable-changes-in-rspec-3#new__config_option_to_disable_rspeccore_monkey_patching
|
56
|
+
config.disable_monkey_patching!
|
57
|
+
|
58
|
+
# This setting enables warnings. It's recommended, but in some cases may
|
59
|
+
# be too noisy due to issues in dependencies.
|
60
|
+
config.warnings = true
|
61
|
+
|
62
|
+
# Many RSpec users commonly either run the entire suite or an individual
|
63
|
+
# file, and it's useful to allow more verbose output when running an
|
64
|
+
# individual spec file.
|
65
|
+
if config.files_to_run.one?
|
66
|
+
# Use the documentation formatter for detailed output,
|
67
|
+
# unless a formatter has already been configured
|
68
|
+
# (e.g. via a command-line flag).
|
69
|
+
config.default_formatter = 'doc'
|
70
|
+
end
|
71
|
+
|
72
|
+
# Print the 10 slowest examples and example groups at the
|
73
|
+
# end of the spec run, to help surface which specs are running
|
74
|
+
# particularly slow.
|
75
|
+
config.profile_examples = 10
|
76
|
+
|
77
|
+
# Run specs in random order to surface order dependencies. If you find an
|
78
|
+
# order dependency and want to debug it, you can fix the order by providing
|
79
|
+
# the seed, which is printed after each run.
|
80
|
+
# --seed 1234
|
81
|
+
config.order = :random
|
82
|
+
|
83
|
+
# Seed global randomization in this process using the `--seed` CLI option.
|
84
|
+
# Setting this allows you to use `--seed` to deterministically reproduce
|
85
|
+
# test failures related to randomization by passing the same `--seed` value
|
86
|
+
# as the one that triggered the failure.
|
87
|
+
Kernel.srand config.seed
|
88
|
+
=end
|
89
|
+
end
|
metadata
ADDED
@@ -0,0 +1,145 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: maguro
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Bottega8
|
8
|
+
- newyorkpizza
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2015-01-13 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: thor
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
|
+
requirements:
|
18
|
+
- - "~>"
|
19
|
+
- !ruby/object:Gem::Version
|
20
|
+
version: '0.19'
|
21
|
+
type: :runtime
|
22
|
+
prerelease: false
|
23
|
+
version_requirements: !ruby/object:Gem::Requirement
|
24
|
+
requirements:
|
25
|
+
- - "~>"
|
26
|
+
- !ruby/object:Gem::Version
|
27
|
+
version: '0.19'
|
28
|
+
- !ruby/object:Gem::Dependency
|
29
|
+
name: rails
|
30
|
+
requirement: !ruby/object:Gem::Requirement
|
31
|
+
requirements:
|
32
|
+
- - '='
|
33
|
+
- !ruby/object:Gem::Version
|
34
|
+
version: 4.2.0
|
35
|
+
type: :runtime
|
36
|
+
prerelease: false
|
37
|
+
version_requirements: !ruby/object:Gem::Requirement
|
38
|
+
requirements:
|
39
|
+
- - '='
|
40
|
+
- !ruby/object:Gem::Version
|
41
|
+
version: 4.2.0
|
42
|
+
- !ruby/object:Gem::Dependency
|
43
|
+
name: bundler
|
44
|
+
requirement: !ruby/object:Gem::Requirement
|
45
|
+
requirements:
|
46
|
+
- - "~>"
|
47
|
+
- !ruby/object:Gem::Version
|
48
|
+
version: '1.6'
|
49
|
+
type: :development
|
50
|
+
prerelease: false
|
51
|
+
version_requirements: !ruby/object:Gem::Requirement
|
52
|
+
requirements:
|
53
|
+
- - "~>"
|
54
|
+
- !ruby/object:Gem::Version
|
55
|
+
version: '1.6'
|
56
|
+
- !ruby/object:Gem::Dependency
|
57
|
+
name: rake
|
58
|
+
requirement: !ruby/object:Gem::Requirement
|
59
|
+
requirements:
|
60
|
+
- - "~>"
|
61
|
+
- !ruby/object:Gem::Version
|
62
|
+
version: '0'
|
63
|
+
type: :development
|
64
|
+
prerelease: false
|
65
|
+
version_requirements: !ruby/object:Gem::Requirement
|
66
|
+
requirements:
|
67
|
+
- - "~>"
|
68
|
+
- !ruby/object:Gem::Version
|
69
|
+
version: '0'
|
70
|
+
- !ruby/object:Gem::Dependency
|
71
|
+
name: rspec
|
72
|
+
requirement: !ruby/object:Gem::Requirement
|
73
|
+
requirements:
|
74
|
+
- - "~>"
|
75
|
+
- !ruby/object:Gem::Version
|
76
|
+
version: '0'
|
77
|
+
type: :development
|
78
|
+
prerelease: false
|
79
|
+
version_requirements: !ruby/object:Gem::Requirement
|
80
|
+
requirements:
|
81
|
+
- - "~>"
|
82
|
+
- !ruby/object:Gem::Version
|
83
|
+
version: '0'
|
84
|
+
description: Get stuff done faster.
|
85
|
+
email:
|
86
|
+
- haji@bottega8.com
|
87
|
+
executables:
|
88
|
+
- maguro
|
89
|
+
extensions: []
|
90
|
+
extra_rdoc_files: []
|
91
|
+
files:
|
92
|
+
- ".gitignore"
|
93
|
+
- ".rspec"
|
94
|
+
- ".ruby-gemset"
|
95
|
+
- ".ruby-version"
|
96
|
+
- Gemfile
|
97
|
+
- Gemfile.lock
|
98
|
+
- LICENSE.txt
|
99
|
+
- README.md
|
100
|
+
- Rakefile
|
101
|
+
- bin/maguro
|
102
|
+
- lib/maguro.rb
|
103
|
+
- lib/maguro/app_generator.rb
|
104
|
+
- lib/maguro/bitbucket.rb
|
105
|
+
- lib/maguro/cli.rb
|
106
|
+
- lib/maguro/features.rb
|
107
|
+
- lib/maguro/gemfile.rb
|
108
|
+
- lib/maguro/github.rb
|
109
|
+
- lib/maguro/heroku.rb
|
110
|
+
- lib/maguro/keychain.rb
|
111
|
+
- lib/maguro/version.rb
|
112
|
+
- maguro.gemspec
|
113
|
+
- spec/maguro/app_generator_spec.rb
|
114
|
+
- spec/maguro/bitbucket_spec.rb
|
115
|
+
- spec/spec_helper.rb
|
116
|
+
- templates/home_controller.rb
|
117
|
+
- templates/home_index.html.erb
|
118
|
+
homepage: https://github.com/Bottega8/maguro
|
119
|
+
licenses:
|
120
|
+
- MIT
|
121
|
+
metadata: {}
|
122
|
+
post_install_message:
|
123
|
+
rdoc_options: []
|
124
|
+
require_paths:
|
125
|
+
- lib
|
126
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
127
|
+
requirements:
|
128
|
+
- - ">="
|
129
|
+
- !ruby/object:Gem::Version
|
130
|
+
version: '0'
|
131
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
132
|
+
requirements:
|
133
|
+
- - ">="
|
134
|
+
- !ruby/object:Gem::Version
|
135
|
+
version: '0'
|
136
|
+
requirements: []
|
137
|
+
rubyforge_project:
|
138
|
+
rubygems_version: 2.4.5
|
139
|
+
signing_key:
|
140
|
+
specification_version: 4
|
141
|
+
summary: Bottega8's rails application template.
|
142
|
+
test_files:
|
143
|
+
- spec/maguro/app_generator_spec.rb
|
144
|
+
- spec/maguro/bitbucket_spec.rb
|
145
|
+
- spec/spec_helper.rb
|