depsio 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +21 -0
- data/Gemfile +5 -0
- data/LICENSE.txt +22 -0
- data/README.md +32 -0
- data/Rakefile +5 -0
- data/depsio.gemspec +22 -0
- data/lib/depsio.rb +37 -0
- data/lib/depsio/configuration.rb +18 -0
- data/lib/depsio/railtie.rb +19 -0
- data/lib/depsio/version.rb +3 -0
- data/lib/generators/depsio/install_generator.rb +34 -0
- data/lib/generators/depsio/templates/initializer.rb +4 -0
- data/spec/depsio_spec.rb +14 -0
- data/spec/spec_helper.rb +9 -0
- metadata +94 -0
data/.gitignore
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2013 Alexandre Gerlic
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,32 @@
|
|
1
|
+
Deps.io
|
2
|
+
========
|
3
|
+
|
4
|
+
This is the notifier gem for integrating apps with [Deps.io](http://deps.io).
|
5
|
+
|
6
|
+
When server starts, this gem will POST the Gemfile.lock content to Deps.io to update project dependencies.
|
7
|
+
|
8
|
+
Rails Installation
|
9
|
+
------------------
|
10
|
+
|
11
|
+
Add this line to your application's Gemfile:
|
12
|
+
|
13
|
+
gem 'depsio'
|
14
|
+
|
15
|
+
And then execute:
|
16
|
+
|
17
|
+
$ bundle
|
18
|
+
$ rails generate depsio:install --api-key your_api_key_here
|
19
|
+
|
20
|
+
The generator creates a file under `config/initializers/depsio.rb` configuring Deps.io with your API key.
|
21
|
+
|
22
|
+
The default behaviour of the gem is to only operate in Rails environments that are NOT **development**, **test** & **staging**.
|
23
|
+
|
24
|
+
You can change this by altering this array:
|
25
|
+
|
26
|
+
config.enabled_environments = ["production", "staging", "custom"]
|
27
|
+
|
28
|
+
Set it to empty array and it will report errors on all environments.
|
29
|
+
|
30
|
+
### License
|
31
|
+
|
32
|
+
MIT License. Copyright 2013 LetsDoApps. [http://letsdoapps.com/](http://letsdoapps.com/)
|
data/Rakefile
ADDED
data/depsio.gemspec
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'depsio/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |gem|
|
7
|
+
gem.name = "depsio"
|
8
|
+
gem.version = Depsio::VERSION
|
9
|
+
gem.authors = ["Alexandre Gerlic", "Jeremie Bordier"]
|
10
|
+
gem.email = ["contact@deps.io"]
|
11
|
+
gem.description = %q{Deps.io: Keep your project dependencies under control}
|
12
|
+
gem.summary = gem.description
|
13
|
+
gem.homepage = "http://deps.io"
|
14
|
+
|
15
|
+
gem.files = `git ls-files`.split($/)
|
16
|
+
gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
|
17
|
+
gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
|
18
|
+
gem.require_paths = ["lib"]
|
19
|
+
|
20
|
+
gem.add_runtime_dependency("json")
|
21
|
+
gem.add_runtime_dependency("rest-client")
|
22
|
+
end
|
data/lib/depsio.rb
ADDED
@@ -0,0 +1,37 @@
|
|
1
|
+
require "depsio/version"
|
2
|
+
require "depsio/configuration"
|
3
|
+
|
4
|
+
require 'depsio/railtie' if defined?(Rails::Railtie)
|
5
|
+
|
6
|
+
require 'rest_client'
|
7
|
+
|
8
|
+
module Depsio
|
9
|
+
|
10
|
+
class << self
|
11
|
+
def configure
|
12
|
+
yield(config)
|
13
|
+
end
|
14
|
+
|
15
|
+
def config
|
16
|
+
@configuration ||= Configuration.new
|
17
|
+
end
|
18
|
+
|
19
|
+
def logger
|
20
|
+
@configuration.logger
|
21
|
+
end
|
22
|
+
|
23
|
+
def update_dependencies
|
24
|
+
filepath = "Gemfile.lock"
|
25
|
+
if config.enabled? && File.exists?(filepath)
|
26
|
+
dependencies = IO.read(filepath)
|
27
|
+
logger.info "Deps.io: Update dependencies"
|
28
|
+
begin
|
29
|
+
RestClient.post config.endpoint, { :dependencies => dependencies, :type => :gemfile }
|
30
|
+
rescue Exception => e
|
31
|
+
logger.error e
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
end
|
37
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
module Depsio
|
2
|
+
# Used to set up and modify settings for the notifier.
|
3
|
+
class Configuration
|
4
|
+
attr_accessor :api_key, :endpoint, :enabled_environments, :logger
|
5
|
+
|
6
|
+
def initialize
|
7
|
+
@enabled_environments = %w(production)
|
8
|
+
end
|
9
|
+
|
10
|
+
def endpoint
|
11
|
+
@endpoint ||= "https://deps.io/api/v1/apps/#{@api_key}/update.json"
|
12
|
+
end
|
13
|
+
|
14
|
+
def enabled?
|
15
|
+
enabled_environments.include?(::Rails.env)
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
require 'depsio'
|
2
|
+
require 'rails'
|
3
|
+
|
4
|
+
module Depsio
|
5
|
+
class Railtie < ::Rails::Railtie
|
6
|
+
if not ENV['RACK_ENV'].blank?
|
7
|
+
config.after_initialize do
|
8
|
+
Depsio.configure do |config|
|
9
|
+
if ::Rails.env == "development"
|
10
|
+
config.logger = Logger.new(STDOUT)
|
11
|
+
else
|
12
|
+
config.logger = ::Rails.logger
|
13
|
+
end
|
14
|
+
end
|
15
|
+
Depsio.update_dependencies
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,34 @@
|
|
1
|
+
class Depsio::InstallGenerator < ::Rails::Generators::Base
|
2
|
+
desc "Creates the Depsio initializer file at config/initializers/depsio.rb"
|
3
|
+
|
4
|
+
source_root File.expand_path("../templates", __FILE__)
|
5
|
+
|
6
|
+
class_option :api_key, :aliases => "-k", :type => :string,
|
7
|
+
:desc => "Your Deps.io API key"
|
8
|
+
|
9
|
+
def install
|
10
|
+
ensure_api_key_exists
|
11
|
+
generate_initializer unless api_key_configured?
|
12
|
+
end
|
13
|
+
|
14
|
+
private
|
15
|
+
|
16
|
+
def ensure_api_key_exists
|
17
|
+
if !options[:api_key] && !api_key_configured?
|
18
|
+
puts "Must pass --api-key or create config/initializers/depsio.rb"
|
19
|
+
exit
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
def api_key_expression
|
24
|
+
"#{options[:api_key]}"
|
25
|
+
end
|
26
|
+
|
27
|
+
def generate_initializer
|
28
|
+
template 'initializer.rb', 'config/initializers/depsio.rb'
|
29
|
+
end
|
30
|
+
|
31
|
+
def api_key_configured?
|
32
|
+
File.exists?('config/initializers/depsio.rb')
|
33
|
+
end
|
34
|
+
end
|
data/spec/depsio_spec.rb
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Depsio do
|
4
|
+
describe Depsio::Configuration do
|
5
|
+
it "should use production as default enabled environments" do
|
6
|
+
Depsio.config.enabled_environments.should match_array(%w(production))
|
7
|
+
end
|
8
|
+
|
9
|
+
it "should add api_key to endpoint" do
|
10
|
+
Depsio.configure {|config| config.api_key = "test_key" }
|
11
|
+
Depsio.config.endpoint.should eq("https://deps.io/api/v1/apps/test_key/update.json")
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
data/spec/spec_helper.rb
ADDED
metadata
ADDED
@@ -0,0 +1,94 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: depsio
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.2
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Alexandre Gerlic
|
9
|
+
- Jeremie Bordier
|
10
|
+
autorequire:
|
11
|
+
bindir: bin
|
12
|
+
cert_chain: []
|
13
|
+
date: 2013-04-04 00:00:00.000000000 Z
|
14
|
+
dependencies:
|
15
|
+
- !ruby/object:Gem::Dependency
|
16
|
+
name: json
|
17
|
+
requirement: !ruby/object:Gem::Requirement
|
18
|
+
none: false
|
19
|
+
requirements:
|
20
|
+
- - ! '>='
|
21
|
+
- !ruby/object:Gem::Version
|
22
|
+
version: '0'
|
23
|
+
type: :runtime
|
24
|
+
prerelease: false
|
25
|
+
version_requirements: !ruby/object:Gem::Requirement
|
26
|
+
none: false
|
27
|
+
requirements:
|
28
|
+
- - ! '>='
|
29
|
+
- !ruby/object:Gem::Version
|
30
|
+
version: '0'
|
31
|
+
- !ruby/object:Gem::Dependency
|
32
|
+
name: rest-client
|
33
|
+
requirement: !ruby/object:Gem::Requirement
|
34
|
+
none: false
|
35
|
+
requirements:
|
36
|
+
- - ! '>='
|
37
|
+
- !ruby/object:Gem::Version
|
38
|
+
version: '0'
|
39
|
+
type: :runtime
|
40
|
+
prerelease: false
|
41
|
+
version_requirements: !ruby/object:Gem::Requirement
|
42
|
+
none: false
|
43
|
+
requirements:
|
44
|
+
- - ! '>='
|
45
|
+
- !ruby/object:Gem::Version
|
46
|
+
version: '0'
|
47
|
+
description: ! 'Deps.io: Keep your project dependencies under control'
|
48
|
+
email:
|
49
|
+
- contact@deps.io
|
50
|
+
executables: []
|
51
|
+
extensions: []
|
52
|
+
extra_rdoc_files: []
|
53
|
+
files:
|
54
|
+
- .gitignore
|
55
|
+
- Gemfile
|
56
|
+
- LICENSE.txt
|
57
|
+
- README.md
|
58
|
+
- Rakefile
|
59
|
+
- depsio.gemspec
|
60
|
+
- lib/depsio.rb
|
61
|
+
- lib/depsio/configuration.rb
|
62
|
+
- lib/depsio/railtie.rb
|
63
|
+
- lib/depsio/version.rb
|
64
|
+
- lib/generators/depsio/install_generator.rb
|
65
|
+
- lib/generators/depsio/templates/initializer.rb
|
66
|
+
- spec/depsio_spec.rb
|
67
|
+
- spec/spec_helper.rb
|
68
|
+
homepage: http://deps.io
|
69
|
+
licenses: []
|
70
|
+
post_install_message:
|
71
|
+
rdoc_options: []
|
72
|
+
require_paths:
|
73
|
+
- lib
|
74
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
75
|
+
none: false
|
76
|
+
requirements:
|
77
|
+
- - ! '>='
|
78
|
+
- !ruby/object:Gem::Version
|
79
|
+
version: '0'
|
80
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
81
|
+
none: false
|
82
|
+
requirements:
|
83
|
+
- - ! '>='
|
84
|
+
- !ruby/object:Gem::Version
|
85
|
+
version: '0'
|
86
|
+
requirements: []
|
87
|
+
rubyforge_project:
|
88
|
+
rubygems_version: 1.8.24
|
89
|
+
signing_key:
|
90
|
+
specification_version: 3
|
91
|
+
summary: ! 'Deps.io: Keep your project dependencies under control'
|
92
|
+
test_files:
|
93
|
+
- spec/depsio_spec.rb
|
94
|
+
- spec/spec_helper.rb
|