-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathRakefile
132 lines (101 loc) · 3.91 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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
require 'rubygems'
require 'bundler'
begin
Bundler.setup(:default, :development)
rescue Bundler::BundlerError => e
$stderr.puts e.message
$stderr.puts "Run `bundle install` to install missing gems"
exit e.status_code
end
require 'rake'
LIBRARY_PATH=File.join(File.dirname(__FILE__),"lib")
GENERATOR_PATH=File.join(File.dirname(__FILE__),"generator")
DEST_DIR=LIBRARY_PATH
def generate(code = true)
$LOAD_PATH.unshift(GENERATOR_PATH).unshift(LIBRARY_PATH)
require 'fileutils'
require File.join(GENERATOR_PATH,"ast_tree")
ClassDeclaration.spec_mode = !code
root = Marshal.load(File.open(File.join(GENERATOR_PATH,"result.dat")).read)
new_root = ModuleDeclaration.new
Dir.chdir(DEST_DIR)
new_root.properties[:name] = "IControl"
new_root.children = root.children
new_root.children.each { |i| i.parent = new_root }
new_root.parent = nil
puts "Generating Code.."
new_root.compile
end
desc "Generates the source code after the dump of the doc was made"
task "icontrol:generate:code" do
generate
end
desc "Generates skeleton for the spec files (it not present)"
task "icontrol:generate:spec" do
generate(false)
end
desc "Downloads the contents of the documentation of the F5 project in (this is done only once)"
task "icontrol:get_documentation" do
require 'nokogiri'
require 'mechanize'
require 'logger'
require File.join(File.dirname(__FILE__),"generator","ast_tree")
# Credentials loading
credentials_file_path = File.join(File.dirname(__FILE__),"generator","credentials.yml")
unless File.exist?(credentials_file_path)
puts "Error, no credentials file found, please copy \"#{credentials_file_path}.example\" to \"#{credentials_file_path}\" and fill it with actual values. The values should be your account to the F5dev project"
exit 1
end
config = YAML.load(File.read(credentials_file_path))
# First of all the browser creation
agent = Mechanize.new
agent.user_agent_alias = 'Mac Safari'
# Next the login (with a bit of a hack)
page = agent.get("http://devcentral.f5.com/Community/Login/tabid/1082224/Default.aspx")
login_form = page.form_with(:name => "Form")
login_form.field_with(:name => "dnn$ctr1085423$Main$login$txtLoginId").value = config[:user]
login_form.field_with(:name => "dnn$ctr1085423$Main$login$txtPassword").value = config[:password]
login_form.field_with(:name => "__EVENTTARGET").value = "dnn$ctr1085423$Main$login$btnLogin";
agent.submit(login_form)
# Then we create a parser an let it work
Parser.agent = agent
data = Parser.parse("http://devcentral.f5.com/wiki/default.aspx/iControl.APIReference")
# The results are marshaller for later proccess
File.open(File.join(GENERATOR_PATH,"result.dat"),"w+") do |file|
file << Marshal.dump(data)
end
end
begin
require 'jeweler'
Jeweler::Tasks.new do |gem|
gem.name = "icontrol"
gem.summary = %Q{A ruby client to the BigIP F5}
gem.description = %Q{This gem allows you to Connect to a F5 appliance by means of its web services}
gem.email = "[email protected]"
gem.homepage = "http://github.com/magec/icontrol"
gem.authors = ["Jose Fernandez (magec)"]
# gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
gem.files = FileList['lib/**/*.rb']
gem.extra_rdoc_files << ".yardopts"
end
Jeweler::GemcutterTasks.new
rescue LoadError
puts "Jeweler (or a dependency) not available. Install it with: gem install jeweler"
end
Jeweler::RubygemsDotOrgTasks.new
require 'rspec/core'
require 'rspec/core/rake_task'
RSpec::Core::RakeTask.new(:spec) do |spec|
spec.pattern = FileList['spec/**/*_spec.rb']
end
RSpec::Core::RakeTask.new(:rcov) do |spec|
spec.pattern = 'spec/**/*_spec.rb'
spec.rcov = true
end
task :default => :spec
require 'yard'
require 'yard-examples-from-rspec'
YARD::Rake::YardocTask.new do |task|
task.options = ["--no-private"]
task.files << FileList['spec/**/*.rb']
end