itamae-plugin-resource-pip 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +9 -0
- data/CODE_OF_CONDUCT.md +13 -0
- data/Gemfile +4 -0
- data/README.md +48 -0
- data/Rakefile +10 -0
- data/itamae-plugin-resource-pip.gemspec +25 -0
- data/lib/itamae/plugin/resource/pip.rb +92 -0
- metadata +93 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 585b791c1cc78b0711d872c051b8a50d402d900d
|
4
|
+
data.tar.gz: a4caf09814e071e7b2fdfc7758b5d55b08cf5b15
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 347a34a691b455141705915bc2623d026fb60bea4d4119a68407e5860e36ccb0928b8e0ea010d802f536601d41de7657f4fe1bf69770450ca602a89ffee5d95b
|
7
|
+
data.tar.gz: 3c4e216f424705a8e3a66d94e6ac9963b262800e0ef0e8645395d5b12f47a9de0deaeff4974c4d896d34dae535180e31eeecc0bd817a13fb48ad761fc8f6d81e
|
data/.gitignore
ADDED
data/CODE_OF_CONDUCT.md
ADDED
@@ -0,0 +1,13 @@
|
|
1
|
+
# Contributor Code of Conduct
|
2
|
+
|
3
|
+
As contributors and maintainers of this project, we pledge to respect all people who contribute through reporting issues, posting feature requests, updating documentation, submitting pull requests or patches, and other activities.
|
4
|
+
|
5
|
+
We are committed to making participation in this project a harassment-free experience for everyone, regardless of level of experience, gender, gender identity and expression, sexual orientation, disability, personal appearance, body size, race, ethnicity, age, or religion.
|
6
|
+
|
7
|
+
Examples of unacceptable behavior by participants include the use of sexual language or imagery, derogatory comments or personal attacks, trolling, public or private harassment, insults, or other unprofessional conduct.
|
8
|
+
|
9
|
+
Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct. Project maintainers who do not follow the Code of Conduct may be removed from the project team.
|
10
|
+
|
11
|
+
Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by opening an issue or contacting one or more of the project maintainers.
|
12
|
+
|
13
|
+
This Code of Conduct is adapted from the [Contributor Covenant](http://contributor-covenant.org), version 1.0.0, available at [http://contributor-covenant.org/version/1/0/0/](http://contributor-covenant.org/version/1/0/0/)
|
data/Gemfile
ADDED
data/README.md
ADDED
@@ -0,0 +1,48 @@
|
|
1
|
+
# Itamae::Plugin::Resource::Pip
|
2
|
+
|
3
|
+
Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/itamae/plugin/resource/pip`. To experiment with that code, run `bin/console` for an interactive prompt.
|
4
|
+
|
5
|
+
TODO: Delete this and the text above, and describe your gem
|
6
|
+
|
7
|
+
## Installation
|
8
|
+
|
9
|
+
Add this line to your application's Gemfile:
|
10
|
+
|
11
|
+
```ruby
|
12
|
+
gem 'itamae-plugin-resource-pip'
|
13
|
+
```
|
14
|
+
|
15
|
+
And then execute:
|
16
|
+
|
17
|
+
$ bundle
|
18
|
+
|
19
|
+
Or install it yourself as:
|
20
|
+
|
21
|
+
$ gem install itamae-plugin-resource-pip
|
22
|
+
|
23
|
+
## Usage
|
24
|
+
|
25
|
+
write recipe:
|
26
|
+
```ruby
|
27
|
+
require 'itamae/plugin/resource/pip'
|
28
|
+
pip "tornado" do
|
29
|
+
pip_binary "/home/user/.pyenv/shims/pip"
|
30
|
+
version "4.1"
|
31
|
+
end
|
32
|
+
```
|
33
|
+
|
34
|
+
run script:
|
35
|
+
```console
|
36
|
+
$ itamae local recipe.rb
|
37
|
+
```
|
38
|
+
|
39
|
+
## Development
|
40
|
+
|
41
|
+
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake test` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
42
|
+
|
43
|
+
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
44
|
+
|
45
|
+
## Contributing
|
46
|
+
|
47
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/katyoshi/itamae-plugin-resource-pip. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](contributor-covenant.org) code of conduct.
|
48
|
+
|
data/Rakefile
ADDED
@@ -0,0 +1,25 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
|
5
|
+
Gem::Specification.new do |spec|
|
6
|
+
spec.name = "itamae-plugin-resource-pip"
|
7
|
+
spec.version = "0.1.0"
|
8
|
+
spec.authors = ["MATSUMOTO, Katsuyoshi"]
|
9
|
+
spec.email = ["github@katsyoshi.org"]
|
10
|
+
|
11
|
+
spec.summary = %q{itamae plugin resource pip}
|
12
|
+
spec.description = %q{itamae plugin resource pip}
|
13
|
+
spec.license = "MIT"
|
14
|
+
spec.homepage = "https://github.com/katsyoshi/itamae-plugin-resource-pip"
|
15
|
+
|
16
|
+
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
17
|
+
spec.bindir = "exe"
|
18
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
19
|
+
spec.require_paths = ["lib"]
|
20
|
+
|
21
|
+
spec.add_dependency "itamae", "~> 1.2"
|
22
|
+
|
23
|
+
spec.add_development_dependency "bundler", "~> 1.10"
|
24
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
25
|
+
end
|
@@ -0,0 +1,92 @@
|
|
1
|
+
require 'itamae/resource/base'
|
2
|
+
|
3
|
+
module Itamae
|
4
|
+
module Plugin
|
5
|
+
module Resource
|
6
|
+
class Pip < Itamae::Resource::Base
|
7
|
+
define_attribute :action, default: :install
|
8
|
+
define_attribute :pip_binary, type: [String, Array], default: 'pip'
|
9
|
+
define_attribute :package_name, type: String, default_name: true
|
10
|
+
define_attribute :version, type: String, default: false
|
11
|
+
|
12
|
+
def pre_action
|
13
|
+
case @current_action
|
14
|
+
when :install
|
15
|
+
attributes.installed = true
|
16
|
+
when :uninstall
|
17
|
+
attributes.installed = false
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
def set_current_attributes
|
22
|
+
installed = installed_pips.find {|pip| pip[:name] == attributes.package_name }
|
23
|
+
current.installed = !!installed
|
24
|
+
|
25
|
+
if current.installed
|
26
|
+
version = installed[:version]
|
27
|
+
current.version = version if version != attributes.version
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
def action_install(action_options)
|
32
|
+
if current.installed
|
33
|
+
if attributes.version && current.version != attributes.version
|
34
|
+
install!
|
35
|
+
updated!
|
36
|
+
end
|
37
|
+
else
|
38
|
+
install!
|
39
|
+
updated!
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
def action_upgrade(action_options)
|
44
|
+
return if current.installed && attributes.version && attributes.version == current.version
|
45
|
+
install!
|
46
|
+
updated!
|
47
|
+
end
|
48
|
+
|
49
|
+
def action_uninstall(action_options)
|
50
|
+
install!
|
51
|
+
updated!
|
52
|
+
end
|
53
|
+
|
54
|
+
private
|
55
|
+
|
56
|
+
def installed_pips
|
57
|
+
pips = []
|
58
|
+
run_command([*Array(attributes.pip_binary), 'freeze']).stdout.each_line do |line|
|
59
|
+
name, version = line.split(/==/)
|
60
|
+
pips << {name: name, version: version}
|
61
|
+
end
|
62
|
+
pips
|
63
|
+
rescue Backend::CommandExecutionError
|
64
|
+
[]
|
65
|
+
end
|
66
|
+
|
67
|
+
def build_pip_install_command
|
68
|
+
cmd = [*Array(attributes.pip_binary), 'install']
|
69
|
+
if attributes.version
|
70
|
+
cmd << "#{attributes.package_name}==#{attributes.version}"
|
71
|
+
else
|
72
|
+
cmd << attributes.package_name
|
73
|
+
end
|
74
|
+
|
75
|
+
case @current_action
|
76
|
+
when :upgrade
|
77
|
+
cmd << '--upgrade'
|
78
|
+
when :uninstall
|
79
|
+
cmd.find {|w| w =~ /\Ainstall\z/ }.sub!(/\A/, 'un')
|
80
|
+
cmd << '-y'
|
81
|
+
end
|
82
|
+
|
83
|
+
cmd
|
84
|
+
end
|
85
|
+
|
86
|
+
def install!
|
87
|
+
run_command(build_pip_install_command)
|
88
|
+
end
|
89
|
+
end
|
90
|
+
end
|
91
|
+
end
|
92
|
+
end
|
metadata
ADDED
@@ -0,0 +1,93 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: itamae-plugin-resource-pip
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- MATSUMOTO, Katsuyoshi
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2015-08-24 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: itamae
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.2'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.2'
|
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.10'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '1.10'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rake
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '10.0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '10.0'
|
55
|
+
description: itamae plugin resource pip
|
56
|
+
email:
|
57
|
+
- github@katsyoshi.org
|
58
|
+
executables: []
|
59
|
+
extensions: []
|
60
|
+
extra_rdoc_files: []
|
61
|
+
files:
|
62
|
+
- ".gitignore"
|
63
|
+
- CODE_OF_CONDUCT.md
|
64
|
+
- Gemfile
|
65
|
+
- README.md
|
66
|
+
- Rakefile
|
67
|
+
- itamae-plugin-resource-pip.gemspec
|
68
|
+
- lib/itamae/plugin/resource/pip.rb
|
69
|
+
homepage: https://github.com/katsyoshi/itamae-plugin-resource-pip
|
70
|
+
licenses:
|
71
|
+
- MIT
|
72
|
+
metadata: {}
|
73
|
+
post_install_message:
|
74
|
+
rdoc_options: []
|
75
|
+
require_paths:
|
76
|
+
- lib
|
77
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
78
|
+
requirements:
|
79
|
+
- - ">="
|
80
|
+
- !ruby/object:Gem::Version
|
81
|
+
version: '0'
|
82
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
83
|
+
requirements:
|
84
|
+
- - ">="
|
85
|
+
- !ruby/object:Gem::Version
|
86
|
+
version: '0'
|
87
|
+
requirements: []
|
88
|
+
rubyforge_project:
|
89
|
+
rubygems_version: 2.4.5.1
|
90
|
+
signing_key:
|
91
|
+
specification_version: 4
|
92
|
+
summary: itamae plugin resource pip
|
93
|
+
test_files: []
|