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 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
@@ -0,0 +1,19 @@
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
18
+
19
+ /vendor/bundle
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --format documentation
2
+ --color
data/.travis.yml ADDED
@@ -0,0 +1,3 @@
1
+ language: ruby
2
+ rvm:
3
+ - 2.0.0
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in ponytail.gemspec
4
+ gemspec
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,6 @@
1
+ require "bundler/gem_tasks"
2
+ require "rspec/core/rake_task"
3
+
4
+ RSpec::Core::RakeTask.new(:spec)
5
+
6
+ task :default => :spec
@@ -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,17 @@
1
+ .pt_actions {
2
+ margin: 5px;
3
+ }
4
+
5
+ .pt_actions .button_to {
6
+ float: left;
7
+ margin: 0 2px;
8
+ }
9
+
10
+ .pt_migration .pt_name {
11
+ font-size: large;
12
+ font-weight: bold;
13
+ }
14
+
15
+ .pt_migration .pt_raw_content {
16
+ display: none;
17
+ }
@@ -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>
@@ -0,0 +1,10 @@
1
+ <%= form_for @migration, url: migrations_path do |f| %>
2
+ <%= f.label :name %>
3
+ <%= f.text_field :name %>
4
+
5
+ <div class="pt_raw_content">
6
+ <%= f.text_area :raw_content, size: '80x20' %>
7
+ </div>
8
+
9
+ <%= f.submit 'Submit' %>
10
+ <% end %>
data/config/routes.rb ADDED
@@ -0,0 +1,8 @@
1
+ Rails.application.routes.draw do
2
+ resources :migrations, only: [:index, :new, :create], module: :ponytail, path: 'rails/migrations' do
3
+ collection do
4
+ post :migrate
5
+ post :rollback
6
+ end
7
+ end
8
+ end
@@ -0,0 +1,4 @@
1
+ module Ponytail
2
+ class Engine < Rails::Engine
3
+ end
4
+ end
@@ -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
@@ -0,0 +1,3 @@
1
+ module Ponytail
2
+ VERSION = "0.0.1"
3
+ end
data/lib/ponytail.rb ADDED
@@ -0,0 +1,2 @@
1
+ require 'ponytail/engine'
2
+ require 'ponytail/migration'
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
@@ -0,0 +1,7 @@
1
+ require 'spec_helper'
2
+
3
+ describe Ponytail do
4
+ it 'should have a version number' do
5
+ Ponytail::VERSION.should_not be_nil
6
+ end
7
+ end
@@ -0,0 +1,4 @@
1
+ $LOAD_PATH.unshift File.expand_path('../../lib', __FILE__)
2
+ require 'active_record'
3
+ require 'rails'
4
+ require 'ponytail'
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