ruby-wpdb 1.0 → 1.1.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 6e968b56cfd7561798ecb6a758440a0c88f29f54
4
- data.tar.gz: 97db3eb498ab6302ee76e9803f38739d93b2e5a8
3
+ metadata.gz: fcddf31c275de92d40ca468bcd9412fad4efc5bc
4
+ data.tar.gz: 0c75884198a4da72ed2e1052165eb5957027b297
5
5
  SHA512:
6
- metadata.gz: 991d84686a479f546efd21dd5fd29627c5c4b756507920bd77312f1f4ae7b6a5dc61e8f07fceba6b2e0ce8a6b7ace767e3260b6d53c9371c91b873e809cd584d
7
- data.tar.gz: 18bfcd093fa57da937caf0d3a7a2be034bdf85d735fd539836a9bd9a26681844cea791f214a82c8af0ba1375663ba60bef12e35610e8bfc9047776e06df25faf
6
+ metadata.gz: 683a137904bd03d546e4e7f212d201c38be0491912b0d9f58ce6a2f12cabc9e14d14eca10145591da967f8a4c533679b1a0342d25c4034275cbb5695d5b27a2c
7
+ data.tar.gz: c27d303fed4298d0698b73a0afa4a49dee88cf53bb9ef4b466e674cb201335bfa6f26dd0e932171cc67a65431ebd56c00fd3c4d6beb868928041f7d764782faa
data/README.md CHANGED
@@ -97,14 +97,30 @@ Note that you get access to all the fields of the GravityForm as though
97
97
  they were first-class members of an actual model, allowing you to use
98
98
  their values when filtering and ordering.
99
99
 
100
- ## Usage
100
+ ## Console
101
+
102
+ ruby-wpdb comes with an interactive REPL console, so you can explore
103
+ a WordPress install without actually having to write any scripts.
104
+
105
+ Fire it up with:
106
+
107
+ $ ruby-wpdb console
108
+
109
+ And you can then call:
110
+
111
+ > init('mysql2://user:password@hostname/db_name')
112
+
113
+ To connect to your database.
114
+
115
+ If you find yourself connecting regularly to the same database, you can
116
+ tell ruby-wpdb where to find a config file:
117
+
118
+ $ ruby-wpdb console --config-file wp-config.php
101
119
 
102
- Models map exactly to database names without the prefix, and dataset
103
- properties map exactly to column names. So, if you're familiar with
104
- WordPress's database structure, ruby-wpdb should come fairly easy.
120
+ Which will remove the need to call `init` manually.
105
121
 
106
- So a post is `WPDB::Post`; a comment is `WPDB::Comment`; and so on.
122
+ Once you're in the console, you can do anything you'd be able to do with
123
+ ruby-wpdb normally. So to list all posts with the title 'Hello World',
124
+ you could call:
107
125
 
108
- Beyond that, you're limited with what you can do only by the
109
- capabilities of Sequel; you can find out more in [their
110
- README](http://sequel.rubyforge.org/rdoc/files/README_rdoc.html).
126
+ > Post.where(post_title: "Hello World").all
data/bin/ruby-wpdb ADDED
@@ -0,0 +1,43 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+
5
+ require "pry"
6
+ require "thor"
7
+
8
+ require "ruby-wpdb"
9
+
10
+ module WPDB
11
+ class CLI < Thor
12
+ package_name "ruby-wpdb"
13
+
14
+ method_option :config_file, :required => false
15
+
16
+ desc "console", "Runs an interactive ruby-wpdb console"
17
+ def console
18
+ if options[:config_file]
19
+ WPDB.from_config(options[:config_file])
20
+ end
21
+
22
+ Pry.config.should_load_rc = false
23
+ Pry.config.prompt = [
24
+ proc { |_obj, nest_level, _| "ruby-wpdb: #{nest_level} > " },
25
+ proc { |_obj, nest_level, _| "ruby-wpdb: #{nest_level}*> " },
26
+ ]
27
+
28
+ puts "You're now in an interactive ruby-wpdb session. To leave, type 'exit'"
29
+
30
+ if WPDB.initialized
31
+ puts "WPDB is already initialized; you're connected to #{WPDB.db.uri}"
32
+ else
33
+ puts "WPDB isn't yet connected to a WordPress install; use from_config() or init() to initialize it."
34
+ end
35
+
36
+ puts "\n"
37
+
38
+ WPDB.pry
39
+ end
40
+ end
41
+ end
42
+
43
+ WPDB::CLI.start
@@ -1,3 +1,3 @@
1
1
  module WPDB
2
- VERSION = "1.0"
2
+ VERSION = "1.1.1"
3
3
  end
data/lib/ruby-wpdb.rb CHANGED
@@ -2,11 +2,10 @@ require 'bundler/setup'
2
2
 
3
3
  require 'sequel'
4
4
  require 'pry'
5
- require 'pry-debugger'
6
5
 
7
6
  module WPDB
8
7
  class << self
9
- attr_accessor :db, :prefix, :user_prefix
8
+ attr_accessor :db, :prefix, :user_prefix, :initialized
10
9
 
11
10
  # Given the path to a YAML file, will initialise WPDB using the
12
11
  # config files found in that file.
@@ -44,6 +43,8 @@ module WPDB
44
43
  require_relative 'ruby-wpdb/comments'
45
44
  require_relative 'ruby-wpdb/links'
46
45
  require_relative 'ruby-wpdb/gravityforms'
46
+
47
+ WPDB.initialized = true
47
48
  end
48
49
  end
49
50
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ruby-wpdb
3
3
  version: !ruby/object:Gem::Version
4
- version: '1.0'
4
+ version: 1.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Rob Miller
@@ -14,122 +14,143 @@ dependencies:
14
14
  name: mysql2
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - ~>
17
+ - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: 0.3.11
19
+ version: '0.3'
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - ~>
24
+ - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: 0.3.11
26
+ version: '0.3'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: sequel
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - ~>
31
+ - - "~>"
32
32
  - !ruby/object:Gem::Version
33
- version: 4.2.0
33
+ version: '4.2'
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - ~>
38
+ - - "~>"
39
39
  - !ruby/object:Gem::Version
40
- version: 4.2.0
40
+ version: '4.2'
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: sequel_sluggable
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
- - - ~>
45
+ - - "~>"
46
46
  - !ruby/object:Gem::Version
47
47
  version: 0.0.6
48
48
  type: :runtime
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
- - - ~>
52
+ - - "~>"
53
53
  - !ruby/object:Gem::Version
54
54
  version: 0.0.6
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: php-serialize
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
- - - ~>
59
+ - - "~>"
60
60
  - !ruby/object:Gem::Version
61
61
  version: '1.1'
62
62
  type: :runtime
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
- - - ~>
66
+ - - "~>"
67
67
  - !ruby/object:Gem::Version
68
68
  version: '1.1'
69
69
  - !ruby/object:Gem::Dependency
70
- name: rake
70
+ name: pry
71
71
  requirement: !ruby/object:Gem::Requirement
72
72
  requirements:
73
- - - ~>
73
+ - - "~>"
74
74
  - !ruby/object:Gem::Version
75
- version: 10.1.0
76
- type: :development
75
+ version: '0.9'
76
+ type: :runtime
77
77
  prerelease: false
78
78
  version_requirements: !ruby/object:Gem::Requirement
79
79
  requirements:
80
- - - ~>
80
+ - - "~>"
81
81
  - !ruby/object:Gem::Version
82
- version: 10.1.0
82
+ version: '0.9'
83
83
  - !ruby/object:Gem::Dependency
84
- name: letters
84
+ name: thor
85
85
  requirement: !ruby/object:Gem::Requirement
86
86
  requirements:
87
- - - ~>
87
+ - - "~>"
88
+ - !ruby/object:Gem::Version
89
+ version: '0.18'
90
+ type: :runtime
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - "~>"
88
95
  - !ruby/object:Gem::Version
89
- version: 0.4.1
96
+ version: '0.18'
97
+ - !ruby/object:Gem::Dependency
98
+ name: rake
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - "~>"
102
+ - !ruby/object:Gem::Version
103
+ version: '10.1'
90
104
  type: :development
91
105
  prerelease: false
92
106
  version_requirements: !ruby/object:Gem::Requirement
93
107
  requirements:
94
- - - ~>
108
+ - - "~>"
95
109
  - !ruby/object:Gem::Version
96
- version: 0.4.1
110
+ version: '10.1'
97
111
  - !ruby/object:Gem::Dependency
98
- name: pry
112
+ name: letters
99
113
  requirement: !ruby/object:Gem::Requirement
100
114
  requirements:
101
- - - ~>
115
+ - - "~>"
102
116
  - !ruby/object:Gem::Version
103
- version: 0.9.12
117
+ version: '0.4'
104
118
  type: :development
105
119
  prerelease: false
106
120
  version_requirements: !ruby/object:Gem::Requirement
107
121
  requirements:
108
- - - ~>
122
+ - - "~>"
109
123
  - !ruby/object:Gem::Version
110
- version: 0.9.12
124
+ version: '0.4'
111
125
  - !ruby/object:Gem::Dependency
112
- name: pry-debugger
126
+ name: rubygems-tasks
113
127
  requirement: !ruby/object:Gem::Requirement
114
128
  requirements:
115
- - - ~>
129
+ - - "~>"
116
130
  - !ruby/object:Gem::Version
117
- version: 0.2.2
131
+ version: '0.2'
118
132
  type: :development
119
133
  prerelease: false
120
134
  version_requirements: !ruby/object:Gem::Requirement
121
135
  requirements:
122
- - - ~>
136
+ - - "~>"
123
137
  - !ruby/object:Gem::Version
124
- version: 0.2.2
138
+ version: '0.2'
125
139
  description: ruby-wpdb gives you a painless way to access and interact with WordPress
126
140
  from Ruby, accessing posts, tags, and all other WordPress concepts as plain-old
127
141
  Ruby objects.
128
142
  email: rob@bigfish.co.uk
129
- executables: []
143
+ executables:
144
+ - ruby-wpdb
130
145
  extensions: []
131
146
  extra_rdoc_files: []
132
147
  files:
148
+ - Gemfile
149
+ - LICENSE
150
+ - README.md
151
+ - bin/ruby-wpdb
152
+ - data/query.log
153
+ - lib/ruby-wpdb.rb
133
154
  - lib/ruby-wpdb/comments.rb
134
155
  - lib/ruby-wpdb/gravityforms.rb
135
156
  - lib/ruby-wpdb/links.rb
@@ -138,8 +159,6 @@ files:
138
159
  - lib/ruby-wpdb/terms.rb
139
160
  - lib/ruby-wpdb/users.rb
140
161
  - lib/ruby-wpdb/version.rb
141
- - lib/ruby-wpdb.rb
142
- - data/query.log
143
162
  - test/comments_test.rb
144
163
  - test/gravityforms_test.rb
145
164
  - test/links_test.rb
@@ -149,9 +168,6 @@ files:
149
168
  - test/terms_test.rb
150
169
  - test/test_helper.rb
151
170
  - test/users_test.rb
152
- - LICENSE
153
- - README.md
154
- - Gemfile
155
171
  homepage: http://github.com/robmiller/ruby-wpdb
156
172
  licenses:
157
173
  - MIT
@@ -162,19 +178,18 @@ require_paths:
162
178
  - lib
163
179
  required_ruby_version: !ruby/object:Gem::Requirement
164
180
  requirements:
165
- - - '>='
181
+ - - ">="
166
182
  - !ruby/object:Gem::Version
167
183
  version: '0'
168
184
  required_rubygems_version: !ruby/object:Gem::Requirement
169
185
  requirements:
170
- - - '>='
186
+ - - ">="
171
187
  - !ruby/object:Gem::Version
172
188
  version: '0'
173
189
  requirements: []
174
190
  rubyforge_project:
175
- rubygems_version: 2.0.3
191
+ rubygems_version: 2.2.2
176
192
  signing_key:
177
193
  specification_version: 4
178
194
  summary: A Ruby ORM wrapper for WordPress
179
195
  test_files: []
180
- has_rdoc: