sourceninja 0.0.6

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.
data/.gitignore ADDED
@@ -0,0 +1,6 @@
1
+ *.gem
2
+ .bundle
3
+ Gemfile.lock
4
+ pkg/*
5
+ *~
6
+ .idea
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source "http://rubygems.org"
2
+
3
+ # Specify your gem's dependencies in splinter.gemspec
4
+ gemspec
data/README.md ADDED
@@ -0,0 +1,52 @@
1
+ Note
2
+ ----
3
+ * This gem is currently alpha. __You need to be invited to [SourceNinja Alpha](http://www.sourceninja.com/sign-up.html) in order to use this gem__.
4
+ * If you are using Heroku, please refer to the [Heroku Documentation](heroku-addon) and please ignore this documentation.
5
+
6
+ What is SourceNinja
7
+ -------------------
8
+ SourceNinja is an awesome service that allows you to stay informed of updates to the open source packages that your application uses. When a newer version of a package is released, SourceNinja alerts you and gives you actionable information to help you determine whether you should upgrade to the newer package.
9
+
10
+ Visit [SourceNinja](http://sourceninja.com) to learn more.
11
+
12
+ What is the sourceninja gem
13
+ ------------------------
14
+ The sourceninja gem is a gem that can be included in your rails application to allow seamless integration with SourceNinja. The sourceninja gem will send all of your gem files and versions to SourceNinja to begin managing your open source libraries.
15
+
16
+ Getting Started
17
+ ---------------
18
+ First of all, you'll need the gem. If you're using Bundler, just add the following to your `Gemfile`.
19
+
20
+ gem 'sourceninja'
21
+
22
+ Of course, as always, when you edit your Gemfile:
23
+
24
+ bundle install
25
+
26
+ Before you can do anything with the sourceninja gem, you'll need to create your very own SourceNinja account (please read the notice above). Go ahead and do so at [http://sourceninja.com](http://sourceninja.com). Once created, you will need to create a product. This is the application you want SourceNinja to track.
27
+
28
+ Once your create a product, you will be directed to a page asking what language your application is running. Select `Rails` from the menu on the left side. You will be presented with two keys that you will need for the rest of the installation.
29
+
30
+ You will then need to setup two environment variables in production, `ENV["SOURCENINJA_TOKEN"]` and `ENV["SOURCENINJA_PRODUCT_ID"]`. You could set these up in a configuration file that is only used in production, however, that is not suggested. You should setup the environment variables according to your hosting documentation.
31
+
32
+ Updated Magically in Production
33
+ -----------------
34
+ Now each time you push to production the sourceninja gem will be run and data will be populated back to SourceNinja. If you visit your SourceNinja page you will be given a list of outdated gems.
35
+
36
+ The sourceninja data is populated whenever the app is initialized.
37
+
38
+ Testing Locally
39
+ ---------------
40
+ If you would like to test sourceninja gem locally, you will want to create an initializer script to set the variables.
41
+
42
+ ### Contents of `config/initializers/sourceninja.rb`
43
+ ENV["SOURCENINJA_TOKEN"] ||= "1cea0be98caf02e830ac2aadbe44e4ee"
44
+ ENV["SOURCENINJA_PRODUCT_ID"] ||= "fb89e064-b48c-d0c3-81x4-a34a5b60a654"
45
+
46
+ Upon doing this, each time you start the rails server locally the data will be pushed.
47
+
48
+ You could also use these steps if you want to manage a production instance and a development instance.
49
+
50
+ Support
51
+ -------
52
+ Feel free to email us at support at sourceninja dot com if you have any questions or issues.
data/Rakefile ADDED
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
@@ -0,0 +1,4 @@
1
+ require "sourceninja/version"
2
+
3
+ # only allow this to be run under rails for the time being.
4
+ require "sourceninja/sourceninja.rb" if defined? Rails
@@ -0,0 +1,57 @@
1
+ require 'httparty'
2
+ require 'json'
3
+
4
+ module Sourceninja
5
+ class Sourceninja
6
+ include HTTParty
7
+
8
+ @@base_uri = "https://app.sourceninja.com"
9
+
10
+ def self.send_package_info
11
+ Rails.logger.debug "Sourceninja: Attempting to send package information to SourceNinja"
12
+
13
+ base_uri = @@base_uri
14
+
15
+ if not ENV['SOURCENINJA_UPLOAD_URL'].nil? and ENV['SOURCENINJA_UPLOAD_URL'] != ""
16
+ Rails.logger.debug "Sourceninja: using #{ENV['SOURCENINJA_UPLOAD_URL']} for the upload URI"
17
+ base_uri = ENV['SOURCENINJA_UPLOAD_URL']
18
+ end
19
+
20
+ if ENV['SOURCENINJA_TOKEN'].nil? or ENV['SOURCENINJA_TOKEN'] == ""
21
+ Rails.logger.debug "Sourceninja: No SOURCENINJA_TOKEN set, not uploading information to SourceNinja"
22
+ return
23
+ end
24
+
25
+ if ENV['SOURCENINJA_PRODUCT_ID'].nil? or ENV['SOURCENINJA_PRODUCT_ID'] == ""
26
+ Rails.logger.debug "Sourceninja: No SOURCENINJA_PRODUCT_ID set, not uploading information to SourceNinja"
27
+ return
28
+ end
29
+
30
+ package_data = []
31
+ spec_hash = Bundler.environment.specs.to_hash
32
+ spec_hash.keys.each do |key|
33
+ unless %r{Gem::Specification name=#{key} version=([\d.]+)} =~ spec_hash[key][0].to_s
34
+ Rails.logger.info "Sourceninja: Could not parse information for gem #{key}: #{spec_hash[key]}"
35
+ next
36
+ end
37
+ package_data << { :package_name => key, :package_version => $1 }
38
+ end
39
+
40
+ if package_data.empty?
41
+ Rails.logger.info "Sourceninja: Did not successfully parse any packages, will not attempt to upload information"
42
+ return
43
+ end
44
+
45
+ params = { :id => ENV['SOURCENINJA_PRODUCT_ID'], :token => ENV['SOURCENINJA_TOKEN'], :package_info => { :package_details => package_data}.to_json }
46
+ Rails.logger.debug "Sourceninja: Attempting to send package_info of #{params.to_s} to #{[base_uri,'rubygems/1_0'].join('/')}"
47
+ response = HTTParty.post([base_uri,'rubygems/1_0'].join('/'), :body => params )
48
+ Rails.logger.debug "Sourceninja: Got back status #{response.code}"
49
+ end
50
+ end
51
+
52
+ class RailTie < Rails::Railtie
53
+ ActiveSupport.on_load(:after_initialize) do
54
+ Sourceninja.send_package_info
55
+ end
56
+ end
57
+ end
@@ -0,0 +1,3 @@
1
+ module Sourceninja
2
+ VERSION = "0.0.6"
3
+ end
@@ -0,0 +1,21 @@
1
+ # -*- encoding: utf-8 -*-
2
+ $:.push File.expand_path("../lib", __FILE__)
3
+ require "sourceninja/version"
4
+
5
+ Gem::Specification.new do |s|
6
+ s.name = "sourceninja"
7
+ s.version = Sourceninja::VERSION
8
+ s.authors = ["SourceNinja"]
9
+ s.email = ["support@sourceninja.com"]
10
+ s.homepage = "http://www.sourceninja.com"
11
+ s.summary = %q{Integration with SourceNinja software tracking.}
12
+ s.description = %q{Integration with SourceNinja software tracking. Will allow a user to scan their installed gemlist and automatically populate their product within the SourceNinja system.}
13
+
14
+ s.files = `git ls-files`.split("\n")
15
+ s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
16
+ s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
17
+ s.require_paths = ["lib"]
18
+
19
+ s.add_runtime_dependency "json"
20
+ s.add_runtime_dependency "httparty"
21
+ end
metadata ADDED
@@ -0,0 +1,87 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: sourceninja
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.6
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - SourceNinja
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2012-03-13 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: json
16
+ requirement: !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
21
+ version: '0'
22
+ type: :runtime
23
+ prerelease: false
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ! '>='
28
+ - !ruby/object:Gem::Version
29
+ version: '0'
30
+ - !ruby/object:Gem::Dependency
31
+ name: httparty
32
+ requirement: !ruby/object:Gem::Requirement
33
+ none: false
34
+ requirements:
35
+ - - ! '>='
36
+ - !ruby/object:Gem::Version
37
+ version: '0'
38
+ type: :runtime
39
+ prerelease: false
40
+ version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ! '>='
44
+ - !ruby/object:Gem::Version
45
+ version: '0'
46
+ description: Integration with SourceNinja software tracking. Will allow a user to
47
+ scan their installed gemlist and automatically populate their product within the
48
+ SourceNinja system.
49
+ email:
50
+ - support@sourceninja.com
51
+ executables: []
52
+ extensions: []
53
+ extra_rdoc_files: []
54
+ files:
55
+ - .gitignore
56
+ - Gemfile
57
+ - README.md
58
+ - Rakefile
59
+ - lib/sourceninja.rb
60
+ - lib/sourceninja/sourceninja.rb
61
+ - lib/sourceninja/version.rb
62
+ - sourceninja.gemspec
63
+ homepage: http://www.sourceninja.com
64
+ licenses: []
65
+ post_install_message:
66
+ rdoc_options: []
67
+ require_paths:
68
+ - lib
69
+ required_ruby_version: !ruby/object:Gem::Requirement
70
+ none: false
71
+ requirements:
72
+ - - ! '>='
73
+ - !ruby/object:Gem::Version
74
+ version: '0'
75
+ required_rubygems_version: !ruby/object:Gem::Requirement
76
+ none: false
77
+ requirements:
78
+ - - ! '>='
79
+ - !ruby/object:Gem::Version
80
+ version: '0'
81
+ requirements: []
82
+ rubyforge_project:
83
+ rubygems_version: 1.8.18
84
+ signing_key:
85
+ specification_version: 3
86
+ summary: Integration with SourceNinja software tracking.
87
+ test_files: []