dpl 1.4.7.travis.135.2 → 1.4.7.travis.140.2

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: c8fff797463257453d5adca079243739356b324a
4
- data.tar.gz: 6750a6902c88209e9297c622db3d6cdf36c92039
3
+ metadata.gz: ca7a08d634d9f07c6dfe2e383ababbea2326d1da
4
+ data.tar.gz: e93c0baf30853ef4a2110cefcf1b9fc55f1bb429
5
5
  SHA512:
6
- metadata.gz: 46a1cb4624e51cb4ca6edc4dd8c5b292b342c9a0419184da2b250a1e685b783dd3b242c0aabca1fec62e88baf905da84aea95ddc3b1d847789a000fccb873ebc
7
- data.tar.gz: 044ad1b2626e10ce71329bab80887ed989186aa5533c63a501e82e3c470b247abfea794a846add093c0e59242fecee8c03855212743bc9e18af8a9e0bf33a52c
6
+ metadata.gz: 0c55a68c8c1793776298a0e4a9527b0552b46ca666910a08c99a4c7786e01ce377f54e40053c7809404598f4760b720e067bcf893f16ebbd8df774c2d58bfafd
7
+ data.tar.gz: ae35d9a5b2ddc60be9ea9cb3c054f34846a7fde772dd2f7ec4a17c1639e545ec487490cd81f66e2fe5b34f50719276e2a89a3eb164a0f75ceb747f9ab26b2fe3
@@ -13,6 +13,7 @@ module DPL
13
13
  autoload :RubyGems, 'dpl/provider/rubygems'
14
14
  autoload :CloudControl, 'dpl/provider/cloudcontrol'
15
15
  autoload :CloudFoundry, 'dpl/provider/cloud_foundry'
16
+ autoload :PyPI, 'dpl/provider/pypi'
16
17
 
17
18
  def self.new(context, options)
18
19
  return super if self < Provider
@@ -0,0 +1,66 @@
1
+ module DPL
2
+ class Provider
3
+ class PyPI < Provider
4
+ DEFAULT_SERVER = 'http://www.python.org/pypi'
5
+ PYPIRC_FILE = '~/.pypirc'
6
+
7
+ def self.install_setuptools
8
+ shell 'wget https://bitbucket.org/pypa/setuptools/raw/bootstrap/ez_setup.py -O - | sudo python'
9
+ end
10
+
11
+ install_setuptools
12
+
13
+ def config
14
+ {
15
+ :header => '[distutils]',
16
+ :servers_line => 'index-servers =',
17
+ :servers => {
18
+ 'pypi' => [
19
+ "repository: #{options[:server] || DEFAULT_SERVER}",
20
+ "username: #{option(:user)}",
21
+ "password: #{option(:password)}",
22
+ ]
23
+ }
24
+ }
25
+ end
26
+
27
+ def write_servers(f)
28
+ config[:servers].each do |key, val|
29
+ f.puts " " * 4 + key
30
+ end
31
+
32
+ config[:servers].each do |key, val|
33
+ f.puts "[#{key}]"
34
+ f.puts val
35
+ end
36
+ end
37
+
38
+ def write_config
39
+ File.open(File.expand_path(PYPIRC_FILE), 'w') do |f|
40
+ config.each do |key, val|
41
+ f.puts(val) if val.is_a? String or val.is_a? Array
42
+ end
43
+ write_servers(f)
44
+ end
45
+ end
46
+
47
+ def check_auth
48
+ write_config
49
+ log "Authenticated as #{option(:user)}"
50
+ end
51
+
52
+ def check_app
53
+ end
54
+
55
+ def needs_key?
56
+ false
57
+ end
58
+
59
+ def push_app
60
+ context.shell "python setup.py register -r #{options[:server] || 'pypi'}"
61
+ context.shell "python setup.py #{options[:distributions] || 'sdist'} upload -r #{options[:server] || 'pypi'}"
62
+ context.shell "python setup.py upload_docs --upload-dir #{options[:docs_dir] || 'build/docs'}"
63
+ end
64
+ end
65
+ end
66
+ end
@@ -0,0 +1,68 @@
1
+ require 'spec_helper'
2
+ require 'dpl/provider/pypi'
3
+
4
+ describe DPL::Provider::PyPI do
5
+ subject :provider do
6
+ described_class.new(DummyContext.new, :user => 'foo', :password => 'bar')
7
+ end
8
+
9
+ describe :config do
10
+ it 'accepts a user and a password' do
11
+ provider.config[:servers]['pypi'].should include 'username: foo'
12
+ provider.config[:servers]['pypi'].should include 'password: bar'
13
+ end
14
+ end
15
+
16
+ describe :check_auth do
17
+ example do
18
+ provider.should_receive(:log).with("Authenticated as foo")
19
+ provider.check_auth
20
+ end
21
+ end
22
+
23
+ describe :push_app do
24
+ example do
25
+ provider.context.should_receive(:shell).with("python setup.py register -r pypi")
26
+ provider.context.should_receive(:shell).with("python setup.py sdist upload -r pypi")
27
+ provider.context.should_receive(:shell).with("python setup.py upload_docs --upload-dir build/docs")
28
+ provider.push_app
29
+ end
30
+
31
+ example "with :distributions option" do
32
+ provider.options.update(:distributions => 'sdist bdist')
33
+ provider.context.should_receive(:shell).with("python setup.py register -r pypi")
34
+ provider.context.should_receive(:shell).with("python setup.py sdist bdist upload -r pypi")
35
+ provider.context.should_receive(:shell).with("python setup.py upload_docs --upload-dir build/docs")
36
+ provider.push_app
37
+ end
38
+
39
+ example "with :server option" do
40
+ provider.options.update(:server => 'http://blah.com')
41
+ provider.context.should_receive(:shell).with("python setup.py register -r http://blah.com")
42
+ provider.context.should_receive(:shell).with("python setup.py sdist upload -r http://blah.com")
43
+ provider.context.should_receive(:shell).with("python setup.py upload_docs --upload-dir build/docs")
44
+ provider.push_app
45
+ end
46
+
47
+ example "with :docs_dir option" do
48
+ provider.options.update(:docs_dir => 'some/dir')
49
+ provider.context.should_receive(:shell).with("python setup.py register -r pypi")
50
+ provider.context.should_receive(:shell).with("python setup.py sdist upload -r pypi")
51
+ provider.context.should_receive(:shell).with("python setup.py upload_docs --upload-dir some/dir")
52
+ provider.push_app
53
+ end
54
+ end
55
+
56
+ describe :write_servers do
57
+ example do
58
+ f = double(:f)
59
+ f.should_receive(:puts).with(" pypi")
60
+ f.should_receive(:puts).with("[pypi]")
61
+ f.should_receive(:puts).with(["repository: http://www.python.org/pypi",
62
+ "username: foo",
63
+ "password: bar"
64
+ ])
65
+ provider.write_servers(f)
66
+ end
67
+ end
68
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dpl
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.4.7.travis.135.2
4
+ version: 1.4.7.travis.140.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Konstantin Haase
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-09-07 00:00:00.000000000 Z
11
+ date: 2013-09-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rspec
@@ -94,6 +94,7 @@ files:
94
94
  - lib/dpl/provider/heroku/git.rb
95
95
  - lib/dpl/provider/nodejitsu.rb
96
96
  - lib/dpl/provider/openshift.rb
97
+ - lib/dpl/provider/pypi.rb
97
98
  - lib/dpl/provider/rubygems.rb
98
99
  - lib/dpl/version.rb
99
100
  - notes/dotcloud.md
@@ -105,6 +106,7 @@ files:
105
106
  - spec/provider/heroku_anvil_spec.rb
106
107
  - spec/provider/heroku_git_spec.rb
107
108
  - spec/provider/openshift_spec.rb
109
+ - spec/provider/pypi_spec.rb
108
110
  - spec/provider/rubygems_spec.rb
109
111
  - spec/provider_spec.rb
110
112
  - spec/spec_helper.rb