forked from rockonla23/ar-sunlight-legislators
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Rakefile
65 lines (54 loc) · 1.67 KB
/
Rakefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
require 'rake'
require 'rspec/core/rake_task'
require_relative 'db/config'
desc "create the database"
task "db:create" do
touch 'db/ar-sunlight-legislators.sqlite3'
end
desc "import data into db"
task "db:import" do
require_relative 'app'
file_name = 'db/data/legislators.csv'
SunlightLegislatorsImporter.import(file_name)
end
desc "update type from title"
task "db:type_to_title" do
require_relative 'app'
Politician.all.each do |politician|
if politician.title == "Rep"
politician.type = "Representative"
elsif politician.title == "Sen"
politician.type = "Senator"
end
politician.save
end
end
desc "import last 10 twitter from politician"
task :import_tweeter, [:arg1] do |t, args|
require_relative 'app'
TwitterImporter.login_client
TwitterImporter.get_last_10_tweets(args[:arg1])
end
desc "drop the database"
task "db:drop" do
rm_f 'db/ar-sunlight-legislators.sqlite3'
end
desc "loads console with files"
task "db:console" do
exec "irb -r./app.rb"
end
desc "migrate the database (options: VERSION=x, VERBOSE=false, SCOPE=blog)."
task "db:migrate" do
ActiveRecord::Migrator.migrations_paths << File.dirname(__FILE__) + 'db/migrate'
ActiveRecord::Migration.verbose = ENV["VERBOSE"] ? ENV["VERBOSE"] == "true" : true
ActiveRecord::Migrator.migrate(ActiveRecord::Migrator.migrations_paths, ENV["VERSION"] ? ENV["VERSION"].to_i : nil) do |migration|
ENV["SCOPE"].blank? || (ENV["SCOPE"] == migration.scope)
end
end
desc 'Retrieves the current schema version number'
task "db:version" do
puts "Current version: #{ActiveRecord::Migrator.current_version}"
end
desc "Run the specs"
RSpec::Core::RakeTask.new(:specs)
task :default => :specs