From 0bd46b524f459255cf9271a9f17016d7505a2c24 Mon Sep 17 00:00:00 2001 From: Andrew Cantino Date: Sat, 27 Sep 2014 21:44:36 -0700 Subject: [PATCH] initial effort on pulling Agents into gems --- Gemfile | 4 ++- Gemfile.lock | 11 +++++++- Rakefile | 7 ++++++ agents/rss_agent/LICENSE.txt | 22 ++++++++++++++++ .../rss_agent/lib/huginn_agent}/rss_agent.rb | 0 agents/rss_agent/lib/rss_agent.rb | 3 +++ agents/rss_agent/rss_agent.gemspec | 25 +++++++++++++++++++ .../rss_agent/spec}/rss_agent_spec.rb | 0 config/initializers/requires.rb | 3 ++- 9 files changed, 72 insertions(+), 3 deletions(-) create mode 100644 agents/rss_agent/LICENSE.txt rename {app/models/agents => agents/rss_agent/lib/huginn_agent}/rss_agent.rb (100%) create mode 100644 agents/rss_agent/lib/rss_agent.rb create mode 100644 agents/rss_agent/rss_agent.gemspec rename {spec/models/agents => agents/rss_agent/spec}/rss_agent_spec.rb (100%) diff --git a/Gemfile b/Gemfile index 3d73400a..bb217c5f 100644 --- a/Gemfile +++ b/Gemfile @@ -23,6 +23,8 @@ def if_true(condition) end end +gem 'rss_agent', path: 'agents/rss_agent' + # Optional libraries. To conserve RAM, comment out any that you don't need, # then run `bundle` and commit the updated Gemfile and Gemfile.lock. gem 'twilio-ruby', '~> 3.11.5' # TwilioAgent @@ -92,7 +94,6 @@ gem 'devise', '~> 3.5.4' gem 'em-http-request', '~> 1.1.2' gem 'faraday', '~> 0.9.0' gem 'faraday_middleware', github: 'lostisland/faraday_middleware', branch: 'master' # '>= 0.10.1' -gem 'feed-normalizer' gem 'font-awesome-sass', '~> 4.3.2' gem 'foreman', '~> 0.63.0' # geokit-rails doesn't work with geokit 1.8.X but it specifies ~> 1.5 @@ -102,6 +103,7 @@ gem 'geokit-rails', '~> 2.0.1' gem 'httparty', '~> 0.13' gem 'httmultiparty', '~> 0.3.16' gem 'jquery-rails', '~> 3.1.3' +gem 'huginn_agent' gem 'json', '~> 1.8.1' gem 'jsonpath', '~> 0.5.6' gem 'kaminari', '~> 0.16.1' diff --git a/Gemfile.lock b/Gemfile.lock index 349d3406..e11ffb9a 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -58,6 +58,13 @@ GIT omniauth (~> 1.0) omniauth-oauth2 (~> 1.1) +PATH + remote: agents/rss_agent + specs: + rss_agent (0.1) + feed-normalizer (~> 1.5.2) + huginn_agent + PATH remote: vendor/gems/dotenv-2.0.1 specs: @@ -281,6 +288,7 @@ GEM httparty (0.13.7) json (~> 1.8) multi_xml (>= 0.5.2) + huginn_agent (0.1) hypdf (1.0.10) httmultiparty (~> 0.3) httparty (~> 0.13) @@ -614,7 +622,6 @@ DEPENDENCIES evernote_oauth faraday (~> 0.9.0) faraday_middleware! - feed-normalizer ffi (>= 1.9.4) font-awesome-sass (~> 4.3.2) forecast_io (~> 2.0.0) @@ -629,6 +636,7 @@ DEPENDENCIES hipchat (~> 1.2.0) httmultiparty (~> 0.3.16) httparty (~> 0.13) + huginn_agent hypdf (~> 1.0.10) jquery-rails (~> 3.1.3) json (~> 1.8.1) @@ -666,6 +674,7 @@ DEPENDENCIES rspec-collection_matchers (~> 1.1.0) rspec-html-matchers (~> 0.7) rspec-rails (~> 3.1) + rss_agent! rturk (~> 2.12.1) ruby-growl (~> 4.1.0) rufus-scheduler (~> 3.0.8) diff --git a/Rakefile b/Rakefile index 748c0435..d33f8679 100644 --- a/Rakefile +++ b/Rakefile @@ -5,3 +5,10 @@ require File.expand_path('../config/application', __FILE__) Huginn::Application.load_tasks + +task("spec").clear +RSpec::Core::RakeTask.new(:spec) do |t| + t.pattern = ['spec/**/*_spec.rb', 'agents/**/spec/**/*_spec.rb'] +end + +task :default => :spec diff --git a/agents/rss_agent/LICENSE.txt b/agents/rss_agent/LICENSE.txt new file mode 100644 index 00000000..51430144 --- /dev/null +++ b/agents/rss_agent/LICENSE.txt @@ -0,0 +1,22 @@ +Copyright (c) 2014 Andrew Cantino + +MIT License + +Permission is hereby granted, free of charge, to any person obtaining +a copy of this software and associated documentation files (the +"Software"), to deal in the Software without restriction, including +without limitation the rights to use, copy, modify, merge, publish, +distribute, sublicense, and/or sell copies of the Software, and to +permit persons to whom the Software is furnished to do so, subject to +the following conditions: + +The above copyright notice and this permission notice shall be +included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/app/models/agents/rss_agent.rb b/agents/rss_agent/lib/huginn_agent/rss_agent.rb similarity index 100% rename from app/models/agents/rss_agent.rb rename to agents/rss_agent/lib/huginn_agent/rss_agent.rb diff --git a/agents/rss_agent/lib/rss_agent.rb b/agents/rss_agent/lib/rss_agent.rb new file mode 100644 index 00000000..7d4b22b9 --- /dev/null +++ b/agents/rss_agent/lib/rss_agent.rb @@ -0,0 +1,3 @@ +require 'huginn_agent' + +HuginnAgent.register 'huginn_agent/rss_agent' diff --git a/agents/rss_agent/rss_agent.gemspec b/agents/rss_agent/rss_agent.gemspec new file mode 100644 index 00000000..3ec12c12 --- /dev/null +++ b/agents/rss_agent/rss_agent.gemspec @@ -0,0 +1,25 @@ +# coding: utf-8 +lib = File.expand_path('../lib', __FILE__) +$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib) + +Gem::Specification.new do |spec| + spec.name = "rss_agent" + spec.version = '0.1' + spec.authors = ["Andrew Cantino"] + spec.email = ["https://github.com/cantino/huginn"] + spec.summary = %q{The default Huginn RSSAgent for consuming RSS and Atom feeds.} + spec.homepage = "https://github.com/cantino/huginn" + spec.license = "MIT" + + spec.files = `git ls-files -z`.split("\x0") + spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) } + spec.test_files = spec.files.grep(%r{^(test|spec|features)/}) + spec.require_paths = ["lib"] + + spec.add_development_dependency "bundler", "~> 1.7" + spec.add_development_dependency "rake", "~> 10.0" + spec.add_development_dependency "rspec" + + spec.add_runtime_dependency "huginn_agent" + spec.add_runtime_dependency "feed-normalizer", "~> 1.5.2" +end diff --git a/spec/models/agents/rss_agent_spec.rb b/agents/rss_agent/spec/rss_agent_spec.rb similarity index 100% rename from spec/models/agents/rss_agent_spec.rb rename to agents/rss_agent/spec/rss_agent_spec.rb diff --git a/config/initializers/requires.rb b/config/initializers/requires.rb index f6d0aa85..2413335a 100644 --- a/config/initializers/requires.rb +++ b/config/initializers/requires.rb @@ -1 +1,2 @@ -require 'pp' \ No newline at end of file +require 'pp' +HuginnAgent.require! \ No newline at end of file