rubygems_herald 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (79) hide show
  1. checksums.yaml +7 -0
  2. data/.coveralls.yml +1 -0
  3. data/.document +5 -0
  4. data/.rspec +1 -0
  5. data/.travis.yml +5 -0
  6. data/Gemfile +16 -0
  7. data/Gemfile.lock +205 -0
  8. data/LICENSE.txt +20 -0
  9. data/README.md +40 -0
  10. data/Rakefile +49 -0
  11. data/VERSION +1 -0
  12. data/app/controllers/gem_displays_controller.rb +38 -0
  13. data/app/models/gem_display.rb +47 -0
  14. data/app/views/gem_displays/index.html.haml +5 -0
  15. data/app/views/gem_displays/show.html.haml +30 -0
  16. data/config/locales/en.yml +42 -0
  17. data/config/routes.rb +5 -0
  18. data/lib/generators/rubygems_herald/install/install_generator.rb +43 -0
  19. data/lib/generators/rubygems_herald/install/templates/initializer.rb +4 -0
  20. data/lib/generators/rubygems_herald/install/templates/migrate/create_gem_displays_table.rb +25 -0
  21. data/lib/generators/rubygems_herald/utils.rb +16 -0
  22. data/lib/rubygems_herald.rb +13 -0
  23. data/lib/rubygems_herald/configuration.rb +21 -0
  24. data/lib/rubygems_herald/engine.rb +4 -0
  25. data/lib/rubygems_herald/localization.rb +31 -0
  26. data/lib/rubygems_herald/railtie.rb +4 -0
  27. data/lib/rubygems_herald/spider.rb +52 -0
  28. data/lib/rubygems_herald/version.rb +7 -0
  29. data/rubygems_herald.gemspec +155 -0
  30. data/spec/controllers/gem_displays_controller_spec.rb +39 -0
  31. data/spec/dummy/.rspec +1 -0
  32. data/spec/dummy/Rakefile +7 -0
  33. data/spec/dummy/app/controllers/application_controller.rb +5 -0
  34. data/spec/dummy/app/helpers/application_helper.rb +2 -0
  35. data/spec/dummy/app/views/layouts/application.html.haml +34 -0
  36. data/spec/dummy/bin/bundle +3 -0
  37. data/spec/dummy/bin/rails +4 -0
  38. data/spec/dummy/bin/rake +4 -0
  39. data/spec/dummy/config.ru +4 -0
  40. data/spec/dummy/config/application.rb +31 -0
  41. data/spec/dummy/config/boot.rb +4 -0
  42. data/spec/dummy/config/database.yml +25 -0
  43. data/spec/dummy/config/environment.rb +5 -0
  44. data/spec/dummy/config/environments/development.rb +29 -0
  45. data/spec/dummy/config/environments/production.rb +80 -0
  46. data/spec/dummy/config/environments/test.rb +36 -0
  47. data/spec/dummy/config/initializers/backtrace_silencers.rb +7 -0
  48. data/spec/dummy/config/initializers/bootstrap_leather.rb +6 -0
  49. data/spec/dummy/config/initializers/filter_parameter_logging.rb +4 -0
  50. data/spec/dummy/config/initializers/inflections.rb +16 -0
  51. data/spec/dummy/config/initializers/mime_types.rb +5 -0
  52. data/spec/dummy/config/initializers/rubygems_herald.rb +4 -0
  53. data/spec/dummy/config/initializers/secret_token.rb +12 -0
  54. data/spec/dummy/config/initializers/session_store.rb +3 -0
  55. data/spec/dummy/config/initializers/wrap_parameters.rb +14 -0
  56. data/spec/dummy/config/routes.rb +56 -0
  57. data/spec/dummy/db/development.sqlite3 +0 -0
  58. data/spec/dummy/db/migrate/20140512012318_create_gem_displays_table.rb +30 -0
  59. data/spec/dummy/db/schema.rb +44 -0
  60. data/spec/dummy/db/seeds.rb +7 -0
  61. data/spec/dummy/db/test.sqlite3 +0 -0
  62. data/spec/dummy/lib/assets/.keep +0 -0
  63. data/spec/dummy/lib/tasks/.keep +0 -0
  64. data/spec/dummy/log/.keep +0 -0
  65. data/spec/dummy/log/development.log +91355 -0
  66. data/spec/dummy/log/test.log +10670 -0
  67. data/spec/dummy/public/404.html +58 -0
  68. data/spec/dummy/public/422.html +58 -0
  69. data/spec/dummy/public/500.html +57 -0
  70. data/spec/dummy/public/favicon.ico +0 -0
  71. data/spec/dummy/public/robots.txt +5 -0
  72. data/spec/factories/gem_display.rb +7 -0
  73. data/spec/models/gem_display_spec.rb +50 -0
  74. data/spec/rubygems_herald_spec.rb +7 -0
  75. data/spec/spec_helper.rb +37 -0
  76. data/spec/support/gem_display_support.rb +5 -0
  77. data/spec/views/gem_displays/index.html.haml_spec.rb +12 -0
  78. data/spec/views/gem_displays/show.html.haml_spec.rb +12 -0
  79. metadata +320 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: b439d4175912df56a895958407a056471418d70d
4
+ data.tar.gz: f73f412309a9349cad63a465752dc13899ca76da
5
+ SHA512:
6
+ metadata.gz: 7b25419c7dc938ada9a5459b09fa8a7631cc7b31e7e0313c65a894e4756f536a4dfa1dd995c1b182a2f6a897966971c109caf4a715d3417da15cccb8ef89f2f4
7
+ data.tar.gz: a27b6e8d1152049d92b96d8aaf2881c6fb7b660cbdf5f841f910615f183bcedbb43806daf4097103f390525ca6805175742ae69fa06afab19772503d518899d2
data/.coveralls.yml ADDED
@@ -0,0 +1 @@
1
+ service_name: travis-ci
data/.document ADDED
@@ -0,0 +1,5 @@
1
+ lib/**/*.rb
2
+ bin/*
3
+ -
4
+ features/**/*.feature
5
+ LICENSE.txt
data/.rspec ADDED
@@ -0,0 +1 @@
1
+ --color
data/.travis.yml ADDED
@@ -0,0 +1,5 @@
1
+ language: ruby
2
+ rvm:
3
+ - 2.1.1
4
+ - 2.0.0
5
+ - 1.9.3
data/Gemfile ADDED
@@ -0,0 +1,16 @@
1
+ source "http://rubygems.org"
2
+ # Add dependencies required to use your gem here.
3
+ # Example:
4
+ # gem "activesupport", ">= 2.3.5"
5
+
6
+ # Add dependencies to develop your gem here.
7
+ # Include everything needed to run rake, tests, features, etc.
8
+ gem 'rails', '>= 4.1'
9
+ gem 'rails-i18n'
10
+ gem 'jquery-rails'
11
+ gem 'haml-rails'
12
+ gem 'bootstrap_leather'
13
+ gem 'factory_girl_rails'
14
+ gem 'database_cleaner'
15
+
16
+ gemspec
data/Gemfile.lock ADDED
@@ -0,0 +1,205 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ rubygems_herald (0.0.1)
5
+ bootstrap_leather
6
+ database_cleaner
7
+ factory_girl_rails
8
+ haml-rails
9
+ jquery-rails
10
+ rails (>= 4.1)
11
+ rails-i18n
12
+ rubygems_herald
13
+
14
+ GEM
15
+ remote: http://rubygems.org/
16
+ specs:
17
+ actionmailer (4.1.1)
18
+ actionpack (= 4.1.1)
19
+ actionview (= 4.1.1)
20
+ mail (~> 2.5.4)
21
+ actionpack (4.1.1)
22
+ actionview (= 4.1.1)
23
+ activesupport (= 4.1.1)
24
+ rack (~> 1.5.2)
25
+ rack-test (~> 0.6.2)
26
+ actionview (4.1.1)
27
+ activesupport (= 4.1.1)
28
+ builder (~> 3.1)
29
+ erubis (~> 2.7.0)
30
+ activemodel (4.1.1)
31
+ activesupport (= 4.1.1)
32
+ builder (~> 3.1)
33
+ activerecord (4.1.1)
34
+ activemodel (= 4.1.1)
35
+ activesupport (= 4.1.1)
36
+ arel (~> 5.0.0)
37
+ activesupport (4.1.1)
38
+ i18n (~> 0.6, >= 0.6.9)
39
+ json (~> 1.7, >= 1.7.7)
40
+ minitest (~> 5.1)
41
+ thread_safe (~> 0.1)
42
+ tzinfo (~> 1.1)
43
+ addressable (2.3.6)
44
+ arel (5.0.1.20140414130214)
45
+ bootstrap_leather (0.1.6)
46
+ haml
47
+ rails
48
+ builder (3.2.2)
49
+ coveralls (0.7.0)
50
+ multi_json (~> 1.3)
51
+ rest-client
52
+ simplecov (>= 0.7)
53
+ term-ansicolor
54
+ thor
55
+ database_cleaner (1.2.0)
56
+ descendants_tracker (0.0.4)
57
+ thread_safe (~> 0.3, >= 0.3.1)
58
+ diff-lcs (1.2.5)
59
+ docile (1.1.3)
60
+ erubis (2.7.0)
61
+ factory_girl (4.4.0)
62
+ activesupport (>= 3.0.0)
63
+ factory_girl_rails (4.4.1)
64
+ factory_girl (~> 4.4.0)
65
+ railties (>= 3.0.0)
66
+ faraday (0.9.0)
67
+ multipart-post (>= 1.2, < 3)
68
+ git (1.2.6)
69
+ github_api (0.11.3)
70
+ addressable (~> 2.3)
71
+ descendants_tracker (~> 0.0.1)
72
+ faraday (~> 0.8, < 0.10)
73
+ hashie (>= 1.2)
74
+ multi_json (>= 1.7.5, < 2.0)
75
+ nokogiri (~> 1.6.0)
76
+ oauth2
77
+ haml (4.0.5)
78
+ tilt
79
+ haml-rails (0.5.3)
80
+ actionpack (>= 4.0.1)
81
+ activesupport (>= 4.0.1)
82
+ haml (>= 3.1, < 5.0)
83
+ railties (>= 4.0.1)
84
+ hashie (2.1.1)
85
+ highline (1.6.21)
86
+ hike (1.2.3)
87
+ i18n (0.6.9)
88
+ jeweler (2.0.1)
89
+ builder
90
+ bundler (>= 1.0)
91
+ git (>= 1.2.5)
92
+ github_api
93
+ highline (>= 1.6.15)
94
+ nokogiri (>= 1.5.10)
95
+ rake
96
+ rdoc
97
+ jquery-rails (3.1.0)
98
+ railties (>= 3.0, < 5.0)
99
+ thor (>= 0.14, < 2.0)
100
+ json (1.8.1)
101
+ jwt (0.1.13)
102
+ multi_json (>= 1.5)
103
+ mail (2.5.4)
104
+ mime-types (~> 1.16)
105
+ treetop (~> 1.4.8)
106
+ mime-types (1.25.1)
107
+ mini_portile (0.5.3)
108
+ minitest (5.3.3)
109
+ multi_json (1.10.0)
110
+ multi_xml (0.5.5)
111
+ multipart-post (2.0.0)
112
+ nokogiri (1.6.1)
113
+ mini_portile (~> 0.5.0)
114
+ oauth2 (0.9.3)
115
+ faraday (>= 0.8, < 0.10)
116
+ jwt (~> 0.1.8)
117
+ multi_json (~> 1.3)
118
+ multi_xml (~> 0.5)
119
+ rack (~> 1.2)
120
+ polyglot (0.3.4)
121
+ rack (1.5.2)
122
+ rack-test (0.6.2)
123
+ rack (>= 1.0)
124
+ rails (4.1.1)
125
+ actionmailer (= 4.1.1)
126
+ actionpack (= 4.1.1)
127
+ actionview (= 4.1.1)
128
+ activemodel (= 4.1.1)
129
+ activerecord (= 4.1.1)
130
+ activesupport (= 4.1.1)
131
+ bundler (>= 1.3.0, < 2.0)
132
+ railties (= 4.1.1)
133
+ sprockets-rails (~> 2.0)
134
+ rails-i18n (4.0.2)
135
+ i18n (~> 0.6)
136
+ rails (>= 4.0)
137
+ railties (4.1.1)
138
+ actionpack (= 4.1.1)
139
+ activesupport (= 4.1.1)
140
+ rake (>= 0.8.7)
141
+ thor (>= 0.18.1, < 2.0)
142
+ rake (10.3.1)
143
+ rdoc (4.1.1)
144
+ json (~> 1.4)
145
+ rest-client (1.6.7)
146
+ mime-types (>= 1.16)
147
+ rspec-core (2.14.8)
148
+ rspec-expectations (2.14.5)
149
+ diff-lcs (>= 1.1.3, < 2.0)
150
+ rspec-mocks (2.14.6)
151
+ rspec-rails (2.14.2)
152
+ actionpack (>= 3.0)
153
+ activemodel (>= 3.0)
154
+ activesupport (>= 3.0)
155
+ railties (>= 3.0)
156
+ rspec-core (~> 2.14.0)
157
+ rspec-expectations (~> 2.14.0)
158
+ rspec-mocks (~> 2.14.0)
159
+ shoulda-matchers (2.6.1)
160
+ activesupport (>= 3.0.0)
161
+ simplecov (0.8.2)
162
+ docile (~> 1.1.0)
163
+ multi_json
164
+ simplecov-html (~> 0.8.0)
165
+ simplecov-html (0.8.0)
166
+ sprockets (2.12.1)
167
+ hike (~> 1.2)
168
+ multi_json (~> 1.0)
169
+ rack (~> 1.0)
170
+ tilt (~> 1.1, != 1.3.0)
171
+ sprockets-rails (2.1.3)
172
+ actionpack (>= 3.0)
173
+ activesupport (>= 3.0)
174
+ sprockets (~> 2.8)
175
+ sqlite3 (1.3.9)
176
+ term-ansicolor (1.3.0)
177
+ tins (~> 1.0)
178
+ thor (0.19.1)
179
+ thread_safe (0.3.3)
180
+ tilt (1.4.1)
181
+ tins (1.2.0)
182
+ treetop (1.4.15)
183
+ polyglot
184
+ polyglot (>= 0.3.1)
185
+ tzinfo (1.1.0)
186
+ thread_safe (~> 0.1)
187
+
188
+ PLATFORMS
189
+ ruby
190
+
191
+ DEPENDENCIES
192
+ bootstrap_leather
193
+ bundler
194
+ coveralls
195
+ database_cleaner
196
+ factory_girl_rails
197
+ haml-rails
198
+ jeweler
199
+ jquery-rails
200
+ rails (>= 4.1)
201
+ rails-i18n
202
+ rspec-rails
203
+ rubygems_herald!
204
+ shoulda-matchers
205
+ sqlite3
data/LICENSE.txt ADDED
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2013 Karen Lundgren
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,40 @@
1
+ Rubygems Herald
2
+ ===========
3
+
4
+ [![GitHub version](https://badge.fury.io/gh/gemvein%2Frubygems_herald.svg)](http://badge.fury.io/gh/gemvein%2Frubygems_herald)
5
+ [![Build Status](https://travis-ci.org/gemvein/rubygems_herald.svg)](https://travis-ci.org/gemvein/rubygems_herald)
6
+ [![Coverage Status](https://coveralls.io/repos/gemvein/rubygems_herald/badge.png)](https://coveralls.io/r/gemvein/rubygems_herald)
7
+
8
+ For organizations that want to market a gem in style, Rubygems Herald syncs your gems' data via the RubyGems.org API so that your software marketing website stays up to date with the latest information about your gems.
9
+
10
+ Installation
11
+ ----------------------------
12
+
13
+ First, add the gem to your Gemfile
14
+
15
+ gem 'cooperative', :git => 'git://github.com/nerakdon/cooperative.git'
16
+
17
+ Next, run the following commands
18
+
19
+ > bundle install
20
+ > rails g cooperative:install
21
+ > rake db:migrate
22
+
23
+ Edit the initializer to set the names of the gems that Rubygems Herald should fetch.
24
+
25
+ Contributing to Rubygems Herald
26
+ ----------------------------
27
+
28
+ * Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet.
29
+ * Check out the issue tracker to make sure someone already hasn't requested it and/or contributed it.
30
+ * Fork the project.
31
+ * Start a feature/bugfix branch.
32
+ * Commit and push until you are happy with your contribution.
33
+ * Make sure to add tests for it. This is important so I don't break it in a future version unintentionally.
34
+ * Please try not to mess with the Rakefile, version, or history. If you want to have your own version, or is otherwise necessary, that is fine, but please isolate to its own commit so I can cherry-pick around it.
35
+
36
+ Copyright
37
+ ---------
38
+
39
+ Copyright (c) 2014 Gem Vein. See LICENSE.txt for further details.
40
+
data/Rakefile ADDED
@@ -0,0 +1,49 @@
1
+ # encoding: utf-8
2
+
3
+ require 'rubygems'
4
+ require 'bundler'
5
+ begin
6
+ Bundler.setup(:default, :development)
7
+ rescue Bundler::BundlerError => e
8
+ $stderr.puts e.message
9
+ $stderr.puts "Run `bundle install` to install missing gems"
10
+ exit e.status_code
11
+ end
12
+ require 'rake'
13
+
14
+ require 'jeweler'
15
+ Jeweler::Tasks.new do |gem|
16
+ # gem is a Gem::Specification... see http://docs.rubygems.org/read/chapter/20 for more options
17
+ gem.name = "rubygems_herald"
18
+ gem.homepage = "http://github.com/gemvein/rubygems_herald"
19
+ gem.license = "MIT"
20
+ gem.summary = %Q{Rails 4 Engine that populates a marketing site with data from RubyGems.org}
21
+ gem.description = %Q{For organizations that want to market a gem in style, Rubygems Herald syncs your gems' data via the RubyGems.org API so that your software marketing website stays up to date with the latest information about your gems.}
22
+ gem.email = "karen.e.lundgren@gmail.com"
23
+ gem.authors = ["Karen Lundgren"]
24
+ # dependencies defined in Gemfile
25
+ end
26
+ Jeweler::RubygemsDotOrgTasks.new
27
+
28
+ require 'rspec/core'
29
+ require 'rspec/core/rake_task'
30
+ RSpec::Core::RakeTask.new(:spec) do |spec|
31
+ spec.pattern = FileList['spec/**/*_spec.rb']
32
+ end
33
+
34
+ RSpec::Core::RakeTask.new(:rcov) do |spec|
35
+ spec.pattern = 'spec/**/*_spec.rb'
36
+ spec.rcov = true
37
+ end
38
+
39
+ task :default => :spec
40
+
41
+ require 'rdoc/task'
42
+ Rake::RDocTask.new do |rdoc|
43
+ version = File.exist?('VERSION') ? File.read('VERSION') : ""
44
+
45
+ rdoc.rdoc_dir = 'rdoc'
46
+ rdoc.title = "rubygems_herald #{version}"
47
+ rdoc.rdoc_files.include('README*')
48
+ rdoc.rdoc_files.include('lib/**/*.rb')
49
+ end
data/VERSION ADDED
@@ -0,0 +1 @@
1
+ 0.0.1
@@ -0,0 +1,38 @@
1
+ class GemDisplaysController < ApplicationController
2
+
3
+ # GET /gem_displays
4
+ def index
5
+ @gem_displays = GemDisplay.all
6
+ if @gem_displays.empty?
7
+ @gem_displays = GemDisplay.load_rubygems
8
+ end
9
+ end
10
+
11
+ # GET /gem_displays/1
12
+ def show
13
+ load_gem_display
14
+ end
15
+
16
+ # PATCH/PUT /gem_displays/1/refresh
17
+ def refresh
18
+ if load_gem_display
19
+ if @gem_display.update
20
+ redirect_to @gem_display.reload, notice: 'Gem display was successfully refreshed.'
21
+ else
22
+ redirect_to @gem_display, error: 'Gem display failed to refresh.'
23
+ end
24
+ end
25
+ end
26
+
27
+ private
28
+
29
+ def not_found
30
+ render :file => "#{Rails.root}/public/404", :status => :not_found
31
+ false #return false so things will fail
32
+ end
33
+
34
+ def load_gem_display
35
+ @gem_display = GemDisplay.find_by_name(params[:id]) or not_found
36
+ end
37
+
38
+ end
@@ -0,0 +1,47 @@
1
+ class GemDisplay < ActiveRecord::Base
2
+ validates_presence_of :name
3
+ validates :name, :inclusion=> { :in => RubygemsHerald.configuration.gems }
4
+
5
+ before_create :load_rubygem
6
+ after_find :check_expiration
7
+
8
+ def check_expiration
9
+ if expires_at > Time.now
10
+ update
11
+ end
12
+ expires_at
13
+ end
14
+
15
+ def update
16
+ load_rubygem
17
+ save
18
+ end
19
+
20
+ def rubygem
21
+ spider.data
22
+ end
23
+
24
+ def rubygems_uri
25
+ spider.url
26
+ end
27
+
28
+ def spider
29
+ RubygemsHerald::Spider.new(name)
30
+ end
31
+
32
+ def self.load_rubygems
33
+ for gem_name in RubygemsHerald.configuration.gems
34
+ find_or_create_by( { name: gem_name } )
35
+ end
36
+ all
37
+ end
38
+
39
+ def load_rubygem
40
+ rubygem.each {|key, value| write_attribute(key, value.to_s) if self.respond_to?(key) }
41
+ self
42
+ end
43
+
44
+ def to_param
45
+ name
46
+ end
47
+ end