wpb 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
data/.gitignore ADDED
@@ -0,0 +1,4 @@
1
+ *.gem
2
+ .bundle
3
+ Gemfile.lock
4
+ pkg/*
data/Changelog.md ADDED
@@ -0,0 +1,11 @@
1
+ ## Changelog
2
+
3
+ ### Release 0.0.2
4
+ * 1 minor feature
5
+ * Added connection between the User and the Post/Page
6
+ * 1 major bug fix
7
+ * WordPress pages would break with inheritance issue
8
+
9
+ ### Release 0.0.1
10
+ * 1 major feature
11
+ * Initial release
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source "http://rubygems.org"
2
+
3
+ # Specify your gem's dependencies in wpb.gemspec
4
+ gemspec
data/README.md ADDED
@@ -0,0 +1,9 @@
1
+ # WPB (WordPress Bash)
2
+
3
+ ## About
4
+ WPB (aka WordPress Bash) provides a Terminal interface to WordPress. It tries to achieve a similar feel to irb and the rails console.
5
+ For example working with users you will be able to do something like this
6
+ ```ruby
7
+ wpb:01> User.find 1
8
+ => #<WPB::UserObject:0x0000010087ef78 @name="James Birtles", @username="jamesbirtles">
9
+ ```
data/Rakefile ADDED
@@ -0,0 +1,2 @@
1
+ require 'bundler'
2
+ Bundler::GemHelper.install_tasks
data/bin/wpb ADDED
@@ -0,0 +1,7 @@
1
+ #!/usr/bin/env ruby
2
+ irb = RUBY_PLATFORM =~ /(:?mswin|mingw)/ ? 'irb.bat' : 'irb'
3
+
4
+ libs = " -r irb/completion"
5
+ libs << " -r #{File.expand_path('../../lib/wpb.rb', __FILE__)}"
6
+ puts "Loading WPB (WordPress Bash)"
7
+ exec "#{irb} #{libs} -f --simple-prompt"
data/lib/wpb/page.rb ADDED
@@ -0,0 +1,3 @@
1
+ class Page < PagePost
2
+ belongs_to :user
3
+ end
@@ -0,0 +1,28 @@
1
+ require "active_record"
2
+
3
+ class PagePost < ActiveRecord::Base
4
+ set_table_name :wp_posts
5
+ set_primary_key :ID
6
+
7
+ before_save :update_date
8
+
9
+ def update_date
10
+ #TODO: update date_modified column
11
+ end
12
+
13
+ def title
14
+ post_title
15
+ end
16
+
17
+ def title= new_title
18
+ post_title = new_title
19
+ end
20
+
21
+ def body
22
+ post_content
23
+ end
24
+
25
+ def body= new_content
26
+ post_content = new_content
27
+ end
28
+ end
data/lib/wpb/post.rb ADDED
@@ -0,0 +1,3 @@
1
+ class Post < PagePost
2
+ belongs_to :user
3
+ end
@@ -0,0 +1,8 @@
1
+ require "active_record"
2
+
3
+ class Setting < ActiveRecord::Base
4
+ set_table_name :wp_usermeta
5
+ set_primary_key :umeta_id
6
+
7
+ belongs_to :user
8
+ end
data/lib/wpb/user.rb ADDED
@@ -0,0 +1,34 @@
1
+ require "active_record"
2
+
3
+ class User < ActiveRecord::Base
4
+ set_table_name :wp_users
5
+ set_primary_key :ID
6
+
7
+ has_many :settings
8
+ has_many :pages, :foreign_key => :post_author
9
+ has_many :posts, :foreign_key => :post_author
10
+
11
+ def name
12
+ display_name
13
+ end
14
+
15
+ def name= name
16
+ display_name = name
17
+ end
18
+
19
+ def username
20
+ user_login
21
+ end
22
+
23
+ def username= username
24
+ user_login = username
25
+ end
26
+
27
+ def email
28
+ user_email
29
+ end
30
+
31
+ def email= email
32
+ user_email = email
33
+ end
34
+ end
@@ -0,0 +1,3 @@
1
+ module WPB
2
+ VERSION = "0.0.2"
3
+ end
data/lib/wpb.rb ADDED
@@ -0,0 +1,43 @@
1
+ require "wpb/version"
2
+ require "wpb/user"
3
+ require "wpb/setting"
4
+ require "wpb/pagepost"
5
+ require "wpb/page"
6
+ require "wpb/post"
7
+ require "active_record"
8
+
9
+ config = {
10
+ :adapter => "mysql",
11
+ :socket => "/Applications/MAMP/tmp/mysql/mysql.sock", #/tmp/mysql.sock
12
+ :host => "localhost",
13
+ :username => "root",
14
+ :password => "root",
15
+ :database => "wordpress"
16
+ }
17
+
18
+ ActiveRecord::Base.establish_connection(config)
19
+
20
+ class AddType < ActiveRecord::Migration
21
+ def self.up
22
+ suppress_messages do
23
+ unless column_exists? :wp_posts, :type
24
+ add_column :wp_posts, :type, :string
25
+ PagePost.reset_column_information
26
+ end
27
+ PagePost.all.each do |p|
28
+ p.type = p.post_type.capitalize
29
+ p.save
30
+ end
31
+ end
32
+ end
33
+
34
+ def self.down
35
+ remove_column :wp_posts, :type
36
+ end
37
+ end
38
+
39
+ AddType::up
40
+
41
+ module WPB
42
+
43
+ end
data/wpb.gemspec ADDED
@@ -0,0 +1,21 @@
1
+ # -*- encoding: utf-8 -*-
2
+ $:.push File.expand_path("../lib", __FILE__)
3
+ require "wpb/version"
4
+
5
+ Gem::Specification.new do |s|
6
+ s.name = "wpb"
7
+ s.version = WPB::VERSION
8
+ s.platform = Gem::Platform::RUBY
9
+ s.authors = ["James Birtles"]
10
+ s.email = ["itsme@jamesbirtles.com"]
11
+ s.homepage = "http://github.com/jamesbirtles/wpb"
12
+ s.summary = %q{A Terminal interface to WordPress}
13
+ s.description = %q{WPB (WordPress Bash) provides a Terminal interface to WordPress. It tries to achieve a similar feel to the rails console.}
14
+
15
+ s.files = `git ls-files`.split("\n")
16
+ s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
17
+ s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
18
+ s.require_paths = ["lib"]
19
+
20
+ s.add_dependency('activerecord', '>= 3.0.0')
21
+ end
metadata ADDED
@@ -0,0 +1,80 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: wpb
3
+ version: !ruby/object:Gem::Version
4
+ prerelease:
5
+ version: 0.0.2
6
+ platform: ruby
7
+ authors:
8
+ - James Birtles
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+
13
+ date: 2011-05-17 00:00:00 +01:00
14
+ default_executable:
15
+ dependencies:
16
+ - !ruby/object:Gem::Dependency
17
+ name: activerecord
18
+ prerelease: false
19
+ requirement: &id001 !ruby/object:Gem::Requirement
20
+ none: false
21
+ requirements:
22
+ - - ">="
23
+ - !ruby/object:Gem::Version
24
+ version: 3.0.0
25
+ type: :runtime
26
+ version_requirements: *id001
27
+ description: WPB (WordPress Bash) provides a Terminal interface to WordPress. It tries to achieve a similar feel to the rails console.
28
+ email:
29
+ - itsme@jamesbirtles.com
30
+ executables:
31
+ - wpb
32
+ extensions: []
33
+
34
+ extra_rdoc_files: []
35
+
36
+ files:
37
+ - .gitignore
38
+ - Changelog.md
39
+ - Gemfile
40
+ - README.md
41
+ - Rakefile
42
+ - bin/wpb
43
+ - lib/wpb.rb
44
+ - lib/wpb/page.rb
45
+ - lib/wpb/pagepost.rb
46
+ - lib/wpb/post.rb
47
+ - lib/wpb/setting.rb
48
+ - lib/wpb/user.rb
49
+ - lib/wpb/version.rb
50
+ - wpb.gemspec
51
+ has_rdoc: true
52
+ homepage: http://github.com/jamesbirtles/wpb
53
+ licenses: []
54
+
55
+ post_install_message:
56
+ rdoc_options: []
57
+
58
+ require_paths:
59
+ - lib
60
+ required_ruby_version: !ruby/object:Gem::Requirement
61
+ none: false
62
+ requirements:
63
+ - - ">="
64
+ - !ruby/object:Gem::Version
65
+ version: "0"
66
+ required_rubygems_version: !ruby/object:Gem::Requirement
67
+ none: false
68
+ requirements:
69
+ - - ">="
70
+ - !ruby/object:Gem::Version
71
+ version: "0"
72
+ requirements: []
73
+
74
+ rubyforge_project:
75
+ rubygems_version: 1.6.2
76
+ signing_key:
77
+ specification_version: 3
78
+ summary: A Terminal interface to WordPress
79
+ test_files: []
80
+