presspass 0.1.0 → 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
data/bin/presspass CHANGED
File without changes
@@ -0,0 +1,62 @@
1
+ require 'yaml'
2
+
3
+ module PressPass
4
+
5
+ module Cli
6
+
7
+ class Linker
8
+
9
+ def self.run(arguments = nil)
10
+
11
+ config_file = File.join(Dir.home, '.presspass.yml')
12
+
13
+ config = {}
14
+
15
+ File.open( config_file, "r+") do |file|
16
+ config = YAML.load(file)
17
+ end
18
+
19
+ if config["installation_dir"].nil?
20
+ puts <<-EOF
21
+
22
+ You don't have a local PressPass-enabled WordPress installation yet.
23
+
24
+ Install one using:
25
+
26
+ presspass new <directory>
27
+
28
+ EOF
29
+ return
30
+ end
31
+
32
+ if arguments.empty?
33
+ if directory_is_theme?(Dir.pwd)
34
+ link(Dir.pwd, File.expand_path(config["installation_dir"]))
35
+ end
36
+ end
37
+
38
+ end
39
+
40
+ def self.directory_is_theme?(path)
41
+ File.exists?(File.join(path, 'style.css'))
42
+ end
43
+
44
+ def self.link(theme_path, installation_path)
45
+
46
+ link_path = File.join(installation_path, 'wp-content', 'themes', File.basename(theme_path))
47
+
48
+ if File.symlink?(link_path)
49
+ puts "Theme directory #{theme_path} is already linked in #{link_path}"
50
+ return
51
+ end
52
+
53
+ puts "Linking #{theme_path} into #{link_path}"
54
+ File.symlink(theme_path, link_path)
55
+
56
+ end
57
+
58
+ end
59
+
60
+ end
61
+
62
+ end
@@ -5,13 +5,13 @@ module PressPass
5
5
 
6
6
  class NewProjectGenerator
7
7
 
8
- def initialize
8
+ def initialize(command = "new")
9
9
  @options = {:php => nil}
10
10
 
11
11
  @app_name = ARGV.first
12
12
 
13
13
  OptionParser.new do |opts|
14
- opts.banner = "Usage: presspass new <app_name> [options]"
14
+ opts.banner = "Usage: presspass #{command} <app_name> [options]"
15
15
 
16
16
  opts.on("--php PATH", "Path to PHP CGI binary") do |php_path|
17
17
  @options[:php] = php_path
@@ -28,13 +28,32 @@ module PressPass
28
28
 
29
29
  extract_wordpress_into_project_directory
30
30
 
31
- add_rack_config(:php_cgi_path => @options[:php])
31
+ init
32
32
 
33
33
  puts "WordPress installation created at #{@app_name}."
34
34
  end
35
35
 
36
+ def init
37
+ add_rack_config(:php_cgi_path => @options[:php])
38
+
39
+ set_default_config
40
+ end
41
+
36
42
  private
37
43
 
44
+ def set_default_config
45
+
46
+ config_file = File.join(Dir.home, '.presspass.yml')
47
+
48
+ config = {}
49
+ config["installation_dir"] = File.expand_path(@app_name)
50
+
51
+ File.open( config_file, "w+") do |file|
52
+ file.write(YAML.dump(config))
53
+ end
54
+
55
+ end
56
+
38
57
  def create_project_directory
39
58
  if Dir.exists?(@app_name)
40
59
  puts "A directory with name #{@app_name} already exists."
data/lib/presspass/cli.rb CHANGED
@@ -4,6 +4,7 @@ require 'optparse'
4
4
 
5
5
  require 'presspass'
6
6
  require 'presspass/cli/new_project_generator'
7
+ require 'presspass/cli/linker'
7
8
 
8
9
  if ARGV.first == "new"
9
10
  ARGV.shift
@@ -14,4 +15,17 @@ if ARGV.first == "new"
14
15
 
15
16
  generator = PressPass::Cli::NewProjectGenerator.new
16
17
  generator.run
18
+ elsif ARGV.first == "init"
19
+ ARGV.shift
20
+
21
+ if ARGV.first.nil?
22
+ ARGV << "--help"
23
+ end
24
+
25
+ generator = PressPass::Cli::NewProjectGenerator.new
26
+ generator.init
27
+ elsif ARGV.first == "link"
28
+ ARGV.shift
29
+
30
+ PressPass::Cli::Linker.run(ARGV)
17
31
  end
@@ -1,6 +1,6 @@
1
1
  module PressPass
2
2
 
3
- WORDPRESS_VERSION = "3.4.2"
4
- VERSION = "0.1.0"
3
+ WORDPRESS_VERSION = "3.5"
4
+ VERSION = "0.1.1"
5
5
 
6
6
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: presspass
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-09-16 00:00:00.000000000 Z
12
+ date: 2012-12-15 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rack
@@ -74,6 +74,7 @@ files:
74
74
  - lib/presspass/presspass.rb
75
75
  - lib/presspass/cli.rb
76
76
  - lib/presspass/cli/new_project_generator.rb
77
+ - lib/presspass/cli/linker.rb
77
78
  - bin/presspass
78
79
  homepage: http://github.com/firmhouse/presspass
79
80
  licenses:
@@ -99,7 +100,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
99
100
  version: '0'
100
101
  requirements: []
101
102
  rubyforge_project:
102
- rubygems_version: 1.8.24
103
+ rubygems_version: 1.8.23
103
104
  signing_key:
104
105
  specification_version: 3
105
106
  summary: PressPass makes doing WordPress development awesome