Skip to content

Instantly share code, notes, and snippets.

@stefanoverna
Created June 5, 2012 23:41
Show Gist options
  • Select an option

  • Save stefanoverna/2878875 to your computer and use it in GitHub Desktop.

Select an option

Save stefanoverna/2878875 to your computer and use it in GitHub Desktop.
Prima implementazione
-
ChangeLog.md
LICENSE.txt
Gemfile.lock
doc/
pkg/
vendor/cache/*.gem
--colour --format documentation
--markup markdown --title "redditor Documentation" --protected

Implementazione della gemma.

0.1.0 / 2012-06-06

  • Initial release:
require 'active_support'
require 'thor'
require 'command_line_reporter'
require 'json'
require 'googl'
require 'rest_client'
require 'launchy'
require 'ostruct'
module Redditor
class CLI < Thor
include CommandLineReporter
desc "hot", "it prints out the homepage Reddit hot stories"
def hot
result = RestClient.get "http://www.reddit.com/hot.json"
items = JSON.parse(result)["data"]["children"].map do |item|
OpenStruct.new(item["data"])
end
table(:border => true) do
row header: true, color: :yellow do
column "#" , width: 2 , align: "right"
column "Story" , width: 70
column "Pts/Comms." , width: 10 , align: "right"
column "URL" , width: 20
end
items[0...5].each_with_index do |item, index|
row do
column index + 1
column item.title
column "#{item.score}/#{item.num_comments}"
column Googl.shorten(item.url).short_url
end
end
end
end
end
end
source :rubygems
gemspec
group :development do
gem 'kramdown'
gem 'rubygems-tasks', '~> 0.2'
gem 'rspec', '~> 2.4'
gem 'yard', '~> 0.7'
gem 'bundler', '~> 1.0'
gem 'rake', '~> 0.8'
end
Copyright (c) 2012 Stefano Verna
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.
# encoding: utf-8
require 'rubygems'
begin
require 'bundler'
rescue LoadError => e
warn e.message
warn "Run `gem install bundler` to install Bundler."
exit e.status_code
end
begin
Bundler.setup(:development)
rescue Bundler::BundlerError => e
warn e.message
warn "Run `bundle install` to install missing gems."
exit e.status_code
end
require 'rake'
require 'rubygems/tasks'
Gem::Tasks.new
require 'rspec/core/rake_task'
RSpec::Core::RakeTask.new
task :test => :spec
task :default => :spec
require 'yard'
YARD::Rake::YardocTask.new
task :doc => :yard
#!/usr/bin/env ruby
require 'redditor/cli'
Redditor::CLI.start
# -*- encoding: utf-8 -*-
require File.expand_path('../lib/redditor/version', __FILE__)
Gem::Specification.new do |gem|
gem.name = "redditor"
gem.version = Redditor::VERSION
gem.summary = %q{Reddit on CLI}
gem.description = %q{Browse Reddit from CLI}
gem.license = "MIT"
gem.authors = ["Stefano Verna"]
gem.email = "stefano.verna@welaika.com"
gem.homepage = "https://github.com/stefanoverna/redditor#readme"
gem.files = `git ls-files`.split($/)
gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
gem.require_paths = ['lib']
gem.add_dependency 'activesupport'
gem.add_dependency 'thor'
gem.add_dependency 'command_line_reporter'
gem.add_dependency 'json'
gem.add_dependency 'googl'
gem.add_dependency 'rest-client'
gem.add_dependency 'launchy'
gem.add_development_dependency 'bundler', '~> 1.0'
gem.add_development_dependency 'yard', '~> 0.7'
end
require 'redditor/version'
module Redditor
end
require 'spec_helper'
require 'redditor'
describe Redditor do
it "should have a VERSION constant" do
subject.const_get('VERSION').should_not be_empty
end
end
require 'rspec'
require 'redditor/version'
include Redditor
module Redditor
# redditor version
VERSION = "0.1.0"
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment