ponytail 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.
- checksums.yaml +7 -0
- data/.gitignore +19 -0
- data/.rspec +2 -0
- data/.travis.yml +3 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +29 -0
- data/Rakefile +6 -0
- data/app/assets/javascripts/ponytail/application.js +1 -0
- data/app/assets/javascripts/ponytail/migrations.js +20 -0
- data/app/assets/stylesheets/ponytail/application.css +17 -0
- data/app/controllers/ponytail/migrations_controller.rb +45 -0
- data/app/views/layouts/ponytail/application.html.erb +14 -0
- data/app/views/ponytail/migrations/_migration.html.erb +10 -0
- data/app/views/ponytail/migrations/index.html.erb +13 -0
- data/app/views/ponytail/migrations/new.html.erb +10 -0
- data/config/routes.rb +8 -0
- data/lib/ponytail/engine.rb +4 -0
- data/lib/ponytail/migration.rb +40 -0
- data/lib/ponytail/version.rb +3 -0
- data/lib/ponytail.rb +2 -0
- data/ponytail.gemspec +26 -0
- data/spec/migration_spec.rb +21 -0
- data/spec/ponytail_spec.rb +7 -0
- data/spec/spec_helper.rb +4 -0
- metadata +127 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: c75b33fbb39b0a78274a6a673377999cddb9fce9
|
4
|
+
data.tar.gz: 6123f5e28927dcc5daeb3c5e34472d7f6917f844
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 301713b64534b02506f7abdc73da999960707224a8a93bd3231a4b07f3a442866f8a21c2e1f5e99e5f63e22d5a60dfbcf4c7423e6496c04699119d543150ba28
|
7
|
+
data.tar.gz: 84b27835b843b182da3443a121979a8fb0617ac812db26b863e2395ee513b15049ba04a9dccfcb76da9b4742350a4d3f0fdfe35f3cb811aa1fca8110a12b4cca
|
data/.gitignore
ADDED
data/.rspec
ADDED
data/.travis.yml
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2013 sinsoku
|
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,29 @@
|
|
1
|
+
# Ponytail
|
2
|
+
|
3
|
+
Ponytail is a Rails engine that shows the migrations.
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
gem 'ponytail'
|
10
|
+
|
11
|
+
And then execute:
|
12
|
+
|
13
|
+
$ bundle
|
14
|
+
|
15
|
+
Or install it yourself as:
|
16
|
+
|
17
|
+
$ gem install ponytail
|
18
|
+
|
19
|
+
## Usage
|
20
|
+
|
21
|
+
TODO: Write usage instructions here
|
22
|
+
|
23
|
+
## Contributing
|
24
|
+
|
25
|
+
1. Fork it
|
26
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
27
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
28
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
29
|
+
5. Create new Pull Request
|
data/Rakefile
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
//= require_tree .
|
@@ -0,0 +1,20 @@
|
|
1
|
+
function each(elems, func) {
|
2
|
+
if (!elems instanceof Array) { elems = [elems]; }
|
3
|
+
for (var i = elems.length; i--; ) {
|
4
|
+
func(elems[i]);
|
5
|
+
}
|
6
|
+
}
|
7
|
+
|
8
|
+
function onClick(elems, func) {
|
9
|
+
each(elems, function(elem) {
|
10
|
+
elem.onclick = func;
|
11
|
+
});
|
12
|
+
}
|
13
|
+
|
14
|
+
function setupMigrations() {
|
15
|
+
var elems = document.querySelectorAll(".pt_migration .pt_header");
|
16
|
+
onClick(elems, function() {
|
17
|
+
var content = this.nextElementSibling;
|
18
|
+
content.style.display = content.style.display === "" ? "block" : "";
|
19
|
+
});
|
20
|
+
}
|
@@ -0,0 +1,45 @@
|
|
1
|
+
module Ponytail
|
2
|
+
class MigrationsController < ActionController::Base
|
3
|
+
layout 'ponytail/application'
|
4
|
+
|
5
|
+
def index
|
6
|
+
@migrations = Migration.all
|
7
|
+
@current_version = Migration.current_version
|
8
|
+
end
|
9
|
+
|
10
|
+
def new
|
11
|
+
@migration = Migration.new
|
12
|
+
end
|
13
|
+
|
14
|
+
def create
|
15
|
+
@migration = Migration.new(migraion_params)
|
16
|
+
|
17
|
+
if @migration.save
|
18
|
+
redirect_to :migrations, notice: 'Migration was successfully created.'
|
19
|
+
else
|
20
|
+
render action: 'new'
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
def migrate
|
25
|
+
if Migration.migrate
|
26
|
+
redirect_to :migrations, notice: 'Migrate was succeed.'
|
27
|
+
else
|
28
|
+
redirect_to :migrations, notice: 'Migrate was failed.'
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
def rollback
|
33
|
+
if Migration.rollback
|
34
|
+
redirect_to :migrations, notice: 'Rollback was succeed.'
|
35
|
+
else
|
36
|
+
redirect_to :migrations, notice: 'Rollback was failed.'
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
private
|
41
|
+
def migraion_params
|
42
|
+
params.require(:ponytail_migration).permit(:name, :raw_content)
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
<!DOCTYPE html>
|
2
|
+
<html>
|
3
|
+
<head>
|
4
|
+
<title>Migrations</title>
|
5
|
+
<%= stylesheet_link_tag 'ponytail/application' %>
|
6
|
+
<%= javascript_include_tag 'ponytail/application' %>
|
7
|
+
<%= csrf_meta_tags %>
|
8
|
+
</head>
|
9
|
+
<body>
|
10
|
+
|
11
|
+
<%= yield %>
|
12
|
+
|
13
|
+
</body>
|
14
|
+
</html>
|
@@ -0,0 +1,10 @@
|
|
1
|
+
<div class="pt_migration">
|
2
|
+
<div class="pt_header">
|
3
|
+
<% if migration.version == @current_version %>
|
4
|
+
<span class="pt_current">current</span>
|
5
|
+
<% end %>
|
6
|
+
<span class="pt_name"><%= migration.name %></span>
|
7
|
+
<span class="pt_filename"><%= migration.filename %></span>
|
8
|
+
</div>
|
9
|
+
<pre class="pt_raw_content"><%= migration.raw_content %></pre>
|
10
|
+
</div>
|
@@ -0,0 +1,13 @@
|
|
1
|
+
<% @migrations.each do |migration| %>
|
2
|
+
<%= render 'migration', migration: migration, current: @current_version %>
|
3
|
+
<% end %>
|
4
|
+
|
5
|
+
<div class="pt_actions">
|
6
|
+
<%= button_to 'New', new_migration_path, class: 'pt_new', method: :get %>
|
7
|
+
<%= button_to 'Migrate', migrate_migrations_path, class: 'pt_migrate' %>
|
8
|
+
<%= button_to 'Rollback', rollback_migrations_path, class: 'pt_rallback' %>
|
9
|
+
</div>
|
10
|
+
|
11
|
+
<script type='text/javascript'>
|
12
|
+
setupMigrations();
|
13
|
+
</script>
|
data/config/routes.rb
ADDED
@@ -0,0 +1,40 @@
|
|
1
|
+
module Ponytail
|
2
|
+
class Migration
|
3
|
+
include ActiveModel::Model
|
4
|
+
attr_accessor :name, :filename, :version, :raw_content
|
5
|
+
|
6
|
+
class << self
|
7
|
+
def all
|
8
|
+
proxys = ActiveRecord::Migrator.migrations(migrations_paths)
|
9
|
+
proxys.map { |p| new(name: p.name, filename: p.filename, version: p.version) }
|
10
|
+
end
|
11
|
+
delegate :migrations_paths, :migrations_path, :current_version, to: ActiveRecord::Migrator
|
12
|
+
|
13
|
+
def migrate
|
14
|
+
ActiveRecord::Migrator.migrate(migrations_paths)
|
15
|
+
end
|
16
|
+
|
17
|
+
def rollback
|
18
|
+
ActiveRecord::Migrator.rollback(migrations_paths)
|
19
|
+
end
|
20
|
+
|
21
|
+
def next_version
|
22
|
+
last = all.last
|
23
|
+
ActiveRecord::Migration.next_migration_number(last ? last.version + 1 : 0).to_i
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
def raw_content
|
28
|
+
@raw_content ||= (filename != nil ? open(filename).read : nil)
|
29
|
+
end
|
30
|
+
|
31
|
+
def save
|
32
|
+
if valid?
|
33
|
+
next_migration_filename = "#{Migration.migrations_path}/#{Migration.next_version}_#{name.underscore}.rb"
|
34
|
+
open(next_migration_filename, 'w').write(raw_content)
|
35
|
+
else
|
36
|
+
false
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
data/lib/ponytail.rb
ADDED
data/ponytail.gemspec
ADDED
@@ -0,0 +1,26 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'ponytail/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "ponytail"
|
8
|
+
spec.version = Ponytail::VERSION
|
9
|
+
spec.authors = ["sinsoku"]
|
10
|
+
spec.email = ["sinsoku.listy@gmail.com"]
|
11
|
+
spec.description = %q{Ponytail is a Rails engine that shows the migrations.}
|
12
|
+
spec.summary = %q{Ponytail is a Rails engine that shows the migrations.}
|
13
|
+
spec.homepage = "https://github.com/sinsoku/ponytail"
|
14
|
+
spec.license = "MIT"
|
15
|
+
|
16
|
+
spec.files = `git ls-files`.split($/)
|
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_dependency 'rails'
|
22
|
+
|
23
|
+
spec.add_development_dependency "bundler", "~> 1.3"
|
24
|
+
spec.add_development_dependency "rake"
|
25
|
+
spec.add_development_dependency "rspec"
|
26
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
module Ponytail
|
4
|
+
describe Migration do
|
5
|
+
describe ".all" do
|
6
|
+
before do
|
7
|
+
proxy = Struct.new(:proxy, :name, :filename, :version)
|
8
|
+
ActiveRecord::Migrator.stub(migrations: [proxy.new('CreateUsers', '001_create_users', 1)])
|
9
|
+
end
|
10
|
+
subject { Migration.all }
|
11
|
+
its(:first) { should be_a_kind_of Migration }
|
12
|
+
end
|
13
|
+
|
14
|
+
describe "#initialize" do
|
15
|
+
subject { Migration.new(name: 'CreateUsers', filename: '001_create_users.rb', version: 1) }
|
16
|
+
its(:name) { should eq 'CreateUsers' }
|
17
|
+
its(:filename) { should eq '001_create_users.rb' }
|
18
|
+
its(:version) { should eq 1 }
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
data/spec/spec_helper.rb
ADDED
metadata
ADDED
@@ -0,0 +1,127 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: ponytail
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- sinsoku
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2013-12-03 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: rails
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - '>='
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - '>='
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: bundler
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ~>
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '1.3'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ~>
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '1.3'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rake
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - '>='
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - '>='
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: rspec
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - '>='
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - '>='
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
69
|
+
description: Ponytail is a Rails engine that shows the migrations.
|
70
|
+
email:
|
71
|
+
- sinsoku.listy@gmail.com
|
72
|
+
executables: []
|
73
|
+
extensions: []
|
74
|
+
extra_rdoc_files: []
|
75
|
+
files:
|
76
|
+
- .gitignore
|
77
|
+
- .rspec
|
78
|
+
- .travis.yml
|
79
|
+
- Gemfile
|
80
|
+
- LICENSE.txt
|
81
|
+
- README.md
|
82
|
+
- Rakefile
|
83
|
+
- app/assets/javascripts/ponytail/application.js
|
84
|
+
- app/assets/javascripts/ponytail/migrations.js
|
85
|
+
- app/assets/stylesheets/ponytail/application.css
|
86
|
+
- app/controllers/ponytail/migrations_controller.rb
|
87
|
+
- app/views/layouts/ponytail/application.html.erb
|
88
|
+
- app/views/ponytail/migrations/_migration.html.erb
|
89
|
+
- app/views/ponytail/migrations/index.html.erb
|
90
|
+
- app/views/ponytail/migrations/new.html.erb
|
91
|
+
- config/routes.rb
|
92
|
+
- lib/ponytail.rb
|
93
|
+
- lib/ponytail/engine.rb
|
94
|
+
- lib/ponytail/migration.rb
|
95
|
+
- lib/ponytail/version.rb
|
96
|
+
- ponytail.gemspec
|
97
|
+
- spec/migration_spec.rb
|
98
|
+
- spec/ponytail_spec.rb
|
99
|
+
- spec/spec_helper.rb
|
100
|
+
homepage: https://github.com/sinsoku/ponytail
|
101
|
+
licenses:
|
102
|
+
- MIT
|
103
|
+
metadata: {}
|
104
|
+
post_install_message:
|
105
|
+
rdoc_options: []
|
106
|
+
require_paths:
|
107
|
+
- lib
|
108
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
109
|
+
requirements:
|
110
|
+
- - '>='
|
111
|
+
- !ruby/object:Gem::Version
|
112
|
+
version: '0'
|
113
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
114
|
+
requirements:
|
115
|
+
- - '>='
|
116
|
+
- !ruby/object:Gem::Version
|
117
|
+
version: '0'
|
118
|
+
requirements: []
|
119
|
+
rubyforge_project:
|
120
|
+
rubygems_version: 2.0.3
|
121
|
+
signing_key:
|
122
|
+
specification_version: 4
|
123
|
+
summary: Ponytail is a Rails engine that shows the migrations.
|
124
|
+
test_files:
|
125
|
+
- spec/migration_spec.rb
|
126
|
+
- spec/ponytail_spec.rb
|
127
|
+
- spec/spec_helper.rb
|